| 1 | import type { MergeParameters } from './versionedTypes'
|
|---|
| 2 | import type { weakMapMemoize } from './weakMapMemoize'
|
|---|
| 3 |
|
|---|
| 4 | export type { MergeParameters } from './versionedTypes'
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * -----------------------------------------------------------------------------
|
|---|
| 8 | * -----------------------------------------------------------------------------
|
|---|
| 9 | *
|
|---|
| 10 | * Reselect Data Types
|
|---|
| 11 | *
|
|---|
| 12 | * -----------------------------------------------------------------------------
|
|---|
| 13 | * -----------------------------------------------------------------------------
|
|---|
| 14 | */
|
|---|
| 15 |
|
|---|
| 16 | /**
|
|---|
| 17 | * A standard selector function.
|
|---|
| 18 | * @template State - The first value, often a Redux root state object.
|
|---|
| 19 | * @template Result - The final result returned by the selector.
|
|---|
| 20 | * @template Params - All additional arguments passed into the selector.
|
|---|
| 21 | *
|
|---|
| 22 | * @public
|
|---|
| 23 | */
|
|---|
| 24 | export type Selector<
|
|---|
| 25 | State = any,
|
|---|
| 26 | Result = unknown,
|
|---|
| 27 | Params extends readonly any[] = any[]
|
|---|
| 28 | > = Distribute<
|
|---|
| 29 | /**
|
|---|
| 30 | * A function that takes a state and returns data that is based on that state.
|
|---|
| 31 | *
|
|---|
| 32 | * @param state - The first argument, often a Redux root state object.
|
|---|
| 33 | * @param params - All additional arguments passed into the selector.
|
|---|
| 34 | * @returns A derived value from the state.
|
|---|
| 35 | */
|
|---|
| 36 | (state: State, ...params: FallbackIfNever<Params, []>) => Result
|
|---|
| 37 | >
|
|---|
| 38 |
|
|---|
| 39 | /**
|
|---|
| 40 | * An array of input selectors.
|
|---|
| 41 | *
|
|---|
| 42 | * @public
|
|---|
| 43 | */
|
|---|
| 44 | export type SelectorArray<State = any> = readonly Selector<State>[]
|
|---|
| 45 |
|
|---|
| 46 | /**
|
|---|
| 47 | * Extracts an array of all return types from all input selectors.
|
|---|
| 48 | *
|
|---|
| 49 | * @public
|
|---|
| 50 | */
|
|---|
| 51 | export type SelectorResultArray<Selectors extends SelectorArray> =
|
|---|
| 52 | ExtractReturnType<Selectors>
|
|---|
| 53 |
|
|---|
| 54 | /**
|
|---|
| 55 | * The options object used inside `createSelector` and `createSelectorCreator`.
|
|---|
| 56 | *
|
|---|
| 57 | * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`).
|
|---|
| 58 | * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used.
|
|---|
| 59 | * @template OverrideMemoizeFunction - The type of the optional `memoize` function that could be passed into the options object inside `createSelector` to override the original `memoize` function that was initially passed into `createSelectorCreator`.
|
|---|
| 60 | * @template OverrideArgsMemoizeFunction - The type of the optional `argsMemoize` function that could be passed into the options object inside `createSelector` to override the original `argsMemoize` function that was initially passed into `createSelectorCreator`. If none was initially provided, `weakMapMemoize` will be used.
|
|---|
| 61 | *
|
|---|
| 62 | * @public
|
|---|
| 63 | */
|
|---|
| 64 | export interface CreateSelectorOptions<
|
|---|
| 65 | MemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize,
|
|---|
| 66 | ArgsMemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize,
|
|---|
| 67 | OverrideMemoizeFunction extends UnknownMemoizer = never,
|
|---|
| 68 | OverrideArgsMemoizeFunction extends UnknownMemoizer = never
|
|---|
| 69 | > {
|
|---|
| 70 | /**
|
|---|
| 71 | * Reselect performs additional checks in development mode to help identify
|
|---|
| 72 | * and warn about potential issues in selector behavior. This option
|
|---|
| 73 | * allows you to customize the behavior of these checks per selector.
|
|---|
| 74 | *
|
|---|
| 75 | * @see {@link https://reselect.js.org/api/development-only-stability-checks Development-Only Stability Checks}
|
|---|
| 76 | *
|
|---|
| 77 | * @since 5.0.0
|
|---|
| 78 | */
|
|---|
| 79 | devModeChecks?: Partial<DevModeChecks>
|
|---|
| 80 |
|
|---|
| 81 | /**
|
|---|
| 82 | * The memoize function that is used to memoize the {@linkcode OutputSelectorFields.resultFunc resultFunc}
|
|---|
| 83 | * inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`).
|
|---|
| 84 | *
|
|---|
| 85 | * When passed directly into `createSelector`, it overrides the `memoize` function initially passed into `createSelectorCreator`.
|
|---|
| 86 | *
|
|---|
| 87 | * @example
|
|---|
| 88 | * ```ts
|
|---|
| 89 | * import { createSelector, weakMapMemoize } from 'reselect'
|
|---|
| 90 | *
|
|---|
| 91 | * const selectItemsByCategory = createSelector(
|
|---|
| 92 | * [
|
|---|
| 93 | * (state: RootState) => state.items,
|
|---|
| 94 | * (state: RootState, category: string) => category
|
|---|
| 95 | * ],
|
|---|
| 96 | * (items, category) => items.filter(item => item.category === category),
|
|---|
| 97 | * { memoize: weakMapMemoize }
|
|---|
| 98 | * )
|
|---|
| 99 | * ```
|
|---|
| 100 | *
|
|---|
| 101 | * @since 5.0.0
|
|---|
| 102 | */
|
|---|
| 103 | memoize?: FallbackIfNever<OverrideMemoizeFunction, MemoizeFunction>
|
|---|
| 104 |
|
|---|
| 105 | /**
|
|---|
| 106 | * The optional memoize function that is used to memoize the arguments
|
|---|
| 107 | * passed into the output selector generated by `createSelector`
|
|---|
| 108 | * (e.g., `lruMemoize` or `weakMapMemoize`).
|
|---|
| 109 | *
|
|---|
| 110 | * When passed directly into `createSelector`, it overrides the
|
|---|
| 111 | * `argsMemoize` function initially passed into `createSelectorCreator`.
|
|---|
| 112 | * If none was initially provided, `weakMapMemoize` will be used.
|
|---|
| 113 | *
|
|---|
| 114 | * @example
|
|---|
| 115 | * ```ts
|
|---|
| 116 | * import { createSelector, weakMapMemoize } from 'reselect'
|
|---|
| 117 | *
|
|---|
| 118 | * const selectItemsByCategory = createSelector(
|
|---|
| 119 | * [
|
|---|
| 120 | * (state: RootState) => state.items,
|
|---|
| 121 | * (state: RootState, category: string) => category
|
|---|
| 122 | * ],
|
|---|
| 123 | * (items, category) => items.filter(item => item.category === category),
|
|---|
| 124 | * { argsMemoize: weakMapMemoize }
|
|---|
| 125 | * )
|
|---|
| 126 | * ```
|
|---|
| 127 | *
|
|---|
| 128 | * @default weakMapMemoize
|
|---|
| 129 | *
|
|---|
| 130 | * @since 5.0.0
|
|---|
| 131 | */
|
|---|
| 132 | argsMemoize?: FallbackIfNever<
|
|---|
| 133 | OverrideArgsMemoizeFunction,
|
|---|
| 134 | ArgsMemoizeFunction
|
|---|
| 135 | >
|
|---|
| 136 |
|
|---|
| 137 | /**
|
|---|
| 138 | * Optional configuration options for the {@linkcode CreateSelectorOptions.memoize memoize} function.
|
|---|
| 139 | * These options are passed to the {@linkcode CreateSelectorOptions.memoize memoize} function as the second argument.
|
|---|
| 140 | *
|
|---|
| 141 | * @since 5.0.0
|
|---|
| 142 | */
|
|---|
| 143 | memoizeOptions?: OverrideMemoizeOptions<
|
|---|
| 144 | MemoizeFunction,
|
|---|
| 145 | OverrideMemoizeFunction
|
|---|
| 146 | >
|
|---|
| 147 |
|
|---|
| 148 | /**
|
|---|
| 149 | * Optional configuration options for the {@linkcode CreateSelectorOptions.argsMemoize argsMemoize} function.
|
|---|
| 150 | * These options are passed to the {@linkcode CreateSelectorOptions.argsMemoize argsMemoize} function as the second argument.
|
|---|
| 151 | *
|
|---|
| 152 | * @since 5.0.0
|
|---|
| 153 | */
|
|---|
| 154 | argsMemoizeOptions?: OverrideMemoizeOptions<
|
|---|
| 155 | ArgsMemoizeFunction,
|
|---|
| 156 | OverrideArgsMemoizeFunction
|
|---|
| 157 | >
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | /**
|
|---|
| 161 | * The additional fields attached to the output selector generated by `createSelector`.
|
|---|
| 162 | *
|
|---|
| 163 | * **Note**: Although {@linkcode CreateSelectorOptions.memoize memoize}
|
|---|
| 164 | * and {@linkcode CreateSelectorOptions.argsMemoize argsMemoize} are included in the attached fields,
|
|---|
| 165 | * the fields themselves are independent of the type of
|
|---|
| 166 | * {@linkcode CreateSelectorOptions.memoize memoize} and {@linkcode CreateSelectorOptions.argsMemoize argsMemoize} functions.
|
|---|
| 167 | * Meaning this type is not going to generate additional fields based on what functions we use to memoize our selectors.
|
|---|
| 168 | *
|
|---|
| 169 | * _This type is not to be confused with {@linkcode ExtractMemoizerFields ExtractMemoizerFields}._
|
|---|
| 170 | *
|
|---|
| 171 | * @template InputSelectors - The type of the input selectors.
|
|---|
| 172 | * @template Result - The type of the result returned by the `resultFunc`.
|
|---|
| 173 | * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`).
|
|---|
| 174 | * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used.
|
|---|
| 175 | *
|
|---|
| 176 | * @public
|
|---|
| 177 | */
|
|---|
| 178 | export type OutputSelectorFields<
|
|---|
| 179 | InputSelectors extends SelectorArray = SelectorArray,
|
|---|
| 180 | Result = unknown,
|
|---|
| 181 | MemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize,
|
|---|
| 182 | ArgsMemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize
|
|---|
| 183 | > = {
|
|---|
| 184 | /**
|
|---|
| 185 | * The final function passed to `createSelector`. Otherwise known as the `combiner`.
|
|---|
| 186 | */
|
|---|
| 187 | resultFunc: Combiner<InputSelectors, Result>
|
|---|
| 188 |
|
|---|
| 189 | /**
|
|---|
| 190 | * The memoized version of {@linkcode OutputSelectorFields.resultFunc resultFunc}.
|
|---|
| 191 | */
|
|---|
| 192 | memoizedResultFunc: Combiner<InputSelectors, Result> &
|
|---|
| 193 | ExtractMemoizerFields<MemoizeFunction>
|
|---|
| 194 |
|
|---|
| 195 | /**
|
|---|
| 196 | * @Returns The last result calculated by {@linkcode OutputSelectorFields.memoizedResultFunc memoizedResultFunc}.
|
|---|
| 197 | */
|
|---|
| 198 | lastResult: () => Result
|
|---|
| 199 |
|
|---|
| 200 | /**
|
|---|
| 201 | * The array of the input selectors used by `createSelector` to compose the
|
|---|
| 202 | * combiner ({@linkcode OutputSelectorFields.memoizedResultFunc memoizedResultFunc}).
|
|---|
| 203 | */
|
|---|
| 204 | dependencies: InputSelectors
|
|---|
| 205 |
|
|---|
| 206 | /**
|
|---|
| 207 | * Counts the number of times {@linkcode OutputSelectorFields.memoizedResultFunc memoizedResultFunc} has been recalculated.
|
|---|
| 208 | */
|
|---|
| 209 | recomputations: () => number
|
|---|
| 210 |
|
|---|
| 211 | /**
|
|---|
| 212 | * Resets the count of {@linkcode OutputSelectorFields.recomputations recomputations} count to 0.
|
|---|
| 213 | */
|
|---|
| 214 | resetRecomputations: () => void
|
|---|
| 215 |
|
|---|
| 216 | /**
|
|---|
| 217 | * Counts the number of times the input selectors ({@linkcode OutputSelectorFields.dependencies dependencies})
|
|---|
| 218 | * have been recalculated. This is distinct from {@linkcode OutputSelectorFields.recomputations recomputations},
|
|---|
| 219 | * which tracks the recalculations of the result function.
|
|---|
| 220 | *
|
|---|
| 221 | * @since 5.0.0
|
|---|
| 222 | */
|
|---|
| 223 | dependencyRecomputations: () => number
|
|---|
| 224 |
|
|---|
| 225 | /**
|
|---|
| 226 | * Resets the count {@linkcode OutputSelectorFields.dependencyRecomputations dependencyRecomputations}
|
|---|
| 227 | * for the input selectors ({@linkcode OutputSelectorFields.dependencies dependencies})
|
|---|
| 228 | * of a memoized selector.
|
|---|
| 229 | *
|
|---|
| 230 | * @since 5.0.0
|
|---|
| 231 | */
|
|---|
| 232 | resetDependencyRecomputations: () => void
|
|---|
| 233 | } & Simplify<
|
|---|
| 234 | Required<
|
|---|
| 235 | Pick<
|
|---|
| 236 | CreateSelectorOptions<MemoizeFunction, ArgsMemoizeFunction>,
|
|---|
| 237 | 'argsMemoize' | 'memoize'
|
|---|
| 238 | >
|
|---|
| 239 | >
|
|---|
| 240 | >
|
|---|
| 241 |
|
|---|
| 242 | /**
|
|---|
| 243 | * Represents the actual selectors generated by `createSelector`.
|
|---|
| 244 | *
|
|---|
| 245 | * @template InputSelectors - The type of the input selectors.
|
|---|
| 246 | * @template Result - The type of the result returned by the `resultFunc`.
|
|---|
| 247 | * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`).
|
|---|
| 248 | * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used.
|
|---|
| 249 | *
|
|---|
| 250 | * @public
|
|---|
| 251 | */
|
|---|
| 252 | export type OutputSelector<
|
|---|
| 253 | InputSelectors extends SelectorArray = SelectorArray,
|
|---|
| 254 | Result = unknown,
|
|---|
| 255 | MemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize,
|
|---|
| 256 | ArgsMemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize
|
|---|
| 257 | > = Selector<
|
|---|
| 258 | GetStateFromSelectors<InputSelectors>,
|
|---|
| 259 | Result,
|
|---|
| 260 | GetParamsFromSelectors<InputSelectors>
|
|---|
| 261 | > &
|
|---|
| 262 | ExtractMemoizerFields<ArgsMemoizeFunction> &
|
|---|
| 263 | OutputSelectorFields<
|
|---|
| 264 | InputSelectors,
|
|---|
| 265 | Result,
|
|---|
| 266 | MemoizeFunction,
|
|---|
| 267 | ArgsMemoizeFunction
|
|---|
| 268 | >
|
|---|
| 269 |
|
|---|
| 270 | /**
|
|---|
| 271 | * A function that takes input selectors' return values as arguments and returns a result. Otherwise known as `resultFunc`.
|
|---|
| 272 | *
|
|---|
| 273 | * @template InputSelectors - An array of input selectors.
|
|---|
| 274 | * @template Result - Result returned by `resultFunc`.
|
|---|
| 275 | *
|
|---|
| 276 | * @public
|
|---|
| 277 | */
|
|---|
| 278 | export type Combiner<InputSelectors extends SelectorArray, Result> = Distribute<
|
|---|
| 279 | /**
|
|---|
| 280 | * A function that takes input selectors' return values as arguments and returns a result. Otherwise known as `resultFunc`.
|
|---|
| 281 | *
|
|---|
| 282 | * @param resultFuncArgs - Return values of input selectors.
|
|---|
| 283 | * @returns The return value of {@linkcode OutputSelectorFields.resultFunc resultFunc}.
|
|---|
| 284 | */
|
|---|
| 285 | (...resultFuncArgs: SelectorResultArray<InputSelectors>) => Result
|
|---|
| 286 | >
|
|---|
| 287 |
|
|---|
| 288 | /**
|
|---|
| 289 | * A standard function returning true if two values are considered equal.
|
|---|
| 290 | *
|
|---|
| 291 | * @public
|
|---|
| 292 | */
|
|---|
| 293 | export type EqualityFn<T = any> = (a: T, b: T) => boolean
|
|---|
| 294 |
|
|---|
| 295 | /**
|
|---|
| 296 | * The frequency of development mode checks.
|
|---|
| 297 | *
|
|---|
| 298 | * @since 5.0.0
|
|---|
| 299 | * @public
|
|---|
| 300 | */
|
|---|
| 301 | export type DevModeCheckFrequency = 'always' | 'once' | 'never'
|
|---|
| 302 |
|
|---|
| 303 | /**
|
|---|
| 304 | * Represents the configuration for development mode checks.
|
|---|
| 305 | *
|
|---|
| 306 | * @since 5.0.0
|
|---|
| 307 | * @public
|
|---|
| 308 | */
|
|---|
| 309 | export interface DevModeChecks {
|
|---|
| 310 | /**
|
|---|
| 311 | * Overrides the global input stability check for the selector.
|
|---|
| 312 | * - `once` - Run only the first time the selector is called.
|
|---|
| 313 | * - `always` - Run every time the selector is called.
|
|---|
| 314 | * - `never` - Never run the input stability check.
|
|---|
| 315 | *
|
|---|
| 316 | * @default 'once'
|
|---|
| 317 | *
|
|---|
| 318 | * @see {@link https://reselect.js.org/api/development-only-stability-checks Development-Only Stability Checks}
|
|---|
| 319 | * @see {@link https://reselect.js.org/api/development-only-stability-checks#inputstabilitycheck `inputStabilityCheck`}
|
|---|
| 320 | * @see {@link https://reselect.js.org/api/development-only-stability-checks#2-per-selector-by-passing-an-inputstabilitycheck-option-directly-to- per-selector-configuration}
|
|---|
| 321 | *
|
|---|
| 322 | * @since 5.0.0
|
|---|
| 323 | */
|
|---|
| 324 | inputStabilityCheck: DevModeCheckFrequency
|
|---|
| 325 |
|
|---|
| 326 | /**
|
|---|
| 327 | * Overrides the global identity function check for the selector.
|
|---|
| 328 | * - `once` - Run only the first time the selector is called.
|
|---|
| 329 | * - `always` - Run every time the selector is called.
|
|---|
| 330 | * - `never` - Never run the identity function check.
|
|---|
| 331 | *
|
|---|
| 332 | * @default 'once'
|
|---|
| 333 | *
|
|---|
| 334 | * @see {@link https://reselect.js.org/api/development-only-stability-checks Development-Only Stability Checks}
|
|---|
| 335 | * @see {@link https://reselect.js.org/api/development-only-stability-checks#identityfunctioncheck `identityFunctionCheck`}
|
|---|
| 336 | * @see {@link https://reselect.js.org/api/development-only-stability-checks#2-per-selector-by-passing-an-identityfunctioncheck-option-directly-to- per-selector-configuration}
|
|---|
| 337 | *
|
|---|
| 338 | * @since 5.0.0
|
|---|
| 339 | */
|
|---|
| 340 | identityFunctionCheck: DevModeCheckFrequency
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | /**
|
|---|
| 344 | * Represents execution information for development mode checks.
|
|---|
| 345 | *
|
|---|
| 346 | * @public
|
|---|
| 347 | * @since 5.0.0
|
|---|
| 348 | */
|
|---|
| 349 | export type DevModeChecksExecutionInfo = {
|
|---|
| 350 | [K in keyof DevModeChecks]: {
|
|---|
| 351 | /**
|
|---|
| 352 | * A boolean indicating whether the check should be executed.
|
|---|
| 353 | */
|
|---|
| 354 | shouldRun: boolean
|
|---|
| 355 |
|
|---|
| 356 | /**
|
|---|
| 357 | * The function to execute for the check.
|
|---|
| 358 | */
|
|---|
| 359 | run: AnyFunction
|
|---|
| 360 | }
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | /**
|
|---|
| 364 | * Determines the combined single "State" type (first arg) from all input selectors.
|
|---|
| 365 | *
|
|---|
| 366 | * @public
|
|---|
| 367 | */
|
|---|
| 368 | export type GetStateFromSelectors<Selectors extends SelectorArray> =
|
|---|
| 369 | MergeParameters<Selectors>[0]
|
|---|
| 370 |
|
|---|
| 371 | /**
|
|---|
| 372 | * Determines the combined "Params" type (all remaining args) from all input selectors.
|
|---|
| 373 | *
|
|---|
| 374 | * @public
|
|---|
| 375 | */
|
|---|
| 376 | export type GetParamsFromSelectors<Selectors extends SelectorArray> = ArrayTail<
|
|---|
| 377 | MergeParameters<Selectors>
|
|---|
| 378 | >
|
|---|
| 379 |
|
|---|
| 380 | /**
|
|---|
| 381 | * Any Memoizer function. A memoizer is a function that accepts another function and returns it.
|
|---|
| 382 | *
|
|---|
| 383 | * @template FunctionType - The type of the function that is memoized.
|
|---|
| 384 | *
|
|---|
| 385 | * @public
|
|---|
| 386 | */
|
|---|
| 387 | export type UnknownMemoizer<
|
|---|
| 388 | FunctionType extends UnknownFunction = UnknownFunction
|
|---|
| 389 | > = (func: FunctionType, ...options: any[]) => FunctionType
|
|---|
| 390 |
|
|---|
| 391 | /**
|
|---|
| 392 | * Extracts the options type for a memoization function based on its parameters.
|
|---|
| 393 | * The first parameter of the function is expected to be the function to be memoized,
|
|---|
| 394 | * followed by options for the memoization process.
|
|---|
| 395 | *
|
|---|
| 396 | * @template MemoizeFunction - The type of the memoize function to be checked.
|
|---|
| 397 | *
|
|---|
| 398 | * @public
|
|---|
| 399 | */
|
|---|
| 400 | export type MemoizeOptionsFromParameters<
|
|---|
| 401 | MemoizeFunction extends UnknownMemoizer
|
|---|
| 402 | > =
|
|---|
| 403 | | (
|
|---|
| 404 | | NonFunctionType<DropFirstParameter<MemoizeFunction>[0]>
|
|---|
| 405 | | FunctionType<DropFirstParameter<MemoizeFunction>[0]>
|
|---|
| 406 | )
|
|---|
| 407 | | (
|
|---|
| 408 | | NonFunctionType<DropFirstParameter<MemoizeFunction>[number]>
|
|---|
| 409 | | FunctionType<DropFirstParameter<MemoizeFunction>[number]>
|
|---|
| 410 | )[]
|
|---|
| 411 |
|
|---|
| 412 | /**
|
|---|
| 413 | * Derive the type of memoize options object based on whether the memoize function itself was overridden.
|
|---|
| 414 | *
|
|---|
| 415 | * _This type can be used for both `memoizeOptions` and `argsMemoizeOptions`._
|
|---|
| 416 | *
|
|---|
| 417 | * @template MemoizeFunction - The type of the `memoize` or `argsMemoize` function initially passed into `createSelectorCreator`.
|
|---|
| 418 | * @template OverrideMemoizeFunction - The type of the optional `memoize` or `argsMemoize` function passed directly into `createSelector` which then overrides the original `memoize` or `argsMemoize` function passed into `createSelectorCreator`.
|
|---|
| 419 | *
|
|---|
| 420 | * @public
|
|---|
| 421 | */
|
|---|
| 422 | export type OverrideMemoizeOptions<
|
|---|
| 423 | MemoizeFunction extends UnknownMemoizer,
|
|---|
| 424 | OverrideMemoizeFunction extends UnknownMemoizer = never
|
|---|
| 425 | > = IfNever<
|
|---|
| 426 | OverrideMemoizeFunction,
|
|---|
| 427 | Simplify<MemoizeOptionsFromParameters<MemoizeFunction>>,
|
|---|
| 428 | Simplify<MemoizeOptionsFromParameters<OverrideMemoizeFunction>>
|
|---|
| 429 | >
|
|---|
| 430 |
|
|---|
| 431 | /**
|
|---|
| 432 | * Extracts the additional properties or methods that a memoize function attaches to
|
|---|
| 433 | * the function it memoizes (e.g., `clearCache`).
|
|---|
| 434 | *
|
|---|
| 435 | * @template MemoizeFunction - The type of the memoize function to be checked.
|
|---|
| 436 | *
|
|---|
| 437 | * @public
|
|---|
| 438 | */
|
|---|
| 439 | export type ExtractMemoizerFields<MemoizeFunction extends UnknownMemoizer> =
|
|---|
| 440 | Simplify<OmitIndexSignature<ReturnType<MemoizeFunction>>>
|
|---|
| 441 |
|
|---|
| 442 | /**
|
|---|
| 443 | * Represents the additional properties attached to a function memoized by `reselect`.
|
|---|
| 444 | *
|
|---|
| 445 | * `lruMemoize`, `weakMapMemoize` and `autotrackMemoize` all return these properties.
|
|---|
| 446 | *
|
|---|
| 447 | * @see {@linkcode ExtractMemoizerFields ExtractMemoizerFields}
|
|---|
| 448 | *
|
|---|
| 449 | * @public
|
|---|
| 450 | */
|
|---|
| 451 | export type DefaultMemoizeFields = {
|
|---|
| 452 | /**
|
|---|
| 453 | * Clears the memoization cache associated with a memoized function.
|
|---|
| 454 | * This method is typically used to reset the state of the cache, allowing
|
|---|
| 455 | * for the garbage collection of previously memoized results and ensuring
|
|---|
| 456 | * that future calls to the function recompute the results.
|
|---|
| 457 | */
|
|---|
| 458 | clearCache: () => void
|
|---|
| 459 | resultsCount: () => number
|
|---|
| 460 | resetResultsCount: () => void
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 | /*
|
|---|
| 464 | * -----------------------------------------------------------------------------
|
|---|
| 465 | * -----------------------------------------------------------------------------
|
|---|
| 466 | *
|
|---|
| 467 | * Reselect Internal Utility Types
|
|---|
| 468 | *
|
|---|
| 469 | * -----------------------------------------------------------------------------
|
|---|
| 470 | * -----------------------------------------------------------------------------
|
|---|
| 471 | */
|
|---|
| 472 |
|
|---|
| 473 | /**
|
|---|
| 474 | * Any function with any arguments.
|
|---|
| 475 | *
|
|---|
| 476 | * @internal
|
|---|
| 477 | */
|
|---|
| 478 | export type AnyFunction = (...args: any[]) => any
|
|---|
| 479 |
|
|---|
| 480 | /**
|
|---|
| 481 | * Any function with unknown arguments.
|
|---|
| 482 | *
|
|---|
| 483 | * @internal
|
|---|
| 484 | */
|
|---|
| 485 | export type UnknownFunction = (...args: unknown[]) => unknown
|
|---|
| 486 |
|
|---|
| 487 | /**
|
|---|
| 488 | * When a generic type parameter is using its default value of `never`, fallback to a different type.
|
|---|
| 489 | *
|
|---|
| 490 | * @template T - Type to be checked.
|
|---|
| 491 | * @template FallbackTo - Type to fallback to if `T` resolves to `never`.
|
|---|
| 492 | *
|
|---|
| 493 | * @internal
|
|---|
| 494 | */
|
|---|
| 495 | export type FallbackIfNever<T, FallbackTo> = IfNever<T, FallbackTo, T>
|
|---|
| 496 |
|
|---|
| 497 | /**
|
|---|
| 498 | * Extracts the non-function part of a type.
|
|---|
| 499 | *
|
|---|
| 500 | * @template T - The input type to be refined by excluding function types and index signatures.
|
|---|
| 501 | *
|
|---|
| 502 | * @internal
|
|---|
| 503 | */
|
|---|
| 504 | export type NonFunctionType<T> = Simplify<
|
|---|
| 505 | OmitIndexSignature<Exclude<T, AnyFunction>>
|
|---|
| 506 | >
|
|---|
| 507 |
|
|---|
| 508 | /**
|
|---|
| 509 | * Extracts the function part of a type.
|
|---|
| 510 | *
|
|---|
| 511 | * @template T - The input type to be refined by extracting function types.
|
|---|
| 512 | *
|
|---|
| 513 | * @internal
|
|---|
| 514 | */
|
|---|
| 515 | export type FunctionType<T> = Extract<T, AnyFunction>
|
|---|
| 516 |
|
|---|
| 517 | /**
|
|---|
| 518 | * Extracts the return type from all functions as a tuple.
|
|---|
| 519 | *
|
|---|
| 520 | * @internal
|
|---|
| 521 | */
|
|---|
| 522 | export type ExtractReturnType<FunctionsArray extends readonly AnyFunction[]> = {
|
|---|
| 523 | [Index in keyof FunctionsArray]: FunctionsArray[Index] extends FunctionsArray[number]
|
|---|
| 524 | ? FallbackIfUnknown<ReturnType<FunctionsArray[Index]>, any>
|
|---|
| 525 | : never
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | /**
|
|---|
| 529 | * Utility type to infer the type of "all params of a function except the first",
|
|---|
| 530 | * so we can determine what arguments a memoize function accepts.
|
|---|
| 531 | *
|
|---|
| 532 | * @internal
|
|---|
| 533 | */
|
|---|
| 534 | export type DropFirstParameter<Func extends AnyFunction> = Func extends (
|
|---|
| 535 | firstArg: any,
|
|---|
| 536 | ...restArgs: infer Rest
|
|---|
| 537 | ) => any
|
|---|
| 538 | ? Rest
|
|---|
| 539 | : never
|
|---|
| 540 |
|
|---|
| 541 | /**
|
|---|
| 542 | * Distributes over a type. It is used mostly to expand a function type
|
|---|
| 543 | * in hover previews while preserving their original JSDoc information.
|
|---|
| 544 | *
|
|---|
| 545 | * If preserving JSDoc information is not a concern, you can use {@linkcode ExpandFunction ExpandFunction}.
|
|---|
| 546 | *
|
|---|
| 547 | * @template T The type to be distributed.
|
|---|
| 548 | *
|
|---|
| 549 | * @internal
|
|---|
| 550 | */
|
|---|
| 551 | export type Distribute<T> = T extends T ? T : never
|
|---|
| 552 |
|
|---|
| 553 | /**
|
|---|
| 554 | * Extracts the type of the first element of an array or tuple.
|
|---|
| 555 | *
|
|---|
| 556 | * @internal
|
|---|
| 557 | */
|
|---|
| 558 | export type FirstArrayElement<ArrayType> = ArrayType extends readonly [
|
|---|
| 559 | unknown,
|
|---|
| 560 | ...unknown[]
|
|---|
| 561 | ]
|
|---|
| 562 | ? ArrayType[0]
|
|---|
| 563 | : never
|
|---|
| 564 |
|
|---|
| 565 | /**
|
|---|
| 566 | * Extracts the type of an array or tuple minus the first element.
|
|---|
| 567 | *
|
|---|
| 568 | * @internal
|
|---|
| 569 | */
|
|---|
| 570 | export type ArrayTail<ArrayType> = ArrayType extends readonly [
|
|---|
| 571 | unknown,
|
|---|
| 572 | ...infer Tail
|
|---|
| 573 | ]
|
|---|
| 574 | ? Tail
|
|---|
| 575 | : []
|
|---|
| 576 |
|
|---|
| 577 | /**
|
|---|
| 578 | * An alias for type `{}`. Represents any value that is not `null` or `undefined`.
|
|---|
| 579 | * It is mostly used for semantic purposes to help distinguish between an
|
|---|
| 580 | * empty object type and `{}` as they are not the same.
|
|---|
| 581 | *
|
|---|
| 582 | * @internal
|
|---|
| 583 | */
|
|---|
| 584 | export type AnyNonNullishValue = NonNullable<unknown>
|
|---|
| 585 |
|
|---|
| 586 | /**
|
|---|
| 587 | * Same as {@linkcode AnyNonNullishValue AnyNonNullishValue} but aliased
|
|---|
| 588 | * for semantic purposes. It is intended to be used in scenarios where
|
|---|
| 589 | * a recursive type definition needs to be interrupted to ensure type safety
|
|---|
| 590 | * and to avoid excessively deep recursion that could lead to performance issues.
|
|---|
| 591 | *
|
|---|
| 592 | * @internal
|
|---|
| 593 | */
|
|---|
| 594 | export type InterruptRecursion = AnyNonNullishValue
|
|---|
| 595 |
|
|---|
| 596 | /*
|
|---|
| 597 | * -----------------------------------------------------------------------------
|
|---|
| 598 | * -----------------------------------------------------------------------------
|
|---|
| 599 | *
|
|---|
| 600 | * External/Copied Utility Types
|
|---|
| 601 | *
|
|---|
| 602 | * -----------------------------------------------------------------------------
|
|---|
| 603 | * -----------------------------------------------------------------------------
|
|---|
| 604 | *
|
|---|
| 605 | */
|
|---|
| 606 |
|
|---|
| 607 | /**
|
|---|
| 608 | * An if-else-like type that resolves depending on whether the given type is `never`.
|
|---|
| 609 | * This is mainly used to conditionally resolve the type of a `memoizeOptions` object based on whether `memoize` is provided or not.
|
|---|
| 610 | * @see {@link https://github.com/sindresorhus/type-fest/blob/main/source/if-never.d.ts Source}
|
|---|
| 611 | *
|
|---|
| 612 | * @internal
|
|---|
| 613 | */
|
|---|
| 614 | export type IfNever<T, TypeIfNever, TypeIfNotNever> = [T] extends [never]
|
|---|
| 615 | ? TypeIfNever
|
|---|
| 616 | : TypeIfNotNever
|
|---|
| 617 |
|
|---|
| 618 | /**
|
|---|
| 619 | * Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|---|
| 620 | * This is mainly used to remove explicit `any`s from the return type of some memoizers (e.g, `microMemoize`).
|
|---|
| 621 | *
|
|---|
| 622 | * __Disclaimer:__ When used on an intersection of a function and an object,
|
|---|
| 623 | * the function is erased.
|
|---|
| 624 | *
|
|---|
| 625 | * @see {@link https://github.com/sindresorhus/type-fest/blob/main/source/omit-index-signature.d.ts Source}
|
|---|
| 626 | *
|
|---|
| 627 | * @internal
|
|---|
| 628 | */
|
|---|
| 629 | export type OmitIndexSignature<ObjectType> = {
|
|---|
| 630 | [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|---|
| 631 | ? never
|
|---|
| 632 | : KeyType]: ObjectType[KeyType]
|
|---|
| 633 | }
|
|---|
| 634 |
|
|---|
| 635 | /**
|
|---|
| 636 | * The infamous "convert a union type to an intersection type" hack
|
|---|
| 637 | * @see {@link https://github.com/sindresorhus/type-fest/blob/main/source/union-to-intersection.d.ts Source}
|
|---|
| 638 | * @see {@link https://github.com/microsoft/TypeScript/issues/29594 Reference}
|
|---|
| 639 | *
|
|---|
| 640 | * @internal
|
|---|
| 641 | */
|
|---|
| 642 | export type UnionToIntersection<Union> =
|
|---|
| 643 | // `extends unknown` is always going to be the case and is used to convert the
|
|---|
| 644 | // `Union` into a [distributive conditional
|
|---|
| 645 | // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|---|
| 646 | (
|
|---|
| 647 | Union extends unknown
|
|---|
| 648 | ? // The union type is used as the only argument to a function since the union
|
|---|
| 649 | // of function arguments is an intersection.
|
|---|
| 650 | (distributedUnion: Union) => void
|
|---|
| 651 | : // This won't happen.
|
|---|
| 652 | never
|
|---|
| 653 | ) extends // Infer the `Intersection` type since TypeScript represents the positional
|
|---|
| 654 | // arguments of unions of functions as an intersection of the union.
|
|---|
| 655 | (mergedIntersection: infer Intersection) => void
|
|---|
| 656 | ? // The `& Union` is to allow indexing by the resulting type
|
|---|
| 657 | Intersection & Union
|
|---|
| 658 | : never
|
|---|
| 659 |
|
|---|
| 660 | /**
|
|---|
| 661 | * Code to convert a union of values into a tuple.
|
|---|
| 662 | * @see {@link https://stackoverflow.com/a/55128956/62937 Source}
|
|---|
| 663 | *
|
|---|
| 664 | * @internal
|
|---|
| 665 | */
|
|---|
| 666 | type Push<T extends any[], V> = [...T, V]
|
|---|
| 667 |
|
|---|
| 668 | /**
|
|---|
| 669 | * @see {@link https://stackoverflow.com/a/55128956/62937 Source}
|
|---|
| 670 | *
|
|---|
| 671 | * @internal
|
|---|
| 672 | */
|
|---|
| 673 | type LastOf<T> = UnionToIntersection<
|
|---|
| 674 | T extends any ? () => T : never
|
|---|
| 675 | > extends () => infer R
|
|---|
| 676 | ? R
|
|---|
| 677 | : never
|
|---|
| 678 |
|
|---|
| 679 | /**
|
|---|
| 680 | * TS4.1+
|
|---|
| 681 | * @see {@link https://stackoverflow.com/a/55128956/62937 Source}
|
|---|
| 682 | *
|
|---|
| 683 | * @internal
|
|---|
| 684 | */
|
|---|
| 685 | export type TuplifyUnion<
|
|---|
| 686 | T,
|
|---|
| 687 | L = LastOf<T>,
|
|---|
| 688 | N = [T] extends [never] ? true : false
|
|---|
| 689 | > = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>
|
|---|
| 690 |
|
|---|
| 691 | /**
|
|---|
| 692 | * Converts "the values of an object" into a tuple, like a type-level `Object.values()`
|
|---|
| 693 | * @see {@link https://stackoverflow.com/a/68695508/62937 Source}
|
|---|
| 694 | *
|
|---|
| 695 | * @internal
|
|---|
| 696 | */
|
|---|
| 697 | export type ObjectValuesToTuple<
|
|---|
| 698 | T,
|
|---|
| 699 | KS extends any[] = TuplifyUnion<keyof T>,
|
|---|
| 700 | R extends any[] = []
|
|---|
| 701 | > = KS extends [infer K, ...infer KT]
|
|---|
| 702 | ? ObjectValuesToTuple<T, KT, [...R, T[K & keyof T]]>
|
|---|
| 703 | : R
|
|---|
| 704 |
|
|---|
| 705 | /**
|
|---|
| 706 | * Create a type that makes the given keys required.
|
|---|
| 707 | * The remaining keys are kept as is.
|
|---|
| 708 | *
|
|---|
| 709 | * @see {@link https://github.com/sindresorhus/type-fest/blob/main/source/set-required.d.ts Source}
|
|---|
| 710 | *
|
|---|
| 711 | * @internal
|
|---|
| 712 | */
|
|---|
| 713 | export type SetRequired<BaseType, Keys extends keyof BaseType> = Omit<
|
|---|
| 714 | BaseType,
|
|---|
| 715 | Keys
|
|---|
| 716 | > &
|
|---|
| 717 | Required<Pick<BaseType, Keys>>
|
|---|
| 718 |
|
|---|
| 719 | /**
|
|---|
| 720 | * An if-else-like type that resolves depending on whether the given type is `unknown`.
|
|---|
| 721 | * @see {@link https://github.com/sindresorhus/type-fest/blob/main/source/if-unknown.d.ts Source}
|
|---|
| 722 | *
|
|---|
| 723 | * @internal
|
|---|
| 724 | */
|
|---|
| 725 | export type IfUnknown<T, TypeIfUnknown, TypeIfNotUnknown> = unknown extends T // `T` can be `unknown` or `any`
|
|---|
| 726 | ? [T] extends [null] // `any` can be `null`, but `unknown` can't be
|
|---|
| 727 | ? TypeIfNotUnknown
|
|---|
| 728 | : TypeIfUnknown
|
|---|
| 729 | : TypeIfNotUnknown
|
|---|
| 730 |
|
|---|
| 731 | /**
|
|---|
| 732 | * When a type is resolves to `unknown`, fallback to a different type.
|
|---|
| 733 | *
|
|---|
| 734 | * @template T - Type to be checked.
|
|---|
| 735 | * @template FallbackTo - Type to fallback to if `T` resolves to `unknown`.
|
|---|
| 736 | *
|
|---|
| 737 | * @internal
|
|---|
| 738 | */
|
|---|
| 739 | export type FallbackIfUnknown<T, FallbackTo> = IfUnknown<T, FallbackTo, T>
|
|---|
| 740 |
|
|---|
| 741 | /**
|
|---|
| 742 | *
|
|---|
| 743 | * -----------------------------------------------------------------------------
|
|---|
| 744 | * -----------------------------------------------------------------------------
|
|---|
| 745 | *
|
|---|
| 746 | * Type Expansion Utilities
|
|---|
| 747 | *
|
|---|
| 748 | * -----------------------------------------------------------------------------
|
|---|
| 749 | * -----------------------------------------------------------------------------
|
|---|
| 750 | *
|
|---|
| 751 | */
|
|---|
| 752 |
|
|---|
| 753 | /**
|
|---|
| 754 | * Check whether `U` contains `U1`.
|
|---|
| 755 | * @see {@link https://millsp.github.io/ts-toolbelt/modules/union_has.html Source}
|
|---|
| 756 | *
|
|---|
| 757 | * @internal
|
|---|
| 758 | */
|
|---|
| 759 | export type Has<U, U1> = [U1] extends [U] ? 1 : 0
|
|---|
| 760 |
|
|---|
| 761 | /**
|
|---|
| 762 | * @internal
|
|---|
| 763 | */
|
|---|
| 764 | export type Boolean2 = 0 | 1
|
|---|
| 765 |
|
|---|
| 766 | /**
|
|---|
| 767 | * @internal
|
|---|
| 768 | */
|
|---|
| 769 | export type If2<B extends Boolean2, Then, Else = never> = B extends 1
|
|---|
| 770 | ? Then
|
|---|
| 771 | : Else
|
|---|
| 772 |
|
|---|
| 773 | /**
|
|---|
| 774 | * @internal
|
|---|
| 775 | */
|
|---|
| 776 | export type BuiltIn =
|
|---|
| 777 | | Function
|
|---|
| 778 | | Error
|
|---|
| 779 | | Date
|
|---|
| 780 | | { readonly [Symbol.toStringTag]: string }
|
|---|
| 781 | | RegExp
|
|---|
| 782 | | Generator
|
|---|
| 783 |
|
|---|
| 784 | /**
|
|---|
| 785 | * Expand an item a single level.
|
|---|
| 786 | * @see {@link https://stackoverflow.com/a/69288824/62937 Source}
|
|---|
| 787 | *
|
|---|
| 788 | * @internal
|
|---|
| 789 | */
|
|---|
| 790 | export type Expand<T> = T extends (...args: infer A) => infer R
|
|---|
| 791 | ? (...args: Expand<A>) => Expand<R>
|
|---|
| 792 | : T extends infer O
|
|---|
| 793 | ? { [K in keyof O]: O[K] }
|
|---|
| 794 | : never
|
|---|
| 795 |
|
|---|
| 796 | /**
|
|---|
| 797 | * Expand an item recursively.
|
|---|
| 798 | * @see {@link https://stackoverflow.com/a/69288824/62937 Source}
|
|---|
| 799 | *
|
|---|
| 800 | * @internal
|
|---|
| 801 | */
|
|---|
| 802 | export type ExpandRecursively<T> = T extends (...args: infer A) => infer R
|
|---|
| 803 | ? (...args: ExpandRecursively<A>) => ExpandRecursively<R>
|
|---|
| 804 | : T extends object
|
|---|
| 805 | ? T extends infer O
|
|---|
| 806 | ? { [K in keyof O]: ExpandRecursively<O[K]> }
|
|---|
| 807 | : never
|
|---|
| 808 | : T
|
|---|
| 809 |
|
|---|
| 810 | /**
|
|---|
| 811 | * @internal
|
|---|
| 812 | */
|
|---|
| 813 | export type Identity<T> = T
|
|---|
| 814 |
|
|---|
| 815 | /**
|
|---|
| 816 | * Another form of type value expansion
|
|---|
| 817 | * @see {@link https://github.com/microsoft/TypeScript/issues/35247 Source}
|
|---|
| 818 | *
|
|---|
| 819 | * @internal
|
|---|
| 820 | */
|
|---|
| 821 | export type Mapped<T> = Identity<{ [k in keyof T]: T[k] }>
|
|---|
| 822 |
|
|---|
| 823 | /**
|
|---|
| 824 | * This utility type is primarily used to expand a function type in order to
|
|---|
| 825 | * improve its visual display in hover previews within IDEs.
|
|---|
| 826 | *
|
|---|
| 827 | * __Disclaimer:__ Functions expanded using this type will not display their
|
|---|
| 828 | * original JSDoc information in hover previews.
|
|---|
| 829 | *
|
|---|
| 830 | * @template FunctionType - The type of the function to be expanded.
|
|---|
| 831 | *
|
|---|
| 832 | * @internal
|
|---|
| 833 | */
|
|---|
| 834 | export type ExpandFunction<FunctionType extends AnyFunction> =
|
|---|
| 835 | FunctionType extends FunctionType
|
|---|
| 836 | ? (...args: Parameters<FunctionType>) => ReturnType<FunctionType>
|
|---|
| 837 | : never
|
|---|
| 838 |
|
|---|
| 839 | /**
|
|---|
| 840 | * Useful to flatten the type output to improve type hints shown in editors.
|
|---|
| 841 | * And also to transform an interface into a type to aide with assignability.
|
|---|
| 842 | * @see {@link https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts Source}
|
|---|
| 843 | *
|
|---|
| 844 | * @internal
|
|---|
| 845 | */
|
|---|
| 846 | export type Simplify<T> = T extends AnyFunction
|
|---|
| 847 | ? T
|
|---|
| 848 | : {
|
|---|
| 849 | [KeyType in keyof T]: T[KeyType]
|
|---|
| 850 | } & AnyNonNullishValue
|
|---|
| 851 |
|
|---|
| 852 | /**
|
|---|
| 853 | * Fully expand a type, deeply
|
|---|
| 854 | * @see {@link https://github.com/millsp/ts-toolbelt Any.Compute}
|
|---|
| 855 | *
|
|---|
| 856 | * @internal
|
|---|
| 857 | */
|
|---|
| 858 | export type ComputeDeep<A, Seen = never> = A extends BuiltIn
|
|---|
| 859 | ? A
|
|---|
| 860 | : If2<
|
|---|
| 861 | Has<Seen, A>,
|
|---|
| 862 | A,
|
|---|
| 863 | A extends any[]
|
|---|
| 864 | ? A extends Record<PropertyKey, any>[]
|
|---|
| 865 | ? ({
|
|---|
| 866 | [K in keyof A[number]]: ComputeDeep<A[number][K], A | Seen>
|
|---|
| 867 | } & unknown)[]
|
|---|
| 868 | : A
|
|---|
| 869 | : A extends readonly any[]
|
|---|
| 870 | ? A extends readonly Record<PropertyKey, any>[]
|
|---|
| 871 | ? readonly ({
|
|---|
| 872 | [K in keyof A[number]]: ComputeDeep<A[number][K], A | Seen>
|
|---|
| 873 | } & unknown)[]
|
|---|
| 874 | : A
|
|---|
| 875 | : { [K in keyof A]: ComputeDeep<A[K], A | Seen> } & unknown
|
|---|
| 876 | >
|
|---|