变量声明为string | number,当前已收窄为string,为什么稍后赋值42仍可通过编译?

来自类型收窄
TypeScript 6 进阶 3分钟

变量声明为string | number,当前已收窄为string,为什么稍后赋值42仍可通过编译?

报告错误