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

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

Open
lionel-rowe opened this issue Dec 21, 2023 · 1 comment
Labels
bug help wanted Need help with making changes for the issue/feature

Comments

@lionel-rowe
Copy link

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

@RyanCavanaugh RyanCavanaugh added bug help wanted Need help with making changes for the issue/feature labels Dec 21, 2023
@sheetalkamat sheetalkamat transferred this issue from microsoft/TypeScript Jan 3, 2024
@Mister-Hope
Copy link

I believe this is the same as my issue #876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Need help with making changes for the issue/feature
Projects
None yet
Development

No branches or pull requests

3 participants