TypeScript 类型体操 —— IF

264 阅读1分钟

题目地址

实现

type IF<C extends boolean, T, F> = C extends true ? T : F;

type ExampleType = IF<true, string, number>;  // ExampleType 为 string