-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
import/extensions
, import/no-unresolved
don't highlight import of nonexistent .js
#291
Comments
I'm experiencing this same issue. Unfortunately, I think this behavior may be technically correct, by present state of the longstanding conflict between typescript and node about module resolution. microsoft/TypeScript#13422 |
@turbocrime Well, it brings real harm, because Webpack can't resolve it and can't build. (On the other hand, there is strange behavior in VSCode that adds this I suppose the point of ESLint is to prevent this type of situations and be literal in terms of what it is asked to consider an error. And please see the list "the highlight will appear also if" at the end of my post – it demonstrates that, even if this kind of resolving is correct for some reason, it is not consistent. |
part of the situation is you're using three independent resolvers
you could configure your lint rules to permit .js extensions to refer to .ts imports. i understand this is awkward, but typescript devs seem to encourage this. if you are just bundling this code with webpack, you may be interested in tsconfig's "bundler" if you are using or publishing bare tsc output anywhere, you probably don't want to use bundler resolution. |
Thanks for the detailed response. At this stage I just configured VS Code to prevent it from inserting |
Sorry if this is a tangent, but what's the benefit of using |
@AndreaPontrandolfo TypeScript warnings for .js (and only .js) are absent for me just as ESLint warnings. For explicitness, this is my tsconfig.json for this particular test: {
"compilerOptions": {
"outDir": "./built",
"target": "es2022",
"moduleResolution": "Bundler"
}
} And as I said,
|
(Original issue is posted at import-js/eslint-plugin-import#3015.)
Take this simple setup:
eslint.config.js
index.ts
exported.ts
In index.ts,
./exported.js
points to a nonexistent file. Neitherimport/extensions
, norimport/no-unresolved
highlight it though.I narrowed down the problem to
typescript: true
– as soon as I comment that line, I see both errors:I assume this is the problem with
eslint-import-resolver-typescript
. I tried messing with it in some ways, but to no avail.I should also note that the highlight will appear also if:
So, this seems to be a pretty unique case with a nonexistent .js silently mapping to an existent .ts with the same basename.
The text was updated successfully, but these errors were encountered: