Visual Studio Code:[js] 类型只能在 .ts 文件中使用 [英] Visual Studio Code:[js] types can only be used in a .ts file
问题描述
是否可以在 vs 代码的打字稿项目中使用 .js 文件?我从 github 存储库克隆了一个 react-native 项目并在 Visual Studio 代码中打开它.当我添加 tsconfig.json 以开始使用打字稿时,我得到一长串错误.例如,这是一个 drawer.js 文件(具有 es6 功能):
Is it possible to use .js files in a typescript project in vs code? I have clone a react-native project from a github repository and opened it in visual studio code. When I add a tsconfig.json in order to start using typescript, I get a long list of errors. For example here is a drawer.js file (with es6 features):
这是我的 tsconfig.json 文件(如果我删除此文件,则一切正常,不会报告错误):
Here is my tsconfig.json file (If I remove this file then every thing works fine, no error reported) :
推荐答案
注意 - 这只是一个 WORKAROUND,而不是解决方案.仅在找不到合适的解决方案时使用
NOTE - This is just a WORKAROUND, not solution. Use ONLY IF you do not find appropriate solution
解决方法 - 在 $workspace/.vscode/settings.json
{
"javascript.validate.enable": false
}
这篇关于Visual Studio Code:[js] 类型只能在 .ts 文件中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!