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

Syntax highlighting: generic type arguments are highly affected by whitespace and other irrelevant context

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

还没有人认领这个 Issue。

评估

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

调研方向

从此仓库中的 TypeScript TextMate 语法文件开始,使用 Monokai Pro 配色方案在 VS Code 中复现 Playground 示例。比较 issue 中所示的不同空白和周围上下文变体下的泛型类型参数。完成标准是,列出的标识符、尖括号、圆括号、类型参数和数值参数都获得一致的高亮。

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

描述

bug help wanted
🔎 Search Terms

syntax highlighting generics

🕗 Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about syntax highlighting and generics.

⏯ Playground Link

https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXygCMwAeAQQBp4AhKgYQD4AKASgC540BrVHAd1QAoQWDwBnDAWIAmeAF4ppAIxVpVAMwMR4yUTDr5ikgA0qATSoAtLaNQTFAFkN6SggJAr3a9+sE2digCszsSubqbuFu6WfsK29nBiyBAYSiHKqhrMLHEBickYsgou7p5u3m6+2bl2kvkpBsWhpvAW8NasNQkgSSlOTaTuEW5RbjHV2rUEMDCGANruLirwavCarBSLoe4em27le5Xu2XsuLW0dLKfb+8MjhzFuJ4IAul2SOIQAVoYA3u71VIcJaZNYMeAbAE9ArSYE3XY7CpHJ6QtyA9Rw0jnKzPNHQvqYsLhQ6jMbHSEAX2EAHpqfAAHSMwQYACeAAcEMZDNxeAJmeyEGZuagePwhKyOe1haK+UA

💻 Code
declare function abc<A, B, C>(): unknown

const abc2 = abc<1, 2, 3>
const abc3 = abc<X, Y, Z>
const abc4 = abc<
	1,
	2,
	3
>
const abc5 = abc<
	X,
	Y,
	Z
>

const result1 = abc<1, 2, 3>()

const result2 = abc<
	1,
	2,
	3
>()

const result3 = abc<X, Y, Z>()

const result4 = abc<
	X,
	Y,
	Z
>()

const arr = [
	abc<1, 2, 3>(),
	abc<
		1,
		2,
		3
	>(),
	abc<X, Y, Z>(),
	abc<
		X,
		Y,
		Z
	>(),
]

const obj = {
	result1: abc<1, 2, 3> (),
	result2: abc<
		1,
		2,
		3
	>(),
	result3: abc<X, Y, Z>(),
	result4: abc<
		X,
		Y,
		Z
	>(),
}
🙁 Actual behavior

Declaring a function signature with generics seems to be pretty robust to changes in whitespace and surrounding context, but passing type arguments is extremely brittle.

This is the preceding code sample in VS Code with the Monokai Pro color scheme:

image

🙂 Expected behavior

Consistent syntax highlighting:

  • abc to be consistently green (3/16)
  • <> to be consistently gray (3/16)
  • () to be consistently gray (8/12)
  • X, Y, Z to be consistently blue (3/8)
  • 1, 2, 3 to be consistently purple (6/8)
Additional information about the issue

Original issue in monokai-pro-vscode

主要语言
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 摘要。