Skip to content

Parse dotted private names in type queries, forbid in declaration emit - #4898

Merged
Wesley Wigham (weswigham) merged 3 commits into
microsoft:mainfrom
weswigham:private-name-type-queries
Aug 14, 2026
Merged

Parse dotted private names in type queries, forbid in declaration emit#4898
Wesley Wigham (weswigham) merged 3 commits into
microsoft:mainfrom
weswigham:private-name-type-queries

Conversation

@weswigham

Copy link
Copy Markdown
Member

@a-tarasyuk

Copy link
Copy Markdown
Contributor

It looks like this revives the approach from microsoft/TypeScript#47696 while addressing the AST issue that led to its revert. I was wondering whether it still makes sense to consider the approach from microsoft/TypeScript#47595 (comment)?

@weswigham

Copy link
Copy Markdown
Member Author

Private names only appear in dotted expression-like positions elsewhere in the language, I really don't wanna go changing that. If we had expr[#q] in JS, I'd feel better about that approach, but we don't, and I don't wanna conflict with a potential future expression syntax (since typeof is supposed to basically have an expression argument).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enables private identifiers in dotted type queries while preventing invalid declaration emission.

Changes:

  • Parses and prints private names in typeof queries.
  • Extends qualified-name AST support to member names.
  • Adds TS7080 declaration diagnostics and compiler baselines.
Show a summary per file
File Description
_scripts/ast.json Widens qualified-name suffixes.
_packages/native-preview/src/ast/ast.generated.ts Updates AST typing.
_packages/native-preview/src/ast/factory.generated.ts Updates factory signatures.
_packages/native-preview/src/ast/visitor.generated.ts Visits member names.
internal/ast/ast_generated.go Updates Go AST definitions.
internal/parser/parser.go Parses private type-query names.
internal/printer/printer.go Prints private qualified names.
internal/transformers/declarations/transform.go Rejects private declaration references.
internal/diagnostics/extraDiagnosticMessages.json Defines TS7080.
internal/diagnostics/diagnostics_generated.go Generates TS7080 metadata.
testdata/tests/cases/compiler/privateNameInTypeQuery.ts Tests parsing and checking.
testdata/tests/cases/compiler/declarationEmitPrivateNameInTypeQuery.ts Tests declaration diagnostics.
testdata/baselines/reference/compiler/privateNameInTypeQuery.types Records inferred types.
testdata/baselines/reference/compiler/privateNameInTypeQuery.symbols Records resolved symbols.
testdata/baselines/reference/compiler/privateNameInTypeQuery.js Records JavaScript output.
testdata/baselines/reference/compiler/privateNameInTypeQuery.errors.txt Records expected errors.
testdata/baselines/reference/compiler/declarationEmitPrivateNameInTypeQuery.types Records declaration-test types.
testdata/baselines/reference/compiler/declarationEmitPrivateNameInTypeQuery.symbols Records declaration-test symbols.
testdata/baselines/reference/compiler/declarationEmitPrivateNameInTypeQuery.js Records declaration-test output.
testdata/baselines/reference/compiler/declarationEmitPrivateNameInTypeQuery.errors.txt Records TS7080 diagnostics.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Files not reviewed (2)
  • internal/ast/ast_generated.go: Generated file
  • internal/diagnostics/diagnostics_generated.go: Generated file
  • Files reviewed: 18/20 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread internal/printer/printer.go Outdated
Sure, why not, only affects semantic tokens though

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@weswigham
Wesley Wigham (weswigham) added this pull request to the merge queue Aug 14, 2026
Merged via the queue into microsoft:main with commit 0f714a5 Aug 14, 2026
21 checks passed
@weswigham
Wesley Wigham (weswigham) deleted the private-name-type-queries branch August 14, 2026 21:35
Jake Bailey (jakebailey) pushed a commit to jakebailey/TypeScript that referenced this pull request Aug 14, 2026
microsoft/typescript-go#4898)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Inability to use typeof on an ES private property

5 participants