示例工程 15-type-testing-api-design

15-type-testing-api-design/01-type-assertions/demo/unused-expect.ts

typescript · 0.3 KB

运行:15 · type-assertions

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

// 故意写错:这一行本来没有类型错误,下面的指令会未命中。
// 期望 tsc 报 TS2578(由 tsconfig.fail.json 触发)。
export const ok: number = 1;
 
// @ts-expect-error: 这里其实不会报错,用来演示未命中的情况
export const stillOk: number = 2;