react-navigation / redux-helpers

Redux middleware and utils for React Navigation
Other
296 stars 43 forks source link

Typescript 3 compilation error in index.d.ts #61

Closed rodrigoelp closed 6 years ago

rodrigoelp commented 6 years ago

Hi, I've started using this dependency in a brand new project and off the bat I get a compilation error from here as follows:

master ✱ ❯ tsc -v
Version 3.0.1

master ✱ ❯ tsc
node_modules/react-navigation-redux-helpers/index.d.ts:25:71 - error TS2344: Type 'S' does not satisfy the constraint 'Action<any>'.

25   ): React.ComponentType<{ state: NavigationState; dispatch: Dispatch<S> }>;
                                                                         ~

Do you guys know what the problem might be?

I've setup my project with the following dependencies:

{
  "dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-navigation": "2.11.2",
    "react-navigation-redux-helpers": "2.0.5",
    "react-redux": "5.0.7",
    "redux": "4.0.0",
    "redux-thunk": "2.3.0"
  },
  "devDependencies": {
    "@types/react": "16.4.9",
    "@types/react-native": "0.56.7",
    "@types/react-navigation": "2.0.15",
    "@types/react-redux": "6.0.6",
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "^5",
    "jest": "23.5.0",
    "react-test-renderer": "16.4.1",
    "typescript": "3.0.1"
  },
}
rodrigoelp commented 6 years ago

To be more explicit, the may problem is that dispatch should take an A which extends of Action and in here, this definition forces an S of state as an action (which is the reason why the compiler is complaining)...

Has anybody used this type definition successfully before?

Ashoat commented 6 years ago

Hi @rodrigoelp, I unfortunately don’t maintain the Typescript bindings for this project and rely on PRs from the community to keep it updated. I’d suggest looking through the history of the libdef file to find folks who might be able to answer your questions.

rodrigoelp commented 6 years ago

Or, if you want ashoat. I can submit a pull request fixing it. I've checked the bindings for v2.9 and the compilation error is reported there as well (you just need to turn on the proper flags to evaluate your typings).

Interestingly enough, I can't seem to find the typing in the repo I got from the npm package...

Ashoat commented 6 years ago

PRs are welcome!

rodrigoelp commented 6 years ago

Hi, sorry for the delay... Here is the PR.

rodrigoelp commented 6 years ago

Feel free to close this issue once it has been merged.

Ashoat commented 6 years ago

Pro-tip: you can set up a PR to auto-close an issue by just including the text "Fixes #61" in the text of a commit.