-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: unable to import module from typescript #18
base: master
Are you sure you want to change the base?
fix: unable to import module from typescript #18
Conversation
Close #14 |
That |
@fregante Could you be a little more explicit about why it should never be used? Isn't it the standard typescript way to access a commonjs module's module.export (as in typescript docs])? |
That page is for ES Modules, you can use import time = require('time') I think it’s just an old way though |
I did not look at the right part of the typescript documentation. Thank you @fregante for pointing this. The recommanded syntax for commonjs module is indeed:
I edited the issue description and fixed the README in the PR. |
This is still not corrected because tsc would compile it as follow:
Since |
That's not right. Demo with
Documentation: https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require |
So is this PR ready for merge? |
The only thing to notice is that this is a breaking change for TypeScript users that aren’t using esModuleInteropt since |
Allow import in typescript:
EDIT: updated with typescript recommanded import syntax for commonjs module as recommanded by @fregante (see below).