示例工程 17-pre-module-globals

17-pre-module-globals/03-script-order/types.test-d.ts

typescript · 0.3 KB

运行:17 · script-order

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

type Equal<A, B> =
  (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
type Expect<T extends true> = T;
 
// 声明允许 undefined,是因为加载顺序可能让它还没被赋值
type Case1 = Expect<Equal<typeof orderResult, number | undefined>>;
type Case2 = Expect<Equal<ReturnType<typeof DepUtils.double>, number>>;