Skip to content

Add ReduxInitAction interface to type definitions #2189

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

Closed
wants to merge 1 commit into from

Conversation

merrywhether
Copy link

In attempting to model of all of the action types in our TypeScript app, the @@redux/INIT action is the odd one out, as it originates from the redux code itself. It'd be great if that were part of the redux type definitions themselves instead.

@jimbolla
Copy link
Contributor

jimbolla commented Jan 6, 2017

I believe INIT is considered a private and not intended to be exposed to the outside. There's a work item to make the type random. #1736 (comment)

@mfollett
Copy link

mfollett commented Jan 6, 2017

@jimbolla If you wanted to do a discriminated union of actions what would you use to model the internal actions, then?

@jimbolla
Copy link
Contributor

jimbolla commented Jan 6, 2017

I blieve the idea is that a reducer can handle an unknown action.

@mfollett
Copy link

mfollett commented Jan 6, 2017

But, in TS you'd either need to model that unknown action with a specific shape or have a catchall that has no shape and then you lose your type safety, unless there's something I'm missing. There are gradients, you could end with any or {type: string} which would give you various levels of safety loss, but that doesn't seem great.

@mfollett
Copy link

mfollett commented Jan 6, 2017

Actually, if the type is going to be random, the best you can go with is just the {type: any} anyway.

@TrySound
Copy link
Contributor

TrySound commented Jan 6, 2017

Actions shoudn't be random, but init action is internal one which do not required to be public. Typescript is for static analysis of your code, not libraries code.

@merrywhether
Copy link
Author

merrywhether commented Jan 6, 2017

Cool, sounds like a bail then. Thanks for the pointers.

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.

4 participants