1

要在 VSCode 中使用 Flowjs,您应该安装Flow Language Support扩展并通过添加禁用正常的 JS/TS 支持

"javascript.validate.enable": false

到您项目的 VSCode settings.json 文件或完全禁用 JS/TS 功能。

我有一个多根工作区,其中包含使用 JS、TypeScript 或 FlowJS 的不同项目根,所以我不能完全禁用 JS/TS 的东西。但是通过文件夹的 vscode 设置禁用 JS 验证会给我错误/消息:

This setting cannot be applied in this workspace. It will be applied when you open the containing workspace folder directly.

它不工作。Flow 的所有功能都不起作用,VSCode 抱怨这样的事情:

- '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.
- ...

当我使用多根工作区时,如何让 FlowJS + VSCode 工作?

示例项目:

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
4

0 回答 0