Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode syntax highlighting breaks for JSX components with generic parameter defaults #1033

Open
james-yeoman opened this issue Jun 20, 2024 · 0 comments

Comments

@james-yeoman
Copy link

james-yeoman commented Jun 20, 2024

πŸ”Ž Search Terms

"vscode jsx generics"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSX Generics

⏯ Playground Link

https://github.com/james-yeoman/jsx-syntax-bug

πŸ’» Code

import React from "react";

type FooProps<T> = {
  genericProp: T
}

export const Foo = <T = string,>({ genericProp }: FooProps<T>) => {
//                    ^ Error highlighting starts here
  return <div>{String(genericProp)}</div>
}

πŸ™ Actual behavior

When defining a React JSX component as a Generic component, if you add a type default to the type parameter, the syntax highlighting marks it as an error, but no error is actually reported.

If you remove the fallback, or add an extends, the syntax error highlighting goes away.

The readme at my reproduction repo has screenshots of the bug in action, in case I've not explained the behaviour particularly well.

πŸ™‚ Expected behavior

Syntax highlighting should be able to handle Generics with default types in JSX files.

Additional information about the issue

microsoft/TypeScript#45939 - Highly related, but is for typescript itself, rather than for VSCode's syntax highlighting.

My VSCode installation About content

Version: 1.90.0
Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573
Date: 2024-06-04T19:43:07.605Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Linux x64 5.15.0-112-generic
@DanielRosenwasser DanielRosenwasser transferred this issue from microsoft/TypeScript Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant