typelab / conditions / IfPropertyKey
type IfPropertyKey<T, Then, Else> = _IfNotAnyOrNever<T, T extends PropertyKey ? Then : Else, Else>;Resolves to Then if the type T is `PropertyKey`, otherwise resolves to Else.
| Type Parameter | Description |
|---|---|
|
|
The type to be checked. |
|
|
The type to return if |
|
|
The type to return if |
Then if T is `PropertyKey`, Else otherwise.
type Yes = IfPropertyKey<string, 'yes', 'no'>; // 'yes'
type No = IfPropertyKey<boolean, 'yes', 'no'>; // 'no'
type YesOrNo = IfPropertyKey<string | boolean, 'yes', 'no'>; // 'yes' | 'no'