示例工程 09-conditional-types-infer
09-conditional-types-infer/01-is-string/src/main.ts
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
// 演示:最基础的条件类型,以及它在联合上的分配行为
export type IsString<T> = T extends string ? true : false;
export type If<C extends boolean, T, F> = C extends true ? T : F;
export function run(): string[] {
return [];
}