问题描述
我不知道为什么这行不通。我希望@ typescript-eslint / no-unused-vars能够识别该函数返回类型所使用的类型。我究竟做错了什么?我想知道这应该如何工作吗?
.eslintrc.json
{
"env": {
"browser": false,"node": true
},"extends": [
"airbnb-base","eslint:recommended","plugin:@typescript-eslint/eslint-recommended"
],"parser": "@typescript-eslint/parser","parserOptions": {
"ecmaVersion": 2020,"sourceType": "module"
},"plugins": [
"typescript","@typescript-eslint"
],"settings": {
"import/resolver": {
"typescript": {}
}
},"rules": {
"no-unused-vars": "off","@typescript-eslint/no-unused-vars": ["error"]
}
}
Service.ts:
export declare interface FooConfig {}
Foo.ts:
import { FooConfig } from "library/types/Service";
export default function foo(): FooConfig {
return {};
}
错误:
ESLint:已定义“ FooConfig”,但从未使用过。 (@ typescript-eslint / no-unused-vars)
解决方法
对于我正在使用的版本(4.0.0-alpha.1)来说,这似乎是一个已知问题,希望很快会得到解决。
https://github.com/typescript-eslint/typescript-eslint/issues/2337