Skip to content

Commit d1919f4

Browse files
markeriksontimdorr
authored andcommitted
Port TS type fixes from the 4.x branch
1 parent 8685630 commit d1919f4

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/types/store.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,26 @@ declare const $CombinedState: unique symbol
3333
* `$CombinedState` symbol property. Without the property, this type would
3434
* match any object. The symbol doesn't really exist because it's an internal
3535
* (i.e. not exported), and internally we never check its value. Since it's a
36-
* symbol property, it's not expected to be enumerable, and the value is
36+
* symbol property, it's not expected to be unumerable, and the value is
3737
* typed as always undefined, so its never expected to have a meaningful
38-
* value anyway. It just makes this type distinguishable from plain `{}`.
38+
* value anyway. It just makes this type distinquishable from plain `{}`.
3939
*/
40-
export type CombinedState<S> = { readonly [$CombinedState]?: undefined } & S
40+
interface EmptyObject {
41+
readonly [$CombinedState]?: undefined
42+
}
43+
export type CombinedState<S> = EmptyObject & S
4144

4245
/**
4346
* Recursively makes combined state objects partial. Only combined state _root
4447
* objects_ (i.e. the generated higher level object with keys mapping to
4548
* individual reducers) are partial.
4649
*/
47-
export type PreloadedState<S> = Required<S> extends {
48-
[$CombinedState]: undefined
49-
}
50+
export type PreloadedState<S> = Required<S> extends EmptyObject
5051
? S extends CombinedState<infer S1>
5152
? {
5253
[K in keyof S1]?: S1[K] extends object ? PreloadedState<S1[K]> : S1[K]
5354
}
54-
: never
55+
: S
5556
: {
5657
[K in keyof S]: S[K] extends string | number | boolean | symbol
5758
? S[K]
@@ -90,6 +91,12 @@ export interface Unsubscribe {
9091
(): void
9192
}
9293

94+
declare global {
95+
interface SymbolConstructor {
96+
readonly observable: symbol
97+
}
98+
}
99+
93100
/**
94101
* A minimal observable of state changes.
95102
* For more information, see the observable proposal:

0 commit comments

Comments
 (0)