Skip to content

Sym.node and Sym.declarations is not defined correctly #10612

@RodgeFu

Description

@RodgeFu

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions