-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Wrong type definition for placeholder type
property
#921
Comments
I'm having similar issues.
I can create a new instance:
But even though my IDE thinks I can access the namespaced enums, it seems as though PptxGenJs only allows me to access its constructor and not the namespaced enums as follows:
This compiles correctly with no complaints from TS or ESLint, but I get a runtime error saying PptxGenJS is undefined, which is odd since I figured that should resolve at compile time and not runtime. Perhaps this is because the exported class and namespace share the same name? |
This is not ideal, but you can at least bypass the issue with the following:
|
This is the result from the transpilation:
Looks like maybe only the default export gets imported, and the namespace gets ignored. I should add that my compiler target is esnext. Haven't tried another version yet. |
@lukevella - Good catch. The type needs to be exposed correctly like |
@lukevella @jmroon - you're welcome to test the fix by patching your readonly PlaceholderType: typeof PptxGenJS.PLACEHOLDER_TYPES |
@gitbrent That change does not seem to fix the issue for me. What does fix it is the following change: export interface PlaceholderProps {
name: string
- type: PLACEHOLDER_TYPES
+ type: keyof typeof PLACEHOLDER_TYPES
x: Coord
y: Coord
w: Coord
h: Coord
} |
@lukevella - okay, there's yet another change needed - we're using Added: export type PLACEHOLDER_TYPE = 'title' | 'body' | 'pic' | 'chart' | 'tbl' | 'media' Updated: export interface PlaceholderProps {
name: string
type: PLACEHOLDER_TYPE
x: Coord
y: Coord
w: Coord
h: Coord
} |
Category
Version
Please specify what version of the library you are using: [3.4.0]
Desired Behavior
The following code should work fine:
Observed Behavior
We get the following typescript error:
I observed that we can satisfy typescript by passing
PptxGenJs.PLACEHOLDER_TYPES.body
astype
however this causes a runtime error. Seems like the type definition forPlaceholderProps.type
is just wrong.Steps to Reproduce
Copy and paste the snippet above in to a typeescript project.
The text was updated successfully, but these errors were encountered: