From ce0c8389af31fdd110c8cbe9f2a05a9c98e08d55 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Mon, 22 May 2017 00:44:27 +0800 Subject: [PATCH 1/2] Add Action Types --- types/react-navigation/index.d.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 40b83778e0..b3372c5990 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -320,10 +320,10 @@ export type NavigationAction = | NavigationTabAction export namespace NavigationActions { - function navigate(options: NavigationNavigateAction): any; - function reset(options: NavigationResetAction): any; - function back(options?: NavigationBackAction): any; - function setParams(options: NavigationSetParamsAction): any; + function navigate(options: NavigationNavigateAction): NavigationNavigateAction; + function reset(options: NavigationResetAction): NavigationResetAction; + function back(options?: NavigationBackAction): NavigationBackAction; + function setParams(options: NavigationSetParamsAction): NavigationSetParamsAction; } export type NavigationRouteConfig = T & { @@ -602,3 +602,17 @@ export interface DrawerNavigatorScreenOptions { | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) ; } + +export interface NavgationComponentProps { + navigation: { + state: { + key: string + params: T, + }, + } +} + +export type NavigationNavigateActionCreator = (options: NavigationNavigateAction) => NavigationNavigateAction; +export type NavigationResetActionCreator = (options: NavigationResetAction) => NavigationResetAction; +export type NavigationBackActionCreator = (options: NavigationBackAction) => NavigationBackAction; +export type NavigationSetParamsActionCreator = (options: NavigationSetParamsAction) => NavigationSetParamsAction; From 9f5ae6ecfbedc55ef8f060bdc559126a3c8be580 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Tue, 23 May 2017 14:55:52 +0800 Subject: [PATCH 2/2] Add NavgationComponentProps --- types/react-navigation/index.d.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index b3372c5990..ffa936f6d0 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for react-navigation 1.0 // Project: https://github.com/react-community/react-navigation -// Definitions by: Huhuanming -// mhcgrq +// Definitions by: Huhuanming , mhcgrq // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as React from 'react' @@ -603,16 +602,22 @@ export interface DrawerNavigatorScreenOptions { ; } +export type NavigationNavigateActionCreator = (options: NavigationNavigateAction) => boolean; +export type NavigationResetActionCreator = (options: NavigationResetAction) => boolean; +export type NavigationBackActionCreator = (options?: NavigationBackAction) => boolean; +export type NavigationSetParamsActionCreator = (options: NavigationSetParamsAction) => boolean; + export interface NavgationComponentProps { + screenProps: any navigation: { + dispatch: any + goBack: NavigationBackActionCreator + navigate: NavigationNavigateActionCreator + setParams: NavigationSetParamsActionCreator state: { key: string + routeName: string, params: T, }, } } - -export type NavigationNavigateActionCreator = (options: NavigationNavigateAction) => NavigationNavigateAction; -export type NavigationResetActionCreator = (options: NavigationResetAction) => NavigationResetAction; -export type NavigationBackActionCreator = (options: NavigationBackAction) => NavigationBackAction; -export type NavigationSetParamsActionCreator = (options: NavigationSetParamsAction) => NavigationSetParamsAction;