我正在用vscode编写React应用程序(从create react应用程序开始),我也在使用eslint。最近,我开始集成Typescript。
由于某种原因,我在编写一些Typescript表达式时遇到了问题。例如:
interface Lengthwise {
length: number;
}
function loggingIdentity<T extends Lengthwise>(arg: T): T {
console.log(arg.length); // Now we know it has a .length property, so no more error
return arg;
}
此示例摘自typescriptlang.org page。
我收到以下错误:
你知道我的环境有什么问题吗?
答案 0 :(得分:0)
最终,该问题是eslintrc中的无效解析器。
将解析器从“ babel-eslint”更改为@ typescript-eslint / parser,并且可以使用。