示例工程 14-runtime-syntax

14-runtime-syntax/05-using/types.test-d.ts

typescript · 0.3 KB

运行:14 · using

点击「运行示例」后,左侧显示源码、右侧显示运行结果;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 type { Resource } from './src/main.js';
 
// 必须实现 Symbol.dispose 才能被 using 使用
type Case1 = Expect<Equal<Resource[typeof Symbol.dispose], () => void>>;