我开始在我正在Visual Studio代码中工作的Node项目中使用TypeScript.我想遵循"选择加入"策略,类似于Flow.因此,我放在// @ts-check我的.js文件的顶部,希望为该文件启用TS.最终,我希望获得与"linting"相同的Flow体验,因此我安装了插件TSLint,因此我可以看到Intellisense警告/错误.
但我的文件看起来像:
// @ts-check
module.exports = {
someMethod: (param: string): string => {
return param;
},
};
Run Code Online (Sandbox Code Playgroud)
我的tsconfig.json文件看起来像......
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"allowJs": true
}
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:[js] 'types' can only be used in a .ts file.如下图所示.
我看到这个问题建议在vscode中禁用javascript验证,但那时我没有向我显示任何 TypeScript Intellisense信息.
我尝试设置tslint.jsEnable到true作为TSLint扩展文档中提到,但没有运气就在我vscode设置.
为了使用.jsTypeScript文件并获得Intellisense ,正确的设置是什么,所以在运行任何TS命令之前,我知道代码中的错误是什么?