Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 660 Bytes

File metadata and controls

46 lines (33 loc) · 660 Bytes

typelab / utils / ArrayOmitOptional

type ArrayOmitOptional<T> = T extends ReadonlyArray ? _IfNotAnyOrNever<T, _ArrayOmitOptional<T>> : never;

Omit the optional elements from T type.

Type Parameters

Type Parameter Description

T

The Array type to omit the optional elements from.

Returns

Array with elements of T that are required.

Example

// [string, string]
type Result = ArrayOmitOptional<[string, string, string?]>;

// never
type Never = ArrayOmitOptional<any>;