Skip to content

Commit

Permalink
fix: Declare "EmptyObject" interface to wrap $CombinedState (reduxjs#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLey authored Mar 8, 2021
1 parent 0e499c0 commit 4260e08
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,17 @@ declare const $CombinedState: unique symbol
* typed as always undefined, so its never expected to have a meaningful
* value anyway. It just makes this type distinquishable from plain `{}`.
*/
export type CombinedState<S> = { readonly [$CombinedState]?: undefined } & S
interface EmptyObject {
readonly [$CombinedState]?: undefined
}
export type CombinedState<S> = EmptyObject & S

/**
* Recursively makes combined state objects partial. Only combined state _root
* objects_ (i.e. the generated higher level object with keys mapping to
* individual reducers) are partial.
*/
export type PreloadedState<S> = Required<S> extends {
[$CombinedState]: undefined
}
export type PreloadedState<S> = Required<S> extends EmptyObject
? S extends CombinedState<infer S1>
? {
[K in keyof S1]?: S1[K] extends object ? PreloadedState<S1[K]> : S1[K]
Expand Down

0 comments on commit 4260e08

Please sign in to comment.