typelab / utils / ArrayPartial
type ArrayPartial<T, Index> = T extends ReadonlyArray<infer Element> ? _IfNotAnyOrNever<T, _IfNotAnyOrNever<Index, _ArrayPartial<T, Index, Element>>> : never;Extended TypeScript `Partial` to handle Array.
| Type Parameter | Default type | Description |
|---|---|---|
|
|
‐ |
The original |
|
|
|
The index of |
An Array type with the specified Index set as required.
type Result1 = ArrayPartial<[string, string]>; // [string?, string?]
type Result2 = ArrayPartial<[string, string], 1>; // [string, string?]
type Never1 = ArrayPartial<[string, string], any>; // never
type Never2 = ArrayPartial<any, 1>; // never