ts-toolbelt
Advanced tools
Comparing version 9.5.8 to 9.5.9-test.1615046858023
@@ -5,2 +5,31 @@ # Changelog | ||
### [9.5.9](https://github.com/millsp/ts-toolbelt/compare/v9.5.1...v9.5.9) (2021-03-06) | ||
### Bug Fixes | ||
* **f.autopath:** distribute ([29eddd9](https://github.com/millsp/ts-toolbelt/commit/29eddd99c6826696941c50681ce4858243786110)) | ||
* **f.narrow:** fix variance and array inference ([4c7618d](https://github.com/millsp/ts-toolbelt/commit/4c7618d77b07d6b8c6dfd5087aa85a073bf57db3)) | ||
* **f.narrow:** higher order function support ([dad05ee](https://github.com/millsp/ts-toolbelt/commit/dad05eec6e6710ea4f63063658a3dee4d9c0ca28)) | ||
* **f.narrow:** preserve fns and better display ([a0d62d8](https://github.com/millsp/ts-toolbelt/commit/a0d62d8cfcd28eab7132c225ba187556ca749b4d)) | ||
* **f.narrow:** preserve functions ([c34f1b9](https://github.com/millsp/ts-toolbelt/commit/c34f1b95d0e0855203104eb696cfcb8221a65374)) | ||
* **f.narrow:** revert variance fixes ([12e014a](https://github.com/millsp/ts-toolbelt/commit/12e014a3f3d34047a3722486a73493f857a3697a)) | ||
* **f.narrow:** variance ([866ecd7](https://github.com/millsp/ts-toolbelt/commit/866ecd76744fc38244d85e7ef7b4bb90105cf7eb)) | ||
* **fn:** allow for curried in compose ([2bc5604](https://github.com/millsp/ts-toolbelt/commit/2bc560446916b423977c25e396b4f1f310b6c03f)) | ||
### Others | ||
* **list:** more flexible keys ([d9415b2](https://github.com/millsp/ts-toolbelt/commit/d9415b2f85633c7c74a815c9909899114faf530c)) | ||
* **o.p:** re-implement ([0f44362](https://github.com/millsp/ts-toolbelt/commit/0f443626dc3b114b6784d2053510a1e0c2f7f839)) | ||
* **release:** 9.5.2 ([ec4a953](https://github.com/millsp/ts-toolbelt/commit/ec4a953cabe6c4d704c0dca5f37d1dc630de047b)) | ||
* **release:** 9.5.3 ([0836f6e](https://github.com/millsp/ts-toolbelt/commit/0836f6e8187287a0c86f249e4e552d68a44e4f60)) | ||
* **release:** 9.5.4 ([855855e](https://github.com/millsp/ts-toolbelt/commit/855855e520ed4a04059f9d61884d2045dd0d751b)) | ||
* **release:** 9.5.5 ([e28bddf](https://github.com/millsp/ts-toolbelt/commit/e28bddf33066850a764e2ba344883ff84da561b9)) | ||
* **release:** 9.5.6 ([b8e0d0a](https://github.com/millsp/ts-toolbelt/commit/b8e0d0a83228baf666e00f4fdb0d99ca936c133f)) | ||
* **release:** 9.5.7 ([5646455](https://github.com/millsp/ts-toolbelt/commit/564645547862c7d698f4a03b15ccb7a5ffb5fc29)) | ||
* **release:** 9.5.8 ([bceb8be](https://github.com/millsp/ts-toolbelt/commit/bceb8be67701f9c7aba9608aed851567e8118ca5)) | ||
* **update:** remove dirty code ([9d0ff64](https://github.com/millsp/ts-toolbelt/commit/9d0ff6441518c2c9a01cea7726c08acd19eb37d9)) | ||
* cleanup ([6f23f2e](https://github.com/millsp/ts-toolbelt/commit/6f23f2ec79145a0545eb45d15d50d0363a119b12)) | ||
### [9.5.8](https://github.com/millsp/ts-toolbelt/compare/v9.5.1...v9.5.8) (2021-03-05) | ||
@@ -7,0 +36,0 @@ |
@@ -69,3 +69,3 @@ import { Key } from '../Any/Key'; | ||
*/ | ||
export declare type AutoPath<O extends any, P extends string> = _AutoPath<O & {}, P>; | ||
export declare type AutoPath<O extends any, P extends string> = P extends unknown ? _AutoPath<O, P> : never; | ||
export {}; |
@@ -8,2 +8,2 @@ /** @ignore */ /** */ | ||
export declare type Naked<L extends List> = Overwrite<Required<L>, L>; | ||
export declare type Key = string | number; | ||
export declare type Key = string | number | symbol; |
@@ -25,2 +25,2 @@ import { Key } from './_Internal'; | ||
*/ | ||
export declare type AtLeast<L extends List, K extends Key = Keys<L>> = OAtLeast<ObjectOf<L>, `${K}` | K> extends infer U ? U extends unknown ? _ListOf<U & {}> : never : never; | ||
export declare type AtLeast<L extends List, K extends Key = Keys<L>> = OAtLeast<ObjectOf<L>, `${K & number}` | K> extends infer U ? U extends unknown ? _ListOf<U & {}> : never : never; |
@@ -18,2 +18,2 @@ import { Key } from './_Internal'; | ||
*/ | ||
export declare type Either<L extends List, K extends Key, strict extends Boolean = 1> = OEither<ObjectOf<L>, `${K}` | K, strict> extends infer OE ? OE extends unknown ? _ListOf<OE & {}> : never : never; | ||
export declare type Either<L extends List, K extends Key, strict extends Boolean = 1> = OEither<ObjectOf<L>, `${K & number}` | K, strict> extends infer OE ? OE extends unknown ? _ListOf<OE & {}> : never : never; |
@@ -17,2 +17,2 @@ import { Match } from '../Any/_Internal'; | ||
*/ | ||
export declare type Has<L extends List, K extends Key, M extends any = any, match extends Match = 'default'> = OHas<ObjectOf<L>, `${K}` | K, M, match>; | ||
export declare type Has<L extends List, K extends Key, M extends any = any, match extends Match = 'default'> = OHas<ObjectOf<L>, `${K & number}` | K, M, match>; |
@@ -40,3 +40,3 @@ import { Key } from './_Internal'; | ||
*/ | ||
export declare type NonNullable<L extends List, K extends Key = Key, depth extends Depth = 'flat'> = Cast<NonNullablePart<L, `${K}` | K, depth>, List>; | ||
export declare type NonNullable<L extends List, K extends Key = Key, depth extends Depth = 'flat'> = Cast<NonNullablePart<L, `${K & number}` | K, depth>, List>; | ||
export {}; |
import { Key } from './_Internal'; | ||
import { Depth } from '../Object/_Internal'; | ||
import { List } from './List'; | ||
@@ -17,2 +16,2 @@ import { Update } from '../Object/Update'; | ||
*/ | ||
export declare type Nullable<L extends List, K extends Key = Key, depth extends Depth = 'flat'> = Cast<Update<L, `${K}` | K, x | null | undefined, depth>, List>; | ||
export declare type Nullable<L extends List, K extends Key = Key> = Cast<Update<L, `${K & number}` | K, x | null | undefined>, List>; |
@@ -9,3 +9,3 @@ import { _Omit as _OOmit } from '../Object/Omit'; | ||
*/ | ||
export declare type _Omit<L extends List, K extends Key> = _ListOf<_OOmit<ObjectOf<L>, `${K}` | K>>; | ||
export declare type _Omit<L extends List, K extends Key> = _ListOf<_OOmit<ObjectOf<L>, `${K & number}` | K>>; | ||
/** | ||
@@ -12,0 +12,0 @@ * Remove out of `L` the entries of key `K` |
@@ -9,3 +9,3 @@ import { _Pick as _OPick } from '../Object/Pick'; | ||
*/ | ||
export declare type _Pick<L extends List, K extends Key> = _ListOf<_OPick<ObjectOf<L>, `${K}` | K>>; | ||
export declare type _Pick<L extends List, K extends Key> = _ListOf<_OPick<ObjectOf<L>, `${K & number}` | K>>; | ||
/** | ||
@@ -12,0 +12,0 @@ * Extract out of `L` the entries of key `K` |
import { Key } from './_Internal'; | ||
import { Depth } from '../Object/_Internal'; | ||
import { List } from './List'; | ||
@@ -11,3 +10,2 @@ import { Update } from '../Object/Update'; | ||
* @param K (?=`Key`) to choose fields | ||
* @param depth (?=`'flat'`) 'deep' to do it deeply | ||
* @returns [[List]] | ||
@@ -18,2 +16,2 @@ * @example | ||
*/ | ||
export declare type Undefinable<L extends List, K extends Key = Key, depth extends Depth = 'flat'> = Cast<Update<L, `${K}` | K, x | undefined, depth>, List>; | ||
export declare type Undefinable<L extends List, K extends Key = Key> = Cast<Update<L, `${K & number}` | K, x | undefined>, List>; |
import { Key } from './_Internal'; | ||
import { List } from './List'; | ||
import { Update as OUpdate } from '../Object/Update'; | ||
import { Depth } from '../Object/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
@@ -17,2 +16,2 @@ /** | ||
*/ | ||
export declare type Update<L extends List, K extends Key, A extends any, depth extends Depth = 'flat'> = Cast<OUpdate<L, `${K}` | K | K, A, depth>, List>; | ||
export declare type Update<L extends List, K extends Key, A extends any> = Cast<OUpdate<L, `${K & number}` | K, A>, List>; |
@@ -0,14 +1,16 @@ | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../List/List'; | ||
import { Extends } from '../Any/Extends'; | ||
import { Select } from '../Union/Select'; | ||
import { Exclude } from '../Union/Exclude'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Pos } from '../Iteration/Pos'; | ||
import { Key } from '../Iteration/Key'; | ||
import { Append } from '../List/Append'; | ||
import { Next } from '../Iteration/Next'; | ||
import { Append } from '../List/Append'; | ||
import { Exclude } from '../Union/Exclude'; | ||
import { List } from '../List/List'; | ||
import { Extends } from '../Any/Extends'; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type PickIfEntry<O extends object, LN extends List, I extends Iteration> = Key<I> extends keyof O ? Append<LN, O[Key<I> & keyof O]> : LN; | ||
declare type AppendExists<O extends object, LN extends List, I extends Iteration> = Key<I> extends keyof O ? Append<LN, O[Key<I>]> : Pos<I> extends keyof O ? Append<LN, O[Pos<I>]> : LN; | ||
/** | ||
@@ -18,3 +20,3 @@ * @hidden | ||
declare type ___ListOf<O extends object, K, LN extends List = [], I extends Iteration = IterationOf<0>> = { | ||
0: ___ListOf<O, Exclude<K, Key<I>>, PickIfEntry<O, LN, I>, Next<I>>; | ||
0: ___ListOf<O, Exclude<K, Key<I>>, AppendExists<O, LN, I>, Next<I>>; | ||
1: LN; | ||
@@ -25,3 +27,3 @@ }[Extends<[K], [never]>]; | ||
*/ | ||
declare type __ListOf<O extends object> = number extends keyof O ? O[number][] : string extends keyof O ? O[string][] : symbol extends keyof O ? O[symbol][] : ___ListOf<O, keyof O>; | ||
declare type __ListOf<O extends object> = number extends keyof O ? O[number][] : string extends keyof O ? O[string][] : symbol extends keyof O ? O[symbol][] : ___ListOf<O, Select<keyof O, number | `${number}`>>; | ||
/** | ||
@@ -28,0 +30,0 @@ * @hidden |
@@ -1,24 +0,14 @@ | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { Key } from '../../Any/Key'; | ||
import { Merge as OMerge } from '../Merge'; | ||
import { Length } from '../../List/Length'; | ||
import { List } from '../../List/List'; | ||
import { BuiltIn } from '../../Misc/BuiltIn'; | ||
import { Tail } from '../../List/Tail'; | ||
import { Depth } from '../_Internal'; | ||
import { Boolean } from '../../Boolean/_Internal'; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type MergeObject<O, Path extends List<Key>, O1 extends object, depth extends Depth, I extends Iteration = IterationOf<0>> = O extends object ? Pos<I> extends Length<Path> ? OMerge<O, O1, depth> : { | ||
[K in keyof O]: K extends Path[Pos<I>] ? MergeObject<O[K], Path, O1, depth, Next<I>> : O[K]; | ||
} & {} : O; | ||
declare type MergeAt<O, Path extends List<Key>, O1, depth extends Depth> = O extends BuiltIn ? O : Path extends [] ? O extends List ? OMerge<O, O1 & {}, depth> : O extends object ? OMerge<O, O1 & {}, depth> : O : { | ||
[K in keyof O]: K extends Path[0] ? MergeAt<O[K], Tail<Path>, O1, depth> : O[K]; | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type MergeList<O, Path extends List<Key>, O1 extends object, depth extends Depth, I extends Iteration = IterationOf<0>> = O extends object ? O extends (infer A)[] ? MergeList<A, Path, O1, depth, I>[] : Pos<I> extends Length<Path> ? OMerge<O, O1, depth> : { | ||
[K in keyof O]: K extends Path[Pos<I>] ? MergeList<O[K], Path, O1, depth, Next<I>> : O[K]; | ||
} & {} : O; | ||
/** | ||
* Complete the fields of `O` at `Path` with the ones of `O1` | ||
@@ -29,3 +19,2 @@ * @param O to complete | ||
* @param depth (?=`'flat'`) 'deep' to do it deeply | ||
* @param list (?=`0`) `1` to work within object lists of arbitrary depth | ||
* @returns [[Object]] | ||
@@ -36,6 +25,3 @@ * @example | ||
*/ | ||
export declare type Merge<O extends object, Path extends List<Key>, O1 extends object, depth extends Depth = 'flat', list extends Boolean = 0> = { | ||
0: MergeObject<O, Path, O1, depth>; | ||
1: MergeList<O, Path, O1, depth>; | ||
}[list]; | ||
export declare type Merge<O extends object, Path extends List<Key>, O1 extends object, depth extends Depth = 'flat'> = Path extends unknown ? MergeAt<O, Path, O1, depth> : never; | ||
export {}; |
@@ -1,27 +0,17 @@ | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { Key } from '../../Any/Key'; | ||
import { _Omit as _OOmit } from '../Omit'; | ||
import { LastKey } from '../../List/LastKey'; | ||
import { _Omit as _LOmit } from '../../List/Omit'; | ||
import { List } from '../../List/List'; | ||
import { Boolean } from '../../Boolean/_Internal'; | ||
import { BuiltIn } from '../../Misc/BuiltIn'; | ||
import { Tail } from '../../List/Tail'; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type OmitObject<O, Path extends List<Key>, I extends Iteration = IterationOf<0>> = O extends object ? Pos<I> extends LastKey<Path> ? _OOmit<O, Path[Pos<I>]> : { | ||
[K in keyof O]: K extends Path[Pos<I>] ? OmitObject<O[K], Path, Next<I>> : O[K]; | ||
} & {} : O; | ||
declare type OmitAt<O, Path extends List<Key>> = O extends BuiltIn ? O : Path extends [Key] ? O extends List ? _LOmit<O, Path[0]> : O extends object ? _OOmit<O, Path[0]> : O : { | ||
[K in keyof O]: K extends Path[0] ? OmitAt<O[K], Tail<Path>> : O[K]; | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type OmitList<O, Path extends List<Key>, I extends Iteration = IterationOf<0>> = O extends object ? O extends (infer A)[] ? OmitList<A, Path, I>[] : Pos<I> extends LastKey<Path> ? _OOmit<O, Path[Pos<I>]> : { | ||
[K in keyof O]: K extends Path[Pos<I>] ? OmitList<O[K], Path, Next<I>> : O[K]; | ||
} & {} : O; | ||
/** | ||
* Remove out of `O` the fields at `Path` | ||
* @param O to remove from | ||
* @param Path to be followed | ||
* @param list (?=`0`) `1` to work within object lists of arbitrary depth | ||
* @returns [[Object]] | ||
@@ -32,6 +22,3 @@ * @example | ||
*/ | ||
export declare type Omit<O extends object, Path extends List<Key>, list extends Boolean = 0> = { | ||
0: OmitObject<O, Path>; | ||
1: OmitList<O, Path>; | ||
}[list]; | ||
export declare type Omit<O extends object, Path extends List<Key>> = Path extends unknown ? OmitAt<O, Path> : never; | ||
export {}; |
@@ -1,33 +0,20 @@ | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { Key } from '../../Any/Key'; | ||
import { _Pick as _OPick } from '../Pick'; | ||
import { _Pick as _LPick } from '../../List/Pick'; | ||
import { LastKey } from '../../List/LastKey'; | ||
import { List } from '../../List/List'; | ||
import { Boolean } from '../../Boolean/_Internal'; | ||
import { Length } from '../../List/Length'; | ||
import { Tail } from '../../List/Tail'; | ||
import { BuiltIn } from '../../Misc/BuiltIn'; | ||
import { _ListOf } from '../ListOf'; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type Action<O extends object, K extends Key> = O extends List ? number extends Length<O> ? Action<O[number], Key>[] : _LPick<O, (string | number)> : _OPick<O, K>; | ||
declare type PickAt<O, Path extends List<Key>> = [ | ||
] extends Path ? O : O extends BuiltIn ? O : O extends List ? _ListOf<{ | ||
[K in keyof _OPick<O, Path[0]>]: PickAt<O[K], Tail<Path>>; | ||
}> : O extends object ? { | ||
[K in keyof _OPick<O, Path[0]>]: PickAt<O[K], Tail<Path>>; | ||
} : O; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type PickObject<O, Path extends List<Key>, I extends Iteration = IterationOf<0>> = O extends object ? Action<O, Path[Pos<I>]> extends infer Picked ? Pos<I> extends LastKey<Path> ? Picked : { | ||
[K in keyof Picked]: PickObject<Picked[K], Path, Next<I>>; | ||
} & {} : never : O; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type PickList<O, Path extends List<Key>, I extends Iteration = IterationOf<0>> = O extends object ? O extends (infer A)[] ? PickList<A, Path, I>[] : _OPick<O, Path[Pos<I>]> extends infer Picked ? Pos<I> extends LastKey<Path> ? Picked : { | ||
[K in keyof Picked]: PickList<Picked[K], Path, Next<I>>; | ||
} & {} : never : O; | ||
/** | ||
* Extract out of `O` the fields at `Path` | ||
* @param O to extract from | ||
* @param Path to be followed | ||
* @param list (?=`0`) `1` to work within object lists of arbitrary depth | ||
* @returns [[Object]] | ||
@@ -38,6 +25,3 @@ * @example | ||
*/ | ||
export declare type Pick<O extends object, Path extends List<Key>, list extends Boolean = 0> = { | ||
0: PickObject<O, Path>; | ||
1: PickList<O, Path>; | ||
}[list]; | ||
export declare type Pick<O extends object, Path extends List<Key>> = Path extends unknown ? PickAt<O, Path> : never; | ||
export {}; |
@@ -1,24 +0,14 @@ | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { Key } from '../../Any/Key'; | ||
import { Readonly as OReadonly } from '../Readonly'; | ||
import { LastKey } from '../../List/LastKey'; | ||
import { List } from '../../List/List'; | ||
import { BuiltIn } from '../../Misc/BuiltIn'; | ||
import { Tail } from '../../List/Tail'; | ||
import { Depth } from '../_Internal'; | ||
import { Boolean } from '../../Boolean/_Internal'; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type ReadonlyObject<O, Path extends List<Key>, depth extends Depth, I extends Iteration = IterationOf<0>> = O extends object ? Pos<I> extends LastKey<Path> ? OReadonly<O, Path[Pos<I>], depth> : { | ||
[K in keyof O]: K extends Path[Pos<I>] ? ReadonlyObject<O[K], Path, depth, Next<I>> : O[K]; | ||
} & {} : O; | ||
declare type ReadonlyAt<O, Path extends List<Key>, depth extends Depth> = O extends BuiltIn ? O : Path extends [Key] ? O extends List ? OReadonly<O, Path[0], depth> : O extends object ? OReadonly<O, Path[0], depth> : O : { | ||
[K in keyof O]: K extends Path[0] ? ReadonlyAt<O[K], Tail<Path>, depth> : O[K]; | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type ReadonlyArrays<O, Path extends List<Key>, depth extends Depth, I extends Iteration = IterationOf<0>> = O extends object ? O extends (infer A)[] ? ReadonlyArrays<A, Path, depth, I>[] : Pos<I> extends LastKey<Path> ? OReadonly<O, Path[Pos<I>], depth> : { | ||
[K in keyof O]: K extends Path[Pos<I>] ? ReadonlyArrays<O[K], Path, depth, Next<I>> : O[K]; | ||
} & {} : O; | ||
/** | ||
* Make some fields of `O` readonly at `Path` (deeply or not) | ||
@@ -28,3 +18,2 @@ * @param O to make readonly | ||
* @param depth (?=`'flat'`) 'deep' to do it deeply | ||
* @param list (?=`0`) `1` to work within object lists of arbitrary depth | ||
* @returns [[Object]] | ||
@@ -35,6 +24,3 @@ * @example | ||
*/ | ||
export declare type Readonly<O extends object, Path extends List<Key>, depth extends Depth = 'flat', list extends Boolean = 0> = { | ||
0: ReadonlyObject<O, Path, depth>; | ||
1: ReadonlyArrays<O, Path, depth>; | ||
}[list]; | ||
export declare type Readonly<O extends object, Path extends List<Key>, depth extends Depth = 'flat'> = Path extends unknown ? ReadonlyAt<O, Path, depth> : never; | ||
export {}; |
@@ -1,16 +0,13 @@ | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { Key } from '../../Any/Key'; | ||
import { LastKey } from '../../List/LastKey'; | ||
import { Update as OUpdate } from '../Update'; | ||
import { Update as LUpdate } from '../../List/Update'; | ||
import { List } from '../../List/List'; | ||
import { Record } from '../Record'; | ||
import { Patch } from '../Patch'; | ||
import { BuiltIn } from '../../Misc/BuiltIn'; | ||
import { Tail } from '../../List/Tail'; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type UpdateObject<O, Path extends List<Key>, A, I extends Iteration = IterationOf<0>> = O extends object ? Pos<I> extends LastKey<Path> ? Patch<Record<Path[Pos<I>], A>, O> : (O & Record<Exclude<Path[Pos<I>], keyof O>, {}>) extends infer O ? { | ||
[K in keyof O]: K extends Path[Pos<I>] ? UpdateObject<O[K], Path, A, Next<I>> : O[K]; | ||
} & {} : never : O; | ||
declare type UpdateAt<O, Path extends List<Key>, A> = O extends BuiltIn ? O : Path extends [Key] ? O extends List ? LUpdate<O, Path[0], A> : O extends object ? OUpdate<O, Path[0], A> : O : { | ||
[K in keyof O]: K extends Path[0] ? UpdateAt<O[K], Tail<Path>, A> : O[K]; | ||
}; | ||
/** | ||
@@ -26,3 +23,3 @@ * Update in `O` the fields at `Path` with `A` | ||
*/ | ||
export declare type Update<O extends object, Path extends List<Key>, A extends any> = UpdateObject<O, Path, A>; | ||
export declare type Update<O extends object, Path extends List<Key>, A extends any> = Path extends unknown ? UpdateAt<O, Path, A> : never; | ||
export {}; |
import { Key } from '../Any/Key'; | ||
import { x } from '../Any/x'; | ||
import { Replace } from '../Union/Replace'; | ||
import { Depth } from './_Internal'; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type UpdateFlat<O extends object, K extends Key, A extends any> = { | ||
[P in keyof O]: P extends K ? Replace<A, x, O[P]> : O[P]; | ||
} & {}; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type __UpdateDeep<O, A extends any> = { | ||
[K in keyof O]: Replace<A, x, O[K]> extends infer X ? X extends object ? __UpdateDeep<X, A> : X : never; | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
declare type _UpdateDeep<O extends object, K extends Key, A extends any, OU = Update<O, K, x | A>> = { | ||
[K in keyof OU]: __UpdateDeep<OU[K], A>; | ||
} & {}; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare type UpdateDeep<O extends object, K extends Key, A extends any> = _UpdateDeep<O, K, A>; | ||
/** | ||
* Update in `O` the fields of key `K` with `A`. | ||
@@ -58,6 +35,4 @@ * Use the [[x]] placeholder to get the current field type. | ||
*/ | ||
export declare type Update<O extends object, K extends Key, A extends any, depth extends Depth = 'flat'> = { | ||
'flat': UpdateFlat<O, K, A>; | ||
'deep': UpdateDeep<O, K, A>; | ||
}[depth]; | ||
export {}; | ||
export declare type Update<O extends object, K extends Key, A extends any> = { | ||
[P in keyof O]: P extends K ? Replace<A, x, O[P]> : O[P]; | ||
} & {}; |
{ | ||
"name": "ts-toolbelt", | ||
"version": "9.5.8", | ||
"version": "9.5.9-test.1615046858023", | ||
"description": "TypeScript's largest utility library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
254123
5940
1