typelab / assertions / IsRequiredProperty
type IsRequiredProperty<T, Key> = _IsTrueAndNotNever<IfRequiredProperty<T, Key, true, false>>;Determines whether the type of T[Key] is required.
| Type Parameter | Description |
|---|---|
|
|
The type to be checked. |
|
|
The key of |
true if T[Key] is required, false otherwise.
type Valid = IsRequiredProperty<{ a: string }, 'a'>; // true
type Invalid = IsRequiredProperty<{ a?: string }, 'a'>; // false
type Never1 = IsRequiredProperty<{ a: string }, 'b'>; // never
type Never2 = IsRequiredProperty<{}, 'b'>; // never
type Never3 = IsRequiredProperty<undefined, 'b'>; // never