fix: correct Sym.node and getSymNode types to include undefined#10613
Draft
fix: correct Sym.node and getSymNode types to include undefined#10613
Sym.node and getSymNode types to include undefined#10613Conversation
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/c9bd61fa-0967-4040-bf79-605fbc758e88 Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/c9bd61fa-0967-4040-bf79-605fbc758e88 Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Sym.node and Sym.declarations definition to include undefined
fix: correct May 6, 2026
Sym.node and getSymNode types to include undefined
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sym.nodewas typed asNodebut is alwaysundefinedfor declaration symbols (where nodes are stored indeclarations[]instead).createSymbol()acceptsundefinedasnode, yet the type hid this, masking bugs at call sites that never checked forundefined.Type fixes
Sym.node:Node→Node | undefinedgetSymNode(): return typeNode→Node | undefinedCaller fixes
checker.tscompilerAssertwhere nodes are guaranteed by invariants (member containers, member symbols, template parameters, alias symbols) — documents the invariant and fails fast if violatedisTemplatedNode(node): acceptsNode | undefined, returnsfalseforundefinedgetMemberKindName(node): acceptsNode | undefined, returns"Type"forundefinedname-resolver.tsresolveMetaMemberByName: returnsNotFoundearly if symbol has no nodecreateMetaTypePrototypesmodel property handler: was usingbaseSym.node(alwaysundefinedfor declaration symbols) — fixed to usegetSymNode(baseSym)with acompilerAssert