microsoft / TypeScript-TmLanguage

TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom.
MIT License
397 stars 125 forks source link

A minor syntax highlighting issue in Typescript/React documents #931

Closed fatih-erikli closed 1 year ago

fatih-erikli commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Create the React component below
  2. See the syntax highlighting for the function keyword doesn't work
export const SvgDocument = forwardRef<SVGSVGElement, {
  width: number;
  height: number;
  nodes: NodeData[];
  edges: EdgeData[];
}>(function SvgDocument({ width, height, nodes, edges }, ref) {
// function body

It works fine when you move the type as a separate type definition

type Props = {
  width: number;
  height: number;
  nodes: NodeData[];
  edges: EdgeData[];
};
export const SvgDocument = forwardRef<SVGSVGElement, Props>(function SvgDocument({ width, height, nodes, edges }, ref) {
// function body

I don't know if both they use same library for syntax highligting (feels like they are same) but it seems to be working fine on github, has a minor glitch on vscode.

Screen Shot 2022-09-19 at 04 27 21
sheetalkamat commented 1 year ago

This is limitation of the tmLanguage grammar which doesnt let us determine if these are type arguments or expression followed by next variable declaration/binding pattern