#9501·flow

[flow-for-vscode] Ship the Try Flow grammar so VS Code highlights component and hook syntax

Author: matclaytonCreated Sep 23, 2026Updated Sep 23, 2026

Proposal

Ship the Try Flow TextMate grammar in the public VS Code extension (packages/flow-for-vscode), so that VS Code highlights component syntax, hook syntax and match.

The grammar already exists. website/src/try-flow/flow-grammar.json says it is "copied from fbsource/vscode/vscode-extensions/flow/syntaxes", and the team keeps it current. For example, async component and async hook support landed in February 2026 (de7094cd, 5363e534). The only gap is that flow-for-vscode does not ship it.

The change:

  • Copy flow-grammar.json and flow-regex-grammar.json into packages/flow-for-vscode/syntaxes/. The internal sync that copies them to the website could copy them there too.
  • Contribute flow-grammar.json as the source.js grammar for javascript and javascriptreact. Babel JavaScript does the same.
  • Map meta.tag.jsx to the built-in jsx-tags language, and meta.embedded.expression.js back to the host language. Comment toggling then uses {/* */} in JSX tags and // in code.
  • Add syntaxes/*.json to .vscodeignore, which excludes everything by default.
  • Replace the README note that points to Babel JavaScript.

We have this as a patch against main and can open a PR if you want it.

Trade-offs for you to decide:

  • The extension would change the JavaScript grammar for every workspace, including ones that do not use Flow. A TextMate grammar cannot be switched on or off with a setting.
  • The grammar includes grammars for styled-components CSS and Mustache templates that the extension would not ship. VS Code ignores a missing include, so that embedded code has no highlighting, the same as today.