-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] no-unresolved: ignore type-only imports #2220
Conversation
…ng and `import/extensions` setting
Does typescript actually confirm resolution for untyped imports? |
Yes (I'm pretty sure). If I
I can't think of a TypeScript setup where that wouldn't be the case ... |
Those are types packages. I’m talking about untyped commonjs packages, that the lint rule enforces resolution on. |
Codecov Report
@@ Coverage Diff @@
## main #2220 +/- ##
==========================================
+ Coverage 84.03% 84.04% +0.01%
==========================================
Files 96 96
Lines 3032 3034 +2
Branches 899 900 +1
==========================================
+ Hits 2548 2550 +2
Misses 484 484
Continue to review full report at Codecov.
|
Sorry, good point: TypeScript doesn't complain that That works for me: There's no mdast untyped package. But if I add As far as I know, eslint-import-resolver-typescript can get the kind of import (type-only or value) from the TypeScript parser -- based on usage, regardless of the Ideally eslint-import-resolver-typescript would only consider ∴ my mistake, thanks for spotting! I'll close this and maybe investigate eslint-import-resolver-typescript + import kinds. |
Reopening this after revising the title because it carries on from the previous discussion: Although TypeScript doesn't confirm that value imports can be resolved, it does confirm that type-only imports can. ∴ instead of disabling Also, ∴ remove The result is that DetailsRemoving In addition to explicit type-only imports, I investigated ignoring implicit type-only imports: when you
So I think the choice is between:
Note that case 1 (keep
|
3a13ee5
to
caec287
Compare
cc7de4a
to
caec287
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable to me. .d.ts
is of course redundant when we have .ts
; and no-unresolved
shouldn't bother checking type imports since tsc/flow does that for us. Thanks!
Thank you! |
It still gives me an |
tmp: Vector tiles experimentations build: Fix ESLint ignoring type-only imports PR: import-js/eslint-plugin-import#2220
tmp: Vector tiles experimentations build: Fix ESLint ignoring type-only imports PR: import-js/eslint-plugin-import#2220 feat: Naïve vector tile implementation
I'm getting the following errors when linting TypeScript, without installing eslint-import-resolver-typescript:
Can
import/no-unresolved: off
be added to theplugin:import/typescript
preset, by the same logic as in #1726 (TypeScript compilation already confirms that imports are resolved)?