Skip to content

Conversation

@srittau
Copy link
Contributor

@srittau srittau commented Jul 31, 2018

When wrapping createStore() using typescript, the typescript definition prevents an optional preloadedState argument:

function myCreateStore<S>(reducer: Reducer<S>, preloadedState?: Redux.DeepPartial<S>) {
    return createStore(reducer, preloadedState);
}

This will complain that type undefined is not assignable to DeepPartial<S>. Marking the preloadedState argument as optional fixes this problem.

@timdorr
Copy link
Member

timdorr commented Jul 31, 2018

Interesting that was overlooked, since StoreEnhancerStoreCreator already has an optional preloadedState. Funky.

Thanks for the one-character fix!

@timdorr timdorr merged commit 3cb7b8d into reduxjs:master Jul 31, 2018
@srittau srittau deleted the ts-store-creator branch July 31, 2018 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants