Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

VSCode syntax highlighting breaks for JSX components with generic parameter defaults

未关闭
#1,033 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react, typescript
领域
tooling

调研方向

从链接的 jsx-syntax-bug 复现和负责 JSX 高亮的 TypeScript-TmLanguage 语法文件开始。将该示例与相关的 TypeScript issue 进行比较,然后验证带有默认类型参数的泛型 JSX 组件不再被标记为错误,同时现有示例仍能正确高亮。

由索引模型根据 Issue 内容生成。

描述

🔎 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

https://github.com/microsoft/TypeScript/issues/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
主要语言
TypeScript
星标
471
派生
149
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/TypeScript-TmLanguage 的其他 Issue

查看 microsoft/TypeScript-TmLanguage 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。