typelab / conditions / IfAny
type IfAny<T, Then, Else> = false extends T & true ? Then : Else;Resolves to Then if the type T is an any type, otherwise resolves to Else.
| Type Parameter | Default type | Description |
|---|---|---|
|
|
‐ |
The type to be checked. |
|
|
‐ |
The type to return if |
|
|
|
The type to return if |
Then if T is an any type, Else otherwise.
type Yes = IfAny<any, 'yes', 'no'>; // 'yes'
type No = IfAny<string, 'yes', 'no'>; // 'no'