-
-
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
TypeScript export and import/named rule #1282
Comments
It seems like the right thing to do here is to include TypeScript |
Not just |
Presumably somewhere in https://github.com/benmosher/eslint-plugin-import/blob/master/src/ExportMap.js#L335 - cc @benmosher |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
May also want to check a package's |
Weirdly |
`eslint-plugin-import` doesn't support exported types: import-js/eslint-plugin-import#1282
Was the ExportMap a comment about how to fix this bug via PR or is there some config to fix this? Just hit this one as well :-\ pretty major rule to disable. Ah ok guessing the case statement needs to just have whatever ts is calling its type declarations?
|
@bradennapier even if it were; there's only one person who can cut a release, so it's not likely to be published asap. |
Ahh, ok thanks. |
FYI, this only appears to happen when using |
A bug in eslint-plugin-import cauess ESLint to error when trying to import exported TypeScript types. Upgrading to version 2.17 fixes this. See import-js/eslint-plugin-import#1282
A bug in eslint-plugin-import cauess ESLint to error when trying to import exported TypeScript types. Upgrading to version 2.17 fixes this. See import-js/eslint-plugin-import#1282
A bug in eslint-plugin-import cauess ESLint to error when trying to import exported TypeScript types. Upgrading to version 2.17 fixes this. See import-js/eslint-plugin-import#1282
like @schmod said the bug is present with when using |
it seems to only happen when the type are in a separate |
I'm getting this issue with
|
A bug in eslint-plugin-import cauess ESLint to error when trying to import exported TypeScript types. Upgrading to version 2.17 fixes this. See import-js/eslint-plugin-import#1282
A bug in eslint-plugin-import cauess ESLint to error when trying to import exported TypeScript types. Upgrading to version 2.17 fixes this. See import-js/eslint-plugin-import#1282
I'm experiencing this error as well, with the package
|
A bug in eslint-plugin-import cauess ESLint to error when trying to import exported TypeScript types. Upgrading to version 2.17 fixes this. See import-js/eslint-plugin-import#1282
So in the import-js/eslint-import-resolver-typescript#31 it passed to |
I'm still getting this, for example when importing the Keyframes interface from
|
The same. Is there any solution? We have to disable the rule for now. |
Issue seems to appear when importing interface from Adding this to settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true
}
}
} seems to solve this problem. |
That’s because typescript’s module system is broken unless you enable synthetic imports and es module interop. If you enable those, what happens? |
Just to give a feedback, i had same issue and had all tried that should fix this issue. Nothing helped. So i played more with the settings and fixed it with setting the babel/env preset modules to "commonjs". Was set to "false". "presets": [
[
"@babel/env",
{
"useBuiltIns": "entry",
"corejs": 3,
"modules": "commonjs"
}
],
"@babel/react",
"@babel/typescript"
] |
I'm afraid you're missing the point of modules entry in babel/env preset and most likely you aren't running eslint cli, but rather using it as a webpack (or other bundler) plugin/loader. eslint-plugin-import/src/rules/named.js Line 79 in 94d6739
And if you use "modules": "commonjs" (especially in production), as a result you have larger bundle size, since webpack can't tree-shake commonjs. |
I found a similar problem and am now using the following to ignore the lint rules. (Because there is no problem in the behavior on the web) Currently, interfaces are defined in a set of files called "interfaces". I apologize if this is a lack of knowledge on my part. Please respond. |
Possible solution that works for us:
But it's only available for TS3.8+ |
TypeScript's exported types/interfaces does not work with
import/named
rule.File 'xxx.ts':
Then import it in different file:
Will result in error:
Same error when importing:
Or
The text was updated successfully, but these errors were encountered: