Visual Studio Code:[js] types can only be used in a .ts file

前端 未结 4 1398
小蘑菇
小蘑菇 2021-02-08 06: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

相关标签:
4条回答
  • 2021-02-08 06:18

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

    0 讨论(0)
  • 2021-02-08 06:21

    NOTE - This is just a WORKAROUND, not solution. Use ONLY IF you do not find appropriate solution

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

    {
        "javascript.validate.enable": false
    }
    
    0 讨论(0)
  • 2021-02-08 06:34

    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

    0 讨论(0)
  • 2021-02-08 06:42

    Has that change the "Select Language Mode" for "TypeScript React" in list. it worked for me.

    enter image description here

    0 讨论(0)
提交回复
热议问题