gandm / language-babel

ES2017, flow, React JSX and GraphQL grammar and transpilation for ATOM
https://atom.io/packages/language-babel
MIT License
476 stars 83 forks source link

Flow: typed variable with generic arrow function value breaks syntax #480

Closed CadenP closed 6 years ago

CadenP commented 6 years ago

Syntax seems to break when a variable is given a type and assigned to an arrow function which has a generic type and the generic type is not immediately followed by a colon (and a space or special/numeric character before the generic's type if there is one).

Not Working:

A type on the variable, and the generics of the function not having a type Generic without a type

A type on the variable, and the generics of the function has a type, but no space around the colon. Generic with a type without a separating space

A type on the variable, and the generics of the function having a type with a space before the colon (my personal preference). Generic with a space before the colon and type

Unexpectedly Working [Bugs?]:

A type on the variable, and there's a colon in the function generics, but no type after the colon. Generic with a colon but no type following

A type on the variable, and garbage following the colon in the function generics. I'm not really sure if this is a bad thing, but I am amused by it. Generic with a bunch of special and numerical characters after the colon with no space before the colon

Working Expectedly:

A type on the variable, but there's a space after the colon in the generics and not before. Generic with a space between the colon and type

No type on the variable, but keeping the function generics. Generic but without the type on the variable itself

Summary:

Overall, it seems that it is requiring that a colon come immediately after the generic type, and any following character must be non-alpha. Otherwise it seems to think that it's a JSX tag that needs to close.

It does not appear to matter what order the colon and space/no-space appear with regard to the variable's type.