-
Notifications
You must be signed in to change notification settings - Fork 52
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
TypeScript problem with native ECMAScript Module support #111
Comments
Hi. First of all, there're no Second, regular TypeScript doesn't allow importing files with |
Importing files with an additional
ps. my app has about 30 direct dependencies and |
I see. So looks like TypeScript ESM is incompatible with regular
TypeScript. It’s weird that they haven’t implemented backwards
compatibility though similsr to Node.js’es where they support importing
non-type-module modules from type-module modules. Most likely there is
backwards compatibility, just under some flag.
…On Wed, 8 Feb 2023 at 10:40, peterhirn ***@***.***> wrote:
Importing files with an additional (non-existent) .js extension is
necessary when using TypeScript + ECMAScript Modules in Node.js, see
https://www.typescriptlang.org/docs/handbook/esm-node.html
This code works in CommonJS modules, but will fail in ES modules because
relative import paths need to use extensions. As a result, it will have to
be rewritten to use the extension of the output of foo.ts - so bar.ts will
instead have to import from ./foo.js.
ps. my app has about 30 direct dependencies and read-excel-file is the
only one which doesn't work with "moduleResolution": "nodenext".
—
Reply to this email directly, view it on GitHub
<#111 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADUP35P7EMZQU3IIXWOV5LWWNEXFANCNFSM6AAAAAAUUKRJ4Y>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I couldn't find any additional compatibility flag. It seems adding |
When using TypeScript with native ECMAScript Module support (eg.
"moduleResolution": "nodenext"
) and"type": "module"
importing fromread-excel-file/node
produces the following error:I patched
index.d.ts
andnode/index.d.ts
and this seems to work, even for CJS imports and other settings (eg."moduleResolution": "node"
) :Not sure if this is a good patch or if it would break other users code. Feedback from anyone who's more familiar with TypeScript and native ECMAScript Module support would be appreciated.
The text was updated successfully, but these errors were encountered: