示例工程 08-unions-intersections

08-unions-intersections/01-union-basics/demo/not-in-union.ts

typescript · 0.2 KB

运行:08 · union-basics

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

// 故意写错:boolean 不在 Id 联合里。
// 期望 tsc 报 TS2322(由 tsconfig.fail.json 触发)。
type Id = string | number;
 
const id: Id = true;
 
export { id };