示例工程 25-declaration-distribution

25-declaration-distribution/02-exports-matrix/types.test-d.ts

typescript · 0.4 KB

运行:25 · exports-matrix

点击「运行示例」后,左侧显示源码、右侧显示运行结果;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 { hello } from './fixtures/pkg/types/index.js';
import { feature } from './fixtures/pkg/types/feature.js';
 
type Case1 = Expect<Equal<ReturnType<typeof hello>, string>>;
type Case2 = Expect<Equal<ReturnType<typeof feature>, number>>;