fix(parser): reject 'const' modifier on type alias type parameter#22828
fix(parser): reject 'const' modifier on type alias type parameter#22828Boshen wants to merge 1 commit into
Conversation
a1dcf5e to
3ed3157
Compare
96b2851 to
efa7b94
Compare
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merge activity
|
3ed3157 to
b817ee4
Compare
efa7b94 to
60f0b51
Compare
This feels strange. This is a It feels like we should just emit an error for both and accept the regression in babel? Babel's fixtures don't completly aligh with TS. |

Stacked on #22827.
A
constmodifier on a type parameter is only valid when the type parameter belongs to a function, method, or class (TS1277) — it is not allowed on a type alias.Verified against
typescript-go(internal/checker/grammarchecks.go): for aconsttype-parameter modifier the parent must be one of function-like / class-like / function-type / constructor-type / call|construct|method signature, otherwise TS reports "'const' modifier can only appear on a type parameter of a function, method or class".The check is scoped to type aliases at the parser level: this matches babel's fixtures and avoids regressing the
const-type-parameterspositive fixture (which parsesinterface I<const T>). TypeScript also rejects the interface case, but only as a checker-level diagnostic, so leaving it to a later pass keeps the parser consistent with babel.Conformance
No regressions across any parser suite (positive/AST stay 100%):
parser_babelparser_typescriptFlips
types/const-type-parameters-invalid(babel) andtypeParameterConstModifiers.ts(TypeScript).🤖 Generated with Claude Code