Visual Studio Code:[js] types can only be used in

2020-06-03 01:14发布

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):

enter image description here

Here is my tsconfig.json file (If I remove this file then every thing works fine, no error reported) :

enter image description here

4条回答
男人必须洒脱
2楼-- · 2020-06-03 01:51

You're missing a , comma between type and { Action } in line 2.

查看更多
萌系小妹纸
3楼-- · 2020-06-03 01:53

Workaround - Add the following configuration in $workspace/.vscode/settings.json

{
    "javascript.validate.enable": false
}
查看更多
小情绪 Triste *
4楼-- · 2020-06-03 01:59

You can try with this!!!

Install in your visual studio code the extension Flow Language Support and disable TypeScript and JavaScript Language Features

Search @builtin TypeScript and JavaScript Language Features and reload.

You can see this solutions https://stackoverflow.com/questions/48859169

Its important install npm for flow

Link Flow

查看更多
兄弟一词,经得起流年.
5楼-- · 2020-06-03 02:08

I restarted VS code and the error was gone, just in case it helps

查看更多
登录 后发表回答