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

Can't export combineReducers with TypeScript as AnyAction is private #2508

Closed
alexmngn opened this issue Jul 13, 2017 · 1 comment
Closed

Comments

@alexmngn
Copy link
Contributor

alexmngn commented Jul 13, 2017

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

What is the current behavior?

When I try to export combineReducers, TypeScript throw the following error:

error TS4082: Default export of the module has or is using private name '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.

I simply export combineReducers

export default combineReducers({
  myReducerOne: oneReducer,
  myReducerTwo: twoReducer,
});

What is the expected behavior?

No error from typescript, we should be allowed to export combineReducers

Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?

Typescript 2.4.1
Redux 3.7.2

I noticed the @private flag has been added yesterday as a comment in the definition code

/**
 * An Action type which accepts any other properties.
 * This is mainly for the use of the `Reducer` type.
 * This is not part of `Action` itself to prevent users who are extending `Action.
 * @private
 */
export interface AnyAction extends Action {
  // Allows any extra properties to be defined in an action.
  [extraProps: string]: any;
}

Typescript doesn't like this at all.
Any reason why this is flagged as private?

pelotom added a commit to pelotom/redux that referenced this issue Aug 16, 2017
The AnyAction type isn't needed any more; just use Action with no type parameters. This also
resolves reduxjs#2508.
pelotom added a commit to pelotom/redux that referenced this issue Sep 11, 2017
The AnyAction type isn't needed any more; just use Action with no type parameters. This also
resolves reduxjs#2508.
@timdorr timdorr closed this as completed Oct 6, 2017
@trusktr
Copy link

trusktr commented Dec 21, 2019

Regarding the all-too-common "has or is using private name" error, I've opened a request to fix issues like these in TypeScript by bringing declaration files to parity with language features. microsoft/TypeScript#35822

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