示例工程 14-runtime-syntax
14-runtime-syntax/02-namespace-output/types.test-d.ts
点击「运行示例」后,左侧显示源码、右侧显示运行结果;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 { Geometry } from './src/main.js';
type Case1 = Expect<Equal<Parameters<typeof Geometry.area>, [radius: number]>>;
type Case2 = Expect<Equal<ReturnType<typeof Geometry.area>, number>>;
type Case3 = Expect<Equal<typeof Geometry.Labels.circle, 'circle'>>;