-
-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble importing from inferno-create-element in a TypeScript project #505
Comments
CCing @LukeSheard @nightwolfz @Schnueggel @jrf0110 if this fixes your issue, I'm totally down with a PR to apply this fix and any others you might have. Thank you for raising this issue – I hope to do a release a bit later, so this might get in too :) |
@jrf0110 I've released |
Hm, while typings were changed to export
This causes mismatch between modules and typings, so it will compile but throw runtime error (I tried with TypeScript's compiler option "module": "commonjs"), because the import gets compiled into something like The correct import for what currently module exports is
|
@dchest this is more of an annoying feature/bug of TypeScript and how it deals with NPM modules. The initial require is requiring a module with default. If you have any ideas how to fix, please do raise a PR or let me know. These things are a right PITA to get perfectly right on a UMD package. |
@trueadm it might not be a bug at all. According to an opinion on the same problem with react import, importing npm module as default is a Babel behavior, and it is not described in the specification. So, in my opinion, this behavior should not be treated as a bug, and we can just use code suggested by @dchest as far as it is a common approach in Typescript. |
I think @Lodin is correct — |
I'm closing this for the other issue, that covers this and more. #521 |
Hey @trueadm I appreciate you guys deliberating and coming up with a solution here. I basically turned off programming projects this weekend, so I'll let y'all know early this week how everything goes. |
Found the same problem using a library leaving this here just for reference:
Tried one of the fixes in here
Checked the inferno-create-element repo and just replaced for their recommendation
Hope it helps someone else |
Observed Behaviour
When attempting to import from
inferno-create-element
, I get the following error:I dug into inferno's generated definitions file and saw this:
Expected Current Behaviour
I would think that the
.d.ts
file would look like this:And indeed, changing inferno's definition file to the above seems to fix the problem.
Any thoughts on that? I'm not exactly sure if that's a bug or maybe a user error
The text was updated successfully, but these errors were encountered: