borela / naomi

Sublime Text enhanced syntax highlighting for JavaScript ES6/ES7/ES2015/ES2016/ES2017+, Babel, FlowType, React JSX, Styled Components, HTML5, SCSS3, PHP 7, phpDoc, PHPUnit, MQL4. Basic: Git config files.
Other
557 stars 20 forks source link

[JS/Flow] Implicit return values break syntax highlighting when `<` or `>` used in type definitions #255

Open TomasBarry opened 4 years ago

TomasBarry commented 4 years ago

When defining methods where the types have a < or a > (Array<...> or any Flow utility type) and that method implicitly returns a value the syntax highlighting breaks down. Take the following simple example:

// @flow

const someMethod = (params: Array<string>): Array<string> => params

console.log('some console')

The syntax highlighting breaks down after the implicit return of `params. However, if the above was defined as:

// @flow

const someMethod = (param: string): string => params

console.log('some console')

The syntax highlighting remains intact.

The first example can be fixed by using the long-form with an explicit return:

// @flow

const someMethod = (params: Array<string>): Array<string> => { return params }

console.log('some console')