![](/img/trans.png)
[英]ESLint conflicts with eslint-plugin-import and typescript-eslint
[英]Typescript import type Eslint: import/named
我将Eslint用于我的项目,使用:
@typescript-eslint/parser
1.4.2 @typescript-eslint/eslint-plugin
1.4.2 eslint-import-resolver-typescript
1.1.1 airbnb-base
和plugin:@typescript-eslint/recommended
或者你可以查看我的.eslintrc
:
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": ["airbnb-base", "plugin:@typescript-eslint/recommended"],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts"]
},
"import/resolver": {
"typescript": {}
}
},
"rules": {
"no-plusplus": "off",
"import/no-cycle": "warn",
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/explicit-member-accessibility": "off"
}
}
在文件A.ts
我使用: export type Id = string;
并从B.ts
import { Id } from '../A';
: import { Id } from '../A';
我试着用:
import A from '../A';
并调用A.Id但是ide throw错误:
A仅指类型,但在此处用作命名空间
两种方式都有错误,一种来自eslint
,一种来自IDE(Vs Code,也许是Tshint)
你能帮我解决其中一个问题吗?
预先感谢!
我不认为你的错误与Eslint有关。 从我所看到的,它似乎是一个基本的Typescript错误。
您的A.ts
不包含默认导出。 要从A.ts
导入整个模块,您应该使用
import * as A from '../A';
你试过这个吗?
import A as A from '../A';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.