microsoft / TypeScript-TmLanguage

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

TSX Default Generic Arrow Function Syntax Highlighting #990

Open JustJarethB opened 1 year ago

JustJarethB commented 1 year ago

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

Related to https://github.com/microsoft/TypeScript/issues/47062 TSC has been updated to successfully parse the below TSX code snippet:

const Component = <T = undefined>(props: PropType<T>) => <p>content</p>

however this currently breaks the syntax highlighting in VSCode's typescriptreact parser.

The same can be said for the trailing comma added by prettier (3.0.3):

const Component = <T = undefined,>(props: PropType<T>) => <p>content</p>

Some short term work-arounds are available:

Using extends

const Component = <T extends unknown = undefined>(props: PropType<T>) => <p>content</p>

Using function syntax

const Component = function<T = undefined>(props: PropType<T>) {
  return <p>content</p>
}

Despite these workarounds, the original code seems syntactically valid, and more concise, so I believe this to be a bug

VSCodeTriageBot commented 1 year ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.81.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

JustJarethB commented 1 year ago

Upgraded to 1.81.1; Issue persists