react-navigation / redux-helpers

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

Typescript definitions not updated #3

Closed jbrodriguez closed 6 years ago

jbrodriguez commented 6 years ago

I'd like to say that I feel the jump to 1.0.0 stable was rushed.

As for the bug

Argument of type '{ dispatch: NavigationDispatch<any>; state: NavigationState; addListener: any; }' is not assignable to parameter of type 'NavigationProp<NavigationState, NavigationStackAction>'.
  Object literal may only specify known properties, and 'addListener' does not exist in type 'NavigationProp<NavigationState, NavigationStackAction>'.

comes from

<Navigator
  navigation={addNavigationHelpers({
    dispatch: this.props.dispatch as NavigationDispatch<any>,
    state: this.props.nav,
    addListener,
  })}
/>

since https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-navigation/index.d.ts isn't up to date.

Since I create the store in a separate file from the creation of the Navigator, I had to define an instance property (this.addListener), so that it's created after the redux middleware.

Ashoat commented 6 years ago

It seems like this issue has to do with react-navigation as a whole, rather with the Redux integration specifically. It has to do specifically with the type of Navigator, which is defined in the main react-navigation package, including the definition of the navigation prop which is used for Redux integration. (The same navigation prop is used for nesting navigators.)

More generally, this question is about figuring out a way to maintain a TypeScript libdef as we iterate on the library. (We have a pipeline in place for this for Flow, but not for TypeScript right now.)

Please post this issue on the main react-navigation issue tracker so it can get the appropriate eyeballs. I have some thoughts and advice, feel free to tag me in the post! :)