Added TypeScript definitions file #17
Added TypeScript definitions file #17
Conversation
index.d.ts file was missing Closes #4
Thanks @vyshkant for the PR! I'm not very familiar with TypeScript so I will defer to you and the community on what the types should be. Please let me know if and when the issues are resolved and you think the PR is ready to be merged. |
Hi @vyshkant, I have checked your code and I can see the issues you are mentioning.
|
@rodrigoelp Based on your answer, I can draw the following conclusions:
|
Yup, I am good with that. |
And I'm also going to replace the export function createNavigationReducer(navigator: Navigator): Reducer<ReducerState>; because it's implementation actually use ReducerState type: // src/reducer.js
function createNavigationReducer(navigator: Navigator): Reducer<*, *> {
const initialState = navigator.router.getStateForAction(initAction, null);
return (
state: ReducerState = initialState,
action: NavigationAction,
): ReducerState => {
return navigator.router.getStateForAction(action, state);
};
}; |
Some of definitions in the index.d.ts file were incorrect. Closes #4
@Ashoat I think the PR is ready to be merged. |
@Ashoat could you please take a look and merge this PR? |
My apologies, I'm not sure how I missed this for a whole month. |
I just published |
Is all good |
Here are some issues to be discussed:
src/types.js
exportsNavigator
type:I tried to just give it a TS-style, but found that
NavigationContainer
ofreact-navigation
is not generic (see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/9bb6dc2f8bc00c10f8ce8af74916051c84565ffc/types/react-navigation/index.d.ts#L559-L566)So I'm not sure if this line is correct:
src/reducer.js
that exports functioncreateNavigationReducer
:The problem is that the latest release of
redux
has definition ofReducer
that contains only one generic argument (see https://github.com/reactjs/redux/blob/8f60ba321e8ba5fa71d60fa35573c2cdf9c0d852/index.d.ts#L57)(
beta
pre-releases has two generic arguments, but pre-release is not a release)So I'm not sure if this line is correct: