Skip to content

otplib API Documentation / @otplib/core / NarrowBy

Type Alias: NarrowBy<T, K, V>

NarrowBy<T, K, V> = T extends { [key in K]: V } ? T : never

Defined in: packages/core/src/utility-types.ts:189

Narrow union type by a specific property value

Type Parameters

T

T

K

K extends keyof T

V

V extends T[K]

Example

ts
type Result = VerifyResultValid | VerifyResultInvalid;
type ValidOnly = NarrowBy<Result, 'valid', true>;
// VerifyResultValid

Released under the MIT License.