This commit is contained in:
Maciek Blim
2018-06-04 20:16:31 +02:00
31 changed files with 6157 additions and 553 deletions

View File

@@ -0,0 +1,18 @@
import tokenProvider = require('axios-token-interceptor');
tokenProvider(); // $ExpectError
const validOptions = {
getToken: () => Promise.resolve('qwerty'),
};
tokenProvider(validOptions); // $ExpectType TokenProvider
tokenCache(); // $ExpectError
const getToken = Promise.resolve('qwerty');
const validCacheOptions = {
maxAge: 3600,
};
const cache = tokenProvider.tokenCache(getToken, validCacheOptions); // $Expect TokenCache
cache.reset(); // $ExpectType void

View File

@@ -0,0 +1,32 @@
// Type definitions for axios-token-interceptor 0.1
// Project: https://github.com/sandrinodimattia/axios-token-interceptor#readme
// Definitions by: Mike Dodge <https://github.com/innovation-team>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { AxiosRequestConfig } from 'axios';
// Module
declare function AxiosTokenProvider(Options: AxiosTokenProvider.InterceptorOptions): AxiosTokenProvider.TokenProvider;
declare namespace AxiosTokenProvider {
function tokenCache(getToken: Promise<string>, options: TokenCacheOptions): TokenCache;
// Interfaces
interface InterceptorOptions {
token?: string;
getToken?: () => string | Promise<string>;
header?: string;
headerFormatter?: (token: string) => string;
}
type TokenProvider = (config: AxiosRequestConfig) => Promise<AxiosRequestConfig>;
interface TokenCacheOptions {
getMaxAge?: () => number;
maxAge?: number;
}
interface TokenCache {
reset(): void;
}
}
export = AxiosTokenProvider;

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"axios": "^0.16.2"
}
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"axios-token-interceptor-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -0,0 +1,8 @@
import * as pack from "bin-pack";
// $ExpectType PackResult<{ width: number; height: number; }>
const packResult = pack([
{ width: 50, height: 50 },
{ width: 25, height: 25 },
{ width: 25, height: 20 }
]);

60
types/bin-pack/index.d.ts vendored Normal file
View File

@@ -0,0 +1,60 @@
// Type definitions for bin-pack 1.0
// Project: https://github.com/bryanburgers/bin-pack
// Definitions by: Oren Trutner <https://github.com/orentrutner>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Packs objects that have a width and a height into as small of a square as
* possible, using a binary tree bin packing algorithm. After packing, each
* object is given an (x, y) coordinate of where it would be optimally packed.
* @param bins List of rectangular bins to pack
* @param options Packing options. Use inPlace: true to modify the bins
* argument in-place.
*/
declare function pack<T extends pack.Bin>(bins: T[], options?: pack.Options): pack.PackResult<T>;
declare namespace pack {
/** Packing options. */
interface Options {
/** Use inPlace=true to add x,y fields to the bins argument. */
inPlace?: boolean;
}
/** Specifies the dimensions of a bin to pack. */
interface Bin {
width: number;
height: number;
}
/** Describes the location of a packed bin. */
interface PackedItem<T> {
/** X coordinate of the packed bin. */
x: number;
/** Y coordinate of the packed bin. */
y: number;
/** Width of the bin. */
width: number;
/** Height of the bin. */
height: number;
/** The original bin object. */
item: T;
}
/** The return value from the pack function. */
interface PackResult<T> {
/** Width of the bounding box around all bins. */
width: number;
/** Height of the bounding box around all bins. */
height: number;
/** List of packed bins. */
items: Array<PackedItem<T>>;
}
}
export = pack;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bin-pack-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

5118
types/cesium/index.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
Cesium.buildModuleUrl.setBaseUrl('/assets/cesium/');
const viewer = new Cesium.Viewer('#cesium', {
sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
imageryProvider: new Cesium.IonImageryProvider({ assetId: 3845 }),
baseLayerPicker: false,
geocoder: false,
});
const midnight = Cesium.JulianDate.fromDate(new Date(2018, 5, 14));
const prop = new Cesium.SampledPositionProperty();
const pos = Cesium.Cartesian3.fromDegrees(1, 2, 3);
const time = Cesium.JulianDate.addSeconds(midnight, 12345, new Cesium.JulianDate());
prop.addSample(time, pos);
viewer.entities.add(new Cesium.Entity({
position: pos,
point: new Cesium.PointGraphics({
color: Cesium.Color.fromCssColorString('#123123'),
pixelSize: 2
})
}));
const objStart = Cesium.JulianDate.addSeconds(midnight, 12340, new Cesium.JulianDate());
const objStop = Cesium.JulianDate.addSeconds(midnight, 12350, new Cesium.JulianDate());
const entity = new Cesium.Entity({
name: 'TEST',
availability: new Cesium.TimeIntervalCollection([
new Cesium.TimeInterval({
start: objStart,
stop: objStop
})
]),
position: prop,
orientation: new Cesium.VelocityOrientationProperty(prop),
path: new Cesium.PathGraphics({
resolution: 5,
width: 3,
material: new Cesium.ColorMaterialProperty(Cesium.Color.fromCssColorString('#223344')),
leadTime: 0
}),
model: new Cesium.ModelGraphics({
uri: 'http://assets.agi.com/models/rv1.gltf',
minimumPixelSize: 48
})
});
viewer.entities.add(entity);

View File

@@ -0,0 +1,50 @@
import * as Cesium from 'cesium';
Cesium.buildModuleUrl.setBaseUrl('/assets/cesium/');
const viewer = new Cesium.Viewer('#cesium', {
sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
imageryProvider: new Cesium.IonImageryProvider({ assetId: 3845 }),
baseLayerPicker: false,
geocoder: false,
});
const midnight = Cesium.JulianDate.fromDate(new Date(2018, 5, 14));
const prop = new Cesium.SampledPositionProperty();
const pos = Cesium.Cartesian3.fromDegrees(1, 2, 3);
const time = Cesium.JulianDate.addSeconds(midnight, 12345, new Cesium.JulianDate());
prop.addSample(time, pos);
viewer.entities.add(new Cesium.Entity({
position: pos,
point: new Cesium.PointGraphics({
color: Cesium.Color.fromCssColorString('#123123'),
pixelSize: 2
})
}));
const objStart = Cesium.JulianDate.addSeconds(midnight, 12340, new Cesium.JulianDate());
const objStop = Cesium.JulianDate.addSeconds(midnight, 12350, new Cesium.JulianDate());
const entity = new Cesium.Entity({
name: 'TEST',
availability: new Cesium.TimeIntervalCollection([
new Cesium.TimeInterval({
start: objStart,
stop: objStop
})
]),
position: prop,
orientation: new Cesium.VelocityOrientationProperty(prop),
path: new Cesium.PathGraphics({
resolution: 5,
width: 3,
material: new Cesium.ColorMaterialProperty(Cesium.Color.fromCssColorString('#223344')),
leadTime: 0
}),
model: new Cesium.ModelGraphics({
uri: 'http://assets.agi.com/models/rv1.gltf',
minimumPixelSize: 48
})
});
viewer.entities.add(entity);

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"test/cesium-global.test.ts",
"test/cesium-module.test.ts"
]
}

View File

@@ -1,7 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-any-union": false
"strict-export-declare-modifiers": false
}
}

105
types/jquery.nicescroll/index.d.ts vendored Normal file
View File

@@ -0,0 +1,105 @@
// Type definitions for jquery.nicescroll 3.7
// Project: https://nicescroll.areaaperta.com
// Definitions by: Bohdan Stupak <https://github.com/Wkalmar>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery"/>
declare namespace JQueryNiceScroll {
interface NiceScrollPage {
maxw: number;
maxh: number;
width: number;
height: number;
w: number;
h: number;
}
interface NiceScroll {
show(): NiceScroll;
hide(): NiceScroll;
toggle(): NiceScroll;
onResize(e?: Event, page?: NiceScrollPage): NiceScroll;
resize(e?: Event, page?: NiceScrollPage): NiceScroll;
remove(): void;
stop(): NiceScroll;
doScrollPos(x: number, y: number, spd: number): void;
doScrollLeft(x: number, duration: number): void;
doScrollTop(x: number, duration: number): void;
}
interface NiceScrollOptions {
zindex?: "auto" | number;
cursoropacitymin?: number;
cursoropacitymax?: number;
cursorcolor?: string;
cursorwidth?: string;
cursorborder?: string;
cursorborderradius?: string;
scrollspeed?: number;
mousescrollstep?: number;
touchbehavior?: boolean;
emulatetouch?: boolean;
hwacceleration?: boolean;
usetransition?: boolean;
boxzoom?: boolean;
dblclickzoom?: boolean;
gesturezoom?: boolean;
grabcursorenabled?: boolean;
autohidemode?: "leave" | "scroll" | "cursor" | "hidden" | boolean;
background?: string;
iframeautoresize?: boolean;
cursorminheight?: number;
preservenativescrolling?: boolean;
railoffset?: boolean | {
top?: number;
left?: number;
};
railhoffset?: boolean | {
top?: number;
left?: number;
};
bouncescroll?: boolean;
spacebarenabled?: boolean;
railpadding?: {
top: number;
right: number;
left: number;
bottom: number;
};
disableoutline?: boolean;
horizrailenabled?: boolean;
railalign?: "right" | "left" | "top" | "bottom";
railvalign?: "right" | "left" | "top" | "bottom";
enabletranslate3d?: boolean;
enablemousewheel?: boolean;
enablekeyboard?: boolean;
smoothscroll?: boolean;
sensitiverail?: boolean;
enablemouselockapi?: boolean;
cursorfixedheight?: number;
directionlockdeadzone?: number;
hidecursordelay?: number;
nativeparentscrolling?: boolean;
enablescrollonselection?: boolean;
overflowx?: "auto" | "hidden" | "inherit" | "initial" | "overlay" | "scroll" | "unset" | "visible";
overflowy?: "auto" | "hidden" | "inherit" | "initial" | "overlay" | "scroll" | "unset" | "visible";
cursordragspeed?: number;
rtlmode?: "auto" | boolean;
cursordragontouch?: boolean;
oneaxismousemode?: "auto" | boolean;
scriptpath?: string;
preventmultitouchscrolling?: boolean;
disablemutationobserver?: boolean;
enableobserver?: boolean;
scrollbarid?: string;
scrollCLass?: string;
}
}
interface JQuery {
niceScroll(options?: JQueryNiceScroll.NiceScrollOptions): JQueryNiceScroll.NiceScroll;
niceScroll(wrapper: string, options: JQueryNiceScroll.NiceScrollOptions): JQueryNiceScroll.NiceScroll;
getNiceScroll(index?: number): JQueryNiceScroll.NiceScroll;
}

View File

@@ -0,0 +1,41 @@
// cases from documentation
// 1. Simple mode, it styles document scrollbar:
$(() => {
$("body").niceScroll();
});
// 2. Instance with object returned:
let nice;
$(() => {
nice = $("body").niceScroll();
});
// 3. Style a DIV and change cursor color:
$(() => {
$("#thisdiv").niceScroll({cursorcolor: "#00F"});
});
// 4. DIV with "wrapper", formed by two divs, the first is the vieport, the latter is the content:
$(() => {
$("#viewportdiv").niceScroll("#wrapperdiv", {cursorcolor: "#00F"});
});
// 5. Get nicescroll object:
nice = $("#mydiv").getNiceScroll();
// 6. Hide scrollbars:
$("#mydiv").getNiceScroll().hide();
// 7. Check for scrollbars resize (when content or position have changed):
$("#mydiv").getNiceScroll().resize();
// 8. Scrolling to a position:
$("#mydiv").getNiceScroll(0).doScrollLeft(1, 2); // Scroll X Axis
$("#mydiv").getNiceScroll(0).doScrollTop(1, 14); // Scroll Y Axis
// other cases
$(".ui-grid-viewport").niceScroll({
cursorcolor: "#fff",
cursorwidth: "8px",
autohidemode: "leave"
});

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jquery.nicescroll-tests.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}

View File

@@ -1855,7 +1855,7 @@ declare namespace kendo.ui {
dates?: any;
depth?: string;
disableDates?: any|Function;
footer?: string|Function;
footer?: false | string | Function;
format?: string;
max?: Date;
messages?: CalendarMessages;
@@ -4293,7 +4293,7 @@ declare namespace kendo.ui {
columnMenu?: boolean | GridColumnMenu;
dataSource?: any|any|kendo.data.DataSource;
detailTemplate?: string|Function;
editable?: boolean | GridEditable;
editable?: boolean | "inline" | "incell" | "popup" | GridEditable;
excel?: GridExcel;
filterable?: boolean | GridFilterable;
groupable?: boolean | GridGroupable;

View File

@@ -479,6 +479,8 @@ export namespace AppRegistry {
function runApplication(appKey: string, appParameters: any): void;
function registerHeadlessTask(appKey: string, task: TaskProvider): void;
function getRunnable(appKey: string): Runnable | undefined;
}
export interface LayoutAnimationTypes {

View File

@@ -1,4 +1,4 @@
// Type definitions for react-navigation 1.5
// Type definitions for react-navigation 2.0
// Project: https://github.com/react-navigation/react-navigation
// Definitions by: Huhuanming <https://github.com/huhuanming>
// mhcgrq <https://github.com/mhcgrq>
@@ -16,11 +16,12 @@
// Armando Assuncao <https://github.com/ArmandoAssuncao>
// Ciaran Liedeman <https://github.com/cliedeman>
// Edward Sammut Alessi <https://github.com/Slessi>
// Jérémy Magrin <https://github.com/magrinj>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
/**
* Reference: https://github.com/react-navigation/react-navigation/tree/3f3ef6485c8932f49fddc3dd2c508629110bf2b6
* Reference: https://github.com/react-navigation/react-navigation/tree/a37473c5e4833f48796ee6c7c9cb4a8ac49d9c06
*
* NOTE: Please update the commit/link above when updating to a new Flow
* react-navigation/flow/react-navigation.js reference, so we can conveniently just look at diffs on
@@ -43,15 +44,24 @@ export type AnimatedValue = any;
export type HeaderMode = 'float' | 'screen' | 'none';
export interface HeaderForceInset {
horizontal?: string;
vertical?: string;
left?: string;
right?: string;
top?: string;
bottom?: string;
}
export interface HeaderProps extends NavigationSceneRendererProps {
mode: HeaderMode;
router: NavigationRouter<
NavigationState,
NavigationStackScreenOptions
>;
getScreenDetails: (navigationScene: NavigationScene) => NavigationScreenDetails<
NavigationStackScreenOptions
>;
router: NavigationRouter<NavigationState, NavigationStackScreenOptions>;
getScreenDetails: (
navigationScene: NavigationScene
) => NavigationScreenDetails<NavigationStackScreenOptions>;
leftInterpolator: (props: NavigationSceneRendererProps) => {};
titleInterpolator: (props: NavigationSceneRendererProps) => {};
rightInterpolator: (props: NavigationSceneRendererProps) => {};
style: StyleProp<ViewStyle>;
}
@@ -73,12 +83,14 @@ export interface NavigationState {
* Index refers to the active child route in the routes array.
*/
index: number;
routes: any[];
routes: NavigationRoute[];
}
export type NavigationRoute<Params = NavigationParams> = NavigationLeafRoute<Params> | NavigationStateRoute<Params>;
export type NavigationRoute<Params = NavigationParams> =
| NavigationLeafRoute<Params>
| NavigationStateRoute<Params>;
export interface NavigationLeafRoute<Params> {
export interface NavigationLeafRoute<Params = NavigationParams> {
/**
* React's key used by some navigators. No need to specify these manually,
* they will be defined by the router.
@@ -100,7 +112,9 @@ export interface NavigationLeafRoute<Params> {
params?: Params;
}
export type NavigationStateRoute<NavigationLeafRouteParams> = NavigationLeafRoute<NavigationLeafRouteParams> & NavigationState;
export type NavigationStateRoute<
NavigationLeafRouteParams
> = NavigationLeafRoute<NavigationLeafRouteParams> & NavigationState;
export type NavigationScreenOptionsGetter<Options> = (
navigation: NavigationScreenProp<NavigationRoute<any>>,
@@ -113,7 +127,10 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
* an optional previous state. When the action is considered handled but the
* state is unchanged, the output state is null.
*/
getStateForAction: (action: NavigationAction, lastState?: State) => (State | null);
getStateForAction: (
action: NavigationAction,
lastState?: State
) => State | null;
/**
* Maps a URI-like string to an action. This can be mapped to a state
@@ -122,14 +139,14 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
getActionForPathAndParams: (
path: string,
params?: NavigationParams
) => (NavigationAction | null);
) => NavigationAction | null;
getPathAndParamsForState: (
state: State
) => {
path: string,
params?: NavigationParams,
};
path: string;
params?: NavigationParams;
};
getComponentForRouteName: (routeName: string) => NavigationComponent;
@@ -147,11 +164,8 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
}
export type NavigationScreenOption<T> =
T
| ((
navigation: NavigationScreenProp<NavigationRoute>,
config: T
) => T);
| T
| ((navigation: NavigationScreenProp<NavigationRoute>, config: T) => T);
export interface NavigationScreenDetails<T> {
options: T;
@@ -159,7 +173,9 @@ export interface NavigationScreenDetails<T> {
navigation: NavigationScreenProp<NavigationRoute>;
}
export type NavigationScreenOptions = NavigationStackScreenOptions & NavigationTabScreenOptions & NavigationDrawerScreenOptions;
export type NavigationScreenOptions = NavigationStackScreenOptions &
NavigationTabScreenOptions &
NavigationDrawerScreenOptions;
export interface NavigationScreenConfigProps {
navigation: NavigationScreenProp<NavigationRoute>;
@@ -167,30 +183,34 @@ export interface NavigationScreenConfigProps {
}
export type NavigationScreenConfig<Options> =
Options
| ((navigationOptionsContainer: NavigationScreenConfigProps & {
navigationOptions: NavigationScreenProp<NavigationRoute>,
}) => Options);
| Options
| ((
navigationOptionsContainer: NavigationScreenConfigProps & {
navigationOptions: NavigationScreenProp<NavigationRoute>;
}
) => Options);
export type NavigationComponent =
NavigationScreenComponent<any, any, any>
| NavigationNavigator<any, any, any>;
| NavigationScreenComponent<NavigationParams, any, any>
| NavigationNavigator<any, any, any>
| any;
export type NavigationScreenComponent<
Params = NavigationParams,
Options = {},
Props = {}
> = React.ComponentType<NavigationScreenProps<Params, Options> & Props> &
{ navigationOptions?: NavigationScreenConfig<Options> };
Params = NavigationParams,
Options = {},
Props = {}
> = React.ComponentType<NavigationScreenProps<Params, Options> & Props> & {
navigationOptions?: NavigationScreenConfig<Options>;
};
export type NavigationNavigator<
State = NavigationState,
Options = {},
Props = {}
> = React.ComponentType<NavigationNavigatorProps<Options, State> & Props> & {
router: NavigationRouter<State, Options>,
navigationOptions?: NavigationScreenConfig<Options>,
};
State = NavigationState,
Options = {},
Props = {}
> = React.ComponentType<NavigationNavigatorProps<Options, State> & Props> & {
router: NavigationRouter<State, Options>;
navigationOptions?: NavigationScreenConfig<Options>;
};
export interface NavigationParams {
[key: string]: any;
@@ -206,7 +226,8 @@ export interface NavigationNavigateActionPayload {
key?: string;
}
export interface NavigationNavigateAction extends NavigationNavigateActionPayload {
export interface NavigationNavigateAction
extends NavigationNavigateActionPayload {
type: 'Navigation/NAVIGATE';
}
@@ -226,7 +247,8 @@ export interface NavigationSetParamsActionPayload {
params?: NavigationParams;
}
export interface NavigationSetParamsAction extends NavigationSetParamsActionPayload {
export interface NavigationSetParamsAction
extends NavigationSetParamsActionPayload {
type: 'Navigation/SET_PARAMS';
}
@@ -271,40 +293,70 @@ export interface NavigationPopToTopActionPayload {
immediate?: boolean;
}
export interface NavigationPopToTopAction extends NavigationPopToTopActionPayload {
export interface NavigationPopToTopAction
extends NavigationPopToTopActionPayload {
type: 'Navigation/POP_TO_TOP';
}
export interface NavigationStackViewConfig {
mode?: 'card' | 'modal';
headerMode?: HeaderMode;
headerTransitionPreset?: 'fade-in-place' | 'uikit';
cardStyle?: StyleProp<ViewStyle>;
transitionConfig?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps: NavigationTransitionProps,
isModal: boolean,
isModal: boolean
) => TransitionConfig;
onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise<void> | void;
onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void;
onTransitionStart?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => Promise<void> | void;
onTransitionEnd?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => void;
}
/**
* Switch Navigator
*/
export interface NavigationSwitchRouterConfig {
initialRouteName?: string;
initialRouteParams?: NavigationParams;
paths?: NavigationPathsConfig;
navigationOptions?: NavigationScreenConfig<NavigationScreenOptions>;
order?: string[];
backBehavior?: 'none' | 'initialRoute'; // defaults to `'none'`
resetOnBlur?: boolean; // defaults to `true`
}
export interface NavigationStackScreenOptions {
title?: string;
header?: (React.ReactElement<any> | ((headerProps: HeaderProps) => React.ReactElement<any>)) | null;
header?:
| (
| React.ReactElement<any>
| ((headerProps: HeaderProps) => React.ReactElement<any>))
| null;
headerTransparent?: boolean;
headerTitle?: string | React.ReactElement<any>;
headerTitleStyle?: StyleProp<TextStyle>;
headerTitleAllowFontScaling?: boolean;
headerTintColor?: string;
headerLeft?: React.ReactElement<any>;
headerBackTitle?: string | null;
headerBackImage?: React.ReactElement<any>;
headerTruncatedBackTitle?: string;
headerBackTitleStyle?: StyleProp<TextStyle>;
headerPressColorAndroid?: string;
headerRight?: React.ReactElement<any>;
headerStyle?: StyleProp<ViewStyle>;
headerForceInset?: HeaderForceInset;
headerBackground?: React.ReactNode | React.ReactType;
gesturesEnabled?: boolean;
gestureResponseDistance?: { vertical?: number; horizontal?: number };
gestureDirection?: 'default' | 'inverted';
}
export interface NavigationStackRouterConfig {
@@ -317,7 +369,7 @@ export interface NavigationStackRouterConfig {
}
export type NavigationStackAction =
NavigationInitAction
| NavigationInitAction
| NavigationNavigateAction
| NavigationBackAction
| NavigationSetParamsAction
@@ -326,25 +378,30 @@ export type NavigationStackAction =
| NavigationPopToTopAction;
export type NavigationTabAction =
NavigationInitAction
| NavigationInitAction
| NavigationNavigateAction
| NavigationBackAction;
export type NavigationAction =
NavigationInitAction
| NavigationInitAction
| NavigationStackAction
| NavigationTabAction;
export type NavigationRouteConfig = NavigationComponent | ({
navigationOptions?: NavigationScreenConfig<any>,
path?: string,
} & NavigationScreenRouteConfig);
export type NavigationRouteConfig =
| NavigationComponent
| ({
navigationOptions?: NavigationScreenConfig<any>;
path?: string;
} & NavigationScreenRouteConfig);
export type NavigationScreenRouteConfig = NavigationComponent | {
screen: NavigationComponent,
} | {
getScreen: () => NavigationComponent,
};
export type NavigationScreenRouteConfig =
| NavigationComponent
| {
screen: NavigationComponent;
}
| {
getScreen: () => NavigationComponent;
};
export interface NavigationPathsConfig {
[routeName: string]: string;
@@ -352,6 +409,7 @@ export interface NavigationPathsConfig {
export interface NavigationTabRouterConfig {
initialRouteName?: string;
initialRouteParams?: NavigationParams;
paths?: NavigationPathsConfig;
navigationOptions?: NavigationScreenConfig<NavigationScreenOptions>;
order?: string[]; // todo: type these as the real route names rather than 'string'
@@ -360,45 +418,48 @@ export interface NavigationTabRouterConfig {
backBehavior?: 'none' | 'initialRoute'; // defaults `initialRoute`
}
export interface TabScene {
route: NavigationRoute;
focused: boolean;
index: number;
tintColor?: string;
route: NavigationRoute;
focused: boolean;
index: number;
tintColor?: string;
}
export interface NavigationTabScreenOptions {
title?: string;
tabBarIcon?:
React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | null));
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | null);
tabBarLabel?:
string
| React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | string | null));
| string
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | string | null);
tabBarVisible?: boolean;
tabBarTestIDProps?: { testID?: string, accessibilityLabel?: string };
tabBarOnPress?: (options: {
scene: TabScene,
jumpToIndex: (index: number) => void
}) => void;
tabBarTestIDProps?: { testID?: string; accessibilityLabel?: string };
tabBarOnPress?: (
options: {
scene: TabScene;
jumpToIndex: (index: number) => void;
}
) => void;
}
export interface NavigationDrawerScreenOptions {
title?: string;
drawerIcon?:
React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | null));
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | null);
drawerLabel?:
string
| React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | null));
| string
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | null);
drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open';
}
export interface NavigationRouteConfigMap {
@@ -413,22 +474,20 @@ export interface NavigationProp<S> {
}
export type EventType =
| 'willFocus'
| 'didFocus'
| 'willBlur'
| 'didBlur'
| 'action';
| 'willFocus'
| 'didFocus'
| 'willBlur'
| 'didBlur'
| 'action';
export interface NavigationEventPayload {
type: EventType;
action: NavigationAction;
state: NavigationState;
lastState: NavigationState;
lastState: NavigationState | null | undefined;
}
export type NavigationEventCallback = (
payload: NavigationEventPayload
) => void;
export type NavigationEventCallback = (payload: NavigationEventPayload) => void;
export interface NavigationEventSubscription {
remove: () => void;
@@ -438,8 +497,14 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
state: S;
dispatch: NavigationDispatch;
goBack: (routeKey?: string | null) => boolean;
dismiss: () => boolean;
navigate(options: {
routeName: string;
routeName: string | {
routeName: string;
params?: NavigationParams;
action?: NavigationNavigateAction;
key?: string;
};
params?: NavigationParams;
action?: NavigationAction;
key?: string;
@@ -447,8 +512,11 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
navigate(
routeNameOrOptions: string,
params?: NavigationParams,
action?: NavigationAction,
action?: NavigationAction
): boolean;
openDrawer: () => any;
closeDrawer: () => any;
toggleDrawer: () => any;
getParam: <T extends keyof P>(param: T, fallback?: P[T]) => P[T];
setParams: (newParams: P) => boolean;
addListener: (
@@ -467,6 +535,7 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
) => boolean;
pop: (n?: number, params?: { immediate?: boolean }) => boolean;
popToTop: (params?: { immediate?: boolean }) => boolean;
isFocused: () => boolean;
}
export interface NavigationNavigatorProps<O = {}, S = {}> {
@@ -550,6 +619,14 @@ export interface TransitionConfig {
// How to animate position and opacity of the screen
// based on the value generated by the transitionSpec
screenInterpolator?: (props: NavigationSceneRendererProps) => any;
// How to animate position and opacity of the header componetns
// based on the value generated by the transitionSpec
headerLeftInterpolator?: (props: NavigationSceneRendererProps) => any;
headerTitleInterpolator?: (props: NavigationSceneRendererProps) => any;
headerRightInterpolator?: (props: NavigationSceneRendererProps) => any;
// The style of the container. Useful when a scene doesn't have
// 100% opacity and the underlying container is visible.
containerStyle?: StyleProp<ViewStyle>;
}
export type NavigationAnimationSetter = (
@@ -558,7 +635,7 @@ export type NavigationAnimationSetter = (
lastState: NavigationState
) => void;
export type NavigationSceneRenderer = () => (React.ReactElement<any> | null);
export type NavigationSceneRenderer = () => React.ReactElement<any> | null;
export type NavigationStyleInterpolator = (
props: NavigationSceneRendererProps
@@ -567,50 +644,49 @@ export type NavigationStyleInterpolator = (
export interface LayoutEvent {
nativeEvent: {
layout: {
x: number,
y: number,
width: number,
height: number,
},
x: number;
y: number;
width: number;
height: number;
};
};
}
export type NavigatorType =
| 'react-navigation/STACK'
| 'react-navigation/TABS'
| 'react-navigation/DRAWER';
| 'react-navigation/STACK'
| 'react-navigation/TABS'
| 'react-navigation/DRAWER';
export function addNavigationHelpers<S = {}>(
navigation: {
state: S;
dispatch: (action: NavigationAction) => any;
addListener?: (
eventName: string,
callback: NavigationEventCallback
) => NavigationEventSubscription;
}
): NavigationScreenProp<S>;
export interface NavigationContainerProps {
export interface NavigationContainerProps<S = {}, O = {}> {
uriPrefix?: string | RegExp;
onNavigationStateChange?: (
prevNavigationState: NavigationState,
nextNavigationState: NavigationState,
action: NavigationAction,
) => void;
action: NavigationAction
) => void | null | undefined;
navigation?: NavigationScreenProp<S>;
persistenceKey?: string | null;
renderLoadingExperimental?: React.ComponentType;
screenProps?: any;
navigationOptions?: O;
style?: StyleProp<ViewStyle>;
}
export interface NavigationContainerComponent extends React.Component<
export interface NavigationContainerComponent
extends React.Component<
NavigationContainerProps & NavigationNavigatorProps<any>
> {
dispatch: NavigationDispatch;
}
export interface NavigationContainer extends React.ComponentClass<
export interface NavigationContainer
extends React.ComponentClass<
NavigationContainerProps & NavigationNavigatorProps<any>
> {
new(props: NavigationContainerProps & NavigationNavigatorProps<any>, context?: any): NavigationContainerComponent;
new(
props: NavigationContainerProps & NavigationNavigatorProps<any>,
context?: any
): NavigationContainerComponent;
router: NavigationRouter<any, any>;
screenProps: { [key: string]: any };
@@ -618,14 +694,21 @@ export interface NavigationContainer extends React.ComponentClass<
state: { nav: NavigationState | null };
}
export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig {
export interface StackNavigatorConfig
extends NavigationStackViewConfig,
NavigationStackRouterConfig {
containerOptions?: any;
}
// Return createNavigationContainer
export function StackNavigator(
routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig,
stackConfig?: StackNavigatorConfig
): NavigationContainer;
export function createStackNavigator(
routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig
): NavigationContainer;
export interface SwitchNavigatorConfig {
@@ -636,11 +719,18 @@ export interface SwitchNavigatorConfig {
}
// Return createNavigationContainer
export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig;
export function SwitchNavigator(
routeConfigMap: NavigationRouteConfigMap,
switchConfig?: SwitchNavigatorConfig
): NavigationContainer;
export function createSwitchNavigator(
routeConfigMap: NavigationRouteConfigMap,
switchConfig?: SwitchNavigatorConfig
): NavigationContainer;
// DrawerItems
export const DrawerItems: React.ReactType;
@@ -655,21 +745,28 @@ export interface DrawerViewConfig {
contentOptions?: any;
style?: StyleProp<ViewStyle>;
}
export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, DrawerViewConfig {
export interface DrawerNavigatorConfig
extends NavigationTabRouterConfig,
DrawerViewConfig {
containerConfig?: any;
contentOptions?: {
activeTintColor?: string,
activeBackgroundColor?: string,
inactiveTintColor?: string,
inactiveBackgroundColor?: string,
style?: StyleProp<ViewStyle>,
labelStyle?: StyleProp<TextStyle>,
activeTintColor?: string;
activeBackgroundColor?: string;
inactiveTintColor?: string;
inactiveBackgroundColor?: string;
style?: StyleProp<ViewStyle>;
labelStyle?: StyleProp<TextStyle>;
};
}
export function DrawerNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawerConfig?: DrawerNavigatorConfig,
drawerConfig?: DrawerNavigatorConfig
): NavigationContainer;
export function createDrawerNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawerConfig?: DrawerNavigatorConfig
): NavigationContainer;
/**
@@ -681,23 +778,23 @@ export interface TabViewConfig {
tabBarComponent?: React.ReactType;
tabBarPosition?: 'top' | 'bottom';
tabBarOptions?: {
activeTintColor?: string,
allowFontScaling?: boolean,
activeBackgroundColor?: string,
inactiveTintColor?: string,
inactiveBackgroundColor?: string,
showLabel?: boolean,
style?: StyleProp<ViewStyle>,
labelStyle?: StyleProp<TextStyle>,
iconStyle?: StyleProp<ViewStyle>,
activeTintColor?: string;
allowFontScaling?: boolean;
activeBackgroundColor?: string;
inactiveTintColor?: string;
inactiveBackgroundColor?: string;
showLabel?: boolean;
style?: StyleProp<ViewStyle>;
labelStyle?: StyleProp<TextStyle>;
iconStyle?: StyleProp<ViewStyle>;
// Top
showIcon?: boolean,
upperCaseLabel?: boolean,
pressColor?: string,
pressOpacity?: number,
scrollEnabled?: boolean,
tabStyle?: StyleProp<ViewStyle>,
indicatorStyle?: StyleProp<ViewStyle>,
showIcon?: boolean;
upperCaseLabel?: boolean;
pressColor?: string;
pressOpacity?: number;
scrollEnabled?: boolean;
tabStyle?: StyleProp<ViewStyle>;
indicatorStyle?: StyleProp<ViewStyle>;
};
swipeEnabled?: boolean;
animationEnabled?: boolean;
@@ -705,16 +802,33 @@ export interface TabViewConfig {
}
// From navigators/TabNavigator.js
export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig {
export interface TabNavigatorConfig
extends NavigationTabRouterConfig,
TabViewConfig {
lazy?: boolean;
removeClippedSubviews?: boolean;
initialLayout?: { height: number, width: number };
initialLayout?: { height: number; width: number };
}
// From navigators/TabNavigator.js
export function TabNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig,
drawConfig?: TabNavigatorConfig
): NavigationContainer;
export function createTabNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig
): NavigationContainer;
export function createBottomTabNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig
): NavigationContainer;
export function createMaterialTopTabNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig
): NavigationContainer;
export interface TabBarTopProps {
@@ -729,15 +843,17 @@ export interface TabBarTopProps {
tabBarPosition: string;
navigation: NavigationScreenProp<NavigationState>;
jumpToIndex: (index: number) => void;
getLabel: (scene: TabScene) => (React.ReactNode | string);
getLabel: (scene: TabScene) => React.ReactNode | string;
getOnPress: (
previousScene: NavigationRoute,
scene: TabScene
) => (args: {
previousScene: NavigationRoute,
scene: TabScene,
jumpToIndex: (index: number) => void,
}) => void;
) => (
args: {
previousScene: NavigationRoute;
scene: TabScene;
jumpToIndex: (index: number) => void;
}
) => void;
renderIcon: (scene: TabScene) => React.ReactElement<any>;
labelStyle?: TextStyle;
iconStyle?: ViewStyle;
@@ -754,15 +870,17 @@ export interface TabBarBottomProps {
position: AnimatedValue;
navigation: NavigationScreenProp<NavigationState>;
jumpToIndex: (index: number) => void;
getLabel: (scene: TabScene) => (React.ReactNode | string);
getLabel: (scene: TabScene) => React.ReactNode | string;
getOnPress: (
previousScene: NavigationRoute,
scene: TabScene
) => (args: {
previousScene: NavigationRoute,
scene: TabScene,
jumpToIndex: (index: number) => void,
}) => void;
) => (
args: {
previousScene: NavigationRoute;
scene: TabScene;
jumpToIndex: (index: number) => void;
}
) => void;
getTestIDProps: (scene: TabScene) => (scene: TabScene) => any;
renderIcon: (scene: TabScene) => React.ReactNode;
style?: ViewStyle;
@@ -789,12 +907,18 @@ export namespace NavigationActions {
const POP_TO_TOP: 'Navigation/POP_TO_TOP';
function init(options?: NavigationInitActionPayload): NavigationInitAction;
function navigate(options: NavigationNavigateActionPayload): NavigationNavigateAction;
function navigate(
options: NavigationNavigateActionPayload
): NavigationNavigateAction;
function reset(options: NavigationResetActionPayload): NavigationResetAction;
function back(options?: NavigationBackActionPayload): NavigationBackAction;
function setParams(options: NavigationSetParamsActionPayload): NavigationSetParamsAction;
function setParams(
options: NavigationSetParamsActionPayload
): NavigationSetParamsAction;
function pop(options: NavigationPopActionPayload): NavigationPopAction;
function popToTop(options: NavigationPopToTopActionPayload): NavigationPopToTopAction;
function popToTop(
options: NavigationPopToTopActionPayload
): NavigationPopToTopAction;
}
/**
@@ -807,8 +931,14 @@ export interface TransitionerProps {
prevTransitionProps?: NavigationTransitionProps
) => NavigationTransitionSpec;
navigation: NavigationScreenProp<NavigationState>;
onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise<void> | void;
onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void;
onTransitionStart?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => Promise<void> | void;
onTransitionEnd?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => void;
render: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
@@ -826,7 +956,7 @@ export interface TransitionerState {
export class Transitioner extends React.Component<
TransitionerProps,
TransitionerState
> { }
> { }
/**
* Tab Router
@@ -853,12 +983,23 @@ export function StackRouter(
*
* @see https://github.com/react-navigation/react-navigation/blob/master/src/navigators/createNavigator.js
*/
export function createNavigator<C, S, Options>(
export interface NavigationDescriptor<Params = NavigationParams> {
key: string;
state: NavigationLeafRoute<Params> | NavigationStateRoute<Params>;
navigation: NavigationScreenProp<any>;
getComponent: () => React.ComponentType;
}
export type NavigationView<O, S> = React.ComponentType<{
descriptors: { [key: string]: NavigationDescriptor };
} & NavigationInjectedProps>;
export function createNavigator<S, Options>(
view: NavigationView<Options, S>,
router: NavigationRouter<S, Options>,
routeConfigs?: NavigationRouteConfigMap,
navigatorConfig?: {} | null,
navigatorType?: NavigatorType
): (NavigationView: React.ComponentClass<C>) => NavigationNavigator<C, S, Options>;
): any;
/**
* Create an HOC that injects the navigation and manages the navigation state
@@ -879,7 +1020,10 @@ export function createNavigationContainer(
* BEGIN CUSTOM CONVENIENCE INTERFACES
*/
export interface NavigationScreenProps<Params = NavigationParams, Options = any> {
export interface NavigationScreenProps<
Params = NavigationParams,
Options = any
> {
navigation: NavigationScreenProp<NavigationRoute<Params>, Params>;
screenProps?: { [key: string]: any };
navigationOptions?: NavigationScreenConfig<Options>;
@@ -936,6 +1080,7 @@ export interface SafeAreaViewProps extends ViewProps {
horizontal?: SafeAreaViewForceInsetValue;
vertical?: SafeAreaViewForceInsetValue;
};
children?: React.ReactNode;
}
export const SafeAreaView: React.ComponentClass<SafeAreaViewProps>;

View File

@@ -5,7 +5,7 @@ import {
ViewStyle,
} from 'react-native';
import {
DrawerNavigator,
createDrawerNavigator,
DrawerNavigatorConfig,
NavigationAction,
NavigationActions,
@@ -22,15 +22,14 @@ import {
NavigationStackScreenOptions,
NavigationTabScreenOptions,
NavigationTransitionProps,
StackNavigator,
createStackNavigator,
StackNavigatorConfig,
SwitchNavigator,
createSwitchNavigator,
SwitchNavigatorConfig,
TabBarTop,
TabNavigator,
createTabNavigator,
TabNavigatorConfig,
Transitioner,
addNavigationHelpers,
HeaderBackButton,
Header,
NavigationContainer,
@@ -128,7 +127,7 @@ const routeConfigMap: NavigationRouteConfigMap = {
screen: NextScreen,
},
};
export const AppNavigator = StackNavigator(
export const AppNavigator = createStackNavigator(
routeConfigMap,
{
initialRouteName: ROUTE_NAME_START_SCREEN,
@@ -147,7 +146,7 @@ const StatelessScreen: NavigationScreenComponent<StatelessScreenParams> = (props
StatelessScreen.navigationOptions = { title: 'Stateless' };
const SimpleStackNavigator = StackNavigator(
const SimpleStackNavigator = createStackNavigator(
{
simple: {
screen: StatelessScreen,
@@ -155,20 +154,6 @@ const SimpleStackNavigator = StackNavigator(
}
);
/**
* Router.
*/
const Router = (props: any) => (
<AppNavigator
navigation={
addNavigationHelpers({
dispatch: (action: NavigationStackAction): boolean => true,
state: {},
})
}
/>
);
/**
* Tab navigator.
*/
@@ -204,7 +189,7 @@ const tabNavigatorConfigWithNavigationOptions: TabNavigatorConfig = {
},
};
const BasicTabNavigator = TabNavigator(
const BasicTabNavigator = createTabNavigator(
routeConfigMap,
tabNavigatorConfig,
);
@@ -232,7 +217,7 @@ const stackNavigatorConfig: StackNavigatorConfig = {
navigationOptions: stackNavigatorScreenOptions,
};
const BasicStackNavigator = StackNavigator(
const BasicStackNavigator = createStackNavigator(
routeConfigMap,
stackNavigatorConfig,
);
@@ -252,7 +237,7 @@ const stackNavigatorConfigWithNavigationOptionsAsFunction: StackNavigatorConfig
navigationOptions: ({navigationOptions, navigation, screenProps}) => (stackNavigatorScreenOptions),
};
const AdvancedStackNavigator = StackNavigator(
const AdvancedStackNavigator = createStackNavigator(
routeConfigMap,
stackNavigatorConfigWithNavigationOptionsAsFunction
);
@@ -276,7 +261,7 @@ const switchNavigatorConfig: SwitchNavigatorConfig = {
backBehavior: 'none'
};
const BasicSwitchNavigator = SwitchNavigator(
const BasicSwitchNavigator = createSwitchNavigator(
routeConfigMap,
switchNavigatorConfig,
);
@@ -296,7 +281,7 @@ const switchNavigatorConfigWithInitialRoute: SwitchNavigatorConfig = {
backBehavior: 'initialRoute'
};
const SwitchNavigatorWithInitialRoute = SwitchNavigator(
const SwitchNavigatorWithInitialRoute = createSwitchNavigator(
routeConfigMap,
switchNavigatorConfigWithInitialRoute,
);
@@ -326,7 +311,7 @@ const drawerNavigatorConfig: DrawerNavigatorConfig = {
},
};
const BasicDrawerNavigator = DrawerNavigator(
const BasicDrawerNavigator = createDrawerNavigator(
routeConfigMap,
stackNavigatorConfig,
);
@@ -449,7 +434,7 @@ const popToTopAction: NavigationPopToTopAction = NavigationActions.popToTop({
class Page1 extends React.Component { }
const RootNavigator: NavigationContainer = SwitchNavigator({
const RootNavigator: NavigationContainer = createSwitchNavigator({
default: { getScreen: () => Page1 },
});

View File

@@ -22,4 +22,4 @@
"index.d.ts",
"react-navigation-tests.tsx"
]
}
}

View File

@@ -1 +1,7 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-any-union": false
}
}

View File

@@ -1,4 +1,4 @@
// Type definitions for react-navigation 2.0
// Type definitions for react-navigation 1.5
// Project: https://github.com/react-navigation/react-navigation
// Definitions by: Huhuanming <https://github.com/huhuanming>
// mhcgrq <https://github.com/mhcgrq>
@@ -16,12 +16,11 @@
// Armando Assuncao <https://github.com/ArmandoAssuncao>
// Ciaran Liedeman <https://github.com/cliedeman>
// Edward Sammut Alessi <https://github.com/Slessi>
// Jérémy Magrin <https://github.com/magrinj>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
/**
* Reference: https://github.com/react-navigation/react-navigation/tree/a37473c5e4833f48796ee6c7c9cb4a8ac49d9c06
* Reference: https://github.com/react-navigation/react-navigation/tree/3f3ef6485c8932f49fddc3dd2c508629110bf2b6
*
* NOTE: Please update the commit/link above when updating to a new Flow
* react-navigation/flow/react-navigation.js reference, so we can conveniently just look at diffs on
@@ -44,24 +43,15 @@ export type AnimatedValue = any;
export type HeaderMode = 'float' | 'screen' | 'none';
export interface HeaderForceInset {
horizontal?: string;
vertical?: string;
left?: string;
right?: string;
top?: string;
bottom?: string;
}
export interface HeaderProps extends NavigationSceneRendererProps {
mode: HeaderMode;
router: NavigationRouter<NavigationState, NavigationStackScreenOptions>;
getScreenDetails: (
navigationScene: NavigationScene
) => NavigationScreenDetails<NavigationStackScreenOptions>;
leftInterpolator: (props: NavigationSceneRendererProps) => {};
titleInterpolator: (props: NavigationSceneRendererProps) => {};
rightInterpolator: (props: NavigationSceneRendererProps) => {};
router: NavigationRouter<
NavigationState,
NavigationStackScreenOptions
>;
getScreenDetails: (navigationScene: NavigationScene) => NavigationScreenDetails<
NavigationStackScreenOptions
>;
style: StyleProp<ViewStyle>;
}
@@ -83,14 +73,12 @@ export interface NavigationState {
* Index refers to the active child route in the routes array.
*/
index: number;
routes: NavigationRoute[];
routes: any[];
}
export type NavigationRoute<Params = NavigationParams> =
| NavigationLeafRoute<Params>
| NavigationStateRoute<Params>;
export type NavigationRoute<Params = NavigationParams> = NavigationLeafRoute<Params> | NavigationStateRoute<Params>;
export interface NavigationLeafRoute<Params = NavigationParams> {
export interface NavigationLeafRoute<Params> {
/**
* React's key used by some navigators. No need to specify these manually,
* they will be defined by the router.
@@ -112,9 +100,7 @@ export interface NavigationLeafRoute<Params = NavigationParams> {
params?: Params;
}
export type NavigationStateRoute<
NavigationLeafRouteParams
> = NavigationLeafRoute<NavigationLeafRouteParams> & NavigationState;
export type NavigationStateRoute<NavigationLeafRouteParams> = NavigationLeafRoute<NavigationLeafRouteParams> & NavigationState;
export type NavigationScreenOptionsGetter<Options> = (
navigation: NavigationScreenProp<NavigationRoute<any>>,
@@ -127,10 +113,7 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
* an optional previous state. When the action is considered handled but the
* state is unchanged, the output state is null.
*/
getStateForAction: (
action: NavigationAction,
lastState?: State
) => State | null;
getStateForAction: (action: NavigationAction, lastState?: State) => (State | null);
/**
* Maps a URI-like string to an action. This can be mapped to a state
@@ -139,14 +122,14 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
getActionForPathAndParams: (
path: string,
params?: NavigationParams
) => NavigationAction | null;
) => (NavigationAction | null);
getPathAndParamsForState: (
state: State
) => {
path: string;
params?: NavigationParams;
};
path: string,
params?: NavigationParams,
};
getComponentForRouteName: (routeName: string) => NavigationComponent;
@@ -164,8 +147,11 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
}
export type NavigationScreenOption<T> =
| T
| ((navigation: NavigationScreenProp<NavigationRoute>, config: T) => T);
T
| ((
navigation: NavigationScreenProp<NavigationRoute>,
config: T
) => T);
export interface NavigationScreenDetails<T> {
options: T;
@@ -173,9 +159,7 @@ export interface NavigationScreenDetails<T> {
navigation: NavigationScreenProp<NavigationRoute>;
}
export type NavigationScreenOptions = NavigationStackScreenOptions &
NavigationTabScreenOptions &
NavigationDrawerScreenOptions;
export type NavigationScreenOptions = NavigationStackScreenOptions & NavigationTabScreenOptions & NavigationDrawerScreenOptions;
export interface NavigationScreenConfigProps {
navigation: NavigationScreenProp<NavigationRoute>;
@@ -183,34 +167,30 @@ export interface NavigationScreenConfigProps {
}
export type NavigationScreenConfig<Options> =
| Options
| ((
navigationOptionsContainer: NavigationScreenConfigProps & {
navigationOptions: NavigationScreenProp<NavigationRoute>;
}
) => Options);
Options
| ((navigationOptionsContainer: NavigationScreenConfigProps & {
navigationOptions: NavigationScreenProp<NavigationRoute>,
}) => Options);
export type NavigationComponent =
| NavigationScreenComponent<NavigationParams, any, any>
| NavigationNavigator<any, any, any>
| any;
NavigationScreenComponent<any, any, any>
| NavigationNavigator<any, any, any>;
export type NavigationScreenComponent<
Params = NavigationParams,
Options = {},
Props = {}
> = React.ComponentType<NavigationScreenProps<Params, Options> & Props> & {
navigationOptions?: NavigationScreenConfig<Options>;
};
Params = NavigationParams,
Options = {},
Props = {}
> = React.ComponentType<NavigationScreenProps<Params, Options> & Props> &
{ navigationOptions?: NavigationScreenConfig<Options> };
export type NavigationNavigator<
State = NavigationState,
Options = {},
Props = {}
> = React.ComponentType<NavigationNavigatorProps<Options, State> & Props> & {
router: NavigationRouter<State, Options>;
navigationOptions?: NavigationScreenConfig<Options>;
};
State = NavigationState,
Options = {},
Props = {}
> = React.ComponentType<NavigationNavigatorProps<Options, State> & Props> & {
router: NavigationRouter<State, Options>,
navigationOptions?: NavigationScreenConfig<Options>,
};
export interface NavigationParams {
[key: string]: any;
@@ -226,8 +206,7 @@ export interface NavigationNavigateActionPayload {
key?: string;
}
export interface NavigationNavigateAction
extends NavigationNavigateActionPayload {
export interface NavigationNavigateAction extends NavigationNavigateActionPayload {
type: 'Navigation/NAVIGATE';
}
@@ -247,8 +226,7 @@ export interface NavigationSetParamsActionPayload {
params?: NavigationParams;
}
export interface NavigationSetParamsAction
extends NavigationSetParamsActionPayload {
export interface NavigationSetParamsAction extends NavigationSetParamsActionPayload {
type: 'Navigation/SET_PARAMS';
}
@@ -293,70 +271,40 @@ export interface NavigationPopToTopActionPayload {
immediate?: boolean;
}
export interface NavigationPopToTopAction
extends NavigationPopToTopActionPayload {
export interface NavigationPopToTopAction extends NavigationPopToTopActionPayload {
type: 'Navigation/POP_TO_TOP';
}
export interface NavigationStackViewConfig {
mode?: 'card' | 'modal';
headerMode?: HeaderMode;
headerTransitionPreset?: 'fade-in-place' | 'uikit';
cardStyle?: StyleProp<ViewStyle>;
transitionConfig?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps: NavigationTransitionProps,
isModal: boolean
isModal: boolean,
) => TransitionConfig;
onTransitionStart?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => Promise<void> | void;
onTransitionEnd?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => void;
}
/**
* Switch Navigator
*/
export interface NavigationSwitchRouterConfig {
initialRouteName?: string;
initialRouteParams?: NavigationParams;
paths?: NavigationPathsConfig;
navigationOptions?: NavigationScreenConfig<NavigationScreenOptions>;
order?: string[];
backBehavior?: 'none' | 'initialRoute'; // defaults to `'none'`
resetOnBlur?: boolean; // defaults to `true`
onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise<void> | void;
onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void;
}
export interface NavigationStackScreenOptions {
title?: string;
header?:
| (
| React.ReactElement<any>
| ((headerProps: HeaderProps) => React.ReactElement<any>))
| null;
header?: (React.ReactElement<any> | ((headerProps: HeaderProps) => React.ReactElement<any>)) | null;
headerTransparent?: boolean;
headerTitle?: string | React.ReactElement<any>;
headerTitleStyle?: StyleProp<TextStyle>;
headerTitleAllowFontScaling?: boolean;
headerTintColor?: string;
headerLeft?: React.ReactElement<any>;
headerBackTitle?: string | null;
headerBackImage?: React.ReactElement<any>;
headerTruncatedBackTitle?: string;
headerBackTitleStyle?: StyleProp<TextStyle>;
headerPressColorAndroid?: string;
headerRight?: React.ReactElement<any>;
headerStyle?: StyleProp<ViewStyle>;
headerForceInset?: HeaderForceInset;
headerBackground?: React.ReactNode | React.ReactType;
gesturesEnabled?: boolean;
gestureResponseDistance?: { vertical?: number; horizontal?: number };
gestureDirection?: 'default' | 'inverted';
}
export interface NavigationStackRouterConfig {
@@ -369,7 +317,7 @@ export interface NavigationStackRouterConfig {
}
export type NavigationStackAction =
| NavigationInitAction
NavigationInitAction
| NavigationNavigateAction
| NavigationBackAction
| NavigationSetParamsAction
@@ -378,30 +326,25 @@ export type NavigationStackAction =
| NavigationPopToTopAction;
export type NavigationTabAction =
| NavigationInitAction
NavigationInitAction
| NavigationNavigateAction
| NavigationBackAction;
export type NavigationAction =
| NavigationInitAction
NavigationInitAction
| NavigationStackAction
| NavigationTabAction;
export type NavigationRouteConfig =
| NavigationComponent
| ({
navigationOptions?: NavigationScreenConfig<any>;
path?: string;
} & NavigationScreenRouteConfig);
export type NavigationRouteConfig = NavigationComponent | ({
navigationOptions?: NavigationScreenConfig<any>,
path?: string,
} & NavigationScreenRouteConfig);
export type NavigationScreenRouteConfig =
| NavigationComponent
| {
screen: NavigationComponent;
}
| {
getScreen: () => NavigationComponent;
};
export type NavigationScreenRouteConfig = NavigationComponent | {
screen: NavigationComponent,
} | {
getScreen: () => NavigationComponent,
};
export interface NavigationPathsConfig {
[routeName: string]: string;
@@ -409,7 +352,6 @@ export interface NavigationPathsConfig {
export interface NavigationTabRouterConfig {
initialRouteName?: string;
initialRouteParams?: NavigationParams;
paths?: NavigationPathsConfig;
navigationOptions?: NavigationScreenConfig<NavigationScreenOptions>;
order?: string[]; // todo: type these as the real route names rather than 'string'
@@ -418,48 +360,45 @@ export interface NavigationTabRouterConfig {
backBehavior?: 'none' | 'initialRoute'; // defaults `initialRoute`
}
export interface TabScene {
route: NavigationRoute;
focused: boolean;
index: number;
tintColor?: string;
route: NavigationRoute;
focused: boolean;
index: number;
tintColor?: string;
}
export interface NavigationTabScreenOptions {
title?: string;
tabBarIcon?:
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | null);
React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | null));
tabBarLabel?:
| string
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | string | null);
string
| React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | string | null));
tabBarVisible?: boolean;
tabBarTestIDProps?: { testID?: string; accessibilityLabel?: string };
tabBarOnPress?: (
options: {
scene: TabScene;
jumpToIndex: (index: number) => void;
}
) => void;
tabBarTestIDProps?: { testID?: string, accessibilityLabel?: string };
tabBarOnPress?: (options: {
scene: TabScene,
jumpToIndex: (index: number) => void
}) => void;
}
export interface NavigationDrawerScreenOptions {
title?: string;
drawerIcon?:
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | null);
React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | null));
drawerLabel?:
| string
| React.ReactElement<any>
| ((
options: { tintColor: string | null; focused: boolean }
) => React.ReactElement<any> | null);
drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open';
string
| React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
any
> | null));
}
export interface NavigationRouteConfigMap {
@@ -474,20 +413,22 @@ export interface NavigationProp<S> {
}
export type EventType =
| 'willFocus'
| 'didFocus'
| 'willBlur'
| 'didBlur'
| 'action';
| 'willFocus'
| 'didFocus'
| 'willBlur'
| 'didBlur'
| 'action';
export interface NavigationEventPayload {
type: EventType;
action: NavigationAction;
state: NavigationState;
lastState: NavigationState | null | undefined;
lastState: NavigationState;
}
export type NavigationEventCallback = (payload: NavigationEventPayload) => void;
export type NavigationEventCallback = (
payload: NavigationEventPayload
) => void;
export interface NavigationEventSubscription {
remove: () => void;
@@ -497,14 +438,8 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
state: S;
dispatch: NavigationDispatch;
goBack: (routeKey?: string | null) => boolean;
dismiss: () => boolean;
navigate(options: {
routeName: string | {
routeName: string;
params?: NavigationParams;
action?: NavigationNavigateAction;
key?: string;
};
routeName: string;
params?: NavigationParams;
action?: NavigationAction;
key?: string;
@@ -512,11 +447,8 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
navigate(
routeNameOrOptions: string,
params?: NavigationParams,
action?: NavigationAction
action?: NavigationAction,
): boolean;
openDrawer: () => any;
closeDrawer: () => any;
toggleDrawer: () => any;
getParam: <T extends keyof P>(param: T, fallback?: P[T]) => P[T];
setParams: (newParams: P) => boolean;
addListener: (
@@ -535,7 +467,6 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
) => boolean;
pop: (n?: number, params?: { immediate?: boolean }) => boolean;
popToTop: (params?: { immediate?: boolean }) => boolean;
isFocused: () => boolean;
}
export interface NavigationNavigatorProps<O = {}, S = {}> {
@@ -619,14 +550,6 @@ export interface TransitionConfig {
// How to animate position and opacity of the screen
// based on the value generated by the transitionSpec
screenInterpolator?: (props: NavigationSceneRendererProps) => any;
// How to animate position and opacity of the header componetns
// based on the value generated by the transitionSpec
headerLeftInterpolator?: (props: NavigationSceneRendererProps) => any;
headerTitleInterpolator?: (props: NavigationSceneRendererProps) => any;
headerRightInterpolator?: (props: NavigationSceneRendererProps) => any;
// The style of the container. Useful when a scene doesn't have
// 100% opacity and the underlying container is visible.
containerStyle?: StyleProp<ViewStyle>;
}
export type NavigationAnimationSetter = (
@@ -635,7 +558,7 @@ export type NavigationAnimationSetter = (
lastState: NavigationState
) => void;
export type NavigationSceneRenderer = () => React.ReactElement<any> | null;
export type NavigationSceneRenderer = () => (React.ReactElement<any> | null);
export type NavigationStyleInterpolator = (
props: NavigationSceneRendererProps
@@ -644,49 +567,50 @@ export type NavigationStyleInterpolator = (
export interface LayoutEvent {
nativeEvent: {
layout: {
x: number;
y: number;
width: number;
height: number;
};
x: number,
y: number,
width: number,
height: number,
},
};
}
export type NavigatorType =
| 'react-navigation/STACK'
| 'react-navigation/TABS'
| 'react-navigation/DRAWER';
| 'react-navigation/STACK'
| 'react-navigation/TABS'
| 'react-navigation/DRAWER';
export interface NavigationContainerProps<S = {}, O = {}> {
export function addNavigationHelpers<S = {}>(
navigation: {
state: S;
dispatch: (action: NavigationAction) => any;
addListener?: (
eventName: string,
callback: NavigationEventCallback
) => NavigationEventSubscription;
}
): NavigationScreenProp<S>;
export interface NavigationContainerProps {
uriPrefix?: string | RegExp;
onNavigationStateChange?: (
prevNavigationState: NavigationState,
nextNavigationState: NavigationState,
action: NavigationAction
) => void | null | undefined;
navigation?: NavigationScreenProp<S>;
persistenceKey?: string | null;
renderLoadingExperimental?: React.ComponentType;
screenProps?: any;
navigationOptions?: O;
action: NavigationAction,
) => void;
style?: StyleProp<ViewStyle>;
}
export interface NavigationContainerComponent
extends React.Component<
export interface NavigationContainerComponent extends React.Component<
NavigationContainerProps & NavigationNavigatorProps<any>
> {
dispatch: NavigationDispatch;
}
export interface NavigationContainer
extends React.ComponentClass<
export interface NavigationContainer extends React.ComponentClass<
NavigationContainerProps & NavigationNavigatorProps<any>
> {
new(
props: NavigationContainerProps & NavigationNavigatorProps<any>,
context?: any
): NavigationContainerComponent;
new(props: NavigationContainerProps & NavigationNavigatorProps<any>, context?: any): NavigationContainerComponent;
router: NavigationRouter<any, any>;
screenProps: { [key: string]: any };
@@ -694,21 +618,14 @@ export interface NavigationContainer
state: { nav: NavigationState | null };
}
export interface StackNavigatorConfig
extends NavigationStackViewConfig,
NavigationStackRouterConfig {
export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig {
containerOptions?: any;
}
// Return createNavigationContainer
export function StackNavigator(
routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig
): NavigationContainer;
export function createStackNavigator(
routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig
stackConfig?: StackNavigatorConfig,
): NavigationContainer;
export interface SwitchNavigatorConfig {
@@ -719,18 +636,11 @@ export interface SwitchNavigatorConfig {
}
// Return createNavigationContainer
export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig;
export function SwitchNavigator(
routeConfigMap: NavigationRouteConfigMap,
switchConfig?: SwitchNavigatorConfig
): NavigationContainer;
export function createSwitchNavigator(
routeConfigMap: NavigationRouteConfigMap,
switchConfig?: SwitchNavigatorConfig
): NavigationContainer;
// DrawerItems
export const DrawerItems: React.ReactType;
@@ -745,28 +655,21 @@ export interface DrawerViewConfig {
contentOptions?: any;
style?: StyleProp<ViewStyle>;
}
export interface DrawerNavigatorConfig
extends NavigationTabRouterConfig,
DrawerViewConfig {
export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, DrawerViewConfig {
containerConfig?: any;
contentOptions?: {
activeTintColor?: string;
activeBackgroundColor?: string;
inactiveTintColor?: string;
inactiveBackgroundColor?: string;
style?: StyleProp<ViewStyle>;
labelStyle?: StyleProp<TextStyle>;
activeTintColor?: string,
activeBackgroundColor?: string,
inactiveTintColor?: string,
inactiveBackgroundColor?: string,
style?: StyleProp<ViewStyle>,
labelStyle?: StyleProp<TextStyle>,
};
}
export function DrawerNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawerConfig?: DrawerNavigatorConfig
): NavigationContainer;
export function createDrawerNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawerConfig?: DrawerNavigatorConfig
drawerConfig?: DrawerNavigatorConfig,
): NavigationContainer;
/**
@@ -778,23 +681,23 @@ export interface TabViewConfig {
tabBarComponent?: React.ReactType;
tabBarPosition?: 'top' | 'bottom';
tabBarOptions?: {
activeTintColor?: string;
allowFontScaling?: boolean;
activeBackgroundColor?: string;
inactiveTintColor?: string;
inactiveBackgroundColor?: string;
showLabel?: boolean;
style?: StyleProp<ViewStyle>;
labelStyle?: StyleProp<TextStyle>;
iconStyle?: StyleProp<ViewStyle>;
activeTintColor?: string,
allowFontScaling?: boolean,
activeBackgroundColor?: string,
inactiveTintColor?: string,
inactiveBackgroundColor?: string,
showLabel?: boolean,
style?: StyleProp<ViewStyle>,
labelStyle?: StyleProp<TextStyle>,
iconStyle?: StyleProp<ViewStyle>,
// Top
showIcon?: boolean;
upperCaseLabel?: boolean;
pressColor?: string;
pressOpacity?: number;
scrollEnabled?: boolean;
tabStyle?: StyleProp<ViewStyle>;
indicatorStyle?: StyleProp<ViewStyle>;
showIcon?: boolean,
upperCaseLabel?: boolean,
pressColor?: string,
pressOpacity?: number,
scrollEnabled?: boolean,
tabStyle?: StyleProp<ViewStyle>,
indicatorStyle?: StyleProp<ViewStyle>,
};
swipeEnabled?: boolean;
animationEnabled?: boolean;
@@ -802,33 +705,16 @@ export interface TabViewConfig {
}
// From navigators/TabNavigator.js
export interface TabNavigatorConfig
extends NavigationTabRouterConfig,
TabViewConfig {
export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig {
lazy?: boolean;
removeClippedSubviews?: boolean;
initialLayout?: { height: number; width: number };
initialLayout?: { height: number, width: number };
}
// From navigators/TabNavigator.js
export function TabNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig
): NavigationContainer;
export function createTabNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig
): NavigationContainer;
export function createBottomTabNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig
): NavigationContainer;
export function createMaterialTopNavigator(
routeConfigMap: NavigationRouteConfigMap,
drawConfig?: TabNavigatorConfig
drawConfig?: TabNavigatorConfig,
): NavigationContainer;
export interface TabBarTopProps {
@@ -843,17 +729,15 @@ export interface TabBarTopProps {
tabBarPosition: string;
navigation: NavigationScreenProp<NavigationState>;
jumpToIndex: (index: number) => void;
getLabel: (scene: TabScene) => React.ReactNode | string;
getLabel: (scene: TabScene) => (React.ReactNode | string);
getOnPress: (
previousScene: NavigationRoute,
scene: TabScene
) => (
args: {
previousScene: NavigationRoute;
scene: TabScene;
jumpToIndex: (index: number) => void;
}
) => void;
) => (args: {
previousScene: NavigationRoute,
scene: TabScene,
jumpToIndex: (index: number) => void,
}) => void;
renderIcon: (scene: TabScene) => React.ReactElement<any>;
labelStyle?: TextStyle;
iconStyle?: ViewStyle;
@@ -870,17 +754,15 @@ export interface TabBarBottomProps {
position: AnimatedValue;
navigation: NavigationScreenProp<NavigationState>;
jumpToIndex: (index: number) => void;
getLabel: (scene: TabScene) => React.ReactNode | string;
getLabel: (scene: TabScene) => (React.ReactNode | string);
getOnPress: (
previousScene: NavigationRoute,
scene: TabScene
) => (
args: {
previousScene: NavigationRoute;
scene: TabScene;
jumpToIndex: (index: number) => void;
}
) => void;
) => (args: {
previousScene: NavigationRoute,
scene: TabScene,
jumpToIndex: (index: number) => void,
}) => void;
getTestIDProps: (scene: TabScene) => (scene: TabScene) => any;
renderIcon: (scene: TabScene) => React.ReactNode;
style?: ViewStyle;
@@ -907,18 +789,12 @@ export namespace NavigationActions {
const POP_TO_TOP: 'Navigation/POP_TO_TOP';
function init(options?: NavigationInitActionPayload): NavigationInitAction;
function navigate(
options: NavigationNavigateActionPayload
): NavigationNavigateAction;
function navigate(options: NavigationNavigateActionPayload): NavigationNavigateAction;
function reset(options: NavigationResetActionPayload): NavigationResetAction;
function back(options?: NavigationBackActionPayload): NavigationBackAction;
function setParams(
options: NavigationSetParamsActionPayload
): NavigationSetParamsAction;
function setParams(options: NavigationSetParamsActionPayload): NavigationSetParamsAction;
function pop(options: NavigationPopActionPayload): NavigationPopAction;
function popToTop(
options: NavigationPopToTopActionPayload
): NavigationPopToTopAction;
function popToTop(options: NavigationPopToTopActionPayload): NavigationPopToTopAction;
}
/**
@@ -931,14 +807,8 @@ export interface TransitionerProps {
prevTransitionProps?: NavigationTransitionProps
) => NavigationTransitionSpec;
navigation: NavigationScreenProp<NavigationState>;
onTransitionStart?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => Promise<void> | void;
onTransitionEnd?: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
) => void;
onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise<void> | void;
onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void;
render: (
transitionProps: NavigationTransitionProps,
prevTransitionProps?: NavigationTransitionProps
@@ -956,7 +826,7 @@ export interface TransitionerState {
export class Transitioner extends React.Component<
TransitionerProps,
TransitionerState
> { }
> { }
/**
* Tab Router
@@ -983,23 +853,12 @@ export function StackRouter(
*
* @see https://github.com/react-navigation/react-navigation/blob/master/src/navigators/createNavigator.js
*/
export interface NavigationDescriptor<Params = NavigationParams> {
key: string;
state: NavigationLeafRoute<Params> | NavigationStateRoute<Params>;
navigation: NavigationScreenProp<any>;
getComponent: () => React.ComponentType;
}
export type NavigationView<O, S> = React.ComponentType<{
descriptors: { [key: string]: NavigationDescriptor };
} & NavigationInjectedProps>;
export function createNavigator<S, Options>(
view: NavigationView<Options, S>,
export function createNavigator<C, S, Options>(
router: NavigationRouter<S, Options>,
routeConfigs?: NavigationRouteConfigMap,
navigatorConfig?: {} | null,
navigatorType?: NavigatorType
): any;
): (NavigationView: React.ComponentClass<C>) => NavigationNavigator<C, S, Options>;
/**
* Create an HOC that injects the navigation and manages the navigation state
@@ -1020,10 +879,7 @@ export function createNavigationContainer(
* BEGIN CUSTOM CONVENIENCE INTERFACES
*/
export interface NavigationScreenProps<
Params = NavigationParams,
Options = any
> {
export interface NavigationScreenProps<Params = NavigationParams, Options = any> {
navigation: NavigationScreenProp<NavigationRoute<Params>, Params>;
screenProps?: { [key: string]: any };
navigationOptions?: NavigationScreenConfig<Options>;
@@ -1080,7 +936,6 @@ export interface SafeAreaViewProps extends ViewProps {
horizontal?: SafeAreaViewForceInsetValue;
vertical?: SafeAreaViewForceInsetValue;
};
children?: React.ReactNode;
}
export const SafeAreaView: React.ComponentClass<SafeAreaViewProps>;

View File

@@ -5,7 +5,7 @@ import {
ViewStyle,
} from 'react-native';
import {
createDrawerNavigator,
DrawerNavigator,
DrawerNavigatorConfig,
NavigationAction,
NavigationActions,
@@ -22,14 +22,15 @@ import {
NavigationStackScreenOptions,
NavigationTabScreenOptions,
NavigationTransitionProps,
createStackNavigator,
StackNavigator,
StackNavigatorConfig,
createSwitchNavigator,
SwitchNavigator,
SwitchNavigatorConfig,
TabBarTop,
createTabNavigator,
TabNavigator,
TabNavigatorConfig,
Transitioner,
addNavigationHelpers,
HeaderBackButton,
Header,
NavigationContainer,
@@ -127,7 +128,7 @@ const routeConfigMap: NavigationRouteConfigMap = {
screen: NextScreen,
},
};
export const AppNavigator = createStackNavigator(
export const AppNavigator = StackNavigator(
routeConfigMap,
{
initialRouteName: ROUTE_NAME_START_SCREEN,
@@ -146,7 +147,7 @@ const StatelessScreen: NavigationScreenComponent<StatelessScreenParams> = (props
StatelessScreen.navigationOptions = { title: 'Stateless' };
const SimpleStackNavigator = createStackNavigator(
const SimpleStackNavigator = StackNavigator(
{
simple: {
screen: StatelessScreen,
@@ -154,6 +155,20 @@ const SimpleStackNavigator = createStackNavigator(
}
);
/**
* Router.
*/
const Router = (props: any) => (
<AppNavigator
navigation={
addNavigationHelpers({
dispatch: (action: NavigationStackAction): boolean => true,
state: {},
})
}
/>
);
/**
* Tab navigator.
*/
@@ -189,7 +204,7 @@ const tabNavigatorConfigWithNavigationOptions: TabNavigatorConfig = {
},
};
const BasicTabNavigator = createTabNavigator(
const BasicTabNavigator = TabNavigator(
routeConfigMap,
tabNavigatorConfig,
);
@@ -217,7 +232,7 @@ const stackNavigatorConfig: StackNavigatorConfig = {
navigationOptions: stackNavigatorScreenOptions,
};
const BasicStackNavigator = createStackNavigator(
const BasicStackNavigator = StackNavigator(
routeConfigMap,
stackNavigatorConfig,
);
@@ -237,7 +252,7 @@ const stackNavigatorConfigWithNavigationOptionsAsFunction: StackNavigatorConfig
navigationOptions: ({navigationOptions, navigation, screenProps}) => (stackNavigatorScreenOptions),
};
const AdvancedStackNavigator = createStackNavigator(
const AdvancedStackNavigator = StackNavigator(
routeConfigMap,
stackNavigatorConfigWithNavigationOptionsAsFunction
);
@@ -261,7 +276,7 @@ const switchNavigatorConfig: SwitchNavigatorConfig = {
backBehavior: 'none'
};
const BasicSwitchNavigator = createSwitchNavigator(
const BasicSwitchNavigator = SwitchNavigator(
routeConfigMap,
switchNavigatorConfig,
);
@@ -281,7 +296,7 @@ const switchNavigatorConfigWithInitialRoute: SwitchNavigatorConfig = {
backBehavior: 'initialRoute'
};
const SwitchNavigatorWithInitialRoute = createSwitchNavigator(
const SwitchNavigatorWithInitialRoute = SwitchNavigator(
routeConfigMap,
switchNavigatorConfigWithInitialRoute,
);
@@ -311,7 +326,7 @@ const drawerNavigatorConfig: DrawerNavigatorConfig = {
},
};
const BasicDrawerNavigator = createDrawerNavigator(
const BasicDrawerNavigator = DrawerNavigator(
routeConfigMap,
stackNavigatorConfig,
);
@@ -434,7 +449,7 @@ const popToTopAction: NavigationPopToTopAction = NavigationActions.popToTop({
class Page1 extends React.Component { }
const RootNavigator: NavigationContainer = createSwitchNavigator({
const RootNavigator: NavigationContainer = SwitchNavigator({
default: { getScreen: () => Page1 },
});

View File

@@ -17,10 +17,10 @@
"types": [],
"paths": {
"react-navigation": [
"react-navigation/v2"
"react-navigation/v1"
],
"react-navigation/*": [
"react-navigation/v2/*"
"react-navigation/v1/*"
]
},
"noEmit": true,

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -7,10 +7,10 @@
"types": [],
"paths": {
"react-navigation": [
"react-navigation/v2"
"react-navigation/v1"
],
"react-navigation/*": [
"react-navigation/v2/*"
"react-navigation/v1/*"
]
},
"module": "commonjs",

View File

@@ -7,10 +7,10 @@
"types": [],
"paths": {
"react-navigation": [
"react-navigation/v2"
"react-navigation/v1"
],
"react-navigation/*": [
"react-navigation/v2/*"
"react-navigation/v1/*"
]
},
"module": "commonjs",

View File

@@ -1,4 +1,4 @@
// Type definitions for smtp-server 3.3
// Type definitions for smtp-server 3.4
// Project: https://github.com/nodemailer/smtp-server
// Definitions by: markisme <https://github.com/markisme>
// taisiias <https://github.com/Taisiias>
@@ -72,11 +72,19 @@ export interface SMTPServerSession {
*/
id: string;
/**
* the IP address for the connected client
* local IP address for the connected client
*/
localAddress: string;
/**
* local port number for the connected client
*/
localPort: number;
/**
* remote IP address for the connected client
*/
remoteAddress: string;
/**
* port number the connected client
* remote port number for the connected client
*/
remotePort: number;
/**
@@ -126,6 +134,8 @@ export interface SMTPServerOptions extends tls.TlsOptions {
* createServer can be added directly onto this options object.
*/
secure?: boolean;
/** indicate an TLS server where TLS is handled upstream */
secured?: boolean;
/** optional private keys in PEM format */
key?: string | string[] | Buffer | Buffer[] | Array<{ pem: string | Buffer, passphrase: string }>;
/** optional cert chains in PEM format */