To use Flowjs in VSCode you are supposed to install the Flow Language Support extension and disable the normal JS/TS support either by adding
"javascript.validate.enable": false
to your projects' VSCode settings.json file or disable the JS/TS-features completely.
I have a multi-root workspace with different project-roots that use JS, TypeScript or FlowJS so I can't disable the JS/TS stuff completely. But disabling JS validation via the folder's vscode settings give me the error/message:
This setting cannot be applied in this workspace. It will be applied when you open the containing workspace folder directly.
And it is not working. None of the Flow-features are working and VSCode complains about things like this:
- 'import type' declarations can only be used in TypeScript files.
- Type aliases can only be used in TypeScript files.
- Type annotations can only be used in TypeScript files.
- ...
How can I get FlowJS + VSCode working when I'm using a multi-root workspace?
Example project:
Project
├──Root A (plain old JS)
│ └───.vscode
│ └─── settings.json
│
├──Root B (FlowJS)
│ └───.vscode
│ │ └─── settings.json // "javascript.validate.enable": false
│ └─── test.js // error: Type annotations can only be used in TypeScript files.ts(8010)
│
├──Root C (TypeScript)
│ └───.vscode
│ └─── settings.json
│
└─── example.code-workspace