Comparing version 5.0.0 to 5.0.1
@@ -208,3 +208,3 @@ /** | ||
*/ | ||
interface Store<S = any, A extends Action = UnknownAction, StateExt extends {} = {}> { | ||
interface Store<S = any, A extends Action = UnknownAction, StateExt extends unknown = unknown> { | ||
/** | ||
@@ -286,2 +286,3 @@ * Dispatches an action. It is the only way to trigger a state change. | ||
} | ||
type UnknownIfNonSpecific<T> = {} extends T ? unknown : T; | ||
/** | ||
@@ -300,4 +301,4 @@ * A store creator is a function that creates a Redux store. Like with | ||
interface StoreCreator { | ||
<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, StateExt> & Ext; | ||
<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext>): Store<S, A, StateExt> & Ext; | ||
<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext; | ||
<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext; | ||
} | ||
@@ -353,3 +354,3 @@ /** | ||
*/ | ||
declare function createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, StateExt> & Ext; | ||
declare function createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext; | ||
/** | ||
@@ -380,3 +381,3 @@ * @deprecated | ||
*/ | ||
declare function createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, StateExt> & Ext; | ||
declare function createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext; | ||
/** | ||
@@ -412,3 +413,3 @@ * Creates a Redux store that holds the state tree. | ||
*/ | ||
declare function legacy_createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, StateExt> & Ext; | ||
declare function legacy_createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext; | ||
/** | ||
@@ -444,3 +445,3 @@ * Creates a Redux store that holds the state tree. | ||
*/ | ||
declare function legacy_createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, StateExt> & Ext; | ||
declare function legacy_createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext; | ||
@@ -447,0 +448,0 @@ /** |
@@ -27,3 +27,3 @@ // src/utils/formatProdErrorMessage.ts | ||
} | ||
return Object.getPrototypeOf(obj) === proto; | ||
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null; | ||
} | ||
@@ -30,0 +30,0 @@ |
{ | ||
"name": "redux", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Predictable state container for JavaScript apps", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -8,3 +8,4 @@ import $$observable from './utils/symbol-observable' | ||
Observer, | ||
ListenerCallback | ||
ListenerCallback, | ||
UnknownIfNonSpecific | ||
} from './types/store' | ||
@@ -50,3 +51,3 @@ import { Action } from './types/actions' | ||
enhancer?: StoreEnhancer<Ext, StateExt> | ||
): Store<S, A, StateExt> & Ext | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext | ||
/** | ||
@@ -87,3 +88,3 @@ * @deprecated | ||
enhancer?: StoreEnhancer<Ext, StateExt> | ||
): Store<S, A, StateExt> & Ext | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext | ||
export function createStore< | ||
@@ -99,3 +100,3 @@ S, | ||
enhancer?: StoreEnhancer<Ext, StateExt> | ||
): Store<S, A, StateExt> & Ext { | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext { | ||
if (typeof reducer !== 'function') { | ||
@@ -439,3 +440,3 @@ throw new Error( | ||
enhancer?: StoreEnhancer<Ext, StateExt> | ||
): Store<S, A, StateExt> & Ext | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext | ||
/** | ||
@@ -481,3 +482,3 @@ * Creates a Redux store that holds the state tree. | ||
enhancer?: StoreEnhancer<Ext, StateExt> | ||
): Store<S, A, StateExt> & Ext | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext | ||
export function legacy_createStore< | ||
@@ -493,4 +494,4 @@ S, | ||
enhancer?: StoreEnhancer<Ext, StateExt> | ||
): Store<S, A, StateExt> & Ext { | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext { | ||
return createStore(reducer, preloadedState as any, enhancer) | ||
} |
@@ -84,3 +84,3 @@ import { Action, UnknownAction } from './actions' | ||
A extends Action = UnknownAction, | ||
StateExt extends {} = {} | ||
StateExt extends unknown = unknown | ||
> { | ||
@@ -168,2 +168,4 @@ /** | ||
export type UnknownIfNonSpecific<T> = {} extends T ? unknown : T | ||
/** | ||
@@ -185,3 +187,3 @@ * A store creator is a function that creates a Redux store. Like with | ||
enhancer?: StoreEnhancer<Ext, StateExt> | ||
): Store<S, A, StateExt> & Ext | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext | ||
< | ||
@@ -197,3 +199,3 @@ S, | ||
enhancer?: StoreEnhancer<Ext> | ||
): Store<S, A, StateExt> & Ext | ||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext | ||
} | ||
@@ -200,0 +202,0 @@ |
@@ -13,3 +13,5 @@ /** | ||
return Object.getPrototypeOf(obj) === proto | ||
return ( | ||
Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null | ||
) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
289804
3241
1