我将Eslint用于我的项目,请使用:
@typescript-eslint/parser
1.4.2@typescript-eslint/eslint-plugin
1.4.2eslint-import-resolver-typescript
1.1.1airbnb-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 A from '../A';
并调用A.Id但ide抛出错误:
A仅指类型,但在此处被用作名称空间
两种方法都有错误,一种来自eslint
,一种来自IDE(Vs Code,也许是Tshint)
您能帮我修复其中一个吗?
预先感谢!
我不认为您的错误与Eslint有关。从我可以看到,这似乎是一个基本的Typescript错误。
您A.ts
不包含默认导出。为了从中导入整个模块,A.ts
应使用
import * as A from '../A';
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句