Skip to content

fix: correct Sym.node and getSymNode types to include undefined#10613

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-sym-node-declarations-undefined
Draft

fix: correct Sym.node and getSymNode types to include undefined#10613
Copilot wants to merge 3 commits intomainfrom
copilot/fix-sym-node-declarations-undefined

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

Sym.node was typed as Node but is always undefined for declaration symbols (where nodes are stored in declarations[] instead). createSymbol() accepts undefined as node, yet the type hid this, masking bugs at call sites that never checked for undefined.

Type fixes

  • Sym.node: NodeNode | undefined
  • getSymNode(): return type NodeNode | undefined

Caller fixes

checker.ts

  • Added compilerAssert where nodes are guaranteed by invariants (member containers, member symbols, template parameters, alias symbols) — documents the invariant and fails fast if violated
  • isTemplatedNode(node): accepts Node | undefined, returns false for undefined
  • getMemberKindName(node): accepts Node | undefined, returns "Type" for undefined

name-resolver.ts

  • resolveMetaMemberByName: returns NotFound early if symbol has no node
  • createMetaTypePrototypes model property handler: was using baseSym.node (always undefined for declaration symbols) — fixed to use getSymNode(baseSym) with a compilerAssert

@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label May 6, 2026
Copilot AI changed the title [WIP] Fix Sym.node and Sym.declarations definition to include undefined fix: correct Sym.node and getSymNode types to include undefined May 6, 2026
Copilot AI requested a review from timotheeguerin May 6, 2026 18:36
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@10613

commit: 6a1b498

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

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sym.node and Sym.declarations is not defined correctly

2 participants