Flow-for-vscode: Type cast expression in string template breaks syntax highlighting

Created on 4 Apr 2017  路  5Comments  路  Source: flowtype/flow-for-vscode

vscode 1.10.2
OS: Mac 10.12.3

In the following example, syntax highlighting breaks at the first '}'. When there is a subsequent expression after the type cast (e.g. ${2}), it breaks highlighting for the rest of the file.

const x = 0;
const y = `${(x: number)} highlighting is broken here ${2}`;
const z = 'syntax highlighting is broken to the end of the file';

screen shot 2017-04-03 at 3 12 07 pm

See also: #34 #93

This kills the readability of flow programs and I pretty much have to turn syntax highlighting off altogether. In my opinion, either the flow grammar should be resurrected or else the typescript grammar needs to be tweaked to not completely break down in this situation.

Most helpful comment

Another option is to use https://marketplace.visualstudio.com/items?itemName=joshpeng.sublime-babel-vscode, which IMO provides better syntax highlighting.

All 5 comments

If you're willing to create, maintain and set up a Flow tmlanguage for this extension then I'm alright with shipping one. It was done before and removed for being really tough to keep up to date, and support all the vscode features.

IMO it might be better to send a PR to the official JS one to make it not break in cases like this though.

This issue appears to be fixed by installing extension ms-vscode.js-atom-grammar, which uses Atom's javascript grammar. Maybe update the documentation to suggest installing this extension?

Rockin' thanks @siegebell - I've shipped a README fix

Another option is to use https://marketplace.visualstudio.com/items?itemName=joshpeng.sublime-babel-vscode, which IMO provides better syntax highlighting.

This plugin doesn't provide syntax highlighting. Use https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel for that.

Was this page helpful?
0 / 5 - 0 ratings