Repository navigation
Parse readonly.Something and keyof.Other - #65669
Wesley Wigham (weswigham) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change supporting contextual keywords as namespace names in qualified type references.
No open issues 🎉
What changed in this PR
This PR updates the TypeScript parser to recognize keyof, readonly, unique, and infer as namespace names when followed by a dot, rather than treating them as type operators.
Changes:
- Adds dot lookahead to distinguish qualified type references from type operators.
- Adds regression coverage for namespace references alongside existing operator syntax.
- Adds expected type, symbol, JavaScript, and declaration baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/typeOperatorNamespaceReferences.ts |
Tests contextual-keyword namespaces and operator syntax. |
tsc/testdata/baselines/reference/compiler/typeOperatorNamespaceReferences.types |
Records expected resolved types. |
tsc/testdata/baselines/reference/compiler/typeOperatorNamespaceReferences.symbols |
Records expected namespace and member symbols. |
tsc/testdata/baselines/reference/compiler/typeOperatorNamespaceReferences.js |
Records JavaScript and declaration output. |
tsc/internal/parser/parser.go |
Parses contextual keywords followed by a dot as qualified type references. |
Review effort: Balanced
|
TypeScript Bot (@typescript-bot) test this |
|
Hey Wesley Wigham (@weswigham), the results of running the DT tests are ready. Everything looks the same! |
|
Wesley Wigham (@weswigham) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Wesley Wigham (@weswigham) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Wesley Wigham (@weswigham) Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Fixes an issue I noticed in the negated types PR where after adding
notas a type operator,not.Optionwould fail to parse. These keywords (keyof,readonly,unique,infer, and laternot) are all valid type names because they're all only contextual keywords, so generally we strive to parse them as types where they don't successfully parse as the keyword type operator.