js 'types' can only be used in a .ts file - Visual Studio Code using @ts-check js 'types' can only be used in a .ts file - Visual Studio Code using @ts-check javascript javascript

js 'types' can only be used in a .ts file - Visual Studio Code using @ts-check


I'm using flow with vscode but had the same problem. I solved it with these steps:

  1. Install the extension Flow Language Support

  2. Disable the built-in TypeScript extension:

    1. Go to Extensions tab
    2. Search for @builtin TypeScript and JavaScript Language Features
    3. Click on Disable


Use "javascript.validate.enable": false in your VS Code settings, It doesn't disable ESLINT. I use both ESLINT & Flow. Simply follow the instructions Flow For Vs Code Setup

Adding this line in settings.json. Helps"javascript.validate.enable": false


For anyone who lands here and all the other solutions did not work give this a try. I am using typescript + react and my problem was that I was associating the files in vscode as javascriptreact not typescriptreact so check your settings for the following entries.

   "files.associations": {    "*.tsx": "typescriptreact",    "*.ts": "typescriptreact"  },