在我的 Typescript React 项目中,我定义了:
export type NavState = { mounted: boolean }
然后在我的组件中,我使用了如下主题:
import { NavState } from '../../models/nav'
class Nav extends React.Component<any, NavState> {
state: NavState = {
mounted: false
}
}
但我在导入时得到了红色下划线NavState
,上面写着:
'NavState' is defined but never used. (no-unused-vars)standard(no-unused-vars)
在我的package.json
我有这个:
"standard": {
"ignore": [
"node_modules/**",
"**/__generated__/"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
]
}
我的vs代码settings.json
是这样的:
{
"standard.autoFixOnSave": true,
"standard.enable": true,
"standard.run": "onType",
"standard.validate": [
{ "language": "javascript", "autoFix": true },
{ "language": "javascriptreact", "autoFix": true },
{ "language": "typescript", "autoFix": true },
{ "language": "typescriptreact", "autoFix": true }
]
}
为什么 Standardjs 无法理解我使用了类型别名?我该如何解决?