microsoft / microsoft/TypeScript-TmLanguage

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

Open
#1,014 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
TypeScript
Stars
471
Forks
149
PR merge metrics
No merged PRs in 30d

Description

🔎 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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript TextMate grammar files in this repository and reproduce the Playground example in VS Code using the Monokai Pro color scheme. Compare generic type arguments across the whitespace and surrounding-context variations shown in the issue. Done means the listed identifiers, angle brackets, parentheses, type arguments, and numeric arguments receive consistent highlighting.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.