当有需求要求根据传入类型匹配对对应类型时,实现如下:
type Expample=string
type C<T>=T extends Example?string:boolean
const res:C<string | number>=true
const res2:C<string>="12321412"
当有需求要求根据传入类型匹配对对应类型时,实现如下:
type Expample=string
type C<T>=T extends Example?string:boolean
const res:C<string | number>=true
const res2:C<string>="12321412"