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: Can't use strict custom Action types any more #2516

Closed
sbuzonas opened this issue Jul 15, 2017 · 1 comment
Closed

TypeScript: Can't use strict custom Action types any more #2516

sbuzonas opened this issue Jul 15, 2017 · 1 comment

Comments

@sbuzonas
Copy link

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
TypeScript declarations extending Action are broken because the Reducer type requires action to be AnyAction.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar.

const CALL_HISTORY_METHOD: string = "something";

interface RouterAction extends Action {
  type: typeof CALL_HISTORY_METHOD;
  payload: any;
}

interface RouterState { }

interface State {
  router: RouterState;
}

function routerReducer(state?: RouterState, action?: RouterAction): RouterState { }

const reducers: Reducer<State> = combineReducers({router: routerReducer});

What is the expected behavior?
I should be able to strictly type the action my reducer expects.

Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?
This has worked since 3.4.0. (Some vague indication that 3.0.8, but no idea where the types came from prior to 3.4)

@sbuzonas
Copy link
Author

The issue isn't in the definition here. It's in the other definition, AnyAction is more accurate to the actual behavior.

Linking DefinitelyTyped/DefinitelyTyped#17652 and DefinitelyTyped/DefinitelyTyped#18071

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

1 participant