yats.vim
yats.vim copied to clipboard
Arrow function with generic in TSX
I understand this is getting quite ambiguous for the parser 🙈.
In TSX files, arrow functions with generics look a lot like JSX. In this issue the TypeScript side suggests there will be no fix and that extending or having multiple generics are two ways in which the parser can tell the arrow function from JSX. Sadly, this syntax also breaks all highlighting coming after it. Example below.
const updateSet = <T extends {}>(choice, set: Set<T>): Set<T> =>
choice.isShown ? set.delete(choice.id) : set.add(choice.id);
};
// broken highlighting after this point
Sadly this is not easy to fix. To tell generic arrow function from type cast requires complex regexp which usually makes Vim slow...
FWIW, every other text editor fully supports this 🤷♂️
@quinn FWIW, no other text editor plugin supports both highlight richness and performance at the same time. Maybe you could send a pull request for generic function here.
@HerringtonDarkholme sorry about that, I didn’t understand the scope of the problem..