From 4260e082b77ddf91a8272ef414e42b840aff1497 Mon Sep 17 00:00:00 2001 From: JacobLey <37151850+JacobLey@users.noreply.github.com> Date: Mon, 8 Mar 2021 08:49:18 -0800 Subject: [PATCH] fix: Declare "EmptyObject" interface to wrap $CombinedState (#4031) --- index.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4e03686da36..1e3804ae97a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 = { readonly [$CombinedState]?: undefined } & S +interface EmptyObject { + readonly [$CombinedState]?: undefined +} +export type CombinedState = 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 = Required extends { - [$CombinedState]: undefined -} +export type PreloadedState = Required extends EmptyObject ? S extends CombinedState ? { [K in keyof S1]?: S1[K] extends object ? PreloadedState : S1[K]