Skip to content

Fix const type parameters in TSX#1073

Open
phryneas wants to merge 1 commit into
microsoft:masterfrom
phryneas:pr/fix-constTypeParameter-in-tsx
Open

Fix const type parameters in TSX#1073
phryneas wants to merge 1 commit into
microsoft:masterfrom
phryneas:pr/fix-constTypeParameter-in-tsx

Conversation

@phryneas
Copy link
Copy Markdown

@phryneas phryneas commented May 18, 2026

fixes #979

I tried to reuse existing tests as far as possible - this should finally fix synax highlighing for <const Foo extends Bar> kind type parameters.

@@ -1,4 +1,3 @@
// @onlyOwnGrammar - this has type parameters that would be jsx in tsx files
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test now works with both ts and tsx

foo<const U>(x: U) { return x; }
}
const C2 = class <const T> {}
const fx1 = <const T>(x: T) => x;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is ambiguous in tsx - moved into a separate test

source.ts meta.var.expr.ts meta.class.ts punctuation.definition.block.ts
^
source.ts meta.var.expr.ts meta.class.ts punctuation.definition.block.ts
>const fx1 = <const T>(x: T) => x;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just moved to the other file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript's const modifier on type parameteres breaks syntax highlighting in .tsx files

1 participant