示例工程 23-esm-live-bindings

23-esm-live-bindings/02-top-level-this/types.test-d.ts

typescript · 0.3 KB

运行:23 · top-level-this

点击「运行示例」后,左侧显示源码、右侧显示运行结果;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;
 
import { run } from './src/main.js';
 
// 顶层 this 的类型在检查层面并不可靠;只断言运行入口的返回类型
type Case1 = Expect<Equal<ReturnType<typeof run>, string[]>>;