banner
SlhwSR

SlhwSR

热爱技术的一名全栈开发者
github
bilibili

ts Generic Condition Matching

When there is a requirement to match the corresponding type based on the incoming type, implement as follows:

type Example = string

type C<T> = T extends Example ? string : boolean

const res: C<string | number> = true

const res2: C<string> = "12321412"
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.