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

Typescript errors when passing null as payload to actions returned from createSlice #165

Closed
marko911 opened this issue Jul 29, 2019 · 5 comments

Comments

@marko911
Copy link

When using actions created from createSlice, Typescript complains with:

Argument of type 'null' is not assignable to parameter of type '{}' .
But if you just use actions from createAction , it compiles.

Sandbox example

@markerikson
Copy link
Collaborator

tagging @phryneas @Dudeonyx @denisw @Jessidhia

@phryneas
Copy link
Member

Okay, this seems to come from the fact that you are using TS 3.3 - in TS 3.5, the action type infers to a PayloadActionCreator<unknown, string, void> which in fact accepts null. Older versions of TS default to {} instead of unknown.

I'll try and see if we can have it default to unknown in older TS versions. But adding a test for this will be impossible if we don't want to downgrade TS for all tests (although it might be a good idea to run the tests in different TS versions in a separate ticket - what do you think @markerikson ?)

@phryneas
Copy link
Member

see #166 - could you please test this?

@marko911
Copy link
Author

Ok I updated my TS versio from 3.4 to 3.5.3 and it solves the problem yes.

@markerikson
Copy link
Collaborator

Hopefully resolved by #166 . Merged, and will probably get that change out in 0.8 .

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

No branches or pull requests

3 participants