typelab / utils / ArrayOmitRequired
type ArrayOmitRequired<T, OmitHole> = T extends ReadonlyArray ? _IfNotAnyOrNever<T, _ArrayOmitRequired<T, OmitHole>> : never;Omit the required elements from T type.
| Type Parameter | Default type | Description |
|---|---|---|
|
|
‐ |
The |
|
|
|
Whether to omit the hole or not. Defaults to |
Array with elements of T that are optional.
// [string?, string?]
type Result1 = ArrayOmitRequired<[string, string, string?, string?]>;
// [unknown?, string?, string?]
type Result2 = ArrayOmitRequired<[string, string?, string?], false>;
// never
type Never = ArrayOmitRequired<any>;