( collection: C, keyPath: KeyPath<K>, notSetValue: NSV | UpdaterFunction<K, C> | undefined, updater?: UpdaterFunctionWithNSV<K, C, NSV> )
| 96 | ): { [key: PropertyKey]: V }; |
| 97 | |
| 98 | export function updateIn< |
| 99 | K, |
| 100 | V, |
| 101 | TProps extends object, |
| 102 | C extends PossibleCollection<K, V, TProps>, |
| 103 | NSV, |
| 104 | >( |
| 105 | collection: C, |
| 106 | keyPath: KeyPath<K>, |
| 107 | notSetValue: NSV | UpdaterFunction<K, C> | undefined, |
| 108 | updater?: UpdaterFunctionWithNSV<K, C, NSV> |
| 109 | ): C { |
| 110 | if (!updater) { |
| 111 | // handle the fact that `notSetValue` is optional here, in that case `updater` is the updater function |
| 112 | // @ts-expect-error updater is a function here |
| 113 | updater = notSetValue as UpdaterFunction<K, C>; |
| 114 | notSetValue = undefined; |
| 115 | } |
| 116 | const updatedValue = updateInDeeply( |
| 117 | isImmutable(collection), |
| 118 | // @ts-expect-error type issues with Record and mixed types |
| 119 | collection, |
| 120 | coerceKeyPath(keyPath), |
| 121 | 0, |
| 122 | notSetValue, |
| 123 | updater |
| 124 | ); |
| 125 | // @ts-expect-error mixed return type |
| 126 | return updatedValue === NOT_SET ? notSetValue : updatedValue; |
| 127 | } |
| 128 | |
| 129 | function updateInDeeply< |
| 130 | K, |
no test coverage detected