如何使类型缩小在 switch(root.type.code) 中起作用?

How to make types narrowing works inside switch(root.type.code)?

只有在需要检查 root 中的密钥时,缩小范围才有效。如果存在目标键的嵌套,则它不起作用。为什么会这样?

Ts Playground with example

期望的行为: TS 将第二个示例中的类型理解为特定类型而不是 tuple

Typescript 还做不到

Nested Tagged Unions #18758