-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Support recognizing TypeScript files imported with .js
suffix
#214
Comments
hm I'm not sure we will support imports of That link seems to be discussing ECMAScript (the spec for JavaScript). However Besides that, I don't really understand why this feature would be needed - isn't it possible use all TypeScript with Node.js ? Perhaps if you can explain the use case a bit more, that would help ... |
Therefore, for any project that output target is ES6 or above, all import statements must be ended with In fact, example/simple only works when the output format is set to commonjs. If I modify it to output ESM instead, ts-unused-exports/example/simple/tsconfig.json Lines 3 to 4 in 56939d1
the compiled output won't run.
So if I am developing a project which must output ESM code, ts-unused-exports won't work for it. Edit: explain the issue more clearly. |
Specifying the |
Currently having to disable this tool in all our repos since migrating to node16/esm. There are plenty of details in the ts docs if you need to understand why we have to import like this now @mrseanryan . |
Hello - this is somewhat tricky to add support for... Here is a PR that adds initial support: If someone can try it out, that would be great ... |
Released as 9.0.0 - thank you |
@mrseanryan Hello and thanks again for this wonderful library 🙌 It seems the issue has not been resolved when
When I run
But the conjunction of the two ( Do you confirm that's the current behavior? Is it the desired one? Can I do something to help? Many thanks, Thomas |
In TypeScript, it is valid to import TypeScript files with
.js
extension. TypeScript will match the coresponding.ts
files if they exist. This behaviour is commonly used in Node.js projects as.js
file extensions are required in Node.js ESM imports.It would be great if ts-unused-exports also recognize variable imported with
.js
suffix.Related: evanw/esbuild#1343 (comment), microsoft/TypeScript#16577 (comment), microsoft/TypeScript#16577 (comment)
Example
In this example project derived from
example/simple
,inc()
frommath.ts
was imported with.js
extension.ts-unused-exports/example/simple/app.ts
Line 1 in ad208c9
And TypeScript recognize it sucessfully.
However, ts-unused-exports failed to recognize that the default import of
math.ts
was imported inapp.ts
.The text was updated successfully, but these errors were encountered: