Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preloadedState is optional #1806

Merged
merged 2 commits into from
Jun 20, 2016
Merged

preloadedState is optional #1806

merged 2 commits into from
Jun 20, 2016

Conversation

raineorshine
Copy link
Contributor

No description provided.

@gaearon
Copy link
Contributor

gaearon commented Jun 14, 2016

Thank you for the PR!
I don’t know TypeScript so leaving this for @aikoven and @ulfryk to review.
(It should indeed be optional, and we should support omitting both preloadedState and enhancer.)

@aikoven
Copy link
Collaborator

aikoven commented Jun 14, 2016

Isn't the case of omitted preloadedState already covered by the first overload of StoreCreator?

@raineorshine
Copy link
Contributor Author

I learned Typescript four days ago, so bear with me :).

I needed to create a store with redux-socket.io middleware. The key line is here:

const store = applyMiddleware(socketIoMiddleware)(createStore)(reducer)

The typescript compiler was erroring out (no matching type definition for call target) until I added the peloadedState argument:

const store = applyMiddleware(socketIoMiddleware)(createStore)(reducer, {})

I thought I tracked the type definition down to the right place, but it is quite possible that I am off a bit. I am pretty new at this.

Let me know if there is something else I can do to verify the change that needs to be made here without it being too much work for you.

I am using Redux v3.5.2 and Typescript v1.8.10.

@aikoven
Copy link
Collaborator

aikoven commented Jun 15, 2016

@raineorshine You are right, your change to StoreEnhancerStoreCreator fixes exactly your issue.

But change to StoreCreator is unnecessary and creates a bit of ambiguity for which overload to use when calling it with exactly one argument.

@aikoven aikoven merged commit cefb03a into reduxjs:master Jun 20, 2016
@aikoven
Copy link
Collaborator

aikoven commented Jun 20, 2016

Thanks!

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.

3 participants