The definition of Sym.node and Sym.declarations is incorrect, undefined is missed when it's possible, which makes compiler not able to help to do type check and potentially hide some bug when undefined is not handled properly.
Look at the createSymbol() method as below, you can find it accept undefined as node, but the returned Sym.node and Sym.declarations are defined as Node and Node[] only
https://github.com/RodgeFu/typespec/blob/550377179c4173aa27a91605b367d65df17f696f/packages/compiler/src/core/binder.ts#L669
And following is an example when undefined is passed in as node: https://github.com/RodgeFu/typespec/blob/550377179c4173aa27a91605b367d65df17f696f/packages/compiler/src/core/name-resolver.ts#L189
Also this behavior impacts other functions returning Sym.Node/Declaration to miss undefined in the return type, like https://github.com/RodgeFu/typespec/blob/550377179c4173aa27a91605b367d65df17f696f/packages/compiler/src/core/binder.ts#L708
The definition of
Sym.nodeandSym.declarationsis incorrect,undefinedis missed when it's possible, which makes compiler not able to help to do type check and potentially hide some bug whenundefinedis not handled properly.Look at the
createSymbol()method as below, you can find it acceptundefinedas node, but the returnedSym.nodeandSym.declarationsare defined asNodeandNode[]onlyhttps://github.com/RodgeFu/typespec/blob/550377179c4173aa27a91605b367d65df17f696f/packages/compiler/src/core/binder.ts#L669
And following is an example when
undefinedis passed in as node: https://github.com/RodgeFu/typespec/blob/550377179c4173aa27a91605b367d65df17f696f/packages/compiler/src/core/name-resolver.ts#L189Also this behavior impacts other functions returning Sym.Node/Declaration to miss
undefinedin the return type, like https://github.com/RodgeFu/typespec/blob/550377179c4173aa27a91605b367d65df17f696f/packages/compiler/src/core/binder.ts#L708