示例工程 13-declaration-files

13-declaration-files/03-module-augmentation/types.test-d.ts

typescript · 0.4 KB

运行:13 · module-augmentation

点击「运行示例」后,左侧显示源码、右侧显示运行结果;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 { Tracker } from 'analytics';
 
// 原始成员
type Case1 = Expect<Equal<Parameters<Tracker['track']>, [event: string]>>;
// 增强后的成员
type Case2 = Expect<Equal<Parameters<Tracker['trackPage']>, [path: string]>>;