Skip to content

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

Open
@lionel-rowe

Description

@lionel-rowe

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wantedNeed help with making changes for the issue/feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions