From dc8707172a870f10d1aea1787b4ac050d7828558 Mon Sep 17 00:00:00 2001 From: Zach Zanol Date: Wed, 31 May 2017 15:08:08 -0700 Subject: [PATCH 001/100] Update react-spinkit-tests.tsx --- types/react-spinkit/react-spinkit-tests.tsx | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/types/react-spinkit/react-spinkit-tests.tsx b/types/react-spinkit/react-spinkit-tests.tsx index 6742096ebe..f30adea4a2 100644 --- a/types/react-spinkit/react-spinkit-tests.tsx +++ b/types/react-spinkit/react-spinkit-tests.tsx @@ -4,20 +4,20 @@ import * as React from 'react'; // Examples taken from http://kyleamathews.github.io/react-spinkit/ const spinners = [ // Basic spinners - , - , - , - , - , - , - , - , - , - , - , + , + , + , + , + , + , + , + , + , + , + , // Spinner options - , - , - , + , + , + , ]; From fea7fd14b55b08820612207a53088f4c0eb5c5d0 Mon Sep 17 00:00:00 2001 From: Zach Zanol Date: Wed, 31 May 2017 15:09:01 -0700 Subject: [PATCH 002/100] Update index.d.ts --- types/react-spinkit/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-spinkit/index.d.ts b/types/react-spinkit/index.d.ts index 24de75a032..67f3999daa 100644 --- a/types/react-spinkit/index.d.ts +++ b/types/react-spinkit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-spinkit 1.1.4 +// Type definitions for react-spinkit 3.0.0 // Project: https://github.com/KyleAMathews/react-spinkit // Definitions by: Qubo , Mleko , Tom Crockett // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,7 +11,7 @@ declare namespace spinner { /** * Specify spinner to use. */ - spinnerName?: 'three-bounce' | 'double-bounce' | 'rotating-plane' | 'folding-cube' | 'wave' | 'wandering-cubes' | 'pulse' | 'chasing-dots' | 'circle' | 'cube-grid' | 'wordpress'; + name?: 'three-bounce' | 'double-bounce' | 'rotating-plane' | 'folding-cube' | 'wave' | 'wandering-cubes' | 'pulse' | 'chasing-dots' | 'circle' | 'cube-grid' | 'wordpress'; /** * Disable the initial fade-in of the spinner. */ From 90ec58b3ec58ae3c7a61935ee509f846d4cbdc58 Mon Sep 17 00:00:00 2001 From: Zach Zanol Date: Wed, 31 May 2017 15:18:02 -0700 Subject: [PATCH 003/100] Update index.d.ts --- types/react-spinkit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-spinkit/index.d.ts b/types/react-spinkit/index.d.ts index 67f3999daa..1ef769f665 100644 --- a/types/react-spinkit/index.d.ts +++ b/types/react-spinkit/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-spinkit 3.0.0 // Project: https://github.com/KyleAMathews/react-spinkit -// Definitions by: Qubo , Mleko , Tom Crockett +// Definitions by: Qubo , Mleko , Tom Crockett , zzanol // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From 4d66139dc306a86f1b81f618fb31c1e1dc218c4e Mon Sep 17 00:00:00 2001 From: zzanol Date: Thu, 1 Jun 2017 09:45:29 -0700 Subject: [PATCH 004/100] moved v1 to subfolder --- types/react-spinkit/v1/index.d.ts | 34 +++++++++++++++++++ .../react-spinkit/v1/react-spinkit-tests.tsx | 23 +++++++++++++ types/react-spinkit/v1/tsconfig.json | 28 +++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 types/react-spinkit/v1/index.d.ts create mode 100644 types/react-spinkit/v1/react-spinkit-tests.tsx create mode 100644 types/react-spinkit/v1/tsconfig.json diff --git a/types/react-spinkit/v1/index.d.ts b/types/react-spinkit/v1/index.d.ts new file mode 100644 index 0000000000..24de75a032 --- /dev/null +++ b/types/react-spinkit/v1/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for react-spinkit 1.1.4 +// Project: https://github.com/KyleAMathews/react-spinkit +// Definitions by: Qubo , Mleko , Tom Crockett +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// + +declare namespace spinner { + export interface SpinnerProps { + /** + * Specify spinner to use. + */ + spinnerName?: 'three-bounce' | 'double-bounce' | 'rotating-plane' | 'folding-cube' | 'wave' | 'wandering-cubes' | 'pulse' | 'chasing-dots' | 'circle' | 'cube-grid' | 'wordpress'; + /** + * Disable the initial fade-in of the spinner. + */ + noFadeIn?: boolean; + /** + * Change the default "spinner" className. + */ + overrideSpinnerClassName?: string; + /** + * Component className. + */ + className?: string; + } + + export interface Spinner extends React.ComponentClass { + } +} + +declare const spinner: spinner.Spinner; +export = spinner; diff --git a/types/react-spinkit/v1/react-spinkit-tests.tsx b/types/react-spinkit/v1/react-spinkit-tests.tsx new file mode 100644 index 0000000000..6742096ebe --- /dev/null +++ b/types/react-spinkit/v1/react-spinkit-tests.tsx @@ -0,0 +1,23 @@ +import * as Spinner from 'react-spinkit'; +import * as React from 'react'; + +// Examples taken from http://kyleamathews.github.io/react-spinkit/ +const spinners = [ + // Basic spinners + , + , + , + , + , + , + , + , + , + , + , + + // Spinner options + , + , + , +]; diff --git a/types/react-spinkit/v1/tsconfig.json b/types/react-spinkit/v1/tsconfig.json new file mode 100644 index 0000000000..e04f534c2e --- /dev/null +++ b/types/react-spinkit/v1/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../../", + "jsx": "react", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "react-spinkit": ["react-spinkit/v1"], + "react-spinkit/*": ["react-spinkit/v1/*"] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-spinkit-tests.tsx" + ] +} \ No newline at end of file From 4b594ade150a176a5715efd2693130c7c49d9cd8 Mon Sep 17 00:00:00 2001 From: Michel Felipe Date: Mon, 12 Jun 2017 15:33:00 -0300 Subject: [PATCH 005/100] core-js: Added es7 Reflect methods based on reflect-metadata --- types/core-js/index.d.ts | 239 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 237 insertions(+), 2 deletions(-) diff --git a/types/core-js/index.d.ts b/types/core-js/index.d.ts index 9593bc7a76..0a8f506df4 100644 --- a/types/core-js/index.d.ts +++ b/types/core-js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for core-js 0.9 // Project: https://github.com/zloirock/core-js/ -// Definitions by: Ron Buckton +// Definitions by: Ron Buckton , Michel Felipe // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -50,7 +50,10 @@ declare function $for(iterable: Iterable): $for; // ECMAScript 7 // Modules: es7.array.includes, es7.string.at, es7.string.pad-start, es7.string.pad-end, // es7.object.to-array, es7.object.get-own-property-descriptors, es7.regexp.escape, -// es7.map.to-json, and es7.set.to-json +// es7.map.to-json, es7.set.to-json, es7.reflect.define-metadata, es7.reflect.delete-metadata +// es7.reflect.get-metadata, es7.reflect.get-metadata-keys, es7.reflect.get-own-metadata, +// es7.reflect.get-own-metadata-keys, es7.reflect.has-metadata, es7.reflect.has-own-metadata +// es7.reflect.metadata // ############################################################################################# interface String { @@ -473,6 +476,202 @@ declare namespace core { function preventExtensions(target: any): boolean; function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; + /** + * Define a unique metadata entry on the target. + * @param metadataKey A key used to store and retrieve metadata. + * @param metadataValue A value that contains attached metadata. + * @param target The target object on which to define metadata. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * Reflect.defineMetadata("custom:annotation", options, Example); + * + * // decorator factory as metadata-producing annotation. + * function MyAnnotation(options): ClassDecorator { + * return target => Reflect.defineMetadata("custom:annotation", options, target); + * } + * ``` + */ + function defineMetadata(metadataKey: any, metadataValue: any, target: Object, targetKey?: string | symbol): void; + /** + * Deletes the metadata entry from the target object with the provided key. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata entry was found and deleted; otherwise, false. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.deleteMetadata("custom:annotation", Example); + * ``` + */ + function deleteMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): boolean; + /** + * Gets the metadata value for the provided metadata key on the target object or its prototype chain. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getMetadata("custom:annotation", Example); + * ``` + */ + function getMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): any; + /** + * Gets the metadata keys defined on the target object or its prototype chain. + * @param target The target object on which the metadata is defined. + * @returns An array of unique metadata keys. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getMetadataKeys(Example); + * ``` + */ + function getMetadataKeys(target: Object, targetKey?: string | symbol): any[]; + /** + * Gets the metadata value for the provided metadata key on the target object. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getOwnMetadata("custom:annotation", Example); + * ``` + */ + function getOwnMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): any; + + /** + * Gets the unique metadata keys defined on the target object. + * @param target The target object on which the metadata is defined. + * @returns An array of unique metadata keys. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getOwnMetadataKeys(Example); + * ``` + */ + function getOwnMetadataKeys(target: Object, targetKey?: string | symbol): any[]; + /** + * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.hasMetadata("custom:annotation", Example); + * ``` + */ + function hasMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): boolean; + /** + * Gets a value indicating whether the target object has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata key was defined on the target object; otherwise, `false`. + * @example + * + * ### Example + * + * ```typescript + * + * class Example { + * } + * + * // constructor + * result = Reflect.hasOwnMetadata("custom:annotation", Example); + * ``` + */ + function hasOwnMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): boolean; + /** + * A default metadata decorator factory that can be used on a class, class member, or parameter. + * @param metadataKey The key for the metadata entry. + * @param metadataValue The value for the metadata entry. + * @returns A decorator function. + * @remarks + * If `metadataKey` is already defined for the target and target key, the + * metadataValue for that key will be overwritten. + * @example + * + * ### Example + * + * ```typescript + * // constructor + * @Reflect.metadata(key, value) + * class Example { + * } + * + * // property (on constructor, TypeScript only) + * class Example { + * @Reflect.metadata(key, value) + * static staticProperty; + * } + * + * // property (on prototype, TypeScript only) + * class Example { + * @Reflect.metadata(key, value) + * property; + * } + * + * // method (on constructor) + * class Example { + * @Reflect.metadata(key, value) + * static staticMethod() { } + * } + * + * // method (on prototype) + * class Example { + * @Reflect.metadata(key, value) + * method() { } + * } + * ``` + */ + function metadata(metadataKey: any, metadataValue: any): { + (target: Function): void; + (target: Object, targetKey: string | symbol): void; + }; } const Object: { @@ -1991,6 +2190,42 @@ declare module "core-js/library/fn/reflect/set-prototype-of" { const setPrototypeOf: typeof core.Reflect.setPrototypeOf; export = setPrototypeOf; } +declare module "core-js/library/fn/reflect/es7/define-metadata" { + const defineMetadata: typeof core.Reflect.defineMetadata; + export = defineMetadata; +} +declare module "core-js/library/fn/reflect/es7/delete-metadata" { + const deleteMetadata: typeof core.Reflect.deleteMetadata; + export = deleteMetadata; +} +declare module "core-js/library/fn/reflect/es7/get-metadata" { + const getMetadata: typeof core.Reflect.getMetadata; + export = getMetadata; +} +declare module "core-js/library/fn/reflect/es7/get-metadata-keys" { + const getMetadataKeys: typeof core.Reflect.getMetadataKeys; + export = getMetadataKeys; +} +declare module "core-js/library/fn/reflect/es7/get-own-metadata" { + const getOwnMetadata: typeof core.Reflect.getOwnMetadata; + export = getOwnMetadata; +} +declare module "core-js/library/fn/reflect/es7/get-own-metadata-keys'" { + const getOwnMetadataKeys: typeof core.Reflect.getOwnMetadataKeys; + export = getOwnMetadataKeys; +} +declare module "core-js/library/fn/reflect/es7/has-metadata'" { + const hasMetadata: typeof core.Reflect.hasMetadata; + export = hasMetadata; +} +declare module "core-js/library/fn/reflect/es7/has-own-metadata'" { + const hasOwnMetadata: typeof core.Reflect.hasOwnMetadata; + export = hasOwnMetadata; +} +declare module "core-js/library/fn/reflect/es7/metadata'" { + const metadata: typeof core.Reflect.metadata; + export = metadata; +} declare module "core-js/library/fn/regexp" { const RegExp: typeof core.RegExp; export = RegExp; From e9da83fdebed0086f5a4d31414d2ae234521436f Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Tue, 13 Jun 2017 23:46:52 -0700 Subject: [PATCH 006/100] [react-navigation] Update with latest flow typings --- types/react-navigation/index.d.ts | 691 +++++++++++------------------- 1 file changed, 256 insertions(+), 435 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index e343d092c6..ac160a587d 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -1,34 +1,33 @@ // Type definitions for react-navigation 1.0 // Project: https://github.com/react-community/react-navigation -// Definitions by: Huhuanming , mhcgrq +// Definitions by: Huhuanming +// mhcgrq +// abrahambotros // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as React from 'react' +import * as React from 'react'; import { - Animated, ViewStyle, - TextStyle -} from 'react-native' +} from 'react-native'; -export type HeaderMode = 'float' | 'screen' | 'none' +// @todo when we split types into common, native and web, +// we can properly change Animated.Value to its real value +type AnimatedValue = any; -export function addNavigationHelpers(params: any): any - -type SubViewProps = NavigationSceneRendererProps & { - onNavigateBack?: () => void, -} - -type SubViewRenderer = (subViewProps: SubViewProps) => React.ReactElement | undefined +export type HeaderMode = 'float' | 'screen' | 'none'; export type HeaderProps = NavigationSceneRendererProps & { mode: HeaderMode, - onNavigateBack?: () => void, - renderLeftComponent: SubViewRenderer, - renderRightComponent: SubViewRenderer, - renderTitleComponent: SubViewRenderer, - tintColor?: string, - router: NavigationRouter, -} + router: NavigationRouter< + NavigationState, + NavigationAction, + NavigationStackScreenOptions + >, + getScreenDetails: (navigationScene: NavigationScene) => NavigationScreenDetails< + NavigationStackScreenOptions + >, + style: Style, +}; /** * NavigationState is a tree of routes for a single navigator, where each child @@ -43,15 +42,17 @@ export type HeaderProps = NavigationSceneRendererProps & { * The state for the root navigator of our app represents the whole navigation * state for the whole app. */ -export interface NavigationState { +export type NavigationState = { /** * Index refers to the active child route in the routes array. */ index: number, - routes: any[], -} + routes: Array, +}; -export interface NavigationRoute

{ +export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; + +export type NavigationLeafRoute = { /** * React's key used by some navigators. No need to specify these manually, * they will be defined by the router. @@ -70,558 +71,378 @@ export interface NavigationRoute

{ * Params passed to this route when navigating to it, * e.g. `{ car_id: 123 }` in a route that displays a car. */ - params: P, -} + params?: NavigationParams, +}; -export interface NavigationRouter { +export type NavigationStateRoute = NavigationLeafRoute & { + index: number, + routes: Array, +}; + +export type NavigationScreenOptionsGetter = ( + navigation: NavigationScreenProp, + screenProps?: {} +) => Options; + +export type NavigationRouter = { /** * The reducer that outputs the new navigation state for a given action, with * an optional previous state. When the action is considered handled but the * state is unchanged, the output state is null. */ - getStateForAction: ( - action: NavigationAction, - lastState?: NavigationState, - ) => NavigationState | undefined, + getStateForAction: (action: Action, lastState: (State | null)) => (State | null), /** * Maps a URI-like string to an action. This can be mapped to a state * using `getStateForAction`. */ - getActionForPathAndParams: (path: string, params?: NavigationParams) => NavigationAction | undefined, + getActionForPathAndParams: ( + path: string, + params?: NavigationParams + ) => (Action | null), - getPathAndParamsForState: (state: NavigationState) => { path: string, params?: NavigationParams }, + getPathAndParamsForState: ( + state: State + ) => { + path: string, + params?: NavigationParams, + }, getComponentForRouteName: (routeName: string) => NavigationComponent, - getComponentForState: (state: NavigationState) => NavigationComponent, + getComponentForState: (state: State) => NavigationComponent, /** - * Gets the screen config for a given navigation screen prop. + * Gets the screen navigation options for a given screen. * - * For example, we could get the config for a 'Foo' screen when the + * For example, we could get the config for the 'Foo' screen when the * `navigation.state` is: * * {routeName: 'Foo', key: '123'} */ - getScreenConfig: ( - navigation: NavigationScreenProp, - optionName: string, - ) => any, // todo, fix this any type to become a key of NavigationScreenConfig -} + getScreenOptions: NavigationScreenOptionsGetter, +}; -type NavigationFunc = (navigation: NavigationScreenProp, config: E) => E +export type NavigationScreenOption = + | T + | (( + navigation: NavigationScreenProp, + config: T + ) => T); -export type NavigationScreenOption = T | NavigationFunc +export type Style = ViewStyle; -export interface HeaderConfig { - /** - * Title string used by the navigation bar, or a custom component - */ - title?: string | React.ReactElement; +export type NavigationScreenDetails = { + options: T, + state: NavigationRoute, + navigation: NavigationScreenProp, +}; - /** - * Whether the navigation bar is visible. - */ - visible?: boolean; - - /** - * Renders a custom right component - */ - right?: React.ReactElement, - - /** - * Renders a custom left component - */ - left?: React.ReactElement - - /** - * Style passed into navigation bar container - */ - style?: ViewStyle, - - /** - * Style passed into navigation bar title - */ - titleStyle?: TextStyle, - - // // Style of title text - // titleTextStyle?: $NavigationThunk, - // // Tint color of navigation bar contents - // tintColor?: $NavigationThunk, - // // Navigation bar height - // height?: $NavigationThunk, - // // Navigation bar translucentcy - // translucent?: $NavigationThunk, - // // Renders a custom left component - // renderLeft?: React.Element<*> | - // (navigation: NavigationProp<*>, canGoBack: boolean) => React.Element<*>, - // // Renders a custom navigation bar background - // renderBackground?: $NavigationThunk>, -} - -export interface TabBarConfig { - /** - * Icon used by the tab bar. - */ - icon?: (options: { tintColor: string, focused: boolean }) => React.ReactElement | undefined; - /** - * Label text used by the tab bar. - */ - label?: string | React.ReactElement; -} - -export interface DrawerConfig { - /** - * Icon used by the drawer. - */ - icon?: (options: { tintColor: string, focused: boolean }) => React.ReactElement | undefined; - /** - * Label text used by the drawer. - */ - label?: string; -} - -export interface CardStackConfig { - /** - * Whether you can use gestures to dismiss this screen. - * Defaults to true on iOS, false on Android. - */ - gesturesEnabled?: boolean; -} - -export interface NavigationScreenOptions { - /** - * Title is rendered by certain navigators, e.g. the tab navigator, - * or on web as the title of the browser tab. - */ - title?: NavigationScreenOption; - /** - * Options passed to the navigation bar for this screen. - */ - header?: NavigationScreenOption; - /** - * Options passed to the tab bar for this screen. - */ - tabBar?: NavigationScreenOption; - /** - * Options passed to the drawer for this screen. - */ - drawer?: NavigationScreenOption; - /** - * Options passed to the card stack for this screen. - */ - cardStack?: NavigationScreenOption; -} - -export interface NavigationScreenConfig { +export type NavigationScreenOptions = { title?: string, - header?: HeaderConfig, - tabBar?: TabBarConfig, - drawer?: DrawerConfig; -} +}; -export type NavigationComponent = NavigationScreenComponent | NavigationNavigator +export type NavigationScreenConfigProps = { + navigation: NavigationScreenProp, + screenProps: Object, +}; -export type NavigationScreenComponent = React.ComponentClass & { - navigationOptions?: NavigationScreenOptions, -} +export type NavigationScreenConfig = + | Options + | (NavigationScreenConfigProps & + ((navigationOptionsContainer: { + navigationOptions: NavigationScreenProp< + NavigationRoute, + NavigationAction + >, + }) => Options)); -export type NavigationNavigator = React.ComponentClass & { - router?: NavigationRouter, - navigationOptions?: NavigationScreenOptions, -} +export type NavigationComponent = + | NavigationScreenComponent + | NavigationNavigator; -export interface NavigationParams { - [key: string]: any, -} +export type NavigationScreenComponent = React.ComponentClass & { + navigationOptions?: NavigationScreenConfig, +}; -export interface NavigationNavigateAction { - type?: 'Navigation/NAVIGATE', +export type NavigationNavigator = React.ComponentClass & { + router?: NavigationRouter, + navigationOptions?: NavigationScreenConfig, +}; + +export type NavigationParams = { + [key: string]: string, +}; + +export type NavigationNavigateAction = { + type: 'Navigation/NAVIGATE', routeName: string, params?: NavigationParams, // The action to run inside the sub-router action?: NavigationNavigateAction, -} +}; -export interface NavigationBackAction { - type?: 'Navigation/BACK', - key?: string, -} +export type NavigationBackAction = { + type: 'Navigation/BACK', + key?: string | null, +}; -export interface NavigationSetParamsAction { - type?: 'Navigation/SET_PARAMS', +export type NavigationSetParamsAction = { + type: 'Navigation/SET_PARAMS', // The key of the route where the params should be set key: string, // The new params to merge into the existing route params params?: NavigationParams, -} +}; -export interface NavigationInitAction { - type?: 'Navigation/INIT', +export type NavigationInitAction = { + type: 'Navigation/INIT', params?: NavigationParams, -} +}; -export interface NavigationResetAction { - type?: 'Navigation/RESET', +export type NavigationResetAction = { + type: 'Navigation/RESET', index: number, - actions: NavigationNavigateAction[], -} + key?: string | null, + actions: Array, +}; -export interface NavigationUriAction { - type?: 'Navigation/URI', +export type NavigationUriAction = { + type: 'Navigation/URI', uri: string, -} +}; -export interface NavigationContainerOptions { - // This is used to extract the path from the URI passed to the app for a deep link - URIPrefix?: string, -} - -export interface NavigationContainerConfig { - containerOptions?: NavigationContainerOptions, -} - -export interface NavigationStackViewConfig { +export type NavigationStackViewConfig = { mode?: 'card' | 'modal', headerMode?: HeaderMode, - headerComponent?: React.ComponentClass, - cardStyle?: ViewStyle, + cardStyle?: Style, + transitionConfig?: () => TransitionConfig, onTransitionStart?: () => void, onTransitionEnd?: () => void, -} +}; -export interface NavigationStackRouterConfig { +export type NavigationStackScreenOptions = NavigationScreenOptions & { + header?: (React.ReactElement | ((headerProps: HeaderProps) => React.ReactElement)) | null, + headerTitle?: string | React.ReactElement, + headerTitleStyle?: Style, + headerTintColor?: string, + headerLeft?: React.ReactElement, + headerBackTitle?: string, + headerTruncatedBackTitle?: string, + headerBackTitleStyle?: Style, + headerPressColorAndroid?: string, + headerRight?: React.ReactElement, + headerStyle?: Style, + gesturesEnabled?: boolean, +}; + +export type NavigationStackRouterConfig = { initialRouteName?: string, initialRouteParams?: NavigationParams, paths?: NavigationPathsConfig, - navigationOptions?: NavigationScreenOptions, -} + navigationOptions?: NavigationScreenConfig, +}; export type NavigationStackAction = - NavigationInitAction + | NavigationInitAction | NavigationNavigateAction | NavigationBackAction | NavigationSetParamsAction - | NavigationResetAction + | NavigationResetAction; export type NavigationTabAction = - NavigationInitAction + | NavigationInitAction | NavigationNavigateAction - | NavigationBackAction + | NavigationBackAction; export type NavigationAction = - NavigationInitAction + | NavigationInitAction | NavigationStackAction - | NavigationTabAction - -export namespace NavigationActions { - function navigate(options: NavigationNavigateAction): NavigationNavigateAction; - function reset(options: NavigationResetAction): NavigationResetAction; - function back(options?: NavigationBackAction): NavigationBackAction; - function setParams(options: NavigationSetParamsAction): NavigationSetParamsAction; -} + | NavigationTabAction; export type NavigationRouteConfig = T & { - navigationOptions?: NavigationScreenOptions, + navigationOptions?: NavigationScreenConfig, path?: string, -} +}; -export interface NavigationPathsConfig { +export type NavigationScreenRouteConfig = + | { + screen: NavigationComponent, + } + | { + getScreen: () => NavigationComponent, + }; + +export type NavigationPathsConfig = { [routeName: string]: string, -} +}; -export interface NavigationTabRouterConfig { +export type NavigationTabRouterConfig = { initialRouteName?: string, paths?: NavigationPathsConfig, - navigationOptions?: NavigationScreenOptions, - order?: string[], // todo: type these as the real route names rather than 'string' + navigationOptions?: NavigationScreenConfig, + order?: Array, // todo: type these as the real route names rather than 'string' // Does the back button cause the router to switch to the initial tab backBehavior?: 'none' | 'initialRoute', // defaults `initialRoute` -} +}; -export interface NavigationRouteConfigMap { +export type NavigationTabScreenOptions = NavigationScreenOptions & { + tabBarIcon?: + | React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), + tabBarLabel?: + | string + | React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), + tabBarVisible?: boolean, +}; + +export type NavigationDrawerScreenOptions = NavigationScreenOptions & { + drawerIcon?: + | React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), + drawerLabel?: + | React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), +}; + +export type NavigationRouteConfigMap = { [routeName: string]: NavigationRouteConfig, -} +}; -export type NavigationDispatch = (action: A) => boolean +export type NavigationDispatch = (action: A) => boolean; -export interface NavigationProp { +export type NavigationProp = { state: S, dispatch: NavigationDispatch, -} +}; -export type NavigationScreenProp = NavigationProp & { - goBack: (routeKey?: string) => boolean, - navigate: (routeName: string, params?: NavigationParams, action?: NavigationAction) => boolean, +export type NavigationScreenProp = { + state: S, + dispatch: NavigationDispatch, + goBack: (routeKey?: (string | null)) => boolean, + navigate: ( + routeName: string, + params?: NavigationParams, + action?: NavigationAction + ) => boolean, setParams: (newParams: NavigationParams) => boolean, -} +}; -export interface NavigationNavigatorProps

{ - navigation: NavigationProp, NavigationAction>, -} +export type NavigationNavigatorProps = { + navigation: NavigationProp, + screenProps: any, + navigationOptions: any, +}; /** * Gestures, Animations, and Interpolators */ -export type NavigationAnimatedValue = Animated.Value +export type NavigationGestureDirection = 'horizontal' | 'vertical'; -export type NavigationGestureDirection = 'horizontal' | 'vertical' - -export interface NavigationLayout { - height: NavigationAnimatedValue, +export type NavigationLayout = { + height: AnimatedValue, initHeight: number, initWidth: number, isMeasured: boolean, - width: NavigationAnimatedValue, -} + width: AnimatedValue, +}; -export interface NavigationScene { +export type NavigationScene = { index: number, isActive: boolean, isStale: boolean, key: string, - route: any, -} + route: NavigationRoute, +}; -export interface NavigationTransitionProps { - // The layout of the transitioner of the scenes. +export type NavigationTransitionProps = { + // The layout of the screen container layout: NavigationLayout, - // The navigation state of the transitioner. - navigationState: NavigationState, + // The destination navigation state of the transition + navigation: NavigationScreenProp, // The progressive index of the transitioner's navigation state. - position: NavigationAnimatedValue, + position: AnimatedValue, // The value that represents the progress of the transition when navigation // state changes from one to another. Its numberic value will range from 0 // to 1. // progress.__getAnimatedValue() < 1 : transtion is happening. // progress.__getAnimatedValue() == 1 : transtion completes. - progress: NavigationAnimatedValue, + progress: AnimatedValue, // All the scenes of the transitioner. - scenes: NavigationScene[], + scenes: Array, // The active scene, corresponding to the route at - // `navigationState.routes[navigationState.index]`. When rendering + // `navigation.state.routes[navigation.state.index]`. When rendering // NavigationSceneRendererPropsIndex, the scene does not refer to the active // scene, but instead the scene that is being rendered. The index always // is the index of the scene scene: NavigationScene, index: number, - navigation: NavigationScreenProp, - // The gesture distance for `horizontal` and `vertical` transitions - gestureResponseDistance?: number, -} + screenProps?: {}, +}; // The scene renderer props are nearly identical to the props used for rendering // a transition. The exception is that the passed scene is not the active scene // but is instead the scene that the renderer should render content for. -export type NavigationSceneRendererProps = NavigationTransitionProps +export type NavigationSceneRendererProps = NavigationTransitionProps; -export interface NavigationPanHandlers { - onMoveShouldSetResponder: () => void, - onMoveShouldSetResponderCapture: () => void, - onResponderEnd: () => void, - onResponderGrant: () => void, - onResponderMove: () => void, - onResponderReject: () => void, - onResponderRelease: () => void, - onResponderStart: () => void, - onResponderTerminate: () => void, - onResponderTerminationRequest: () => void, - onStartShouldSetResponder: () => void, - onStartShouldSetResponderCapture: () => void, -} - -export interface NavigationTransitionSpec { +export type NavigationTransitionSpec = { duration?: number, // An easing function from `Easing`. - easing?: () => any, + easing?: (t: number) => number, // A timing function such as `Animated.timing`. - timing?: (value: NavigationAnimatedValue, config: any) => any, -} + timing?: (value: AnimatedValue, config: any) => any, +}; + +/** + * Describes a visual transition from one screen to another. + */ +export type TransitionConfig = { + // The basics properties of the animation, such as duration and easing + transitionSpec?: NavigationTransitionSpec, + // How to animate position and opacity of the screen + // based on the value generated by the transitionSpec + screenInterpolator?: (props: NavigationSceneRendererProps) => Object, +}; export type NavigationAnimationSetter = ( - position: NavigationAnimatedValue, + position: AnimatedValue, newState: NavigationState, - lastState: NavigationState, -) => void + lastState: NavigationState +) => void; -export type NavigationSceneRenderer = ( - props: NavigationSceneRendererProps, -) => React.ReactElement +export type NavigationSceneRenderer = () => (React.ReactElement | null); export type NavigationStyleInterpolator = ( - props: NavigationSceneRendererProps, -) => ViewStyle + props: NavigationSceneRendererProps +) => Style; -export interface LayoutEvent { +export type LayoutEvent = { nativeEvent: { layout: { - x: number; - y: number; - width: number; - height: number; + x: number, + y: number, + width: number, + height: number, }, - } -} - -interface NavigationContainerProps { - screenProps?: any - navigation?: NavigationProp - onNavigationStateChange?: ( - preNavigationState: NavigationState, - nextNavigationState: NavigationState, - ) => void -} - -interface NavigationContainerState { - nav?: NavigationState -} - -export interface NavigationContainer extends React.ComponentClass< - NavigationContainerProps -> { - router: NavigationRouter -} - -export type StackNavigatorConfig = - NavigationContainerConfig - & NavigationStackViewConfig - & NavigationStackRouterConfig; - -// Return createNavigationContainer -export function StackNavigator( - routeConfigMap: NavigationRouteConfigMap, - stackConfig?: StackNavigatorConfig, -): NavigationContainer - -/** - * Drawer Navigator - */ -export interface DrawNavigatorConfig { - drawerWidth?: number, - drawerPosition?: 'left'|'right', - contentComponent?: React.ReactElement, - contentOptions?: { - activeTintColor?: string, - activeBackgroundColor?: string, - inactiveTintColor?: string, - inactiveBackgroundColor?: string, - style?: ViewStyle, - labelStyle?: TextStyle - } -} - -export function DrawerNavigator( - routeConfigMap: NavigationRouteConfigMap, - drawConfig?: DrawNavigatorConfig, -): NavigationContainer; - -/** - * Tab Navigator - */ -export interface TabNavigatorConfig { - tabBarComponent?: React.ReactElement, - tabBarPosition?: 'top'|'bottom', - swipeEnabled?: boolean, - animationEnabled?: boolean, - lazy?: boolean, - tabBarOptions?: { - activeTintColor?: string, - activeBackgroundColor?: string, - inactiveTintColor?: string, - inactiveBackgroundColor?: string, - showLabel?: boolean, - style?: ViewStyle, - labelStyle?: TextStyle, - - // Top - showIcon?: boolean, - upperCaseLabel?: boolean, - pressColor?: string, - pressOpacity?: number, - scrollEnabled?: boolean, - tabStyle?: ViewStyle, - indicatorStyle?: ViewStyle - } - initialRouteName?: string, - order?: string[], - paths?: any // TODO: better def - backBehavior?: 'initialRoute'|'none' -} - -export function TabNavigator( - routeConfigMap: NavigationRouteConfigMap, - drawConfig?: TabNavigatorConfig, -): NavigationContainer; -/** - * Screen Options - */ -export interface StackNavigatorScreenOptions { - title?: string; - headerVisible?: boolean; - headerTitle?: string|React.ReactElement; - headerBackTitle?: string; - headerTruncatedBackTitle?: string; - headerRight?: React.ReactElement; - headerLeft?: React.ReactElement; - headerStyle?: ViewStyle; - headerTitleStyle?: ViewStyle; - headerTintColor?: string; - headerPressColorAndroid?: string; - gesturesEnabled?: boolean; -} - -export interface TabNavigatorScreenOptions { - title?: string; - tabBarVisible?: boolean; - tabBarIcon?: React.ReactElement - | ((options: { focused: boolean, tintColor: string }) => React.ReactElement); - tabBarLabel?: string - | React.ReactElement - | ((options: { focused: boolean, tintColor: string }) => React.ReactElement); -} - -export interface DrawerNavigatorScreenOptions { - title?: string; - drawerLabel?: string - |React.ReactElement - | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) - ; - drawerIcon?: React.ReactElement - | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) - ; -} - -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 NavigationComponentProps { - screenProps: any - navigation: { - dispatch: any - goBack: NavigationBackActionCreator - navigate: NavigationNavigateActionCreator - setParams: NavigationSetParamsActionCreator - state: { - key: string - routeName: string, - params: T, - }, - } -} - -export const TabBarTop: React.ReactElement; -export const TabBarBottom: React.ReactElement; + }, +}; From 19d0ec2398c2c29219970e17be5a9d4f941685ab Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Wed, 14 Jun 2017 21:05:01 -0700 Subject: [PATCH 007/100] [react-navigation] Additional fixes and cleanup for defs outside TypeDefinition.js --- types/react-navigation/index.d.ts | 106 ++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index ac160a587d..792a6a5bea 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -5,8 +5,13 @@ // abrahambotros // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/************************************* + * BEGIN FLOW TYPEDEFINITION.JS PORT * + *************************************/ + import * as React from 'react'; import { + TextStyle, ViewStyle, } from 'react-native'; @@ -446,3 +451,104 @@ export type LayoutEvent = { }, }, }; + +/*********************************** + * END FLOW TYPEDEFINITION.JS PORT * + ***********************************/ + +// From createNavigationContainer.js +interface NavigationContainerProps { + uriPrefix?: string | RegExp, + onNavigationStateChange?: ( + prevNav: NavigationState, + nav: NavigationState, + action: NavigationAction, + ) => void, +} + +export interface NavigationContainer extends React.Component< + NavigationContainerProps & NavigationNavigatorProps, + { nav: NavigationState | null } +> { + router: NavigationRouter +} + +export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig { + containerOptions?: any, +} + +// Return createNavigationContainer +export function StackNavigator( + routeConfigMap: NavigationRouteConfigMap, + stackConfig?: StackNavigatorConfig, +): NavigationContainer + +/** + * Drawer Navigator + */ +export interface DrawerViewConfig { + drawerWidth: number, + drawerPosition: 'left' | 'right', + contentComponent: React.ComponentClass, + contentOptions?: any, + style?: ViewStyle, +} +export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, DrawerViewConfig { + containerConfig?: any, + contentOptions?: { + activeTintColor?: string, + activeBackgroundColor?: string, + inactiveTintColor?: string, + inactiveBackgroundColor?: string, + style?: ViewStyle, + labelStyle?: TextStyle, + } +} + +export function DrawerNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawerConfig?: DrawerNavigatorConfig, +): NavigationContainer; + +/** + * Tab Navigator + */ + +// From views/TabView/TabView.js +export interface TabViewConfig { + tabBarComponent?: React.ComponentClass, + tabBarPosition?: 'top' | 'bottom', + tabBarOptions?: { + activeTintColor?: string, + activeBackgroundColor?: string, + inactiveTintColor?: string, + inactiveBackgroundColor?: string, + showLabel?: boolean, + style?: ViewStyle, + labelStyle?: TextStyle, + + // Top + showIcon?: boolean, + upperCaseLabel?: boolean, + pressColor?: string, + pressOpacity?: number, + scrollEnabled?: boolean, + tabStyle?: ViewStyle, + indicatorStyle?: ViewStyle + }, + swipeEnabled?: boolean, + animationEnabled?: boolean, + lazy?: boolean, +} + +// From navigators/TabNavigator.js +export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig { } + +// From navigators/TabNavigator.js +export function TabNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig, +): NavigationContainer; + +export const TabBarTop: React.ReactElement; +export const TabBarBottom: React.ReactElement; From 4312a93b457f0a3a12eb539038d93cfe1ef2cb44 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Wed, 14 Jun 2017 21:17:09 -0700 Subject: [PATCH 008/100] [react-navigation] Fix flow Object -> TS any --- types/react-navigation/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 792a6a5bea..70bb306d1d 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -149,7 +149,7 @@ export type NavigationScreenOptions = { export type NavigationScreenConfigProps = { navigation: NavigationScreenProp, - screenProps: Object, + screenProps: any, }; export type NavigationScreenConfig = @@ -426,7 +426,7 @@ export type TransitionConfig = { transitionSpec?: NavigationTransitionSpec, // How to animate position and opacity of the screen // based on the value generated by the transitionSpec - screenInterpolator?: (props: NavigationSceneRendererProps) => Object, + screenInterpolator?: (props: NavigationSceneRendererProps) => any, }; export type NavigationAnimationSetter = ( From 9be2563bfc81f9127474f0c319c54532a3321517 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Wed, 14 Jun 2017 21:42:24 -0700 Subject: [PATCH 009/100] [react-navigation] Typed generic for NavigationRoute * Also add NavigationParamsGeneric and screenProps additional placeholder types * Add custom/convenience wrapper section, including NavigationScreenProps --- types/react-navigation/index.d.ts | 86 +++++++++++++++++++------------ 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 70bb306d1d..615954c913 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -5,9 +5,15 @@ // abrahambotros // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/************************************* - * BEGIN FLOW TYPEDEFINITION.JS PORT * - *************************************/ +/** + * BEGIN FLOW TYPEDEFINITION.JS PORT + * Reference: https://github.com/react-community/react-navigation/commit/f3a958dca1180af87611a35fb64dbd8dd57da898 + * + * NOTE: Please update the commit/link above when updating to a new Flow + * TypeDefinition.js reference, so we can conveniently just look at diffs on + * TypeDefinition.js between this latest reference point and the one you are + * using when making new updates. + */ import * as React from 'react'; import { @@ -52,12 +58,12 @@ export type NavigationState = { * Index refers to the active child route in the routes array. */ index: number, - routes: Array, + routes: Array, }; -export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; +export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; -export type NavigationLeafRoute = { +export type NavigationLeafRoute = { /** * React's key used by some navigators. No need to specify these manually, * they will be defined by the router. @@ -76,17 +82,17 @@ export type NavigationLeafRoute = { * Params passed to this route when navigating to it, * e.g. `{ car_id: 123 }` in a route that displays a car. */ - params?: NavigationParams, + params?: Params, }; -export type NavigationStateRoute = NavigationLeafRoute & { +export type NavigationStateRoute = NavigationLeafRoute & { index: number, - routes: Array, + routes: Array>, }; export type NavigationScreenOptionsGetter = ( - navigation: NavigationScreenProp, - screenProps?: {} + navigation: NavigationScreenProp, Action>, + screenProps?: { [key: string]: any } ) => Options; export type NavigationRouter = { @@ -103,14 +109,14 @@ export type NavigationRouter = { */ getActionForPathAndParams: ( path: string, - params?: NavigationParams + params?: NavigationParamsGeneric ) => (Action | null), getPathAndParamsForState: ( state: State ) => { path: string, - params?: NavigationParams, + params?: NavigationParamsGeneric, }, getComponentForRouteName: (routeName: string) => NavigationComponent, @@ -131,7 +137,7 @@ export type NavigationRouter = { export type NavigationScreenOption = | T | (( - navigation: NavigationScreenProp, + navigation: NavigationScreenProp, NavigationAction>, config: T ) => T); @@ -139,8 +145,8 @@ export type Style = ViewStyle; export type NavigationScreenDetails = { options: T, - state: NavigationRoute, - navigation: NavigationScreenProp, + state: NavigationRoute, + navigation: NavigationScreenProp, NavigationAction>, }; export type NavigationScreenOptions = { @@ -148,8 +154,8 @@ export type NavigationScreenOptions = { }; export type NavigationScreenConfigProps = { - navigation: NavigationScreenProp, - screenProps: any, + navigation: NavigationScreenProp, NavigationAction>, + screenProps: { [key: string]: any } }; export type NavigationScreenConfig = @@ -157,7 +163,7 @@ export type NavigationScreenConfig = | (NavigationScreenConfigProps & ((navigationOptionsContainer: { navigationOptions: NavigationScreenProp< - NavigationRoute, + NavigationRoute, NavigationAction >, }) => Options)); @@ -175,14 +181,14 @@ export type NavigationNavigator = React.ComponentClas navigationOptions?: NavigationScreenConfig, }; -export type NavigationParams = { +export type NavigationParamsGeneric = { [key: string]: string, }; export type NavigationNavigateAction = { type: 'Navigation/NAVIGATE', routeName: string, - params?: NavigationParams, + params?: any, // The action to run inside the sub-router action?: NavigationNavigateAction, @@ -200,12 +206,12 @@ export type NavigationSetParamsAction = { key: string, // The new params to merge into the existing route params - params?: NavigationParams, + params?: any, }; export type NavigationInitAction = { type: 'Navigation/INIT', - params?: NavigationParams, + params?: any, }; export type NavigationResetAction = { @@ -246,7 +252,7 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & { export type NavigationStackRouterConfig = { initialRouteName?: string, - initialRouteParams?: NavigationParams, + initialRouteParams?: any, paths?: NavigationPathsConfig, navigationOptions?: NavigationScreenConfig, }; @@ -340,15 +346,15 @@ export type NavigationScreenProp = { goBack: (routeKey?: (string | null)) => boolean, navigate: ( routeName: string, - params?: NavigationParams, + params?: NavigationParamsGeneric, action?: NavigationAction ) => boolean, - setParams: (newParams: NavigationParams) => boolean, + setParams: (newParams: NavigationParamsGeneric) => boolean, }; export type NavigationNavigatorProps = { navigation: NavigationProp, - screenProps: any, + screenProps: { [key: string]: any } navigationOptions: any, }; @@ -371,7 +377,7 @@ export type NavigationScene = { isActive: boolean, isStale: boolean, key: string, - route: NavigationRoute, + route: NavigationRoute, }; export type NavigationTransitionProps = { @@ -402,7 +408,7 @@ export type NavigationTransitionProps = { scene: NavigationScene, index: number, - screenProps?: {}, + screenProps?: { [key: string]: any } }; // The scene renderer props are nearly identical to the props used for rendering @@ -452,9 +458,10 @@ export type LayoutEvent = { }, }; -/*********************************** - * END FLOW TYPEDEFINITION.JS PORT * - ***********************************/ +/** + * END FLOW TYPEDEFINITION.JS PORT + */ + // From createNavigationContainer.js interface NavigationContainerProps { @@ -552,3 +559,18 @@ export function TabNavigator( export const TabBarTop: React.ReactElement; export const TabBarBottom: React.ReactElement; + + +/** + * BEGIN CUSTOM CONVENIENCE INTERFACES + */ + +export interface NavigationScreenProps { + navigation: NavigationScreenProp, NavigationAction>, + screenProps: { [key: string]: any }, + navigationOptions: any, +} + +/** + * END CUSTOM CONVENIENCE INTERFACES + */ From e5843ac8f5e492298e8974ee8413cd426d7f6cd4 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Wed, 14 Jun 2017 22:52:14 -0700 Subject: [PATCH 010/100] [react-navigation] Misc fixes and improvements --- types/react-navigation/index.d.ts | 40 ++++++++++--------- .../react-navigation-tests.tsx | 7 ++-- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 615954c913..82de567263 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -61,7 +61,7 @@ export type NavigationState = { routes: Array, }; -export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; +export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; export type NavigationLeafRoute = { /** @@ -85,7 +85,7 @@ export type NavigationLeafRoute = { params?: Params, }; -export type NavigationStateRoute = NavigationLeafRoute & { +export type NavigationStateRoute = NavigationLeafRoute & { index: number, routes: Array>, }; @@ -109,14 +109,14 @@ export type NavigationRouter = { */ getActionForPathAndParams: ( path: string, - params?: NavigationParamsGeneric + params?: NavigationParams ) => (Action | null), getPathAndParamsForState: ( state: State ) => { path: string, - params?: NavigationParamsGeneric, + params?: NavigationParams, }, getComponentForRouteName: (routeName: string) => NavigationComponent, @@ -181,7 +181,7 @@ export type NavigationNavigator = React.ComponentClas navigationOptions?: NavigationScreenConfig, }; -export type NavigationParamsGeneric = { +export type NavigationParams = { [key: string]: string, }; @@ -346,16 +346,16 @@ export type NavigationScreenProp = { goBack: (routeKey?: (string | null)) => boolean, navigate: ( routeName: string, - params?: NavigationParamsGeneric, + params?: any, action?: NavigationAction ) => boolean, - setParams: (newParams: NavigationParamsGeneric) => boolean, + setParams: (newParams: NavigationParams) => boolean, }; export type NavigationNavigatorProps = { - navigation: NavigationProp, - screenProps: { [key: string]: any } - navigationOptions: any, + navigation?: NavigationProp, + screenProps?: { [key: string]: any } + navigationOptions?: any, }; /** @@ -462,6 +462,8 @@ export type LayoutEvent = { * END FLOW TYPEDEFINITION.JS PORT */ +// From addNavigatorHelpers.js +export function addNavigationHelpers(navigation: NavigationProp): NavigationScreenProp; // From createNavigationContainer.js interface NavigationContainerProps { @@ -473,11 +475,13 @@ interface NavigationContainerProps { ) => void, } -export interface NavigationContainer extends React.Component< - NavigationContainerProps & NavigationNavigatorProps, - { nav: NavigationState | null } +export interface NavigationContainer extends React.ComponentClass< + NavigationContainerProps & NavigationNavigatorProps > { router: NavigationRouter + screenProps: { [key: string]: any }, + navigationOptions: any, + state: { nav: NavigationState | null }, } export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig { @@ -488,7 +492,7 @@ export interface StackNavigatorConfig extends NavigationStackViewConfig, Navigat export function StackNavigator( routeConfigMap: NavigationRouteConfigMap, stackConfig?: StackNavigatorConfig, -): NavigationContainer +): NavigationContainer; /** * Drawer Navigator @@ -515,7 +519,7 @@ export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, Drawer export function DrawerNavigator( routeConfigMap: NavigationRouteConfigMap, drawerConfig?: DrawerNavigatorConfig, -): NavigationContainer; +): NavigationContainer; /** * Tab Navigator @@ -555,10 +559,10 @@ export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewCo export function TabNavigator( routeConfigMap: NavigationRouteConfigMap, drawConfig?: TabNavigatorConfig, -): NavigationContainer; +): NavigationContainer; -export const TabBarTop: React.ReactElement; -export const TabBarBottom: React.ReactElement; +export const TabBarTop: React.ComponentClass; +export const TabBarBottom: React.ComponentClass; /** diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 2493d92f84..884d57e4f0 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -2,8 +2,9 @@ import * as React from 'react'; import { View } from 'react-native'; import { addNavigationHelpers, + NavigationStackAction, + NavigationTabScreenOptions, StackNavigator, - TabNavigatorScreenOptions, TabNavigatorConfig, TabBarTop, TabBarBottom, @@ -26,14 +27,14 @@ const Router = (props: any) => ( { return true; }, state: {}, }) } /> ); -const tabNavigatorScreenOptions: TabNavigatorScreenOptions = { +const tabNavigatorScreenOptions: NavigationTabScreenOptions = { title: 'title', tabBarVisible: true, tabBarIcon: , From e34616fd3c94b0b4a1fc8a13c2becd801cdd97ba Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Wed, 14 Jun 2017 22:58:27 -0700 Subject: [PATCH 011/100] [react-navigation] Improve test, add screen component props type checks --- types/react-navigation/index.d.ts | 9 ++++++ .../react-navigation-tests.tsx | 28 ++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 82de567263..ffd543f261 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -462,6 +462,11 @@ export type LayoutEvent = { * END FLOW TYPEDEFINITION.JS PORT */ + +/** + * BEGIN MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS + */ + // From addNavigatorHelpers.js export function addNavigationHelpers(navigation: NavigationProp): NavigationScreenProp; @@ -564,6 +569,10 @@ export function TabNavigator( export const TabBarTop: React.ComponentClass; export const TabBarBottom: React.ComponentClass; +/** + * END MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS + */ + /** * BEGIN CUSTOM CONVENIENCE INTERFACES diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 884d57e4f0..b95092d5e0 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { View } from 'react-native'; import { addNavigationHelpers, + NavigationScreenProps, NavigationStackAction, NavigationTabScreenOptions, StackNavigator, @@ -10,14 +11,33 @@ import { TabBarBottom, } from 'react-navigation'; -const Start = ( - -); +/** + * @class StartScreen @extends React.Component + * @desc Simple screen component class with typed component props that should + * receive the navigation prop from the AppNavigator. + */ +interface StartScreenComponentProps { + id: number, + s: string, +} +interface StartScreenProps extends NavigationScreenProps { } +class StartScreen extends React.Component { + render() { + // Implicit type checks. + const navigationStateParams: StartScreenComponentProps = this.props.navigation.state.params; + const id = this.props.navigation.state.params.id; + const s = this.props.navigation.state.params.s; + + return ( + + ); + } +} export const AppNavigator = StackNavigator({ StartImage: { path: 'startImage', - screen: Start, + screen: StartScreen, }, }, { initialRouteName: 'StartImage', From 4ba39d401688251ef3421d440e4c0bda142e7390 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Thu, 15 Jun 2017 08:40:23 -0700 Subject: [PATCH 012/100] [react-navigation] Fix linter errors --- types/react-navigation/index.d.ts | 34 +++++++++---------- .../react-navigation-tests.tsx | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index ffd543f261..f2c5ff3591 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -135,7 +135,7 @@ export type NavigationRouter = { }; export type NavigationScreenOption = - | T + T | (( navigation: NavigationScreenProp, NavigationAction>, config: T @@ -159,7 +159,7 @@ export type NavigationScreenConfigProps = { }; export type NavigationScreenConfig = - | Options + Options | (NavigationScreenConfigProps & ((navigationOptionsContainer: { navigationOptions: NavigationScreenProp< @@ -169,7 +169,7 @@ export type NavigationScreenConfig = }) => Options)); export type NavigationComponent = - | NavigationScreenComponent + NavigationScreenComponent | NavigationNavigator; export type NavigationScreenComponent = React.ComponentClass & { @@ -226,14 +226,14 @@ export type NavigationUriAction = { uri: string, }; -export type NavigationStackViewConfig = { +export interface NavigationStackViewConfig { mode?: 'card' | 'modal', headerMode?: HeaderMode, cardStyle?: Style, transitionConfig?: () => TransitionConfig, onTransitionStart?: () => void, onTransitionEnd?: () => void, -}; +} export type NavigationStackScreenOptions = NavigationScreenOptions & { header?: (React.ReactElement | ((headerProps: HeaderProps) => React.ReactElement)) | null, @@ -250,27 +250,27 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & { gesturesEnabled?: boolean, }; -export type NavigationStackRouterConfig = { +export interface NavigationStackRouterConfig { initialRouteName?: string, initialRouteParams?: any, paths?: NavigationPathsConfig, navigationOptions?: NavigationScreenConfig, -}; +} export type NavigationStackAction = - | NavigationInitAction + NavigationInitAction | NavigationNavigateAction | NavigationBackAction | NavigationSetParamsAction | NavigationResetAction; export type NavigationTabAction = - | NavigationInitAction + NavigationInitAction | NavigationNavigateAction | NavigationBackAction; export type NavigationAction = - | NavigationInitAction + NavigationInitAction | NavigationStackAction | NavigationTabAction; @@ -280,7 +280,7 @@ export type NavigationRouteConfig = T & { }; export type NavigationScreenRouteConfig = - | { + { screen: NavigationComponent, } | { @@ -291,7 +291,7 @@ export type NavigationPathsConfig = { [routeName: string]: string, }; -export type NavigationTabRouterConfig = { +export interface NavigationTabRouterConfig { initialRouteName?: string, paths?: NavigationPathsConfig, navigationOptions?: NavigationScreenConfig, @@ -299,16 +299,16 @@ export type NavigationTabRouterConfig = { // Does the back button cause the router to switch to the initial tab backBehavior?: 'none' | 'initialRoute', // defaults `initialRoute` -}; +} export type NavigationTabScreenOptions = NavigationScreenOptions & { tabBarIcon?: - | React.ReactElement + React.ReactElement | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< any > | null)), tabBarLabel?: - | string + string | React.ReactElement | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< any @@ -318,12 +318,12 @@ export type NavigationTabScreenOptions = NavigationScreenOptions & { export type NavigationDrawerScreenOptions = NavigationScreenOptions & { drawerIcon?: - | React.ReactElement + React.ReactElement | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< any > | null)), drawerLabel?: - | React.ReactElement + React.ReactElement | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< any > | null)), diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index b95092d5e0..535a7a04af 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -47,7 +47,7 @@ const Router = (props: any) => ( { return true; }, + dispatch: (action: NavigationStackAction): boolean => true, state: {}, }) } From cf39e7e9bd7e233527ba8b86504d30c02815776e Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Thu, 15 Jun 2017 08:48:33 -0700 Subject: [PATCH 013/100] [react-navigation] Add test to navigate to next screen --- .../react-navigation-tests.tsx | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 535a7a04af..3a4e02a16c 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -1,5 +1,8 @@ import * as React from 'react'; -import { View } from 'react-native'; +import { + TouchableOpacity, + View, +} from 'react-native'; import { addNavigationHelpers, NavigationScreenProps, @@ -28,6 +31,40 @@ class StartScreen extends React.Component { const id = this.props.navigation.state.params.id; const s = this.props.navigation.state.params.s; + return ( + + + + ); + } + private navigateToNextScreen = (): void => { + this.props.navigation.navigate( + ROUTE_NAME_NEXT_SCREEN, + { + id: this.props.navigation.state.params.id, + name: this.props.navigation.state.params.s, + } as NextScreenComponentProps, + ); + + } +} + +/** + * @class NextScreen @extends React.Component + */ +const ROUTE_NAME_NEXT_SCREEN = "NextScreen"; +interface NextScreenComponentProps { + id: number, + name: string, +} +interface NextScreenProps extends NavigationScreenProps { } +class NextScreen extends React.Component { + render() { + // Implicit type checks. + const navigationStateParams: NextScreenComponentProps = this.props.navigation.state.params; + const id = this.props.navigation.state.params.id; + const name = this.props.navigation.state.params.name; + return ( ); From 28fc9fb21badc7211009614bc7ae552aa41208e5 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Thu, 15 Jun 2017 08:52:18 -0700 Subject: [PATCH 014/100] [react-navigation] NavigationParams fixes --- types/react-navigation/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index f2c5ff3591..5f53ea7b97 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -181,14 +181,14 @@ export type NavigationNavigator = React.ComponentClas navigationOptions?: NavigationScreenConfig, }; -export type NavigationParams = { - [key: string]: string, -}; +export interface NavigationParams { + [key: string]: any, +} export type NavigationNavigateAction = { type: 'Navigation/NAVIGATE', routeName: string, - params?: any, + params?: NavigationParams, // The action to run inside the sub-router action?: NavigationNavigateAction, @@ -206,12 +206,12 @@ export type NavigationSetParamsAction = { key: string, // The new params to merge into the existing route params - params?: any, + params?: NavigationParams, }; export type NavigationInitAction = { type: 'Navigation/INIT', - params?: any, + params?: NavigationParams, }; export type NavigationResetAction = { @@ -252,7 +252,7 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & { export interface NavigationStackRouterConfig { initialRouteName?: string, - initialRouteParams?: any, + initialRouteParams?: NavigationParams, paths?: NavigationPathsConfig, navigationOptions?: NavigationScreenConfig, } @@ -346,7 +346,7 @@ export type NavigationScreenProp = { goBack: (routeKey?: (string | null)) => boolean, navigate: ( routeName: string, - params?: any, + params?: NavigationParams, action?: NavigationAction ) => boolean, setParams: (newParams: NavigationParams) => boolean, From 9f822c4b0781a6e14ee9ad1f65abc4b87572a089 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Thu, 15 Jun 2017 09:00:56 -0700 Subject: [PATCH 015/100] [react-navigation] Update reference commit link to tree link --- types/react-navigation/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 5f53ea7b97..d2bf9882de 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -7,7 +7,7 @@ /** * BEGIN FLOW TYPEDEFINITION.JS PORT - * Reference: https://github.com/react-community/react-navigation/commit/f3a958dca1180af87611a35fb64dbd8dd57da898 + * Reference: https://github.com/react-community/react-navigation/tree/52a2846e77119148320bcea83b8982a8bc6acce3 * * NOTE: Please update the commit/link above when updating to a new Flow * TypeDefinition.js reference, so we can conveniently just look at diffs on From dbdfb4a24fe0a9b481945e9046e351018d901fd7 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Thu, 15 Jun 2017 09:41:00 -0700 Subject: [PATCH 016/100] [react-navigation] Move NavigationActions namespace, add todo for possibly removal --- types/react-navigation/index.d.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 5f86c8ed58..237813ec0d 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -274,14 +274,6 @@ export type NavigationAction = | NavigationStackAction | NavigationTabAction; -export namespace NavigationActions { - function init(options?: NavigationInitAction): NavigationInitAction; - function navigate(options: NavigationNavigateAction): NavigationNavigateAction; - function reset(options: NavigationResetAction): NavigationResetAction; - function back(options?: NavigationBackAction): NavigationBackAction; - function setParams(options: NavigationSetParamsAction): NavigationSetParamsAction; -} - export type NavigationRouteConfig = T & { navigationOptions?: NavigationScreenConfig, path?: string, @@ -577,6 +569,20 @@ export function TabNavigator( export const TabBarTop: React.ComponentClass; export const TabBarBottom: React.ComponentClass; +/** + * NavigationActions + * @todo Is this necessary, or can we remove? Not referenced anywhere else here, but it seems a + * recent commit or two touches these. Can anyone provide a strong use case for keeping this in? + */ +export namespace NavigationActions { + function init(options?: NavigationInitAction): NavigationInitAction; + function navigate(options: NavigationNavigateAction): NavigationNavigateAction; + function reset(options: NavigationResetAction): NavigationResetAction; + function back(options?: NavigationBackAction): NavigationBackAction; + function setParams(options: NavigationSetParamsAction): NavigationSetParamsAction; +} + + /** * END MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS */ From c5ab866dbccbdb4924946ac4f50ecc76841576c5 Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Sun, 18 Jun 2017 15:21:51 -0700 Subject: [PATCH 017/100] [react-navigation] Minor fixes --- types/react-navigation/index.d.ts | 8 ++++---- .../react-navigation-tests.tsx | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 237813ec0d..89ffec3a09 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -592,10 +592,10 @@ export namespace NavigationActions { * BEGIN CUSTOM CONVENIENCE INTERFACES */ -export interface NavigationScreenProps { - navigation: NavigationScreenProp, NavigationAction>, - screenProps: { [key: string]: any }, - navigationOptions: any, +export interface NavigationScreenProps { + navigation: NavigationScreenProp, NavigationAction>, + screenProps?: { [key: string]: any }, + navigationOptions?: NavigationScreenConfig, } /** diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 3a4e02a16c..5fe48aef1b 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -19,15 +19,15 @@ import { * @desc Simple screen component class with typed component props that should * receive the navigation prop from the AppNavigator. */ -interface StartScreenComponentProps { +interface StartScreenNavigationParams { id: number, s: string, } -interface StartScreenProps extends NavigationScreenProps { } +interface StartScreenProps extends NavigationScreenProps { } class StartScreen extends React.Component { render() { // Implicit type checks. - const navigationStateParams: StartScreenComponentProps = this.props.navigation.state.params; + const navigationStateParams: StartScreenNavigationParams = this.props.navigation.state.params; const id = this.props.navigation.state.params.id; const s = this.props.navigation.state.params.s; @@ -43,7 +43,7 @@ class StartScreen extends React.Component { { id: this.props.navigation.state.params.id, name: this.props.navigation.state.params.s, - } as NextScreenComponentProps, + } as NextScreenNavigationParams, ); } @@ -53,15 +53,15 @@ class StartScreen extends React.Component { * @class NextScreen @extends React.Component */ const ROUTE_NAME_NEXT_SCREEN = "NextScreen"; -interface NextScreenComponentProps { +interface NextScreenNavigationParams { id: number, name: string, } -interface NextScreenProps extends NavigationScreenProps { } +interface NextScreenProps extends NavigationScreenProps { } class NextScreen extends React.Component { render() { // Implicit type checks. - const navigationStateParams: NextScreenComponentProps = this.props.navigation.state.params; + const navigationStateParams: NextScreenNavigationParams = this.props.navigation.state.params; const id = this.props.navigation.state.params.id; const name = this.props.navigation.state.params.name; @@ -71,6 +71,10 @@ class NextScreen extends React.Component { } } +const initialRouteParams: StartScreenNavigationParams = { + id: 1, + s: "Start", +}; export const AppNavigator = StackNavigator({ StartImage: { path: 'startImage', @@ -78,6 +82,7 @@ export const AppNavigator = StackNavigator({ }, }, { initialRouteName: 'StartImage', + initialRouteParams, }); const Router = (props: any) => ( From 9801951d6e1f30174be49d212a8d0e3ef925695e Mon Sep 17 00:00:00 2001 From: rehez Date: Mon, 19 Jun 2017 17:54:15 +0200 Subject: [PATCH 018/100] TextDecoder.decode should accept ArrayBuffer --- types/text-encoding/index.d.ts | 2 +- types/text-encoding/text-encoding-tests.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/text-encoding/index.d.ts b/types/text-encoding/index.d.ts index 08536c5981..50788db138 100644 --- a/types/text-encoding/index.d.ts +++ b/types/text-encoding/index.d.ts @@ -21,7 +21,7 @@ declare namespace TextEncoding { encoding: string; fatal: boolean; ignoreBOM: boolean; - decode(input?: ArrayBufferView, options?: TextDecodeOptions): string; + decode(input?: ArrayBuffer | ArrayBufferView, options?: TextDecodeOptions): string; } interface TextEncoder { diff --git a/types/text-encoding/text-encoding-tests.ts b/types/text-encoding/text-encoding-tests.ts index f92e1f4bca..914f680bd3 100644 --- a/types/text-encoding/text-encoding-tests.ts +++ b/types/text-encoding/text-encoding-tests.ts @@ -27,6 +27,7 @@ function test_encoder() { function test_decoder() { var text = "plain text"; var uint8array: Uint8Array = TextEncoder().encode(text); + var arrayBuffer: ArrayBuffer = uint8array.buffer // constructor text = new TextDecoder().decode(uint8array); @@ -56,5 +57,6 @@ function test_decoder() { // methods decoder.decode(); decoder.decode(uint8array); + decoder.decode(arrayBuffer); decoder.decode(uint8array, { stream: true }); -} \ No newline at end of file +} From 9e58e7e879402ea4972ec666a9c8e5f145ade035 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 14:46:49 -0400 Subject: [PATCH 019/100] [angular] Remove dependency on @types/jquery. --- types/angular/angular-tests.ts | 22 +- types/angular/index.d.ts | 22 +- types/angular/jqlite.d.ts | 799 +++++++++++++++++++++++++++++++++ types/angular/tsconfig.json | 3 +- 4 files changed, 816 insertions(+), 30 deletions(-) create mode 100644 types/angular/jqlite.d.ts diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index d77c18fa37..407d8d9188 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -178,7 +178,7 @@ mod.controller({ mod.directive('myDirectiveA', ($rootScope: ng.IRootScopeService) => { return (scope, el, attrs) => { let foo = 'none'; - el.click(e => { + el.on('click', e => { foo = e.type; $rootScope.$apply(); }); @@ -188,8 +188,9 @@ mod.directive('myDirectiveA', ($rootScope: ng.IRootScopeService) => { mod.directive('myDirectiveB', ['$rootScope', ($rootScope: ng.IRootScopeService) => { return { link(scope, el, attrs) { - el.click(e => { - el.hide(); + el.on('click', e => { + // Doesn't exist on jqLite + // el.hide(); }); } }; @@ -1006,13 +1007,18 @@ angular.module('multiSlotTranscludeExample', []) }, link(scope, element, attrs, ctrl, transclude) { // without scope - transclude().appendTo(element); - transclude(clone => clone.appendTo(element)); + // Doesn't exist on jqLite + // transclude().appendTo(element); + // Doesn't exist on jqLite + // transclude(clone => clone.appendTo(element)); // with scope - transclude(scope, clone => clone.appendTo(element)); - transclude(scope, clone => clone.appendTo(element), element, 'button'); - transclude(scope, null, element, 'list').addClass('drop-down-list').appendTo(element); + // Doesn't exist on jqLite + // transclude(scope, clone => clone.appendTo(element)); + // Doesn't exist on jqLite + // transclude(scope, clone => clone.appendTo(element), element, 'button'); + // Doesn't exist on jqLite + // transclude(scope, null, element, 'list').addClass('drop-down-list').appendTo(element); } }; }); diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index d0e2d978dc..812adbdac8 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -2,9 +2,8 @@ // Project: http://angularjs.org // Definitions by: Diego Vilar , Georgii Dolzhykov , Caleb St-Denis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 -/// +/// declare var angular: angular.IAngularStatic; @@ -2109,22 +2108,3 @@ declare namespace angular { (obj: Object): string; } } - -declare global { - interface JQuery { - // TODO: events, how to define? - // $destroy - - find(element: any): JQuery; - find(obj: JQuery): JQuery; - controller(name?: string): any; - injector(): ng.auto.IInjectorService; - /** It's declared generic for custom scope interfaces */ - scope(): T; - isolateScope(): T; - - inheritedData(key: string, value: any): JQuery; - inheritedData(obj: { [key: string]: any; }): JQuery; - inheritedData(key?: string): any; - } -} diff --git a/types/angular/jqlite.d.ts b/types/angular/jqlite.d.ts new file mode 100644 index 0000000000..4760e520fb --- /dev/null +++ b/types/angular/jqlite.d.ts @@ -0,0 +1,799 @@ +// Definitions by: Boris Yankov +// Christian Hoffmeister +// Steve Fenton +// Diullei Gomes +// Tass Iliopoulos +// Jason Swearingen +// Sean Hill +// Guus Goossens +// Kelly Summerlin +// Basarat Ali Syed +// Nicholas Wolverson +// Derek Cicerone +// Andrew Gaspar +// Seikichi Kondo +// Benjamin Jackman +// Poul Sorensen +// Josh Strobl +// John Reilly +// Dick van den Brink +// Thomas Schulz +// Leonard Thieu + +// Definitions copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0480c5ec87fab41aa23047a02b27f0ea71aaf975/types/jquery/v2/index.d.ts + +interface JQuery { + /** + * Adds the specified class(es) to each of the set of matched elements. + * + * @param className One or more space-separated classes to be added to the class attribute of each matched element. + * @see {@link https://api.jquery.com/addClass/#addClass-className} + */ + addClass(className: string): JQuery; + + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * @param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert after each element in the set of matched elements. + * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + * @see {@link https://api.jquery.com/after/#after-content-content} + */ + after(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/after/#after-function} + */ + after(func: (index: number, html: string) => string | Element | JQuery): JQuery; + + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * @param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + * @see {@link https://api.jquery.com/append/#append-content-content} + */ + append(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/append/#append-function} + */ + append(func: (index: number, html: string) => string | Element | JQuery): JQuery; + + /** + * Get the value of an attribute for the first element in the set of matched elements. + * + * @param attributeName The name of the attribute to get. + * @see {@link https://api.jquery.com/attr/#attr-attributeName} + */ + attr(attributeName: string): string; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param value A value to set for the attribute. If this is `null`, the attribute will be deleted. + * @see {@link https://api.jquery.com/attr/#attr-attributeName-value} + */ + attr(attributeName: string, value: string | number | null): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributes An object of attribute-value pairs to set. + * @see {@link https://api.jquery.com/attr/#attr-attributes} + */ + attr(attributes: Object): JQuery; + + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-handler} + */ + bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-preventBubble} + */ + bind(eventType: string, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param events An object containing one or more DOM event types and functions to execute for them. + * @see {@link https://api.jquery.com/bind/#bind-events} + */ + bind(events: any): JQuery; + + /** + * Get the children of each element in the set of matched elements, optionally filtered by a selector. + * + * @see {@link https://api.jquery.com/children/} + */ + children(): JQuery; + + /** + * Create a deep copy of the set of matched elements. + * + * @param withDataAndEvents A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false. + * @param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). + * @see {@link https://api.jquery.com/clone/} + */ + clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery; + + /** + * Get the children of each element in the set of matched elements, including text and comment nodes. + * @see {@link https://api.jquery.com/contents/} + */ + contents(): JQuery; + + /** + * Get the value of style properties for the first element in the set of matched elements. + * + * @param propertyName A CSS property. + * @see {@link https://api.jquery.com/css/#css-propertyName} + */ + css(propertyName: string): string; + /** + * Get the value of style properties for the first element in the set of matched elements. + * Results in an object of property-value pairs. + * + * @param propertyNames An array of one or more CSS properties. + * @see {@link https://api.jquery.com/css/#css-propertyNames} + */ + css(propertyNames: string[]): any; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + * @see {@link https://api.jquery.com/css/#css-propertyName-value} + */ + css(propertyName: string, value: string | number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + * @see {@link https://api.jquery.com/css/#css-propertyName-function} + */ + css(propertyName: string, value: (index: number, value: string) => string | number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param properties An object of property-value pairs to set. + * @see {@link https://api.jquery.com/css/#css-properties} + */ + css(properties: JQueryCssProperties): JQuery; + + /** + * Store arbitrary data associated with the matched elements. + * + * @param key A string naming the piece of data to set. + * @param value The new data value; it can be any JavaScript type including Array or Object. + * @see {@link https://api.jquery.com/data/#data-key-value} + */ + data(key: string, value: any): JQuery; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + * + * @param key Name of the data stored. + * @see {@link https://api.jquery.com/data/#data-key} + */ + data(key: string): any; + /** + * Store arbitrary data associated with the matched elements. + * + * @param obj An object of key-value pairs of data to update. + * @see {@link https://api.jquery.com/data/#data-obj} + */ + data(obj: { [key: string]: any; }): JQuery; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + * @see {@link https://api.jquery.com/data/#data} + */ + data(): any; + + /** + * Remove the set of matched elements from the DOM. + * + * @param selector A selector expression that filters the set of matched elements to be removed. + * @see {@link https://api.jquery.com/detach/} + */ + detach(selector?: string): JQuery; + + /** + * Remove all child nodes of the set of matched elements from the DOM. + * @see {@link https://api.jquery.com/empty/} + */ + empty(): JQuery; + + /** + * Reduce the set of matched elements to the one at the specified index. + * + * @param index An integer indicating the 0-based position of the element. OR An integer indicating the position of the element, counting backwards from the last element in the set. + * @see {@link https://api.jquery.com/eq/} + */ + eq(index: number): JQuery; + + /** + * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + * + * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/find/#find-selector} + */ + find(selector: string): JQuery; + + /** + * Determine whether any of the matched elements are assigned the given class. + * + * @param className The class name to search for. + * @see {@link https://api.jquery.com/hasClass/} + */ + hasClass(className: string): boolean; + + /** + * Get the HTML contents of the first element in the set of matched elements. + * @see {@link https://api.jquery.com/html/#html} + */ + html(): string; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param htmlString A string of HTML to set as the content of each matched element. + * @see {@link https://api.jquery.com/html/#html-htmlString} + */ + html(htmlString: string): JQuery; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/html/#html-function} + */ + html(func: (index: number, oldhtml: string) => string): JQuery; + + /** + * Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. + * + * @see {@link https://api.jquery.com/next/} + */ + next(): JQuery; + + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} + */ + on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} + */ + on(events: string, data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} + */ + on(events: string, selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} + */ + on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/on/#on-events-selector-data} + */ + on(events: { [key: string]: (eventObject: JQueryEventObject, ...args: any[]) => any; }, selector?: string, data?: any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/on/#on-events-selector-data} + */ + on(events: { [key: string]: (eventObject: JQueryEventObject, ...args: any[]) => any; }, data?: any): JQuery; + + /** + * Remove an event handler. + * @see {@link https://api.jquery.com/off/#off} + */ + off(): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + * @param handler A handler function previously attached for the event(s), or the special value false. + * @see {@link https://api.jquery.com/off/#off-events-selector-handler} + */ + off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param handler A handler function previously attached for the event(s), or the special value false. Takes handler with extra args that can be attached with on(). + * @see {@link https://api.jquery.com/off/#off-events-selector-handler} + */ + off(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param handler A handler function previously attached for the event(s), or the special value false. + * @see {@link https://api.jquery.com/off/#off-events-selector-handler} + */ + off(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events An object where the string keys represent one or more space-separated event types and optional namespaces, and the values represent handler functions previously attached for the event(s). + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + * @see {@link https://api.jquery.com/off/#off-events-selector} + */ + off(events: { [key: string]: any; }, selector?: string): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute at the time the event is triggered. + * @see {@link https://api.jquery.com/one/#one-events-data-handler} + */ + one(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param data An object containing data that will be passed to the event handler. + * @param handler A function to execute at the time the event is triggered. + * @see {@link https://api.jquery.com/one/#one-events-data-handler} + */ + one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler} + */ + one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler} + */ + one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/one/#one-events-selector-data} + */ + one(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/one/#one-events-selector-data} + */ + one(events: { [key: string]: any; }, data?: any): JQuery; + + /** + * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. + * + * @see {@link https://api.jquery.com/parent/} + */ + parent(): JQuery; + + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * @param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + * @see {@link https://api.jquery.com/prepend/#prepend-content-content} + */ + prepend(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/prepend/#prepend-function} + */ + prepend(func: (index: number, html: string) => string | Element | JQuery): JQuery; + + /** + * Get the value of a property for the first element in the set of matched elements. + * + * @param propertyName The name of the property to get. + * @see {@link https://api.jquery.com/prop/#prop-propertyName} + */ + prop(propertyName: string): any; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param value A value to set for the property. + * @see {@link https://api.jquery.com/prop/#prop-propertyName-value} + */ + prop(propertyName: string, value: string | number | boolean): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param properties An object of property-value pairs to set. + * @see {@link https://api.jquery.com/prop/#prop-properties} + */ + prop(properties: Object): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element. + * @see {@link https://api.jquery.com/prop/#prop-propertyName-function} + */ + prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): JQuery; + + /** + * Specify a function to execute when the DOM is fully loaded. + * + * @param handler A function to execute after the DOM is ready. + * @see {@link https://api.jquery.com/ready/} + */ + ready(handler: (jQueryAlias?: JQueryStatic) => any): JQuery; + + /** + * Remove the set of matched elements from the DOM. + * + * @param selector A selector expression that filters the set of matched elements to be removed. + * @see {@link https://api.jquery.com/remove/} + */ + remove(selector?: string): JQuery; + + /** + * Remove an attribute from each element in the set of matched elements. + * + * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes. + * @see {@link https://api.jquery.com/removeAttr/} + */ + removeAttr(attributeName: string): JQuery; + + /** + * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + * + * @param className One or more space-separated classes to be removed from the class attribute of each matched element. + * @see {@link https://api.jquery.com/removeClass/#removeClass-className} + */ + removeClass(className?: string): JQuery; + + /** + * Remove a previously-stored piece of data. + * + * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete. + * @see {@link https://api.jquery.com/removeData/#removeData-name} + */ + removeData(name: string): JQuery; + /** + * Remove a previously-stored piece of data. + * + * @param list An array of strings naming the pieces of data to delete. + * @see {@link https://api.jquery.com/removeData/#removeData-list} + */ + removeData(list: string[]): JQuery; + /** + * Remove all previously-stored piece of data. + * @see {@link https://api.jquery.com/removeData/} + */ + removeData(): JQuery; + + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * @param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + * @see {@link https://api.jquery.com/replaceWith/#replaceWith-newContent} + */ + replaceWith(newContent: JQuery | any[] | Element | Text | string): JQuery; + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * @param func A function that returns content with which to replace the set of matched elements. + * @see {@link https://api.jquery.com/replaceWith/#replaceWith-function} + */ + replaceWith(func: () => Element | JQuery): JQuery; + + /** + * Get the combined text contents of each element in the set of matched elements, including their descendants. + * @see {@link https://api.jquery.com/text/#text} + */ + text(): string; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param text The text to set as the content of each matched element. When Number or Boolean is supplied, it will be converted to a String representation. + * @see {@link https://api.jquery.com/text/#text-text} + */ + text(text: string | number | boolean): JQuery; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param func A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments. + * @see {@link https://api.jquery.com/text/#text-function} + */ + text(func: (index: number, text: string) => string): JQuery; + + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set. + * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. + * @see {@link https://api.jquery.com/toggleClass/#toggleClass-className} + */ + toggleClass(className: string, swtch?: boolean): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param swtch A boolean value to determine whether the class should be added or removed. + * @see {@link https://api.jquery.com/toggleClass/#toggleClass-state} + */ + toggleClass(swtch?: boolean): JQuery; + + /** + * Execute all handlers attached to an element for an event. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters An array of additional parameters to pass along to the event handler. + * @see {@link https://api.jquery.com/triggerHandler/#triggerHandler-eventType-extraParameters} + */ + triggerHandler(eventType: string, ...extraParameters: any[]): Object; + /** + * Execute all handlers attached to an element for an event. + * + * @param event A jQuery.Event object. + * @param extraParameters An array of additional parameters to pass along to the event handler. + * @see {@link https://api.jquery.com/triggerHandler/#triggerHandler-event-extraParameters} + */ + triggerHandler(event: JQueryEventObject, ...extraParameters: any[]): Object; + + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param handler The function that is to be no longer executed. + * @see {@link https://api.jquery.com/unbind/#unbind-eventType-handler} + */ + unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). + * @see {@link https://api.jquery.com/unbind/#unbind-eventType-false} + */ + unbind(eventType: string, fls: boolean): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param evt A JavaScript event object as passed to an event handler. + * @see {@link https://api.jquery.com/unbind/#unbind-event} + */ + unbind(evt: any): JQuery; + + /** + * Get the current value of the first element in the set of matched elements. + * @see {@link https://api.jquery.com/val/#val} + */ + val(): any; + /** + * Set the value of each element in the set of matched elements. + * + * @param value A string of text, an array of strings or number corresponding to the value of each matched element to set as selected/checked. + * @see {@link https://api.jquery.com/val/#val-value} + */ + val(value: string | string[] | number): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + * @see {@link https://api.jquery.com/val/#val-function} + */ + val(func: (index: number, value: string) => string): JQuery; + + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + * @see {@link https://api.jquery.com/wrap/#wrap-wrappingElement} + */ + wrap(wrappingElement: JQuery | Element | string): JQuery; + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/wrap/#wrap-function} + */ + wrap(func: (index: number) => string | JQuery): JQuery; + + // TODO: events, how to define? + // $destroy + + find(element: any): JQuery; + find(obj: JQuery): JQuery; + controller(name?: string): any; + injector(): ng.auto.IInjectorService; + /** It's declared generic for custom scope interfaces */ + scope(): T; + isolateScope(): T; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; +} + +interface JQueryStatic { + (element: string | Element): JQuery; +} + +/** + * Interface of the JQuery extension of the W3C event object + * @see {@link https://api.jquery.com/category/events/event-object/} + */ +interface BaseJQueryEventObject extends Event { + /** + * The current DOM element within the event bubbling phase. + * @see {@link https://api.jquery.com/event.currentTarget/} + */ + currentTarget: Element; + /** + * An optional object of data passed to an event method when the current executing handler is bound. + * @see {@link https://api.jquery.com/event.data/} + */ + data: any; + /** + * The element where the currently-called jQuery event handler was attached. + * @see {@link https://api.jquery.com/event.delegateTarget/} + */ + delegateTarget: Element; + /** + * Returns whether event.preventDefault() was ever called on this event object. + * @see {@link https://api.jquery.com/event.isDefaultPrevented/} + */ + isDefaultPrevented(): boolean; + /** + * Returns whether event.stopImmediatePropagation() was ever called on this event object. + * @see {@link https://api.jquery.com/event.isImmediatePropagationStopped/} + */ + isImmediatePropagationStopped(): boolean; + /** + * Returns whether event.stopPropagation() was ever called on this event object. + * @see {@link https://api.jquery.com/event.isPropagationStopped/} + */ + isPropagationStopped(): boolean; + /** + * The namespace specified when the event was triggered. + * @see {@link https://api.jquery.com/event.namespace/} + */ + namespace: string; + /** + * The browser's original Event object. + * @see {@link https://api.jquery.com/category/events/event-object/} + */ + originalEvent: Event; + /** + * If this method is called, the default action of the event will not be triggered. + * @see {@link https://api.jquery.com/event.preventDefault/} + */ + preventDefault(): any; + /** + * The other DOM element involved in the event, if any. + * @see {@link https://api.jquery.com/event.relatedTarget/} + */ + relatedTarget: Element; + /** + * The last value returned by an event handler that was triggered by this event, unless the value was undefined. + * @see {@link https://api.jquery.com/event.result/} + */ + result: any; + /** + * Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree. + * @see {@link https://api.jquery.com/event.stopImmediatePropagation/} + */ + stopImmediatePropagation(): void; + /** + * Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. + * @see {@link https://api.jquery.com/event.stopPropagation/} + */ + stopPropagation(): void; + /** + * The DOM element that initiated the event. + * @see {@link https://api.jquery.com/event.target/} + */ + target: Element; + /** + * The mouse position relative to the left edge of the document. + * @see {@link https://api.jquery.com/event.pageX/} + */ + pageX: number; + /** + * The mouse position relative to the top edge of the document. + * @see {@link https://api.jquery.com/event.pageY/} + */ + pageY: number; + /** + * For key or mouse events, this property indicates the specific key or button that was pressed. + * @see {@link https://api.jquery.com/event.which/} + */ + which: number; + /** + * Indicates whether the META key was pressed when the event fired. + * @see {@link https://api.jquery.com/event.metaKey/} + */ + metaKey: boolean; +} + +interface JQueryInputEventObject extends BaseJQueryEventObject { + altKey: boolean; + ctrlKey: boolean; + metaKey: boolean; + shiftKey: boolean; +} + +interface JQueryMouseEventObject extends JQueryInputEventObject { + button: number; + clientX: number; + clientY: number; + offsetX: number; + offsetY: number; + pageX: number; + pageY: number; + screenX: number; + screenY: number; +} + +interface JQueryKeyEventObject extends JQueryInputEventObject { + char: any; + charCode: number; + key: any; + keyCode: number; +} + +interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject { +} + +/** + * The interface used to specify the properties parameter in css() + */ +type cssPropertySetter = (index: number, value?: string) => string | number; +interface JQueryCssProperties { + [propertyName: string]: string | number | cssPropertySetter; +} diff --git a/types/angular/tsconfig.json b/types/angular/tsconfig.json index 860cc82f22..3677d33785 100644 --- a/types/angular/tsconfig.json +++ b/types/angular/tsconfig.json @@ -1,6 +1,7 @@ { "files": [ "index.d.ts", + "jqlite.d.ts", "angular-tests.ts" ], "compilerOptions": { @@ -20,4 +21,4 @@ "noEmit": true, "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +} From a7889772425a50eb39cba376f136d43121204e24 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:05:50 -0400 Subject: [PATCH 020/100] [angular] Add undocumented length property. --- types/angular/jqlite.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/angular/jqlite.d.ts b/types/angular/jqlite.d.ts index 4760e520fb..6a486b5452 100644 --- a/types/angular/jqlite.d.ts +++ b/types/angular/jqlite.d.ts @@ -644,6 +644,9 @@ interface JQuery { */ wrap(func: (index: number) => string | JQuery): JQuery; + // Undocumented + length: number; + // TODO: events, how to define? // $destroy From ba0b4d124f251d6e3d84a73efc501a19ad79a54d Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:07:27 -0400 Subject: [PATCH 021/100] [jquery] Change the JQueryEventObject legacy type to extend from other legacy types. --- types/jquery/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 598d71bc60..4b6252cd9f 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -4450,7 +4450,6 @@ declare namespace JQuery { interface JQueryCallback extends JQuery.Callbacks { } interface JQueryDeferred extends JQuery.Deferred { } -interface JQueryEventObject extends JQuery.Event { } interface JQueryEventConstructor extends JQuery.Event { } interface JQueryDeferred extends JQuery.Deferred { } interface JQueryAjaxSettings extends JQuery.AjaxSettings { } @@ -4613,6 +4612,10 @@ interface JQueryKeyEventObject extends JQueryInputEventObject { key: any; keyCode: number; } +/** + * @deprecated + */ +interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject { } /** * @deprecated */ From 7e66d2c46d097135ef7ada1ce72b7094b829948e Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:10:01 -0400 Subject: [PATCH 022/100] [angular] Lint - adjacent signatures. --- types/angular/jqlite.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/angular/jqlite.d.ts b/types/angular/jqlite.d.ts index 6a486b5452..36509143fa 100644 --- a/types/angular/jqlite.d.ts +++ b/types/angular/jqlite.d.ts @@ -228,6 +228,8 @@ interface JQuery { * @see {@link https://api.jquery.com/find/#find-selector} */ find(selector: string): JQuery; + find(element: any): JQuery; + find(obj: JQuery): JQuery; /** * Determine whether any of the matched elements are assigned the given class. @@ -650,8 +652,6 @@ interface JQuery { // TODO: events, how to define? // $destroy - find(element: any): JQuery; - find(obj: JQuery): JQuery; controller(name?: string): any; injector(): ng.auto.IInjectorService; /** It's declared generic for custom scope interfaces */ From 9ada3affb6dc5d0a2b48b280388ea8208d3f287f Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:10:28 -0400 Subject: [PATCH 023/100] [angular-animate] Remove dependency on @types/jquery. --- types/angular-animate/index.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/types/angular-animate/index.d.ts b/types/angular-animate/index.d.ts index 7e3202bc0e..b9ba7e425b 100644 --- a/types/angular-animate/index.d.ts +++ b/types/angular-animate/index.d.ts @@ -2,9 +2,6 @@ // Project: http://angularjs.org // Definitions by: Michel Salib , Adi Dahiya , Raphael Schweizer , Cody Schaaf // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -/// declare var _: string; export = _; From 30922ed80a80e418fb9fff03ce211b69e35b8c72 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:39:48 -0400 Subject: [PATCH 024/100] [angular] Change lib 'es6' to 'es5'. --- types/angular/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/angular/tsconfig.json b/types/angular/tsconfig.json index 3677d33785..7acded105d 100644 --- a/types/angular/tsconfig.json +++ b/types/angular/tsconfig.json @@ -7,7 +7,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", + "es5", "dom" ], "noImplicitAny": false, From 97c4c93ad62b405ed71b92c072a1914fecfe670b Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:40:45 -0400 Subject: [PATCH 025/100] [angular] Add tests for @types/jquery@3 merging. --- .../angular/test/jquery-v3-merging/index.d.ts | 1 + .../jquery-v3-merging-tests.ts | 17 ++++++++++++++ .../test/jquery-v3-merging/tsconfig.json | 23 +++++++++++++++++++ .../test/jquery-v3-merging/tslint.json | 3 +++ 4 files changed, 44 insertions(+) create mode 100644 types/angular/test/jquery-v3-merging/index.d.ts create mode 100644 types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts create mode 100644 types/angular/test/jquery-v3-merging/tsconfig.json create mode 100644 types/angular/test/jquery-v3-merging/tslint.json diff --git a/types/angular/test/jquery-v3-merging/index.d.ts b/types/angular/test/jquery-v3-merging/index.d.ts new file mode 100644 index 0000000000..6b4fc26283 --- /dev/null +++ b/types/angular/test/jquery-v3-merging/index.d.ts @@ -0,0 +1 @@ +// tslint:disable no-useless-files diff --git a/types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts b/types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts new file mode 100644 index 0000000000..2e2b365f8b --- /dev/null +++ b/types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts @@ -0,0 +1,17 @@ +/// + +import * as angular from 'angular'; + +angular.element('div'); +angular.element.noop(); +angular.element('div').appendTo('p'); + +function event() { + const $div = angular.element('div'); + + const Event_v2 = angular.element.Event('click'); + $div.triggerHandler(Event_v2); + + const Event_v3 = jQuery.Event('click'); + $div.triggerHandler(Event_v3); +} diff --git a/types/angular/test/jquery-v3-merging/tsconfig.json b/types/angular/test/jquery-v3-merging/tsconfig.json new file mode 100644 index 0000000000..27816504e7 --- /dev/null +++ b/types/angular/test/jquery-v3-merging/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es5", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../../", + "typeRoots": [ + "../../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery-v3-merging-tests.ts" + ] +} diff --git a/types/angular/test/jquery-v3-merging/tslint.json b/types/angular/test/jquery-v3-merging/tslint.json new file mode 100644 index 0000000000..4c3a548997 --- /dev/null +++ b/types/angular/test/jquery-v3-merging/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dtslint.json" +} From 1f571c4323d07288e6c0ae3217a9e98e5180b3fb Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:44:40 -0400 Subject: [PATCH 026/100] [jquery-mousewheel] Add specialized signature for 'mousewheel'. --- types/jquery-mousewheel/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jquery-mousewheel/index.d.ts b/types/jquery-mousewheel/index.d.ts index fdeaa39585..d89bbb9942 100644 --- a/types/jquery-mousewheel/index.d.ts +++ b/types/jquery-mousewheel/index.d.ts @@ -17,6 +17,7 @@ declare namespace JQueryMousewheel { } interface JQuery { + on(event: 'mousewheel', handler: (eventObject: JQueryMousewheel.JQueryMousewheelEventObject, ...args: any[]) => any): JQuery; mousewheel(handler: (eventObject: JQueryMousewheel.JQueryMousewheelEventObject, ...args: any[]) => any): JQuery unmousewheel(): JQuery; } From 08cac77ad353bf27e7d507298c57f296ea423d1d Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:48:27 -0400 Subject: [PATCH 027/100] [jquery.pjax] Lock jQuery dependency to v2. --- types/jquery.pjax/index.d.ts | 5 +---- types/jquery.pjax/jquery.pjax-tests.ts | 4 +++- types/jquery.pjax/tsconfig.json | 7 ++++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/types/jquery.pjax/index.d.ts b/types/jquery.pjax/index.d.ts index ebb713236e..a8437533c5 100644 --- a/types/jquery.pjax/index.d.ts +++ b/types/jquery.pjax/index.d.ts @@ -2,9 +2,6 @@ // Project: https://github.com/defunkt/jquery-pjax // Definitions by: Junle Li // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -/// /** * Interface for pjax:popstate event. @@ -33,7 +30,7 @@ interface PjaxSettings extends JQueryAjaxSettings { * Whether to replaceState the URL. Defaults to false. */ replace?: boolean; - + /** * How many requests to cache. Defaults to 20. */ diff --git a/types/jquery.pjax/jquery.pjax-tests.ts b/types/jquery.pjax/jquery.pjax-tests.ts index 91cc9391a2..205a1d3cf9 100644 --- a/types/jquery.pjax/jquery.pjax-tests.ts +++ b/types/jquery.pjax/jquery.pjax-tests.ts @@ -1,3 +1,5 @@ +import * as jQuery from 'jquery'; + function test_fn_pjax() { $(document).pjax("a"); $(document).pjax("a", "#pjax-container"); @@ -66,4 +68,4 @@ function test_events() { console.log('pjax:popstate is OK'); } }); -} \ No newline at end of file +} diff --git a/types/jquery.pjax/tsconfig.json b/types/jquery.pjax/tsconfig.json index e48007101b..0cd3f55757 100644 --- a/types/jquery.pjax/tsconfig.json +++ b/types/jquery.pjax/tsconfig.json @@ -12,6 +12,11 @@ "typeRoots": [ "../" ], + "paths": { + "jquery": [ + "jquery/v2" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true @@ -20,4 +25,4 @@ "index.d.ts", "jquery.pjax-tests.ts" ] -} \ No newline at end of file +} From 44e7d1ceef508e697000783b002ab15344175ace Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:49:43 -0400 Subject: [PATCH 028/100] [royalslider] Lock jQuery dependency to v2. --- types/royalslider/index.d.ts | 3 --- types/royalslider/royalslider-tests.ts | 4 ++-- types/royalslider/tsconfig.json | 7 ++++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/types/royalslider/index.d.ts b/types/royalslider/index.d.ts index 844e0d98ac..8ca97a5c33 100644 --- a/types/royalslider/index.d.ts +++ b/types/royalslider/index.d.ts @@ -2,9 +2,6 @@ // Project: http://dimsemenov.com/plugins/royal-slider/documentation/ // Definitions by: Christiaan Rakowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -/// declare namespace RoyalSlider { export interface RoyalSliderThumbsOptions { diff --git a/types/royalslider/royalslider-tests.ts b/types/royalslider/royalslider-tests.ts index c4581230ff..da628dff83 100644 --- a/types/royalslider/royalslider-tests.ts +++ b/types/royalslider/royalslider-tests.ts @@ -1,4 +1,4 @@ - +import * as jQuery from 'jquery'; $(".royalSlider").royalSlider(); @@ -228,4 +228,4 @@ slider.ev.on('rsBeforeParseNode', function (e: JQueryEventObject, content?: any, // before slide node is parsed // content - HTML object of slide that is parsed // obj - RoyalSlider data object (stores image URLs) -}); \ No newline at end of file +}); diff --git a/types/royalslider/tsconfig.json b/types/royalslider/tsconfig.json index b51a2aee85..7df312ec09 100644 --- a/types/royalslider/tsconfig.json +++ b/types/royalslider/tsconfig.json @@ -12,6 +12,11 @@ "typeRoots": [ "../" ], + "paths": { + "jquery": [ + "jquery/v2" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true @@ -20,4 +25,4 @@ "index.d.ts", "royalslider-tests.ts" ] -} \ No newline at end of file +} From ad96e2c5b9bc08873a6dd6c0635b9fed3e53c2f1 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 15:52:03 -0400 Subject: [PATCH 029/100] [sharepoint] Update event type annotation. --- types/sharepoint/sharepoint-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/sharepoint/sharepoint-tests.ts b/types/sharepoint/sharepoint-tests.ts index 56d01b0d0d..8d62972490 100644 --- a/types/sharepoint/sharepoint-tests.ts +++ b/types/sharepoint/sharepoint-tests.ts @@ -2032,7 +2032,7 @@ namespace _ { // do is retrieve a reference to the term set with the same ID as the div, and // then add the term that belong to that term set under the div that was clicked. - function showTerms(event: JQueryEventObject, groupID: SP.Guid, termSetID: SP.Guid) { + function showTerms(event: JQuery.Event, groupID: SP.Guid, termSetID: SP.Guid) { // First, cancel the bubble so that the group div click handler does not also fire // because that removes all term set divs and we don't want that here. event.originalEvent.cancelBubble = true; From bc7d95b4093eb3817c1f7f93612ce43804e4ad3e Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 20:42:19 -0400 Subject: [PATCH 030/100] [jquery.pjax] Update to use @types/jquery v3 types. --- types/jquery.pjax/index.d.ts | 16 ++++++++++------ types/jquery.pjax/jquery.pjax-tests.ts | 4 +--- types/jquery.pjax/tsconfig.json | 5 ----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/types/jquery.pjax/index.d.ts b/types/jquery.pjax/index.d.ts index a8437533c5..1313217a9c 100644 --- a/types/jquery.pjax/index.d.ts +++ b/types/jquery.pjax/index.d.ts @@ -3,17 +3,19 @@ // Definitions by: Junle Li // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + /** * Interface for pjax:popstate event. */ -interface PjaxPopStateEventObject extends JQueryEventObject { +interface PjaxPopStateEventObject extends JQuery.Event { /** * Navigation direction. Could be "back" or "forward". */ direction: string } -interface PjaxSettings extends JQueryAjaxSettings { +interface PjaxSettings extends JQuery.AjaxSettings { /** * A jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). * If it is not defined, the `data-pjax` attribute of the link will be treated as container. @@ -87,6 +89,8 @@ interface JQuery { * @return Returns the jQuery object */ pjax(delegationSelector: string, containerSelector?: string, options?: PjaxSettings): JQuery; + + on(event: 'pjax:popstate', handler: (e: PjaxPopStateEventObject) => void): this; } interface JQueryStatic { @@ -117,7 +121,7 @@ interface PjaxStatic { * - push: a boolean indicates whether to pushState the URL. Default is true. * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ - click(event: JQueryEventObject, options?: PjaxSettings): void; + click(event: JQuery.Event, options?: PjaxSettings): void; /** * PJAX on click handler. @@ -128,7 +132,7 @@ interface PjaxStatic { * - push: a boolean indicates whether to pushState the URL. Default is true. * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ - click(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; + click(event: JQuery.Event, containerSelector?: string, options?: PjaxSettings): void; /** * PJAX on form submit handler @@ -138,7 +142,7 @@ interface PjaxStatic { * - push: a boolean indicates whether to pushState the URL. Default is true. * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ - submit(event: JQueryEventObject, options?: PjaxSettings): void; + submit(event: JQuery.Event, options?: PjaxSettings): void; /** * PJAX on form submit handler @@ -149,7 +153,7 @@ interface PjaxStatic { * - push: a boolean indicates whether to pushState the URL. Default is true. * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ - submit(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; + submit(event: JQuery.Event, containerSelector?: string, options?: PjaxSettings): void; /** * Install pjax functions on $.pjax to enable pushState behavior. Does nothing if already enabled. diff --git a/types/jquery.pjax/jquery.pjax-tests.ts b/types/jquery.pjax/jquery.pjax-tests.ts index 205a1d3cf9..04c9ee5ab3 100644 --- a/types/jquery.pjax/jquery.pjax-tests.ts +++ b/types/jquery.pjax/jquery.pjax-tests.ts @@ -1,5 +1,3 @@ -import * as jQuery from 'jquery'; - function test_fn_pjax() { $(document).pjax("a"); $(document).pjax("a", "#pjax-container"); @@ -63,7 +61,7 @@ function test_support() { } function test_events() { - $(document).on('pjax:popstate', function(e: PjaxPopStateEventObject) { + $(document).on('pjax:popstate', function(e) { if (e.direction === 'back') { console.log('pjax:popstate is OK'); } diff --git a/types/jquery.pjax/tsconfig.json b/types/jquery.pjax/tsconfig.json index 0cd3f55757..5364759f80 100644 --- a/types/jquery.pjax/tsconfig.json +++ b/types/jquery.pjax/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From 3deb1215ca99c7915a03f830559ce3f3805779cc Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 20:45:48 -0400 Subject: [PATCH 031/100] [royalslider] Update to use @types/jquery v3 types. --- types/royalslider/index.d.ts | 4 +++- types/royalslider/royalslider-tests.ts | 10 ++++------ types/royalslider/tsconfig.json | 5 ----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/types/royalslider/index.d.ts b/types/royalslider/index.d.ts index 8ca97a5c33..9595f2d494 100644 --- a/types/royalslider/index.d.ts +++ b/types/royalslider/index.d.ts @@ -1,8 +1,10 @@ -// Type definitions for jQuery royal-slider v9.4.0 +// Type definitions for jQuery royal-slider 9.4 // Project: http://dimsemenov.com/plugins/royal-slider/documentation/ // Definitions by: Christiaan Rakowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + declare namespace RoyalSlider { export interface RoyalSliderThumbsOptions { /** diff --git a/types/royalslider/royalslider-tests.ts b/types/royalslider/royalslider-tests.ts index da628dff83..07c59be432 100644 --- a/types/royalslider/royalslider-tests.ts +++ b/types/royalslider/royalslider-tests.ts @@ -1,5 +1,3 @@ -import * as jQuery from 'jquery'; - $(".royalSlider").royalSlider(); $(".royalSlider").royalSlider({ @@ -171,7 +169,7 @@ slider.ev.on('rsAfterSlideChange', function (event) { slider.ev.on('rsBeforeAnimStart', function (event) { // before animation between slides start }); -slider.ev.on('rsBeforeMove', function (event: JQueryEventObject, type?: string, userAction?: boolean) { +slider.ev.on('rsBeforeMove', function (event, type?: string, userAction?: boolean) { // before any transition start (including after drag release) // "type" - can be "next", "prev", or ID of slide to move // userAction (Boolean) - defines if action is trighered by user (e.g. will be false if movement is trighered by autoPlay) @@ -188,7 +186,7 @@ slider.ev.on('rsDragRelease', function () { slider.ev.on('rsBeforeDestroy', function () { // triggers before slider in destroyed }); -slider.ev.on('rsOnCreateVideoElement', function (e: JQueryEventObject, url?: string) { +slider.ev.on('rsOnCreateVideoElement', function (e, url?: string) { // triggers before video element is created, after click on play button. // Read more in Tips&Tricks section }); @@ -214,7 +212,7 @@ slider.slides[2].holder.on('rsAfterContentSet', function () { // fires when third slide content is loaded and added to DOM }); // or globally -slider.ev.on('rsAfterContentSet', function (e: JQueryEventObject, slideObject?: RoyalSlider.RoyalSlider) { +slider.ev.on('rsAfterContentSet', function (e, slideObject?: RoyalSlider.RoyalSlider) { // fires when every time when slide content is loaded and added to DOM }); @@ -224,7 +222,7 @@ slider.ev.on('rsAfterContentSet', function (e: JQueryEventObject, slideObject?: slider.ev.on('rsAfterInit', function () { // after slider is initialized, }); -slider.ev.on('rsBeforeParseNode', function (e: JQueryEventObject, content?: any, obj?: any) { +slider.ev.on('rsBeforeParseNode', function (e, content?: any, obj?: any) { // before slide node is parsed // content - HTML object of slide that is parsed // obj - RoyalSlider data object (stores image URLs) diff --git a/types/royalslider/tsconfig.json b/types/royalslider/tsconfig.json index 7df312ec09..f30477b966 100644 --- a/types/royalslider/tsconfig.json +++ b/types/royalslider/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From 8764d0f1ec58519dd5a47d2d7424e7e43e91a221 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 20:56:36 -0400 Subject: [PATCH 032/100] [angular] Fix tests. --- types/angular/angular-tests.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index 407d8d9188..870ade8a19 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -1007,18 +1007,13 @@ angular.module('multiSlotTranscludeExample', []) }, link(scope, element, attrs, ctrl, transclude) { // without scope - // Doesn't exist on jqLite - // transclude().appendTo(element); - // Doesn't exist on jqLite - // transclude(clone => clone.appendTo(element)); + element.append(transclude()); + transclude(clone => element.append(clone)); // with scope - // Doesn't exist on jqLite - // transclude(scope, clone => clone.appendTo(element)); - // Doesn't exist on jqLite - // transclude(scope, clone => clone.appendTo(element), element, 'button'); - // Doesn't exist on jqLite - // transclude(scope, null, element, 'list').addClass('drop-down-list').appendTo(element); + transclude(scope, clone => element.append(clone)); + transclude(scope, clone => element.append(clone), element, 'button'); + element.append(transclude(scope, null, element, 'list').addClass('drop-down-list')); } }; }); From 690dcb6d31ff7e5bcca7c2cab43a5e3759bf19a6 Mon Sep 17 00:00:00 2001 From: Dona278 Date: Tue, 20 Jun 2017 14:41:47 +0200 Subject: [PATCH 033/100] [angular-local-storage] - Added missing parameter and function to the ILocalStorageServiceProvider * Added missing parameter "secure" to the "setStorageCookie" function * Added missing function "setDefaultToCookie" to the "ILocalStorageServiceProvider" --- .../angular-local-storage-tests.ts | 1 + types/angular-local-storage/index.d.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/types/angular-local-storage/angular-local-storage-tests.ts b/types/angular-local-storage/angular-local-storage-tests.ts index ead14e85fb..b3fdde8b9e 100644 --- a/types/angular-local-storage/angular-local-storage-tests.ts +++ b/types/angular-local-storage/angular-local-storage-tests.ts @@ -64,6 +64,7 @@ app.config(function (localStorageServiceProvider: ng.local.storage.ILocalStorage localStorageServiceProvider .setPrefix('myApp') .setStorageType('sessionStorage') + .setDefaultToCookie(false) .setNotify(true, true); }); diff --git a/types/angular-local-storage/index.d.ts b/types/angular-local-storage/index.d.ts index faa99065da..76ab65b1b5 100644 --- a/types/angular-local-storage/index.d.ts +++ b/types/angular-local-storage/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for angular-local-storage v0.1.6 +// Type definitions for angular-local-storage v0.6.0 // Project: https://github.com/grevory/angular-local-storage -// Definitions by: Ken Fukuyama +// Definitions by: Ken Fukuyama , Davide Donadello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -27,12 +27,18 @@ declare module 'angular' { * @param storageType localstorage or sessionStorage. default: localStorage */ setStorageType(storageType: string): ILocalStorageServiceProvider; + /** + * If localStorage is not supported, the library will default to cookies instead. This behavior can be disabled + * @param shouldDefault default: true + */ + setDefaultToCookie(shouldDefault: boolean): ILocalStorageServiceProvider; /** * Setter for cookie config * @param exp number of days before cookies expire (0 = does not expire). default: 30 * @param path the web path the cookie represents. default: '/' + * @param secure to store cookies as secure. default: false */ - setStorageCookie(exp: number, path: string): ILocalStorageServiceProvider; + setStorageCookie(exp: number, path: string, secure: boolean): ILocalStorageServiceProvider; /** * Set the cookie domain, since this runs inside a the config() block, only providers and constants can be injected. As a result, $location service can't be used here, use a hardcoded string or window.location. * No default value From d5213b1fa038b435245ad6c3b82d31bd0315a56d Mon Sep 17 00:00:00 2001 From: muecke1312 Date: Tue, 20 Jun 2017 15:38:03 +0200 Subject: [PATCH 034/100] Add missing methods for JasmineAjaxRequest responseTimeout and responseError methods where missing in JasmineAjaxRequest --- types/jasmine-ajax/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/jasmine-ajax/index.d.ts b/types/jasmine-ajax/index.d.ts index dcc6720f04..0d1d92751d 100644 --- a/types/jasmine-ajax/index.d.ts +++ b/types/jasmine-ajax/index.d.ts @@ -24,6 +24,8 @@ interface JasmineAjaxRequest extends XMLHttpRequest { data(): string; respondWith(response: JasmineAjaxResponse): void; + responseTimeout(): void; + responseError(): void; } interface JasmineAjaxRequestTracker { From 5609ba63702683bc43ccc377999cf58f904bf86d Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 20 Jun 2017 16:50:52 -0700 Subject: [PATCH 035/100] elasticsearch: type scroll result and change PromiseLike to Promise --- types/elasticsearch/index.d.ts | 236 ++++++++++++++++----------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index a0606a4961..34be61f5b0 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -13,75 +13,75 @@ declare module Elasticsearch { nodes: Nodes; snapshot: Snapshot; tasks: Tasks; - bulk(params: BulkIndexDocumentsParams): PromiseLike; + bulk(params: BulkIndexDocumentsParams): Promise; bulk(params: BulkIndexDocumentsParams, callback: (error: any, response: any) => void): void; clearScroll(params: ClearScrollParams, callback: (error: any, response: any) => void): void; - clearScroll(params: ClearScrollParams): PromiseLike; + clearScroll(params: ClearScrollParams): Promise; count(params: CountParams, callback: (error: any, response: CountResponse) => void): void; - count(params: CountParams): PromiseLike; - create(params: CreateDocumentParams): PromiseLike; + count(params: CountParams): Promise; + create(params: CreateDocumentParams): Promise; create(params: CreateDocumentParams, callback: (err: any, response: CreateDocumentResponse, status: any) => void): void; - delete(params: DeleteDocumentParams): PromiseLike; + delete(params: DeleteDocumentParams): Promise; delete(params: DeleteDocumentParams, callback: (error: any, response: DeleteDocumentResponse) => void): void; - deleteByQuery(params: DeleteDocumentByQueryParams): PromiseLike; + deleteByQuery(params: DeleteDocumentByQueryParams): Promise; deleteByQuery(params: DeleteDocumentByQueryParams, callback: (error: any, response: DeleteDocumentByQueryResponse) => void): void; - deleteScript(params: DeleteScriptParams): PromiseLike; + deleteScript(params: DeleteScriptParams): Promise; deleteScript(params: DeleteScriptParams, callback: (error: any, response: any) => void): void; - deleteTemplate(params: DeleteTemplateParams): PromiseLike; + deleteTemplate(params: DeleteTemplateParams): Promise; deleteTemplate(params: DeleteTemplateParams, callback: (error: any, response: any) => void): void; - exists(params: ExistsParams): PromiseLike; + exists(params: ExistsParams): Promise; exists(params: ExistsParams, callback: (error: any, response: any, status?: any) => void): void; - explain(params: ExplainParams): PromiseLike; + explain(params: ExplainParams): Promise; explain(params: ExplainParams, callback: (error: any, response: ExplainResponse) => void): void; - fieldStats(params: FieldStatsParams): PromiseLike; + fieldStats(params: FieldStatsParams): Promise; fieldStats(params: FieldStatsParams, callback: (error: any, response: FieldStatsResponse) => void): void; get(params: GetParams, callback: (error: any, response: GetResponse) => void): void; - get(params: GetParams): PromiseLike>; - getScript(params: GetScriptParams): PromiseLike; + get(params: GetParams): Promise>; + getScript(params: GetScriptParams): Promise; getScript(params: GetScriptParams, callback: (error: any, response: any) => void): void; - getSource(params: GetSourceParams): PromiseLike; + getSource(params: GetSourceParams): Promise; getSource(params: GetSourceParams, callback: (error: any, response: any) => void): void; - getTemplate(params: GetTemplateParams): PromiseLike; + getTemplate(params: GetTemplateParams): Promise; getTemplate(params: GetTemplateParams, callback: (error: any, response: any) => void): void; - index(params: IndexDocumentParams): PromiseLike; + index(params: IndexDocumentParams): Promise; index(params: IndexDocumentParams, callback: (error: any, response: any) => void): void; - info(params: InfoParams): PromiseLike; + info(params: InfoParams): Promise; info(params: InfoParams, callback: (error: any, response: any) => void): void; mget(params: MGetParams, callback: (error: any, response: MGetResponse) => void): void; - mget(params: MGetParams): PromiseLike>; + mget(params: MGetParams): Promise>; msearch(params: MSearchParams, callback: (error: any, response: MSearchResponse) => void): void; - msearch(params: MSearchParams): PromiseLike>; + msearch(params: MSearchParams): Promise>; msearchTemplate(params: MSearchTemplateParams, callback: (error: any, response: MSearchResponse) => void): void; - msearchTemplate(params: MSearchTemplateParams): PromiseLike>; - mtermvectors(params: MTermVectorsParams): PromiseLike; + msearchTemplate(params: MSearchTemplateParams): Promise>; + mtermvectors(params: MTermVectorsParams): Promise; mtermvectors(params: MTermVectorsParams, callback: (error: any, response: any) => void): void; - ping(params: PingParams): PromiseLike; + ping(params: PingParams): Promise; ping(params: PingParams, callback: (err: any, response: any, status: any) => void): void; - putScript(params: PutScriptParams): PromiseLike; + putScript(params: PutScriptParams): Promise; putScript(params: PutScriptParams, callback: (err: any, response: any, status: any) => void): void; - putTemplate(params: PutTemplateParams): PromiseLike; + putTemplate(params: PutTemplateParams): Promise; putTemplate(params: PutTemplateParams, callback: (err: any, response: any, status: any) => void): void; - reindex(params: ReindexParams): PromiseLike; + reindex(params: ReindexParams): Promise; reindex(params: ReindexParams, callback: (error: any, response: ReindexResponse) => void): void; - reindexRethrottle(params: ReindexRethrottleParams): PromiseLike; + reindexRethrottle(params: ReindexRethrottleParams): Promise; reindexRethrottle(params: ReindexRethrottleParams, callback: (error: any, response: any) => void): void; - renderSearchTemplate(params: RenderSearchTemplateParams): PromiseLike; + renderSearchTemplate(params: RenderSearchTemplateParams): Promise; renderSearchTemplate(params: RenderSearchTemplateParams, callback: (error: any, response: any) => void): void; - scroll(params: ScrollParams): PromiseLike; - scroll(params: ScrollParams, callback: (error: any, response: any) => void): void; - search(params: SearchParams): PromiseLike>; + scroll(params: ScrollParams): Promise>; + scroll(params: ScrollParams, callback: (error: any, response: SearchResponse) => void): void; + search(params: SearchParams): Promise>; search(params: SearchParams, callback: (error: any, response: SearchResponse) => void): void; - searchShards(params: SearchShardsParams): PromiseLike; + searchShards(params: SearchShardsParams): Promise; searchShards(params: SearchShardsParams, callback: (error: any, response: SearchShardsResponse) => void): void; - searchTemplate(params: SearchTemplateParams): PromiseLike; + searchTemplate(params: SearchTemplateParams): Promise; searchTemplate(params: SearchTemplateParams, callback: (error: any, response: any) => void): void; - suggest(params: SuggestParams): PromiseLike; + suggest(params: SuggestParams): Promise; suggest(params: SuggestParams, callback: (error: any, response: any) => void): void; - termvectors(params: TermvectorsParams): PromiseLike; + termvectors(params: TermvectorsParams): Promise; termvectors(params: TermvectorsParams, callback: (error: any, response: any) => void): void; - update(params: UpdateDocumentParams): PromiseLike; + update(params: UpdateDocumentParams): Promise; update(params: UpdateDocumentParams, callback: (error: any, response: any) => void): void; - updateByQuery(params: UpdateDocumentByQueryParams): PromiseLike; + updateByQuery(params: UpdateDocumentByQueryParams): Promise; updateByQuery(params: UpdateDocumentByQueryParams, callback: (error: any, response: any) => void): void; } @@ -774,43 +774,43 @@ declare module Elasticsearch { export interface Cat { aliases(params: CatAliasesParams, callback: (error: any, response: any) => void): void; - aliases(params: CatAliasesParams): PromiseLike; + aliases(params: CatAliasesParams): Promise; allocation(params: CatAllocationParams, callback: (error: any, response: any) => void): void; - allocation(params: CatAllocationParams): PromiseLike; + allocation(params: CatAllocationParams): Promise; count(params: CatCountParams, callback: (error: any, response: any) => void): void; - count(params: CatAllocationParams): PromiseLike; + count(params: CatAllocationParams): Promise; fielddata(params: CatFielddataParams, callback: (error: any, response: any) => void): void; - fielddata(params: CatFielddataParams): PromiseLike; + fielddata(params: CatFielddataParams): Promise; health(params: CatHealthParams, callback: (error: any, response: any) => void): void; - health(params: CatHealthParams): PromiseLike; + health(params: CatHealthParams): Promise; help(params: CatHelpParams, callback: (error: any, response: any) => void): void; - help(params: CatHelpParams): PromiseLike; + help(params: CatHelpParams): Promise; indices(params: CatIndicesParams, callback: (error: any, response: any) => void): void; - indices(params: CatIndicesParams): PromiseLike; + indices(params: CatIndicesParams): Promise; master(params: CatCommonParams, callback: (error: any, response: any) => void): void; - master(params: CatCommonParams): PromiseLike; + master(params: CatCommonParams): Promise; nodeattrs(params: CatCommonParams, callback: (error: any, response: any) => void): void; - nodeattrs(params: CatCommonParams): PromiseLike; + nodeattrs(params: CatCommonParams): Promise; nodes(params: CatCommonParams, callback: (error: any, response: any) => void): void; - nodes(params: CatCommonParams): PromiseLike; + nodes(params: CatCommonParams): Promise; pendingTasks(params: CatCommonParams, callback: (error: any, response: any) => void): void; - pendingTasks(params: CatCommonParams): PromiseLike; + pendingTasks(params: CatCommonParams): Promise; plugins(params: CatCommonParams, callback: (error: any, response: any) => void): void; - plugins(params: CatCommonParams): PromiseLike; + plugins(params: CatCommonParams): Promise; recovery(params: CatRecoveryParams, callback: (error: any, response: any) => void): void; - recovery(params: CatRecoveryParams): PromiseLike; + recovery(params: CatRecoveryParams): Promise; repositories(params: CatCommonParams, callback: (error: any, response: any) => void): void; - repositories(params: CatCommonParams): PromiseLike; + repositories(params: CatCommonParams): Promise; segments(params: CatSegmentsParams, callback: (error: any, response: any) => void): void; - segments(params: CatSegmentsParams): PromiseLike; + segments(params: CatSegmentsParams): Promise; shards(params: CatShardsParams, callback: (error: any, response: any) => void): void; - shards(params: CatShardsParams): PromiseLike; + shards(params: CatShardsParams): Promise; snapshots(params: CatSnapshotsParams, callback: (error: any, response: any) => void): void; - snapshots(params: CatSnapshotsParams): PromiseLike; + snapshots(params: CatSnapshotsParams): Promise; tasks(params: CatTasksParams, callback: (error: any, response: any) => void): void; - tasks(params: CatTasksParams): PromiseLike; + tasks(params: CatTasksParams): Promise; threadPool(params: CatThreadPoolParams, callback: (error: any, response: any) => void): void; - threadPool(params: CatThreadPoolParams): PromiseLike; + threadPool(params: CatThreadPoolParams): Promise; } export type CatBytes = "b" | "k" | "kb" | "m" | "mb" | "g" | "gb" | "t" | "tb" | "p" | "pb"; @@ -907,21 +907,21 @@ declare module Elasticsearch { export interface Cluster { allocationExplain(params: ClusterAllocationExplainParams, callback: (error: any, response: any) => void): void; - allocationExplain(params: ClusterAllocationExplainParams): PromiseLike; + allocationExplain(params: ClusterAllocationExplainParams): Promise; getSettings(params: ClusterGetSettingsParams, callback: (error: any, response: any) => void): void; - getSettings(params: ClusterGetSettingsParams): PromiseLike; + getSettings(params: ClusterGetSettingsParams): Promise; health(params: ClusterHealthParams, callback: (error: any, response: any) => void): void; - health(params: ClusterHealthParams): PromiseLike; + health(params: ClusterHealthParams): Promise; pendingTasks(params: ClusterPendingTasksParams, callback: (error: any, response: any) => void): void; - pendingTasks(params: ClusterPendingTasksParams): PromiseLike; + pendingTasks(params: ClusterPendingTasksParams): Promise; putSettings(params: ClusterPutSettingsParams, callback: (error: any, response: any) => void): void; - putSettings(params: ClusterPutSettingsParams): PromiseLike; + putSettings(params: ClusterPutSettingsParams): Promise; reroute(params: ClusterRerouteParams, callback: (error: any, response: any) => void): void; - reroute(params: ClusterRerouteParams): PromiseLike; + reroute(params: ClusterRerouteParams): Promise; state(params: ClusterStateParams, callback: (error: any, response: any) => void): void; - state(params: ClusterStateParams): PromiseLike; + state(params: ClusterStateParams): Promise; stats(params: ClusterStatsParams, callback: (error: any, response: any) => void): void; - stats(params: ClusterStatsParams): PromiseLike; + stats(params: ClusterStatsParams): Promise; } export interface ClusterAllocationExplainParams extends GenericParams { @@ -988,77 +988,77 @@ declare module Elasticsearch { export class Indices { analyze(params: IndicesAnalyzeParams, callback: (error: any, response: any, status: any) => void): void; - analyze(params: IndicesAnalyzeParams): PromiseLike; + analyze(params: IndicesAnalyzeParams): Promise; clearCache(params: IndicesClearCacheParams, callback: (error: any, response: any, status: any) => void): void; - clearCache(params: IndicesClearCacheParams): PromiseLike; + clearCache(params: IndicesClearCacheParams): Promise; close(params: IndicesCloseParams, callback: (error: any, response: any, status: any) => void): void; - close(params: IndicesCloseParams): PromiseLike; + close(params: IndicesCloseParams): Promise; create(params: IndicesCreateParams, callback: (error: any, response: any, status: any) => void): void; - create(params: IndicesCreateParams): PromiseLike; + create(params: IndicesCreateParams): Promise; delete(params: IndicesDeleteParams, callback: (error: any, response: any, status: any) => void): void; - delete(params: IndicesDeleteParams): PromiseLike; + delete(params: IndicesDeleteParams): Promise; deleteAlias(params: IndicesDeleteAliasParams, callback: (error: any, response: any, status: any) => void): void; - deleteAlias(params: IndicesDeleteAliasParams): PromiseLike; + deleteAlias(params: IndicesDeleteAliasParams): Promise; deleteTemplate(params: IndicesDeleteTemplateParams, callback: (error: any, response: any, status: any) => void): void; - deleteTemplate(params: IndicesDeleteTemplateParams): PromiseLike; + deleteTemplate(params: IndicesDeleteTemplateParams): Promise; exists(params: IndicesExistsParams, callback: (error: any, response: any, status: any) => void): void; - exists(params: IndicesExistsParams): PromiseLike; + exists(params: IndicesExistsParams): Promise; existsAlias(params: IndicesExistsAliasParams, callback: (error: any, response: any, status: any) => void): void; - existsAlias(params: IndicesExistsAliasParams): PromiseLike; + existsAlias(params: IndicesExistsAliasParams): Promise; existsTemplate(params: IndicesExistsTemplateParams, callback: (error: any, response: any, status: any) => void): void; - existsTemplate(params: IndicesExistsTemplateParams): PromiseLike; + existsTemplate(params: IndicesExistsTemplateParams): Promise; existsType(params: IndicesExistsTypeParams, callback: (error: any, response: any, status: any) => void): void; - existsType(params: IndicesExistsTypeParams): PromiseLike; + existsType(params: IndicesExistsTypeParams): Promise; flush(params: IndicesFlushParams, callback: (error: any, response: any, status: any) => void): void; - flush(params: IndicesFlushParams): PromiseLike; + flush(params: IndicesFlushParams): Promise; flushSynced(params: IndicesFlushSyncedParams, callback: (error: any, response: any, status: any) => void): void; - flushSynced(params: IndicesFlushSyncedParams): PromiseLike; + flushSynced(params: IndicesFlushSyncedParams): Promise; forcemerge(params: IndicesForcemergeParams, callback: (error: any, response: any, status: any) => void): void; - forcemerge(params: IndicesForcemergeParams): PromiseLike; + forcemerge(params: IndicesForcemergeParams): Promise; get(params: IndicesGetParams, callback: (error: any, response: any, status: any) => void): void; - get(params: IndicesGetParams): PromiseLike; + get(params: IndicesGetParams): Promise; getAlias(params: IndicesGetAliasParams, callback: (error: any, response: any, status: any) => void): void; - getAlias(params: IndicesGetAliasParams): PromiseLike; + getAlias(params: IndicesGetAliasParams): Promise; getFieldMapping(params: IndicesGetFieldMappingParams, callback: (error: any, response: any, status: any) => void): void; - getFieldMapping(params: IndicesGetFieldMappingParams): PromiseLike; + getFieldMapping(params: IndicesGetFieldMappingParams): Promise; getMapping(params: IndicesGetMappingParams, callback: (error: any, response: any, status: any) => void): void; - getMapping(params: IndicesGetMappingParams): PromiseLike; + getMapping(params: IndicesGetMappingParams): Promise; getSettings(params: IndicesGetSettingsParams, callback: (error: any, response: any, status: any) => void): void; - getSettings(params: IndicesGetSettingsParams): PromiseLike; + getSettings(params: IndicesGetSettingsParams): Promise; getTemplate(params: IndicesGetTemplateParams, callback: (error: any, response: any, status: any) => void): void; - getTemplate(params: IndicesGetTemplateParams): PromiseLike; + getTemplate(params: IndicesGetTemplateParams): Promise; getUpgrade(params: IndicesGetUpgradeParams, callback: (error: any, response: any, status: any) => void): void; - getUpgrade(params: IndicesGetUpgradeParams): PromiseLike; + getUpgrade(params: IndicesGetUpgradeParams): Promise; open(params: IndicesOpenParams, callback: (error: any, response: any, status: any) => void): void; - open(params: IndicesOpenParams): PromiseLike; + open(params: IndicesOpenParams): Promise; putAlias(params: IndicesPutAliasParams, callback: (error: any, response: any, status: any) => void): void; - putAlias(params: IndicesPutAliasParams): PromiseLike; + putAlias(params: IndicesPutAliasParams): Promise; putMapping(params: IndicesPutMappingParams, callback: (error: any, response: any, status: any) => void): void; - putMapping(params: IndicesPutMappingParams): PromiseLike; + putMapping(params: IndicesPutMappingParams): Promise; putSettings(params: IndicesPutSettingsParams, callback: (error: any, response: any, status: any) => void): void; - putSettings(params: IndicesPutSettingsParams): PromiseLike; + putSettings(params: IndicesPutSettingsParams): Promise; putTemplate(params: IndicesPutTemplateParams, callback: (error: any, response: any) => void): void; - putTemplate(params: IndicesPutTemplateParams): PromiseLike; + putTemplate(params: IndicesPutTemplateParams): Promise; recovery(params: IndicesRecoveryParams, callback: (error: any, response: any) => void): void; - recovery(params: IndicesRecoveryParams): PromiseLike; + recovery(params: IndicesRecoveryParams): Promise; refresh(params: IndicesRefreshParams, callback: (error: any, response: any) => void): void; - refresh(params: IndicesRefreshParams): PromiseLike; + refresh(params: IndicesRefreshParams): Promise; rollover(params: IndicesRolloverParams, callback: (error: any, response: IndicesRolloverResponse) => void): void; - rollover(params: IndicesRolloverParams): PromiseLike; + rollover(params: IndicesRolloverParams): Promise; segments(params: IndicesSegmentsParams, callback: (error: any, response: any) => void): void; - segments(params: IndicesSegmentsParams): PromiseLike; + segments(params: IndicesSegmentsParams): Promise; shardStores(params: IndicesShardStoresParams, callback: (error: any, response: any) => void): void; - shardStores(params: IndicesShardStoresParams): PromiseLike; + shardStores(params: IndicesShardStoresParams): Promise; shrink(params: IndicesShrinkParams, callback: (error: any, response: any) => void): void; - shrink(params: IndicesShrinkParams): PromiseLike; + shrink(params: IndicesShrinkParams): Promise; stats(params: IndicesStatsParams, callback: (error: any, response: any) => void): void; - stats(params: IndicesStatsParams): PromiseLike; + stats(params: IndicesStatsParams): Promise; updateAliases(params: IndicesUpdateAliasesParams, callback: (error: any, response: any) => void): void; - updateAliases(params: IndicesUpdateAliasesParams): PromiseLike; + updateAliases(params: IndicesUpdateAliasesParams): Promise; upgrade(params: IndicesUpgradeParams, callback: (error: any, response: any) => void): void; - upgrade(params: IndicesUpgradeParams): PromiseLike; + upgrade(params: IndicesUpgradeParams): Promise; validateQuery(params: IndicesValidateQueryParams, callback: (error: any, response: any) => void): void; - validateQuery(params: IndicesValidateQueryParams): PromiseLike; + validateQuery(params: IndicesValidateQueryParams): Promise; } export interface IndicesAnalyzeParams extends GenericParams { @@ -1416,13 +1416,13 @@ declare module Elasticsearch { export class Ingest { deletePipeline(params: IngestDeletePipelineParams, callback: (error: any, response: any, status: any) => void): void; - deletePipeline(params: IngestDeletePipelineParams): PromiseLike; + deletePipeline(params: IngestDeletePipelineParams): Promise; getPipeline(params: IngestGetPipelineParams, callback: (error: any, response: any, status: any) => void): void; - getPipeline(params: IngestGetPipelineParams): PromiseLike; + getPipeline(params: IngestGetPipelineParams): Promise; putPipeline(params: IngestPutPipelineParams, callback: (error: any, response: any, status: any) => void): void; - putPipeline(params: IngestPutPipelineParams): PromiseLike; + putPipeline(params: IngestPutPipelineParams): Promise; simulate(params: IngestSimulateParams, callback: (error: any, response: any, status: any) => void): void; - simulate(params: IngestSimulateParams): PromiseLike; + simulate(params: IngestSimulateParams): Promise; } export interface IngestDeletePipelineParams extends GenericParams { @@ -1450,11 +1450,11 @@ declare module Elasticsearch { export class Nodes { hotThreads(params: NodesHotThreadsParams, callback: (error: any, response: any, status: any) => void): void; - hotThreads(params: NodesHotThreadsParams): PromiseLike; + hotThreads(params: NodesHotThreadsParams): Promise; info(params: NodesInfoParams, callback: (error: any, response: any, status: any) => void): void; - info(params: NodesInfoParams): PromiseLike; + info(params: NodesInfoParams): Promise; stats(params: NodesStatsParams, callback: (error: any, response: any, status: any) => void): void; - stats(params: NodesStatsParams): PromiseLike; + stats(params: NodesStatsParams): Promise; } export interface NodesHotThreadsParams extends GenericParams { @@ -1491,23 +1491,23 @@ declare module Elasticsearch { export class Snapshot { create(params: SnapshotCreateParams, callback: (error: any, response: any, status: any) => void): void; - create(params: SnapshotCreateParams): PromiseLike; + create(params: SnapshotCreateParams): Promise; createRepository(params: SnapshotCreateRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - createRepository(params: SnapshotCreateRepositoryParams): PromiseLike; + createRepository(params: SnapshotCreateRepositoryParams): Promise; delete(params: SnapshotDeleteParams, callback: (error: any, response: any, status: any) => void): void; - delete(params: SnapshotDeleteParams): PromiseLike; + delete(params: SnapshotDeleteParams): Promise; deleteRepository(params: SnapshotDeleteRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - deleteRepository(params: SnapshotDeleteRepositoryParams): PromiseLike; + deleteRepository(params: SnapshotDeleteRepositoryParams): Promise; get(params: SnapshotGetParams, callback: (error: any, response: any, status: any) => void): void; - get(params: SnapshotGetParams): PromiseLike; + get(params: SnapshotGetParams): Promise; getRepository(params: SnapshotGetRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - getRepository(params: SnapshotGetRepositoryParams): PromiseLike; + getRepository(params: SnapshotGetRepositoryParams): Promise; restore(params: SnapshotRestoreParams, callback: (error: any, response: any, status: any) => void): void; - restore(params: SnapshotRestoreParams): PromiseLike; + restore(params: SnapshotRestoreParams): Promise; status(params: SnapshotStatusParams, callback: (error: any, response: any, status: any) => void): void; - status(params: SnapshotStatusParams): PromiseLike; + status(params: SnapshotStatusParams): Promise; verifyRepository(params: SnapshotVerifyRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - verifyRepository(params: SnapshotVerifyRepositoryParams): PromiseLike; + verifyRepository(params: SnapshotVerifyRepositoryParams): Promise; } export interface SnapshotCreateParams extends GenericParams { @@ -1571,11 +1571,11 @@ declare module Elasticsearch { export class Tasks { cancel(params: TasksCancelParams, callback: (error: any, response: any, status: any) => void): void; - cancel(params: TasksCancelParams): PromiseLike; + cancel(params: TasksCancelParams): Promise; get(params: TasksGetParams, callback: (error: any, response: any, status: any) => void): void; - get(params: TasksGetParams): PromiseLike; + get(params: TasksGetParams): Promise; list(params: TasksListParams, callback: (error: any, response: any, status: any) => void): void; - list(params: TasksListParams): PromiseLike; + list(params: TasksListParams): Promise; } export interface TasksCancelParams extends GenericParams { From fcd65b03192d6a6e4be96a2c187c3a8b61c67cd9 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 21 Jun 2017 09:58:34 +0300 Subject: [PATCH 036/100] Add foldAll to IEditSession --- types/ace/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/ace/index.d.ts b/types/ace/index.d.ts index 90466c946e..58bf1c2bd8 100644 --- a/types/ace/index.d.ts +++ b/types/ace/index.d.ts @@ -474,7 +474,9 @@ declare namespace AceAjax { removeFold(arg: any): void; expandFold(arg: any): void; - + + foldAll(startRow?: number, endRow?: number, depth?: number): void + unfold(arg1: any, arg2: boolean): void; screenToDocumentColumn(row: number, column: number): void; From 0b243447cff74a92613b8969d596c428d446b5b1 Mon Sep 17 00:00:00 2001 From: Nikita Gubchenko Date: Wed, 21 Jun 2017 11:23:51 +0300 Subject: [PATCH 037/100] Victory: added missing types for VictoryLegend --- types/victory/index.d.ts | 156 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/types/victory/index.d.ts b/types/victory/index.d.ts index 437523f465..b33cda7648 100644 --- a/types/victory/index.d.ts +++ b/types/victory/index.d.ts @@ -1156,6 +1156,17 @@ declare module "victory" { * y as a function of x. Samples is ignored if x props are provided instead. */ samples?: number; + /** + * The labels prop defines the labels that will appear above each point. + * This prop should be given as an array or as a function of data. + */ + labels?: string[]|number[]|Function; + /** + * Use the sortKey prop to indicate how data should be sorted. This prop + * is given directly to the lodash sortBy function to be executed on the + * final dataset. + */ + sortKey?: string|string[]|Function; /** * The style prop specifies styles for your VictoryLine. Any valid inline style properties * will be applied. Height, width, and padding should be specified via the height, @@ -1173,6 +1184,151 @@ declare module "victory" { */ export class VictoryLine extends React.Component {} + export interface VictoryLegendProps extends VictoryCommonProps, VictoryDatableProps, VictorySingleLabableProps { + /** + * The colorScale prop defines a color scale to be applied to each data + * symbol in VictoryLegend. This prop should be given as an array of CSS + * colors, or as a string corresponding to one of the built in color + * scales: "grayscale", "qualitative", "heatmap", "warm", "cool", "red", + * "green", "blue". VictoryLegend will assign a color to each symbol by + * index, unless they are explicitly specified in the data object. + * Colors will repeat when there are more symbols than colors in the + * provided colorScale. + */ + colorScale?: ColorScalePropType; + /** + * The style prop defines the style of the VictoryLegend component. + * The style prop should be given as an object with styles defined for data, labels and + * parent. Any valid svg styles are supported, but width, height, and + * padding should be specified via props as they determine relative + * layout for components in VictoryLegend. + */ + style?: VictoryStyleInterface; + /** + * The containerComponent prop takes a component instance which will be + * used to create a container element for standalone legends. The new + * element created from the passed containerComponent will be provided + * with the following props: height, width, children (the legend itself) + * and style. If a containerComponent is not provided, the default + * VictoryContainer component will be used. VictoryContainer supports + * title and desc props, which are intended to add accessibility to + * Victory components. The more descriptive these props are, the more + * accessible your data will be for people using screen readers. These + * props may be set by passing them directly to the supplied component. + * By default, VictoryContainer renders a responsive svg using the + * viewBox attribute. To render a static container, set + * responsive={false} directly on the instance of VictoryContainer + * supplied via the containerComponent prop. VictoryContainer also + * renders a Portal element that may be used in conjunction with + * VictoryPortal to force components to render above other children. + * @default + */ + containerComponent?: React.ReactElement; + /** + * Specify data via the data prop. VictoryLegend expects data as an + * array of objects with name (required), symbol, and labels properties. + * The data prop must be given as an array. + */ + data?: Array<{ + name?: string; + symbol?: { + type?: string; + }; + }>; + /** + * The dataComponent prop takes a component instance which will be + * responsible for rendering a data element used to associate a symbol + * or color with each data series. The new element created from the + * passed dataComponent will be provided with the following properties + * calculated by VictoryLegend: x, y, size, style, and symbol. Any of + * these props may be overridden by passing in props to the supplied + * component, or modified or ignored within the custom component itself. + * If a dataComponent is not provided, VictoryLegend will use its + * default Point component. + */ + dataComponent?: React.ReactElement; + /** + * The groupComponent prop takes an entire component which will be used to + * create group elements for use within container elements. This prop defaults + * to a tag on web, and a react-native-svg tag on mobile + * @default + */ + groupComponent?: React.ReactElement; + /** + * The gutter prop defines the number of pixels between legend rows or + * columns, depending on orientation. When orientation is horizontal, + * gutters are between columns. When orientation is vertical, gutters + * are the space between rows. + */ + gutter?: number; + /** + * The labelComponent prop takes a component instance which will be used + * to render each legend label. The new element created from the passed + * labelComponent will be supplied with the following properties: x, y, + * style, and text. Any of these props may be overridden by passing in + * props to the supplied component, or modified or ignored within the + * custom component itself. If labelComponent is omitted, a new + * VictoryLabel will be created with the props described above. + */ + labelComponent?: React.ReactElement; + /** + * The orientation prop takes a string that defines whether legend data + * are displayed in a row or column. When orientation is "horizontal", + * legend items will be displayed in a single row. When orientation is + * "vertical", legend items will be displayed in a single column. Line + * and text-wrapping is not currently supported, so "vertical" + * orientation is both the default setting and recommended for + * displaying many series of data. + * @default 'vertical' + */ + orientation?: 'horizontal'|'vertical'; + /** + * The padding prop specifies the amount of padding in pixels between + * the edge of the legend and any rendered child components. This prop + * can be given as a number or as an object with padding specified for + * top, bottom, left and right. As with width and height, the absolute + * padding will depend on whether the component is rendered in a + * responsive container. When a component is nested within + * VictoryLegend, setting padding on the child component will have no + * effect. + */ + padding?: number | { + top?: number; + bottom?: number; + left?: number; + right?: number; + }; + /** + * The standalone props specifies whether the component should be + * rendered in an independent element or in a tag. This prop + * defaults to true, and renders an svg. + */ + standalone?: boolean; + /** + * The symbolSpacer prop defines the number of pixels between data + * components and label components. + */ + symbolSpacer?: number; + /** + * The width and height props define the width and height of the legend. + * These props may be given as positive numbers or functions of data. If + * these props are not set, width and height will be determined based on + * an approximate text size calculated from the text and style props + * provided to VictoryLegend. + */ + width?: number; + height?: number; + /** + * The x and y props define the base position of the legend element. + */ + x?: number; + y?: number; + } + /** + * VictoryLegend renders a chart legend component. + */ + export class VictoryLegend extends React.Component {} + type ScatterSymbolType = "circle" | "diamond" | "plus" | "square" | "star" | "triangleDown" | "triangleUp"; export interface VictoryScatterProps extends VictoryCommonProps, VictoryDatableProps, VictoryMultiLabeableProps { /** From e01f2d7d8752ab11b8d1095bb125ac38337b5ac8 Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Wed, 21 Jun 2017 20:01:17 +0800 Subject: [PATCH 038/100] Change the type of Request.query to any instead of Object for building a fast prototype --- types/hapi/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index f0ed602864..502b8d4362 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for hapi 16.1 +// Type definitions for hapi 16.2 // Project: https://github.com/hapijs/hapi // Definitions by: Jason Swearingen , AJP // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -1938,7 +1938,7 @@ export class Request extends Podium { * an object containing the query parameters. * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 */ - query: Object; + query: any; /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ raw: { req: http.IncomingMessage; // Or http.ClientRequest http://www.apetuts.com/tutorial/node-js-http-client-request-class/ ? From b7f084da26e14287a3712089b8abe54c6fe8d8f3 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 21 Jun 2017 18:07:02 -0400 Subject: [PATCH 039/100] [angular] Add @types/jquery@3 integration tests. --- types/angular/index.d.ts | 1 + .../angular/test/jquery-v3-merging/index.d.ts | 1 - .../jquery-v3-merging-tests.ts | 17 - .../test/jquery-v3-merging/tsconfig.json | 23 - .../test/jquery-v3-merging/tslint.json | 3 - types/angular/test/jquery3-merging-tests.ts | 456 ++++++++++++++++++ types/angular/tsconfig.json | 6 +- 7 files changed, 461 insertions(+), 46 deletions(-) delete mode 100644 types/angular/test/jquery-v3-merging/index.d.ts delete mode 100644 types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts delete mode 100644 types/angular/test/jquery-v3-merging/tsconfig.json delete mode 100644 types/angular/test/jquery-v3-merging/tslint.json create mode 100644 types/angular/test/jquery3-merging-tests.ts diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index b6e1a14cad..6127fdf943 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -2,6 +2,7 @@ // Project: http://angularjs.org // Definitions by: Diego Vilar , Georgii Dolzhykov , Caleb St-Denis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/angular/test/jquery-v3-merging/index.d.ts b/types/angular/test/jquery-v3-merging/index.d.ts deleted file mode 100644 index 6b4fc26283..0000000000 --- a/types/angular/test/jquery-v3-merging/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -// tslint:disable no-useless-files diff --git a/types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts b/types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts deleted file mode 100644 index 2e2b365f8b..0000000000 --- a/types/angular/test/jquery-v3-merging/jquery-v3-merging-tests.ts +++ /dev/null @@ -1,17 +0,0 @@ -/// - -import * as angular from 'angular'; - -angular.element('div'); -angular.element.noop(); -angular.element('div').appendTo('p'); - -function event() { - const $div = angular.element('div'); - - const Event_v2 = angular.element.Event('click'); - $div.triggerHandler(Event_v2); - - const Event_v3 = jQuery.Event('click'); - $div.triggerHandler(Event_v3); -} diff --git a/types/angular/test/jquery-v3-merging/tsconfig.json b/types/angular/test/jquery-v3-merging/tsconfig.json deleted file mode 100644 index 27816504e7..0000000000 --- a/types/angular/test/jquery-v3-merging/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es5", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../../../", - "typeRoots": [ - "../../../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "jquery-v3-merging-tests.ts" - ] -} diff --git a/types/angular/test/jquery-v3-merging/tslint.json b/types/angular/test/jquery-v3-merging/tslint.json deleted file mode 100644 index 4c3a548997..0000000000 --- a/types/angular/test/jquery-v3-merging/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "dtslint/dtslint.json" -} diff --git a/types/angular/test/jquery3-merging-tests.ts b/types/angular/test/jquery3-merging-tests.ts new file mode 100644 index 0000000000..0dbe37f640 --- /dev/null +++ b/types/angular/test/jquery3-merging-tests.ts @@ -0,0 +1,456 @@ +import * as $ from 'jquery'; +import * as angular from 'angular'; + +function JQuery() { + function addClass() { + // $ExpectType JQuery + $('p').addClass('className'); + + // $ExpectType JQuery + $('p').addClass(function(index, currentClassName) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + currentClassName; + + return 'className'; + }); + } + + function attr() { + // $ExpectType JQuery + $('#greatphoto').attr('alt', 'Beijing Brush Seller'); + + // $ExpectType JQuery + $('#greatphoto').attr('width', 200); + + // $ExpectType JQuery + $('#greatphoto').attr('title', null); + + // $ExpectType JQuery + $('#greatphoto').attr('alt', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return 'Beijing Brush Seller'; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('width', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return 200; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('title', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('title', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return undefined; + }); + + // $ExpectType JQuery + $('img').attr({ + src: '/resources/hat.gif', + title: 'jQuery', + alt: 'jQuery Logo' + }); + + // $ExpectType string + $('img').attr('src'); + } + + function bind() { + // $ExpectType JQuery + $('p').bind('myEvent', 'myData', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('p').bind('myEvent', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('p').bind('myEvent', false); + + // $ExpectType JQuery + $('p').bind({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + }, + myEvent2: false + }); + + // $ExpectType JQuery + $('p').bind('myEvent', null); + + // $ExpectType JQuery + $('p').bind('myEvent', undefined); + } + + function children() { + $('p').children(); + + $('p').children('span'); + } + + function off() { + // $ExpectType JQuery + $('table').off('myEvent', 'td', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').off('myEvent', 'td', false); + + // $ExpectType JQuery + $('table').off('myEvent', 'td'); + + // $ExpectType JQuery + $('table').off('myEvent', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').off('myEvent', false); + + // $ExpectType JQuery + $('table').off('myEvent'); + + // $ExpectType JQuery + $('table').off({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, 'td'); + + // $ExpectType JQuery + $('table').off({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }); + + // $ExpectType JQuery + $('table').off($.Event('myEvent')); + + // $ExpectType JQuery + $('table').off(); + } + + function on() { + // $ExpectType JQuery + $('table').on('myEvent', 'td', 'myData', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').on('myEvent', null, 'myData', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').on('myEvent', 'td', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').on('myEvent', 'td', false); + + // $ExpectType JQuery + $('table').on('myEvent', 3, function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').on('myEvent', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').on('myEvent', false); + + // $ExpectType JQuery + $('table').on({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, 'td', 'myData'); + + // $ExpectType JQuery + $('table').on({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, null, 'myData'); + + // $ExpectType JQuery + $('table').on({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, 'td'); + + // $ExpectType JQuery + $('table').on({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, 3); + + // $ExpectType JQuery + $('table').on({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }); + } + + function one() { + // $ExpectType JQuery + $('table').one('myEvent', 'td', 'myData', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').one('myEvent', null, 'myData', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').one('myEvent', 'td', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').one('myEvent', 'td', false); + + // $ExpectType JQuery + $('table').one('myEvent', 3, function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').one('myEvent', function(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }); + + // $ExpectType JQuery + $('table').one('myEvent', false); + + // $ExpectType JQuery + $('table').one({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, 'td', 'myData'); + + // $ExpectType JQuery + $('table').one({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, null, 'myData'); + + // $ExpectType JQuery + $('table').one({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, 'td'); + + // $ExpectType JQuery + $('table').one({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }, 3); + + // $ExpectType JQuery + $('table').one({ + myEvent1(event) { + // $ExpectType HTMLElement + this; + // $ExpectType Event + event; + }, + myEvent2: false + }); + } + + function removeClass() { + // $ExpectType JQuery + $('p').removeClass('className'); + + // $ExpectType JQuery + $('p').removeClass(function(index, currentClassName) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + currentClassName; + + return 'className'; + }); + + // $ExpectType JQuery + $('p').removeClass(); + } + + function toggleClass() { + // $ExpectType JQuery + $('p').toggleClass('className', true); + + // $ExpectType JQuery + $('p').toggleClass(function(index, className, state) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + className; + // $ExpectType true + state; + + return 'className'; + }, true); + + // $ExpectType JQuery + $('p').toggleClass('className'); + + // $ExpectType JQuery + $('p').toggleClass(function(index, className, state) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + className; + // $ExpectType boolean + state; + + return 'className'; + }); + + // $ExpectType JQuery + $('p').toggleClass(false); + + // $ExpectType JQuery + $('p').toggleClass(); + } +} diff --git a/types/angular/tsconfig.json b/types/angular/tsconfig.json index 7acded105d..33c9531cab 100644 --- a/types/angular/tsconfig.json +++ b/types/angular/tsconfig.json @@ -2,13 +2,15 @@ "files": [ "index.d.ts", "jqlite.d.ts", - "angular-tests.ts" + "angular-tests.ts", + "test/jquery3-merging-tests.ts" ], "compilerOptions": { "module": "commonjs", "lib": [ "es5", - "dom" + "dom", + "es2015.iterable" ], "noImplicitAny": false, "noImplicitThis": false, From 798ce5ea6904f00eee62aaf16acff73b125d3f4f Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 21 Jun 2017 19:14:53 -0400 Subject: [PATCH 040/100] [jquery] Clean up manipulation-, queue-, and traversing-related methods on JQuery. Add tests for manipulation-, queue-, and traversing-related methods on JQuery. --- types/jquery/index.d.ts | 30 +- types/jquery/jquery-tests.ts | 985 +++++++++++++++++++++++++++++ types/jquery/test/example-tests.ts | 2 +- 3 files changed, 1001 insertions(+), 16 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index d9d5a5bdc6..0e007b689e 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -62,7 +62,7 @@ interface JQuery { * @see {@link https://api.jquery.com/add/} * @since 1.4 */ - add(selector: JQuery.Selector, context: Element): JQuery; + add(selector: JQuery.Selector, context: Element): this; /** * Create a new jQuery object with elements added to the set of matched elements. * @@ -74,7 +74,7 @@ interface JQuery { * @since 1.0 * @since 1.3.2 */ - add(selector: JQuery.Selector | JQuery.TypeOrArray | JQuery.htmlString | JQuery): JQuery; + add(selector: JQuery.Selector | JQuery.TypeOrArray | JQuery.htmlString | JQuery): this; /** * Add the previous set of elements on the stack to the current set, optionally filtered by a selector. * @@ -426,14 +426,14 @@ interface JQuery { * @since 1.3 * @since 1.6 */ - closest(selector: JQuery.Selector | JQuery | Element): this; + closest(selector: JQuery.Selector | Element | JQuery): this; /** * Get the children of each element in the set of matched elements, including text and comment nodes. * * @see {@link https://api.jquery.com/contents/} * @since 1.2 */ - contents(): this; + contents(): JQuery; /** * Bind an event handler to the "contextmenu" JavaScript event, or trigger that event on an element. * @@ -653,7 +653,7 @@ interface JQuery { * @see {@link https://api.jquery.com/jQuery.fn.extend/} * @since 1.0 */ - extend(obj: object): JQuery; + extend(obj: object): this; /** * Display the matched elements by fading them to opaque. * @@ -796,7 +796,7 @@ interface JQuery { * @since 1.0 * @since 1.6 */ - find(selector: JQuery.Selector | Element | JQuery): JQuery; + find(selector: JQuery.Selector | Element | JQuery): this; /** * Stop the currently-running animation, remove all queued animations, and complete all animations for * the matched elements. @@ -1058,7 +1058,7 @@ interface JQuery { * @since 1.0 * @since 1.6 */ - is(selector: JQuery.Selector | ((this: TElement, index: number, element: TElement) => boolean) | JQuery | Element | Element[]): boolean; + is(selector: JQuery.Selector | JQuery.TypeOrArray | JQuery | ((this: TElement, index: number, element: TElement) => boolean)): boolean; /** * Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element. * @@ -1148,7 +1148,7 @@ interface JQuery { * @see {@link https://api.jquery.com/map/} * @since 1.2 */ - map(callback: (this: TElement, index: number, domElement: TElement) => any | any[] | null | undefined): JQuery; + map(callback: (this: TElement, index: number, domElement: TElement) => any | any[] | null | undefined): this; /** * Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element. * @@ -1309,7 +1309,7 @@ interface JQuery { * @since 1.0 * @since 1.4 */ - not(selector: JQuery.Selector | JQuery.TypeOrArray | ((this: TElement, index: number, element: TElement) => boolean) | JQuery): this; + not(selector: JQuery.Selector | JQuery.TypeOrArray | JQuery | ((this: TElement, index: number, element: TElement) => boolean)): this; /** * Remove an event handler. * @@ -1688,7 +1688,7 @@ interface JQuery { * @see {@link https://api.jquery.com/promise/} * @since 1.6 */ - promise(type: string, target: T): T & JQuery.Promise; + promise(type: string, target: T): T & JQuery.Promise; /** * Return a Promise object to observe when all actions of a certain type bound to the collection, * queued or not, have finished. @@ -1697,7 +1697,7 @@ interface JQuery { * @see {@link https://api.jquery.com/promise/} * @since 1.6 */ - promise(target: T): T & JQuery.Promise; + promise(target: T): T & JQuery.Promise; /** * Return a Promise object to observe when all actions of a certain type bound to the collection, * queued or not, have finished. @@ -1751,7 +1751,7 @@ interface JQuery { * @see {@link https://api.jquery.com/pushStack/} * @since 1.3 */ - pushStack(elements: ArrayLike, name: string, args: any[]): JQuery; + pushStack(elements: ArrayLike, name: string, args: any[]): this; /** * Add a collection of DOM elements onto the jQuery stack. * @@ -1759,7 +1759,7 @@ interface JQuery { * @see {@link https://api.jquery.com/pushStack/} * @since 1.0 */ - pushStack(elements: ArrayLike): JQuery; + pushStack(elements: ArrayLike): this; /** * Manipulate the queue of functions to be executed, once for each matched element. * @@ -1858,7 +1858,7 @@ interface JQuery { * @since 1.2 * @since 1.4 */ - replaceWith(newContent: JQuery.htmlString | JQuery.TypeOrArray | JQuery | ((this: TElement) => any)): JQuery; + replaceWith(newContent: JQuery.htmlString | JQuery | JQuery.TypeOrArray | ((this: TElement) => any)): this; /** * Bind an event handler to the "resize" JavaScript event, or trigger that event on an element. * @@ -2388,7 +2388,7 @@ interface JQuery { * @since 1.2 * @since 1.4 */ - wrapInner(wrappingElement: JQuery.Selector | JQuery.htmlString | Element | JQuery | ((this: TElement, index: number) => string | Element | JQuery)): this; + wrapInner(wrappingElement: JQuery.Selector | JQuery.htmlString | Element | JQuery | ((this: TElement, index: number) => string | JQuery | Element)): this; } interface JQuery extends ArrayLike, Iterable { } diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index c31352cb02..a5b668a9ba 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -1277,7 +1277,9 @@ function JQuery() { // $ExpectType JQuery $('p').show(); } + } + function queue() { function clearQueue() { // $ExpectType JQuery $('p').clearQueue('myQueue'); @@ -1379,6 +1381,17 @@ function JQuery() { // $ExpectType JQuery $('p').stop(true); } + + function promise() { + // $ExpectType { description: string; } & Promise, any, any> + $('p').promise('myQueue', { description: 'desc' }); + + // $ExpectType { description: string; } & Promise, any, any> + $('p').promise({ description: 'desc' }); + + // $ExpectType Promise, any, any> + $('p').promise(); + } } function events() { @@ -2403,6 +2416,978 @@ function JQuery() { }); } } + + function manipulation() { + function after() { + // $ExpectType JQuery + $('p').after('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); + + // $ExpectType JQuery + $('p').after(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return '

'; + }); + + // $ExpectType JQuery + $('p').after(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Element(); + }); + + // $ExpectType JQuery + $('p').after(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Text(); + }); + + // $ExpectType JQuery + $('p').after(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return [new Element(), new Text()]; + }); + + // $ExpectType JQuery + $('p').after(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return $('p'); + }); + } + + function append() { + // $ExpectType JQuery + $('p').append('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); + + // $ExpectType JQuery + $('p').append(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return '

'; + }); + + // $ExpectType JQuery + $('p').append(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Element(); + }); + + // $ExpectType JQuery + $('p').append(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Text(); + }); + + // $ExpectType JQuery + $('p').append(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return [new Element(), new Text()]; + }); + + // $ExpectType JQuery + $('p').append(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return $('p'); + }); + } + + function before() { + // $ExpectType JQuery + $('p').before('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); + + // $ExpectType JQuery + $('p').before(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return '

'; + }); + + // $ExpectType JQuery + $('p').before(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Element(); + }); + + // $ExpectType JQuery + $('p').before(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Text(); + }); + + // $ExpectType JQuery + $('p').before(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return [new Element(), new Text()]; + }); + + // $ExpectType JQuery + $('p').before(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return $('p'); + }); + } + + function prepend() { + // $ExpectType JQuery + $('p').prepend('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); + + // $ExpectType JQuery + $('p').prepend(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return '

'; + }); + + // $ExpectType JQuery + $('p').prepend(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Element(); + }); + + // $ExpectType JQuery + $('p').prepend(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return new Text(); + }); + + // $ExpectType JQuery + $('p').prepend(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return [new Element(), new Text()]; + }); + + // $ExpectType JQuery + $('p').prepend(function(index, html) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + html; + + return $('p'); + }); + } + + function appendTo() { + // $ExpectType JQuery + $('span').appendTo('p'); + + // $ExpectType JQuery + $('span').appendTo('

'); + + // $ExpectType JQuery + $('span').appendTo(new HTMLElement()); + + // $ExpectType JQuery + $('span').appendTo([new HTMLElement()]); + + // $ExpectType JQuery + $('span').appendTo($('p')); + } + + function insertAfter() { + // $ExpectType JQuery + $('span').insertAfter('p'); + + // $ExpectType JQuery + $('span').insertAfter('

'); + + // $ExpectType JQuery + $('span').insertAfter(new HTMLElement()); + + // $ExpectType JQuery + $('span').insertAfter([new HTMLElement()]); + + // $ExpectType JQuery + $('span').insertAfter($('p')); + } + + function insertBefore() { + // $ExpectType JQuery + $('span').insertBefore('p'); + + // $ExpectType JQuery + $('span').insertBefore('

'); + + // $ExpectType JQuery + $('span').insertBefore(new HTMLElement()); + + // $ExpectType JQuery + $('span').insertBefore([new HTMLElement()]); + + // $ExpectType JQuery + $('span').insertBefore($('p')); + } + + function prependTo() { + // $ExpectType JQuery + $('span').prependTo('p'); + + // $ExpectType JQuery + $('span').prependTo('

'); + + // $ExpectType JQuery + $('span').prependTo(new HTMLElement()); + + // $ExpectType JQuery + $('span').prependTo([new HTMLElement()]); + + // $ExpectType JQuery + $('span').prependTo($('p')); + } + + function clone() { + // $ExpectType JQuery + $('p').clone(true, true); + + // $ExpectType JQuery + $('p').clone(true); + + // $ExpectType JQuery + $('p').clone(); + } + + function detach() { + // $ExpectType JQuery + $('p').detach('span'); + + // $ExpectType JQuery + $('p').detach(); + } + + function empty() { + // $ExpectType JQuery + $('p').empty(); + } + + function remove() { + // $ExpectType JQuery + $('p').remove('span'); + + // $ExpectType JQuery + $('p').remove(); + } + + function replaceAll() { + // $ExpectType JQuery + $('p').replaceAll('span'); + + // $ExpectType JQuery + $('p').replaceAll($('span')); + + // $ExpectType JQuery + $('p').replaceAll(new HTMLElement()); + + // $ExpectType JQuery + $('p').replaceAll([new HTMLElement()]); + } + + function replaceWith() { + // $ExpectType JQuery + $('p').replaceWith(''); + + // $ExpectType JQuery + $('p').replaceWith($('span')); + + // $ExpectType JQuery + $('p').replaceWith(new HTMLElement()); + + // $ExpectType JQuery + $('p').replaceWith([new HTMLElement()]); + + // $ExpectType JQuery + $('p').replaceWith(function() { + // $ExpectType HTMLElement + this; + + return this; + }); + } + + function unwrap() { + // $ExpectType JQuery + $('p').unwrap('span'); + + // $ExpectType JQuery + $('p').unwrap(); + } + + function wrap() { + // $ExpectType JQuery + $('p').wrap('span'); + + // $ExpectType JQuery + $('p').wrap(''); + + // $ExpectType JQuery + $('p').wrap(new HTMLElement()); + + // $ExpectType JQuery + $('p').wrap($('span')); + + // $ExpectType JQuery + $('p').wrap(function(index) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + + return ''; + }); + + // $ExpectType JQuery + $('p').wrap(function(index) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + + return $('span'); + }); + } + + function wrapAll() { + // $ExpectType JQuery + $('p').wrapAll('span'); + + // $ExpectType JQuery + $('p').wrapAll(''); + + // $ExpectType JQuery + $('p').wrapAll(new HTMLElement()); + + // $ExpectType JQuery + $('p').wrapAll($('span')); + + // $ExpectType JQuery + $('p').wrapAll(function() { + // $ExpectType HTMLElement + this; + + return ''; + }); + + // $ExpectType JQuery + $('p').wrapAll(function() { + // $ExpectType HTMLElement + this; + + return $('span'); + }); + } + + function wrapInner() { + // $ExpectType JQuery + $('p').wrapInner('span'); + + // $ExpectType JQuery + $('p').wrapInner(''); + + // $ExpectType JQuery + $('p').wrapInner(new HTMLElement()); + + // $ExpectType JQuery + $('p').wrapInner($('span')); + + // $ExpectType JQuery + $('p').wrapInner(function(index) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + + return ''; + }); + + // $ExpectType JQuery + $('p').wrapInner(function(index) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + + return $('span'); + }); + + // $ExpectType JQuery + $('p').wrapInner(function(index) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + + return new HTMLElement(); + }); + } + + function html() { + // $ExpectType JQuery + $('p').html(''); + + // $ExpectType JQuery + $('p').html(function(index, oldhtml) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + oldhtml; + + return oldhtml; + }); + + // $ExpectType string + $('p').html(); + } + + function text() { + // $ExpectType JQuery + $('p').text('myText'); + + // $ExpectType JQuery + $('p').text(4); + + // $ExpectType JQuery + $('p').text(true); + + // $ExpectType JQuery + $('p').text(function(index, text) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + text; + + return 'myText'; + }); + + // $ExpectType JQuery + $('p').text(function(index, text) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + text; + + return 3; + }); + + // $ExpectType JQuery + $('p').text(function(index, text) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + text; + + return false; + }); + + // $ExpectType string + $('p').text(); + } + + function val() { + // $ExpectType JQuery + $('p').val('myVal'); + + // $ExpectType JQuery + $('p').val(5); + + // $ExpectType JQuery + $('p').val(['myVal']); + + // $ExpectType JQuery + $('p').val(function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 'myVal'; + }); + + // $ExpectType string | number | string[] | undefined + $('p').val(); + } + } + + function traversing() { + function add() { + // $ExpectType JQuery + $('p').add('span', new HTMLElement()); + + // $ExpectType JQuery + $('p').add('span'); + + // $ExpectType JQuery + $('p').add(new HTMLElement()); + + // $ExpectType JQuery + $('p').add([new HTMLElement()]); + + // $ExpectType JQuery + $('p').add(''); + + // $ExpectType JQuery + $('p').add($('span')); + } + + function closest() { + // $ExpectType JQuery + $('p').closest('span', new HTMLElement()); + + // $ExpectType JQuery + $('p').closest('span'); + + // $ExpectType JQuery + $('p').closest(new HTMLElement()); + + // $ExpectType JQuery + $('p').closest($('span')); + } + + function find() { + // $ExpectType JQuery + $('p').find('span'); + + // $ExpectType JQuery + $('p').find(new HTMLElement()); + + // $ExpectType JQuery + $('p').find($('span')); + } + + function addBack() { + // $ExpectType JQuery + $('p').addBack('span'); + + // $ExpectType JQuery + $('p').addBack(); + } + + function children() { + // $ExpectType JQuery + $('p').children('span'); + + // $ExpectType JQuery + $('p').children(); + } + + function siblings() { + // $ExpectType JQuery + $('p').siblings('span'); + + // $ExpectType JQuery + $('p').siblings(); + } + + function contents() { + // $ExpectType JQuery + $('p').contents(); + } + + function end() { + // $ExpectType JQuery + $('p').end(); + } + + function first() { + // $ExpectType JQuery + $('p').first(); + } + + function last() { + // $ExpectType JQuery + $('p').last(); + } + + function offsetParent() { + // $ExpectType JQuery + $('p').offsetParent(); + } + + function filter() { + // $ExpectType JQuery + $('p').filter('span'); + + // $ExpectType JQuery + $('p').filter(new HTMLElement()); + + // $ExpectType JQuery + $('p').filter([new HTMLElement()]); + + // $ExpectType JQuery + $('p').filter($('span')); + + // $ExpectType JQuery + $('p').filter(function(index, element) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + element; + + return false; + }); + } + + function not() { + // $ExpectType JQuery + $('p').not('span'); + + // $ExpectType JQuery + $('p').not(new HTMLElement()); + + // $ExpectType JQuery + $('p').not([new HTMLElement()]); + + // $ExpectType JQuery + $('p').not($('span')); + + // $ExpectType JQuery + $('p').not(function(index, element) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + element; + + return false; + }); + } + + function is() { + // $ExpectType boolean + $('p').is('span'); + + // $ExpectType boolean + $('p').is(new HTMLElement()); + + // $ExpectType boolean + $('p').is([new HTMLElement()]); + + // $ExpectType boolean + $('p').is($('span')); + + // $ExpectType boolean + $('p').is(function(index, element) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + element; + + return false; + }); + } + + function next() { + // $ExpectType JQuery + $('p').next('span'); + + // $ExpectType JQuery + $('p').next(); + } + + function nextAll() { + // $ExpectType JQuery + $('p').nextAll('span'); + + // $ExpectType JQuery + $('p').nextAll(); + } + + function nextUntil() { + // $ExpectType JQuery + $('p').nextUntil('span', 'span'); + + // $ExpectType JQuery + $('p').nextUntil(new HTMLElement(), 'span'); + + // $ExpectType JQuery + $('p').nextUntil($('span'), 'span'); + + // $ExpectType JQuery + $('p').nextUntil('span'); + + // $ExpectType JQuery + $('p').nextUntil(new HTMLElement()); + + // $ExpectType JQuery + $('p').nextUntil($('span')); + + // $ExpectType JQuery + $('p').nextUntil(); + } + + function prev() { + // $ExpectType JQuery + $('p').prev('span'); + + // $ExpectType JQuery + $('p').prev(); + } + + function prevAll() { + // $ExpectType JQuery + $('p').prevAll('span'); + + // $ExpectType JQuery + $('p').prevAll(); + } + + function prevUntil() { + // $ExpectType JQuery + $('p').prevUntil('span', 'span'); + + // $ExpectType JQuery + $('p').prevUntil(new HTMLElement(), 'span'); + + // $ExpectType JQuery + $('p').prevUntil($('span'), 'span'); + + // $ExpectType JQuery + $('p').prevUntil('span'); + + // $ExpectType JQuery + $('p').prevUntil(new HTMLElement()); + + // $ExpectType JQuery + $('p').prevUntil($('span')); + + // $ExpectType JQuery + $('p').prevUntil(); + } + + function parent() { + // $ExpectType JQuery + $('p').parent('span'); + + // $ExpectType JQuery + $('p').parent(); + } + + function parents() { + // $ExpectType JQuery + $('p').parents('span'); + + // $ExpectType JQuery + $('p').parents(); + } + + function parentsUntil() { + // $ExpectType JQuery + $('p').parentsUntil('span', 'span'); + + // $ExpectType JQuery + $('p').parentsUntil(new HTMLElement(), 'span'); + + // $ExpectType JQuery + $('p').parentsUntil($('span'), 'span'); + + // $ExpectType JQuery + $('p').parentsUntil('span'); + + // $ExpectType JQuery + $('p').parentsUntil(new HTMLElement()); + + // $ExpectType JQuery + $('p').parentsUntil($('span')); + + // $ExpectType JQuery + $('p').parentsUntil(); + } + + function eq() { + // $ExpectType JQuery + $('p').eq(0); + } + + function has() { + // $ExpectType JQuery + $('p').has('span'); + + // $ExpectType JQuery + $('p').has(new HTMLElement()); + } + + function map() { + // $ExpectType JQuery + $('p').map(function(index, domElement) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + domElement; + + return 'myVal'; + }); + + // $ExpectType JQuery + $('p').map(function(index, domElement) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + domElement; + + return ['myVal1', 'myVal2']; + }); + + // $ExpectType JQuery + $('p').map(function(index, domElement) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + domElement; + + return null; + }); + + // $ExpectType JQuery + $('p').map(function(index, domElement) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + domElement; + + return undefined; + }); + } + + function slice() { + // $ExpectType JQuery + $('p').slice(0, 10); + + // $ExpectType JQuery + $('p').slice(0); + } + } } function JQueryStatic() { diff --git a/types/jquery/test/example-tests.ts b/types/jquery/test/example-tests.ts index 961e239192..bbb5d15d6c 100644 --- a/types/jquery/test/example-tests.ts +++ b/types/jquery/test/example-tests.ts @@ -4056,7 +4056,7 @@ function examples() { function promise_0() { var div = $('
'); - div.promise().done(function(this: JQuery, arg1: JQuery) { + div.promise().done(function(this: typeof div, arg1) { // Will fire right away and alert "true" alert(this === div && arg1 === div); }); From 40e4a08d669ff1f62e0db17aa298127cd74459b7 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 21 Jun 2017 20:30:39 -0400 Subject: [PATCH 041/100] [jquery] Clean up misc-related methods on JQuery. Add tests for misc-related methods on JQuery. --- types/jquery/index.d.ts | 4 +- types/jquery/jquery-tests.ts | 76 ++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 0e007b689e..60583af1bc 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -620,7 +620,7 @@ interface JQuery { * @see {@link https://api.jquery.com/each/} * @since 1.0 */ - each(fn: (this: TElement, index: number, element: Element) => void | false): this; + each(fn: (this: TElement, index: number, element: TElement) => void | false): this; /** * Remove all child nodes of the set of matched elements from the DOM. * @@ -985,7 +985,7 @@ interface JQuery { * @since 1.0 * @since 1.4 */ - index(element?: Element | JQuery | JQuery.Selector): number; + index(element?: JQuery.Selector | Element | JQuery): number; /** * Set the CSS inner height of each element in the set of matched elements. * diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index a5b668a9ba..2536144845 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -3387,6 +3387,82 @@ function JQuery() { // $ExpectType JQuery $('p').slice(0); } + + function pushStack() { + // $ExpectType JQuery + $('p').pushStack([new HTMLElement()], 'name', ['arg']); + + // $ExpectType JQuery + $('p').pushStack([new HTMLElement()]); + } + } + + function misc() { + function serialize() { + // $ExpectType string + $('p').serialize(); + } + + function serializeArray() { + // $ExpectType NameValuePair[] + $('p').serializeArray(); + } + + function each() { + // $ExpectType JQuery + $('p').each(function(index, element) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + element; + }); + + // $ExpectType JQuery + $('p').each(function(index, element) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType HTMLElement + element; + + return false; + }); + } + + function extend() { + // $ExpectType JQuery + $.fn.extend({ myPlugin: {} }); + } + + function get() { + // $ExpectType HTMLElement + $('p').get(0); + + // $ExpectType HTMLElement[] + $('p').get(); + } + + function index() { + // $ExpectType number + $('p').index('span'); + + // $ExpectType number + $('p').index(new HTMLElement()); + + // $ExpectType number + $('p').index($('span')); + + // $ExpectType number + $('p').index(); + } + + function toArray() { + // $ExpectType HTMLElement[] + $('p').toArray(); + } } } From 9391a9db34e241e044d9bc324721917a16c644a3 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 21 Jun 2017 20:43:05 -0400 Subject: [PATCH 042/100] [jquery.pjax] Add TypeScript Version: 2.3 to header. --- types/jquery.pjax/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jquery.pjax/index.d.ts b/types/jquery.pjax/index.d.ts index 1313217a9c..e71dec35e4 100644 --- a/types/jquery.pjax/index.d.ts +++ b/types/jquery.pjax/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/defunkt/jquery-pjax // Definitions by: Junle Li // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// From 8df4a3060fbbdcddd4c1407882fc297f2c6f3bdd Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 21 Jun 2017 20:43:31 -0400 Subject: [PATCH 043/100] [royalslider] Add TypeScript Version: 2.3 to header. --- types/royalslider/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/royalslider/index.d.ts b/types/royalslider/index.d.ts index 9595f2d494..2eaf6bfe7f 100644 --- a/types/royalslider/index.d.ts +++ b/types/royalslider/index.d.ts @@ -2,6 +2,7 @@ // Project: http://dimsemenov.com/plugins/royal-slider/documentation/ // Definitions by: Christiaan Rakowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// From ecd78f92c07de648be702b21abf1e82dff456424 Mon Sep 17 00:00:00 2001 From: Michael Handley Date: Wed, 21 Jun 2017 17:52:25 -0700 Subject: [PATCH 044/100] Use HTMLElement instead of React.ReactNode for node type --- types/react-sortable-hoc/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-sortable-hoc/index.d.ts b/types/react-sortable-hoc/index.d.ts index 1ae88e258a..784f1c1372 100644 --- a/types/react-sortable-hoc/index.d.ts +++ b/types/react-sortable-hoc/index.d.ts @@ -12,7 +12,7 @@ declare module 'react-sortable-hoc' { export type Offset = number | string; export interface SortStart { - node: React.ReactNode; + node: HTMLElement; index: number; collection: Offset; } From 1412dd25249f8c1cb9a0c4c48084060bfc383798 Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Wed, 21 Jun 2017 18:24:35 -0700 Subject: [PATCH 045/100] Export DraftEditorProps --- types/draft-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/draft-js/index.d.ts b/types/draft-js/index.d.ts index 2474ecf56a..135824039e 100644 --- a/types/draft-js/index.d.ts +++ b/types/draft-js/index.d.ts @@ -54,7 +54,7 @@ declare namespace Draft { * These props are analagous to `value` and `onChange` in controlled React * text inputs. */ - interface DraftEditorProps { + export interface DraftEditorProps { editorState: EditorState; onChange(editorState: EditorState): void; From f10990cb031462390890c8f25091474f929564aa Mon Sep 17 00:00:00 2001 From: Nikita Gubchenko Date: Thu, 22 Jun 2017 11:17:20 +0300 Subject: [PATCH 046/100] Victory: added tests for VictoryLegend --- types/victory/victory-tests.tsx | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/types/victory/victory-tests.tsx b/types/victory/victory-tests.tsx index c6e7fb24b9..2f67b0c1f3 100644 --- a/types/victory/victory-tests.tsx +++ b/types/victory/victory-tests.tsx @@ -10,7 +10,9 @@ import { VictoryLine, VictoryChart, VictoryScatter, - VictoryPie + VictoryPie, + VictoryTheme, + VictoryLegend } from "victory"; // VictoryAnimation test @@ -607,3 +609,31 @@ test = ( test = ( ); + +// VictoryLegend test + +test = ( + +); From b3565001e27053d0f2377cdfc7910630cf2b5dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Lesiecki?= Date: Thu, 22 Jun 2017 11:46:30 +0200 Subject: [PATCH 047/100] update rollup.Option.entry type --- types/rollup/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/rollup/index.d.ts b/types/rollup/index.d.ts index 35cd523e2c..0f7a3e2163 100644 --- a/types/rollup/index.d.ts +++ b/types/rollup/index.d.ts @@ -86,7 +86,7 @@ export interface Bundle { export interface Options { /** The bundle's entry point (e.g. your `main.js` or `app.js` or `index.js`) */ - entry: string + entry: string | string[] /** A previous bundle. Use it to speed up subsequent bundles :) */ cache?: Bundle /** From cb8b474117833504681c7f72a77598388582ceaf Mon Sep 17 00:00:00 2001 From: Bernd Hacker Date: Thu, 22 Jun 2017 11:52:12 +0200 Subject: [PATCH 048/100] fix type for H.service.ServiceResult --- types/heremaps/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/heremaps/index.d.ts b/types/heremaps/index.d.ts index 206a932e68..8218718790 100644 --- a/types/heremaps/index.d.ts +++ b/types/heremaps/index.d.ts @@ -4603,9 +4603,11 @@ declare namespace H { /** * This type encapsulates a response object provider by a HERE platform service. + * In most cases the HERE Maps API for JavaScript communicates with the HERE REST APIs, using the JSON-P protocol. The resulting JSON response is parsed and provided to a callback function. + * The structure of a service response object is specific to each service. */ interface ServiceResult { - [key: string]: string; + [key: string]: any; } /** From 6c2fd39fcde2a3a54a64f6b7ec85817823a106c7 Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:35:03 +0800 Subject: [PATCH 049/100] [hapi] Added test for request.query --- types/hapi/test/request/query.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 types/hapi/test/request/query.ts diff --git a/types/hapi/test/request/query.ts b/types/hapi/test/request/query.ts new file mode 100644 index 0000000000..c6507c2da0 --- /dev/null +++ b/types/hapi/test/request/query.ts @@ -0,0 +1,14 @@ +// Added test in addition to docs, for request.query + +import * as Hapi from 'hapi'; + +interface GetThingQuery { + name: string; +} + +const handler: Hapi.RouteHandler = function (request, reply) { + + const query = request.query as GetThingQuery; + + return reply(`You asked for ${query.name}`); +}; From 161f65a1939e009ace1c1514fe2bfee234f087be Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:36:04 +0800 Subject: [PATCH 050/100] [hapi] Updated docstring of request.query to the latest docs --- types/hapi/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 502b8d4362..c03d6a954b 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1935,8 +1935,9 @@ export class Request extends Podium { /** same as pre but represented as the response object created by the pre method. */ preResponses: Object; /** - * an object containing the query parameters. - * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 + * by default the object outputted from [node's URL parse()](https://nodejs.org/docs/latest/api/url.html#url_urlobject_query) method. + * Might also be set indirectly via [request.setUrl](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17354#requestseturlurl-striptrailingslash) in which case it may be + * a string (if url is set to an object with the query attribute as an unparsed string). */ query: any; /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ From c898c05c771711d68e689d1b1a2d5436be7628c2 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Thu, 22 Jun 2017 07:36:32 -0400 Subject: [PATCH 051/100] [jquery] Update global DOM usage in README. --- types/jquery/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jquery/README.md b/types/jquery/README.md index d1bbad05fc..632805df4a 100644 --- a/types/jquery/README.md +++ b/types/jquery/README.md @@ -9,7 +9,7 @@ When jQuery is globally available, you can use `jQuery` and `$` directly. When you want to import jQuery as a module and have a global DOM available (e.g. browser and browser-like environments): ```typescript -import * as jQuery from 'jquery'; +import jQuery = require('jquery'); ``` #### Importing (without a global DOM available) From 0c95065c18c63b7354ed2821ddeee2067fe2b9cc Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:40:51 +0800 Subject: [PATCH 052/100] [hapi] Keep the version number of type definition as 16.1 --- types/hapi/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index c03d6a954b..91432e1d1f 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for hapi 16.2 +// Type definitions for hapi 16.1 // Project: https://github.com/hapijs/hapi // Definitions by: Jason Swearingen , AJP // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 94f1d2c48ea5b459bd23bf1e3e0a160f86756343 Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:43:15 +0800 Subject: [PATCH 053/100] Add the test file for request.query to tsconfig.json --- types/hapi/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/hapi/tsconfig.json b/types/hapi/tsconfig.json index 01c5a12c89..39ff8e810c 100644 --- a/types/hapi/tsconfig.json +++ b/types/hapi/tsconfig.json @@ -35,6 +35,7 @@ "test/request/generate-response.ts", "test/request/get-log.ts", "test/request/log.ts", + "test/request/query.ts", "test/request/set-method.ts", "test/request/set-url.ts", "test/request/tail.ts", From 80825332fb797dc4b279f059c0387d0ac348a8e0 Mon Sep 17 00:00:00 2001 From: Bernd Hacker Date: Thu, 22 Jun 2017 14:41:59 +0200 Subject: [PATCH 054/100] fix typings, extend definition of H.service.ServiceResult --- types/heremaps/heremaps-tests.ts | 77 ++++++++++++++- types/heremaps/index.d.ts | 160 ++++++++++++++++++++++++++++--- 2 files changed, 222 insertions(+), 15 deletions(-) diff --git a/types/heremaps/heremaps-tests.ts b/types/heremaps/heremaps-tests.ts index 01360c1bdf..d3e161cb74 100644 --- a/types/heremaps/heremaps-tests.ts +++ b/types/heremaps/heremaps-tests.ts @@ -44,7 +44,7 @@ let map = new H.Map(mapContainer, defaultLayers.normal.map, { // initial center and zoom level of the map zoom: 16, // Champs-Elysees - center: {lat: 48.869145, lng: 2.314298} + center: { lat: 48.869145, lng: 2.314298 } }); // Step 3: make the map interactive @@ -85,3 +85,78 @@ let polyline = new H.map.Polyline(new H.geo.Strip()); // tslint:disable-next-line:array-type let clipArr: Array>; clipArr = polyline.clip(new H.geo.Rect(5, 5, 5, 5)); + +let router = platform.getRoutingService(); +let calculateRouteParams = { + waypoint0: 'geo!52.5,13.4', + waypoint1: 'geo!52.5,13.45', + mode: 'fastest;car;traffic:disabled' +}; +router.calculateRoute( + calculateRouteParams, + (result) => { + console.log(result.response.route[0]); + }, + (error) => { + console.log(error); + } +); + +let places = platform.getPlacesService(); +let entryPoint = H.service.PlacesService.EntryPoint; +places.request( + entryPoint.SEARCH, + { + at: '52.5044,13.3909', + q: 'pizza' + }, + (response) => { + console.log(response); + let items = response.results.items; + places.follow( + items[0].href, + (resp) => { + console.log(resp); + }, + (resp) => { + console.log('ERROR: ' + resp); + } + ); + }, + (error) => { + console.log('ERROR: ' + error); + } +); + +let geocoder = platform.getGeocodingService(); +let geocodingParams: H.service.ServiceParameters = { + searchText: '425 W Randolph Street, Chicago' +}; +geocoder.geocode( + geocodingParams, + (result) => { + console.log(result); + console.log(result.Response.View[0].Result[0].Location.DisplayPosition); + }, + (error) => { + console.log(error); + } +); + +// deprecated but w/e +let enterprieseRouter = platform.getEnterpriseRoutingService(); +let calculateIsoline: H.service.ServiceParameters = { + start: 'geo!52.5,13.4', + distance: '1000,2000', + mode: 'fastest;car;traffic:disabled' +}; +enterprieseRouter.calculateIsoline( + calculateIsoline, + (result) => { + console.log(result); + console.log(result.Response.isolines[0]); + }, + (error) => { + console.log(error); + } +); diff --git a/types/heremaps/index.d.ts b/types/heremaps/index.d.ts index 8218718790..ca32173bed 100644 --- a/types/heremaps/index.d.ts +++ b/types/heremaps/index.d.ts @@ -4301,14 +4301,15 @@ declare namespace H { /** * This is generic method to query places RestAPI. - * @param entryPoint {string} - can be one of available entry points H.service.PlacesService.EntryPoint i.e value of H.service.PlacesService.EntryPoint.SEARCH + * @param entryPoint {H.service.PlacesService.EntryPoint} - can be one of available entry points H.service.PlacesService.EntryPoint i.e value of H.service.PlacesService.EntryPoint.SEARCH * @param entryPointParams {Object} - parameter map key value pairs will be transformed into the url key=value parametes. For entry point parameters description please refer to places * restful api documentation documentation for available parameters for chose entry point * @param onResult {Function} - callback which is called when result is returned * @param onError {Function} - callback which is called when error occured (i.e request timeout) * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - request(entryPoint: string, entryPointParams: {}, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + request(entryPoint: H.service.PlacesService.EntryPoint, entryPointParams: {}, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): + H.service.JsonpRequestHandle; /** * Function triggers places api 'search' entry point. Please refer to documentation for parameter specification and response handling. @@ -4317,7 +4318,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - search(searchParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + search(searchParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'suggestions' entry point. Please refer to documentation for parameter specification and response handling. @@ -4326,7 +4327,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - suggest(suggestParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + suggest(suggestParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'explore' entry point. Please refer to documentation for parameter specification and response handling. @@ -4335,7 +4336,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - explore(exploreParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + explore(exploreParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'around' entry point. Please refer to documentation for parameter specification and response handling. @@ -4344,7 +4345,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - around(aroundParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + around(aroundParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'here' entry point. Please refer to documentation for parameter specification and response handling. @@ -4353,7 +4354,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - here(hereParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + here(hereParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'categories' entry point. Please refer to documentation for parameter specification and response handling. @@ -4362,7 +4363,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - categories(categoriesParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + categories(categoriesParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * This method should be used to follow hyperlinks available in results returned by dicovery queries. @@ -4372,7 +4373,7 @@ declare namespace H { * @param opt_additionalParameters {Object=} - additional parameters to send with request * @returns {H.service.JsonpRequestHandle} - jsonp resquest handle */ - follow(hyperlink: string, onResult: () => void, onError: () => void, opt_additionalParameters?: {}): H.service.JsonpRequestHandle; + follow(hyperlink: string, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void, opt_additionalParameters?: {}): H.service.JsonpRequestHandle; } namespace PlacesService { @@ -4603,11 +4604,142 @@ declare namespace H { /** * This type encapsulates a response object provider by a HERE platform service. - * In most cases the HERE Maps API for JavaScript communicates with the HERE REST APIs, using the JSON-P protocol. The resulting JSON response is parsed and provided to a callback function. - * The structure of a service response object is specific to each service. */ interface ServiceResult { [key: string]: any; + response?: { + language?: string, + route?: Array<{ + leg: Array<{ + maneuver: Array<{ + id: string, + instruction: string, + length: number, + note: string[], + position: { + latitude: number, + longitude: number + }, + shape: string[], + travelTime: number, + _type: string + }> + }>, + mode: { + feature: any[], + trafficMode: string, + transportModes: string[], + type: string + } + shape: string[], + summary: { + baseTime: number, + distance: number, + flags: string[], + text: string, + trafficTime: number, + travelTime: number + } + waypoint: Array<{ + label: string, + linkId: string, + mappedPosition: { + latitude: number, + longitude: number + }, + mappedRoadName: string, + originalPosition: { + latitude: number, + longitude: number + }, + shapeIndex: number, + sideOfStreet: string, + spot: number, + type: string + }> + }>, + metaInfo: {} + }; + results?: { + items?: any[], + next?: string + }; + search?: { + context: { + href: string, + location: { + address: { + city: string, + country: string, + countryCode: string, + county: string, + district: string, + house: string, + postalCode: string, + stateCode: string, + street: string, + text: string + }, + position: number[] + }, + type: string + } + }; + Response?: { + MetaInfo: { + Timestamp: string + }, + View: Array<{ + Result: Array<{ + Location: { + Address: { + AdditionalData: Array<{ + key: string, + value: string + }>, + City: string, + Country: string, + County: string, + District: string, + HouseNumber: string, + Label: string, + PostalCode: string, + State: string, + Street: string + }, + DisplayPosition: { + Latitude: number, + Longitude: number + }, + LocationId: string, + LocationType: string, + MapView: { + BottomRight: { + Latitude: number, + Longitude: number + }, + TopLeft: { + Latitude: number, + Longitude: number + } + }, + NavigationPosition: Array<{ + Latitude: number, + Longitude: number + }> + }, + MatchLevel: string, + MatchQuality: { + City: number, + HouseNumber: number, + Street: number[] + }, + MatchType: string, + Relevance: number + }> + }>, + isolines: any[] + }; } /** @@ -4636,7 +4768,7 @@ declare namespace H { * @param onError {function()} * @returns {H.service.JsonpRequestHandle} */ - requestIncidents(serviceParams: H.service.ServiceParameters, onResponse: (result: H.service.ServiceResult) => void, onError: () => void): H.service.JsonpRequestHandle; + requestIncidents(serviceParams: H.service.ServiceParameters, onResponse: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * This method requests traffic incident information by tile coordinates @@ -4648,8 +4780,8 @@ declare namespace H { * @param opt_serviceParams {H.service.ServiceParameters=} - optional service parameters to be added to the request * @returns {H.service.JsonpRequestHandle} */ - requestIncidentsByTile(x: number, y: number, z: number, onResponse: (result: H.service.ServiceResult) => void, onError: () => void, opt_serviceParams?: H.service.ServiceParameters): - H.service.JsonpRequestHandle; + requestIncidentsByTile(x: number, y: number, z: number, onResponse: (result: H.service.ServiceResult) => void, onError: (error: Error) => void, + opt_serviceParams?: H.service.ServiceParameters): H.service.JsonpRequestHandle; } namespace TrafficIncidentsService { From 624cf76cb21d541e45a40592638c46c35da6138c Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Thu, 22 Jun 2017 11:20:42 -0400 Subject: [PATCH 055/100] google-map-react update BootstrapURLKeys add support for client identifier and version instead of api key --- types/google-map-react/google-map-react-tests.tsx | 7 +++++-- types/google-map-react/index.d.ts | 5 +---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/types/google-map-react/google-map-react-tests.tsx b/types/google-map-react/google-map-react-tests.tsx index 959bb8e68a..c01d1e3cab 100644 --- a/types/google-map-react/google-map-react-tests.tsx +++ b/types/google-map-react/google-map-react-tests.tsx @@ -1,6 +1,9 @@ -import GoogleMapReact from 'google-map-react'; +import GoogleMapReact, { BootstrapURLKeys } from 'google-map-react'; import * as React from 'react'; const center = { lat: 0, lng: 0 }; -; +const key: BootstrapURLKeys = { key: 'my-google-maps-key' }; +const client: BootstrapURLKeys = { client: 'my-client-identifier', v: '3.28' , language: 'en' }; + +; diff --git a/types/google-map-react/index.d.ts b/types/google-map-react/index.d.ts index 080dbe5762..812a14d04a 100644 --- a/types/google-map-react/index.d.ts +++ b/types/google-map-react/index.d.ts @@ -6,10 +6,7 @@ import * as React from 'react'; -export interface BootstrapURLKeys { - key: string; - language?: string; -} +export type BootstrapURLKeys = ({ key: string; } | { client: string; v: string; }) & { language?: string }; export interface Options { styles?: any[]; From 114d42bcdb4c79fed85e7d87988ba0b219c85825 Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Thu, 22 Jun 2017 19:53:01 +0300 Subject: [PATCH 056/100] Created type definition & wrote test case --- types/mongoose-simple-random/index.d.ts | 12 ++++++++++ .../mongoose-simple-random-tests.ts | 15 +++++++++++++ types/mongoose-simple-random/tsconfig.json | 22 +++++++++++++++++++ types/mongoose-simple-random/tslint.json | 1 + 4 files changed, 50 insertions(+) create mode 100644 types/mongoose-simple-random/index.d.ts create mode 100644 types/mongoose-simple-random/mongoose-simple-random-tests.ts create mode 100644 types/mongoose-simple-random/tsconfig.json create mode 100644 types/mongoose-simple-random/tslint.json diff --git a/types/mongoose-simple-random/index.d.ts b/types/mongoose-simple-random/index.d.ts new file mode 100644 index 0000000000..deed6a036f --- /dev/null +++ b/types/mongoose-simple-random/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for mongoose-simple-random 0.4 +// Project: https://github.com/larryprice/mongoose-simple-random +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +declare module "mongoose" { + interface Model extends NodeJS.EventEmitter, ModelProperties { + findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void) + : void; + } +} diff --git a/types/mongoose-simple-random/mongoose-simple-random-tests.ts b/types/mongoose-simple-random/mongoose-simple-random-tests.ts new file mode 100644 index 0000000000..2aa9e18296 --- /dev/null +++ b/types/mongoose-simple-random/mongoose-simple-random-tests.ts @@ -0,0 +1,15 @@ +import * as mongoose from 'mongoose'; + +// test compatibility with other libraries - from @types/mongoose +import * as _ from 'lodash'; +import * as fs from "fs"; + +mongoose.Model.findRandom({ + username: { $ne: "DummyUser" }, + rating: { + $gt: 1, + $lt: 11, + }, +}, {}, { limit: 1 }, (error, data) => { + if (error) { console.error("Error!"); } else { console.log("Success!"); } +}); diff --git a/types/mongoose-simple-random/tsconfig.json b/types/mongoose-simple-random/tsconfig.json new file mode 100644 index 0000000000..28627f97dd --- /dev/null +++ b/types/mongoose-simple-random/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mongoose-simple-random-tests.ts" + ] +} diff --git a/types/mongoose-simple-random/tslint.json b/types/mongoose-simple-random/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mongoose-simple-random/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 8d0889c41a952b0beda53639843fedbd023b8ebb Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Thu, 22 Jun 2017 20:24:22 +0300 Subject: [PATCH 057/100] Excluded Object from banned types (as in mongoose) --- types/mongoose-simple-random/tslint.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/mongoose-simple-random/tslint.json b/types/mongoose-simple-random/tslint.json index 3db14f85ea..8438350251 100644 --- a/types/mongoose-simple-random/tslint.json +++ b/types/mongoose-simple-random/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // This package uses the Function type, and it will take effort to fix. + "ban-types": false + } +} \ No newline at end of file From 60e176f79b08f5c38d0081672f6c5de74ddc8781 Mon Sep 17 00:00:00 2001 From: Michael Handley Date: Thu, 22 Jun 2017 10:27:00 -0700 Subject: [PATCH 058/100] Use Element instead of HTMLElement for node --- types/react-sortable-hoc/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-sortable-hoc/index.d.ts b/types/react-sortable-hoc/index.d.ts index 784f1c1372..433824033a 100644 --- a/types/react-sortable-hoc/index.d.ts +++ b/types/react-sortable-hoc/index.d.ts @@ -12,7 +12,7 @@ declare module 'react-sortable-hoc' { export type Offset = number | string; export interface SortStart { - node: HTMLElement; + node: Element; index: number; collection: Offset; } From b90bbb2a093ec83e2863a0a880f20b5ec6a4a9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Thu, 22 Jun 2017 16:40:51 -0300 Subject: [PATCH 059/100] Update three-core.d.ts Changing normalScale type to Vector2 instead of number on MeshStandardMaterial --- types/three/three-core.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/three/three-core.d.ts b/types/three/three-core.d.ts index a160641d99..02cbe672e8 100644 --- a/types/three/three-core.d.ts +++ b/types/three/three-core.d.ts @@ -2626,7 +2626,7 @@ export interface MeshStandardMaterialParameters extends MaterialParameters { bumpMap?: Texture; bumpScale?: number; normalMap?: Texture; - normalScale?: number; + normalScale?: Vector2; displacementMap?: Texture; displacementScale?: number; displacementBias?: number; From 0837fea9eb5a2c65c35a3be137a8860083d07116 Mon Sep 17 00:00:00 2001 From: Marcin Dobosz Date: Thu, 22 Jun 2017 16:33:50 -0700 Subject: [PATCH 060/100] Add optional message param to sinon.match overload that takes a callback --- types/sinon/index.d.ts | 2 +- types/sinon/sinon-tests.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index a48df85258..75e87baae1 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -421,7 +421,7 @@ declare namespace Sinon { (value: string): SinonMatcher; (expr: RegExp): SinonMatcher; (obj: any): SinonMatcher; - (callback: (value: any) => boolean): SinonMatcher; + (callback: (value: any) => boolean, message?: string): SinonMatcher; any: SinonMatcher; defined: SinonMatcher; truthy: SinonMatcher; diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 9184ec6808..406c790a2b 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -119,6 +119,14 @@ function testPromises() { rejectsStub2 = sinon.stub().rejects("TypeError"); } +function testMatchInvoke() { + let stub = sinon.stub(); + stub(123); + stub.calledWithMatch(sinon.match(123)); + stub.calledWithMatch(sinon.match((value: any) => value === 123)); + stub.calledWithMatch(sinon.match((value: any) => value === 123, "Must be 123")); +} + function testSymbolMatch() { let stub = sinon.stub(); stub(Symbol('TestSymbol')); From 5f329049a0e3cd3f84bc9818c4dd2661777967b7 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 22 Jun 2017 16:51:57 -0700 Subject: [PATCH 061/100] Fix breaking change from co-vairant parameter call back --- types/recompose/recompose-tests.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/recompose/recompose-tests.tsx b/types/recompose/recompose-tests.tsx index a698de6ffa..0baef3db4d 100644 --- a/types/recompose/recompose-tests.tsx +++ b/types/recompose/recompose-tests.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { + ComponentEnhancer, Component, // Higher-order components mapProps, withProps, withPropsOnChange, withHandlers, @@ -69,13 +70,13 @@ function testWithHandlers() { const innerComponent = ({onChange, onSubmit}: InnerProps) =>
; - const enhancer = withHandlers({ + const enhancer = withHandlers({ onChange: (props: OutterProps) => (e: any) => {}, onSubmit: (props: OutterProps) => (e: any) => {}, }); const enhanced: React.ComponentClass = enhancer(innerComponent); - const enhancer2 = withHandlers((props: OutterProps) => ({ + const enhancer2 = withHandlers((props: OutterProps) => ({ onChange: (props: OutterProps) => (e: any) => {}, onSubmit: (props: OutterProps) => (e: any) => {}, })); From 2bdb5749a20abdfee2894f8b3461ecab4645adac Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 22 Jun 2017 16:52:50 -0700 Subject: [PATCH 062/100] Remove unuse import --- types/recompose/recompose-tests.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/types/recompose/recompose-tests.tsx b/types/recompose/recompose-tests.tsx index 0baef3db4d..a8bf57ee74 100644 --- a/types/recompose/recompose-tests.tsx +++ b/types/recompose/recompose-tests.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { - ComponentEnhancer, Component, // Higher-order components mapProps, withProps, withPropsOnChange, withHandlers, From 840d52474adbb0fbc7befb70d66eed52a79b98b7 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Fri, 23 Jun 2017 11:48:03 -0400 Subject: [PATCH 063/100] Added definitions for react-native-modalbox --- types/react-native-modalbox/index.d.ts | 205 ++++++++++++++++++ .../react-native-modalbox-tests.tsx | 155 +++++++++++++ types/react-native-modalbox/tsconfig.json | 24 ++ types/react-native-modalbox/tslint.json | 1 + 4 files changed, 385 insertions(+) create mode 100644 types/react-native-modalbox/index.d.ts create mode 100644 types/react-native-modalbox/react-native-modalbox-tests.tsx create mode 100644 types/react-native-modalbox/tsconfig.json create mode 100644 types/react-native-modalbox/tslint.json diff --git a/types/react-native-modalbox/index.d.ts b/types/react-native-modalbox/index.d.ts new file mode 100644 index 0000000000..af99a04f4d --- /dev/null +++ b/types/react-native-modalbox/index.d.ts @@ -0,0 +1,205 @@ +// Type definitions for react-native-modalbox 1.3 +// Project: https://github.com/maxs15/react-native-modalbox#readme +// Definitions by: Kyle Roach +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Typescript Version: 2.3.3 + +import * as React from 'react' +import { ViewProperties } from 'react-native' + +interface ModalProps extends ViewProperties { + /** + * Checks if the modal is open + * + * Default is false + * + * @type {boolean} + * @memberof ModalProps + */ + isOpen?: boolean + + /** + * Checks if the modal is disabled + * + * Default is false + * + * @type {boolean} + * @memberof ModalProps + */ + isDisabled?: boolean + + /** + * If the modal can be closed by pressing on the backdrop + * + * Default is true + * + * @type {boolean} + * @memberof ModalProps + */ + backdropPressToClose?: boolean + + /** + * If the modal can be closed by swiping + * + * Default is true + * + * @type {boolean} + * @memberof ModalProps + */ + swipeToClose?: boolean + + /** + * The threshold to reach in pixels to close the modal + * + * Default is 50 + * + * @type {number} + * @memberof ModalProps + */ + swipeThreshold?: number + + /** + * The height in pixels of the swipeable area + * + * Default is the Window Height + * + * @type {number} + * @memberof ModalProps + */ + swipeArea?: number + + /** + * The final position of the modal. + * Accepts top, center or bottom + * + * Default is center + * + * @type {string} + * @memberof ModalProps + */ + position?: 'top' | 'center' | 'bottom' | string + + /** + * The direction modal enters from + * + * Default is bottom + * + * @type {('top' | 'bottom' | string)} + * @memberof ModalProps + */ + entry?: 'top' | 'bottom' | string + + /** + * If a backdrop is displayed behind the modal + * + * Default is true + * + * @type {boolean} + * @memberof ModalProps + */ + backdrop?: boolean + + /** + * Opacity of the backdrop + * + * Default is 0.5 + * + * @type {number} + * @memberof ModalProps + */ + backdropOpacity?: number + + /** + * Background color of the backdrop + * + * Default is black + * + * @type {string} + * @memberof ModalProps + */ + backdropColor?: string + + /** + * Add an element in the backdrop (a close button for example) + * + * Default is null + * + * @type {JSX.Element} + * @memberof ModalProps + */ + backdropContent?: JSX.Element + + /** + * Duration of the animation + * + * Default is 400ms + * + * @type {number} + * @memberof ModalProps + */ + animationDuration?: number + + /** + * (Android only) Close modal when receiving back button event + * + * Default is false + * + * @type {boolean} + * @memberof ModalProps + */ + backButtonClose?: boolean + + /** + * If the modal should appear open without animation upon first mount + * + * Default is false + * + * @type {boolean} + * @memberof ModalProps + */ + startOpen?: boolean + + /** + * Event fired when the modal is closed and the animation is complete + * + * @memberof ModalProps + */ + onClosed?(): void + + /** + * Event fired when the modal is opened and the animation is complete + * + * @memberof ModalProps + */ + onOpen?(): void + + /** + * When the state of the swipe to close feature has changed + * (useful to change the content of the modal, display a message for example) + * + * @param {boolean} state + * + * @memberof ModalProps + */ + onClosingState?(state: boolean): void +} + +export default class Modal extends React.Component { + /** + * Open the modal + * + * @static + * + * @memberof Modal + */ + static open(): void + + /** + * Close the modal + * + * @static + * + * @memberof Modal + */ + static close(): void +} diff --git a/types/react-native-modalbox/react-native-modalbox-tests.tsx b/types/react-native-modalbox/react-native-modalbox-tests.tsx new file mode 100644 index 0000000000..01a937aea7 --- /dev/null +++ b/types/react-native-modalbox/react-native-modalbox-tests.tsx @@ -0,0 +1,155 @@ +// Test taken from project repo https://github.com/maxs15/react-native-modalbox/blob/master/Example/index.ios.js + +import * as React from 'react'; +import Modal from 'react-native-modalbox'; +import Button from 'react-native-button'; +import Slider from 'react-native-slider'; + +import { + Text, + StyleSheet, + ScrollView, + View, + Dimensions +} from 'react-native'; + +interface State { + isOpen: boolean; + isDisabled: boolean; + swipeToClose: boolean; + slideValue: boolean; +} + +class Example extends React.Component<{}, State> { + constructor() { + super(); + + this.state = { + isOpen: false, + isDisabled: false, + swipeToClose: true, + sliderValue: 0.3 + }; + } + + onClose() { + console.log('Modal just closed'); + } + + onOpen() { + console.log('Modal just openned'); + } + + onClosingState(state) { + console.log('the open/close of the swipeToClose just changed'); + } + + renderList() { + const list = []; + + for (let i = 0; i < 50; i++) { + list.push(Elem {i}); + } + + return list; + } + + render() { + var BContent = ; + + return ( + + + + + + + + + + Basic modal + + + + + Modal on top + + + + Modal centered + + + + + Modal on bottom with backdrop + this.setState({ sliderValue: value })} /> + + + this.setState({ isOpen: false })} style={[styles.modal, styles.modal4]} position={"center"} backdropContent={BContent}> + Modal with backdrop content + + + + + + {this.renderList()} + + + + + ); + } +} + +const styles = StyleSheet.create({ + wrapper: { + paddingTop: 50, + flex: 1 + }, + + modal: { + justifyContent: 'center', + alignItems: 'center' + }, + + modal2: { + height: 230, + backgroundColor: "#3B5998" + }, + + modal3: { + height: 300, + width: 300 + }, + + modal4: { + height: 300 + }, + + btn: { + margin: 10, + backgroundColor: "#3B5998", + color: "white", + padding: 10 + }, + + btnModal: { + position: "absolute", + top: 0, + right: 0, + width: 50, + height: 50, + backgroundColor: "transparent" + }, + + text: { + color: "black", + fontSize: 22 + } +}); diff --git a/types/react-native-modalbox/tsconfig.json b/types/react-native-modalbox/tsconfig.json new file mode 100644 index 0000000000..d9e48e4d6a --- /dev/null +++ b/types/react-native-modalbox/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-native-drawer-tests.tsx" + ] +} diff --git a/types/react-native-modalbox/tslint.json b/types/react-native-modalbox/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-modalbox/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 5944d43eff638d8d76a964c5a6e917aeb7c1d2a5 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Fri, 23 Jun 2017 11:58:57 -0400 Subject: [PATCH 064/100] [react-native-modalbox] Added tslint rules --- types/react-native-modalbox/tslint.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/types/react-native-modalbox/tslint.json b/types/react-native-modalbox/tslint.json index 3db14f85ea..87e0d4dcdd 100644 --- a/types/react-native-modalbox/tslint.json +++ b/types/react-native-modalbox/tslint.json @@ -1 +1,8 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true + } +} From a6390aea00237e774aef059e0fe7cccdb6ae2d11 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Fri, 23 Jun 2017 12:31:10 -0400 Subject: [PATCH 065/100] [jquery] Clean up methods on JQueryStatic. Add tests for methods on JQueryStatic. --- types/jquery/index.d.ts | 85 ++- types/jquery/jquery-tests.ts | 855 +++++++++++++++++++++++++++-- types/jquery/test/example-tests.ts | 2 +- 3 files changed, 858 insertions(+), 84 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 60583af1bc..8f5ceed0ec 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -2411,7 +2411,7 @@ interface JQueryStatic { * @since 1.4.3 */ cssNumber: JQuery.PlainObject; - readonly fn: JQuery; + readonly fn: JQuery; fx: { /** * The rate (in milliseconds) at which animations fire. @@ -2436,7 +2436,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.ready/} * @since 1.8 */ - ready: JQuery.Thenable; + ready: JQuery.Thenable>; /** * A collection of properties that represent the presence of different browser features or bugs. * Intended for jQuery's internal use; specific properties may be removed when they are no longer @@ -2489,7 +2489,9 @@ interface JQueryStatic { * @since 1.0 * @since 1.4 */ - (selector_object_callback?: JQuery.Selector | JQuery.TypeOrArray | JQuery.PlainObject | JQuery | (($: JQueryStatic) => void)): JQuery; + (selector_object_callback?: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery | + JQuery.PlainObject | + ((this: Document, $: JQueryStatic) => void)): JQuery; /** * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. * @@ -2629,7 +2631,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.each/} * @since 1.0 */ - each(array: ArrayLike, callback: (indexInArray: number, value: T) => false | any): ArrayLike; + each(array: ArrayLike, callback: (this: T, indexInArray: number, value: T) => false | any): ArrayLike; /** * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. * Arrays and array-like objects with a length property (such as a function's arguments object) are @@ -2640,7 +2642,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.each/} * @since 1.0 */ - each(obj: T, callback: (propertyName: K, valueOfProperty: T[K]) => false | any): T; + each(obj: T, callback: (this: T[K], propertyName: K, valueOfProperty: T[K]) => false | any): T; /** * Takes a string and throws an exception containing it. * @@ -2648,7 +2650,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.error/} * @since 1.4.1 */ - error(message: string): never; + error(message: string): any; /** * Escapes any character that has a special meaning in a CSS selector. * @@ -2719,7 +2721,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.extend/} * @since 1.1.4 */ - extend(deep: true, target: T, ...objects: U[]): T & U; + extend(deep: true, target: any, object1: any, ...objects: any[]): any; /** * Merge the contents of two or more objects together into the first object. * @@ -2782,7 +2784,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.extend/} * @since 1.0 */ - extend(target: T, ...objects: U[]): T & U; + extend(target: any, object1: any, ...objects: any[]): any; /** * Load data from the server using a HTTP GET request. * @@ -2835,7 +2837,7 @@ interface JQueryStatic { * @since 1.12 * @since 2.2 */ - get(url_settings?: string | JQuery.AjaxSettings): JQuery.jqXHR; + get(url_settings?: string | JQuery.UrlAjaxSettings): JQuery.jqXHR; /** * Load JSON-encoded data from the server using a GET HTTP request. * @@ -2868,7 +2870,7 @@ interface JQueryStatic { * @since 1.0 */ getScript(url: string, - success?: JQuery.jqXHR.DoneCallback): JQuery.jqXHR; + success?: JQuery.jqXHR.DoneCallback): JQuery.jqXHR; /** * Execute some JavaScript code globally. * @@ -2915,7 +2917,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.htmlPrefilter/} * @since 1.12/2.2 */ - htmlPrefilter(html: string): string; + htmlPrefilter(html: JQuery.htmlString): JQuery.htmlString; /** * Search for a specified value within an array and return its index (or -1 if not found). * @@ -3029,7 +3031,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.noConflict/} * @since 1.0 */ - noConflict(removeAll?: boolean): JQueryStatic; + noConflict(removeAll?: boolean): this; /** * An empty function. * @@ -3145,7 +3147,7 @@ interface JQueryStatic { * @since 1.12 * @since 2.2 */ - post(url_settings?: string | JQuery.AjaxSettings): JQuery.jqXHR; + post(url_settings?: string | JQuery.UrlAjaxSettings): JQuery.jqXHR; /** * Takes a function and returns a new one that will always have a particular context. * @@ -3178,16 +3180,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.queue/} * @since 1.3 */ - queue(element: Element, queueName: string, newQueue: JQuery.TypeOrArray>): JQuery; - /** - * Show the queue of functions to be executed on the matched element. - * - * @param element A DOM element to inspect for an attached queue. - * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. - * @see {@link https://api.jquery.com/jQuery.queue/} - * @since 1.3 - */ - queue(element: Element, queueName?: string): JQuery.Queue; + queue(element: T, queueName?: string, newQueue?: JQuery.TypeOrArray>): JQuery.Queue; /** * Handles errors thrown synchronously in functions wrapped in jQuery(). * @@ -3204,7 +3197,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.removeData/} * @since 1.2.3 */ - removeData(element: Element, name?: string): JQuery; + removeData(element: Element, name?: string): void; /** * Creates an object containing a set of properties ready to be used in the definition of custom animations. * @@ -3215,38 +3208,28 @@ interface JQueryStatic { * @since 1.1 */ speed(duration: JQuery.Duration, easing: string, complete: (this: TElement) => void): JQuery.EffectsOptions; - /** - * Creates an object containing a set of properties ready to be used in the definition of custom animations. - * - * @param easing A string indicating which easing function to use for the transition. - * @param complete A function to call once the animation is complete, called once per matched element. - * @see {@link https://api.jquery.com/jQuery.speed/} - * @since 1.1 - */ - speed(easing: string, complete: (this: TElement) => void): JQuery.EffectsOptions; /** * Creates an object containing a set of properties ready to be used in the definition of custom animations. * * @param duration A string or number determining how long the animation will run. - * @param easing_complete_settings A string indicating which easing function to use for the transition. - * A function to call once the animation is complete, called once per matched element. + * @param easing_complete A string indicating which easing function to use for the transition. + * A function to call once the animation is complete, called once per matched element. * @see {@link https://api.jquery.com/jQuery.speed/} * @since 1.0 * @since 1.1 */ speed(duration: JQuery.Duration, - easing_complete_settings: string | ((this: TElement) => void) | JQuery.SpeedSettings): JQuery.EffectsOptions; + easing_complete: string | ((this: TElement) => void)): JQuery.EffectsOptions; /** * Creates an object containing a set of properties ready to be used in the definition of custom animations. * - * @param duration_easing_complete_settings A string or number determining how long the animation will run. - * A string indicating which easing function to use for the transition. - * A function to call once the animation is complete, called once per matched element. + * @param duration_complete_settings A string or number determining how long the animation will run. + * A function to call once the animation is complete, called once per matched element. * @see {@link https://api.jquery.com/jQuery.speed/} * @since 1.0 * @since 1.1 */ - speed(duration_easing_complete_settings?: JQuery.Duration | string | ((this: TElement) => void) | JQuery.SpeedSettings): JQuery.EffectsOptions; + speed(duration_complete_settings?: JQuery.Duration | ((this: TElement) => void) | JQuery.SpeedSettings): JQuery.EffectsOptions; /** * Remove the whitespace from the beginning and end of a string. * @@ -3325,10 +3308,24 @@ declare namespace JQuery { // region Ajax + interface AjaxSettings extends AjaxSettingsBase { + /** + * A string containing the URL to which the request is sent. + */ + url?: string; + } + + interface UrlAjaxSettings extends AjaxSettingsBase { + /** + * A string containing the URL to which the request is sent. + */ + url: string; + } + /** * @see {@link http://api.jquery.com/jquery.ajax/#jQuery-ajax-settings} */ - interface AjaxSettings { + interface AjaxSettingsBase { /** * A set of key/value pairs that map a given dataType to its MIME type, which gets sent in the Accept * request header. This header tells the server what kind of response it will accept in return. @@ -3350,7 +3347,7 @@ declare namespace JQuery { * function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless * of the type of request. */ - beforeSend?(this: TContext, jqXHR: jqXHR, settings: AjaxSettings): false | void; + beforeSend?(this: TContext, jqXHR: jqXHR, settings: AjaxSettingsBase): false | void; /** * If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache * to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" @@ -3559,10 +3556,6 @@ declare namespace JQuery { * An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0. */ type?: string; - /** - * A string containing the URL to which the request is sent. - */ - url?: string; /** * A username to be used with XMLHttpRequest in response to an HTTP access authentication request. */ diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 2536144845..eef1b42fa0 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -3475,18 +3475,65 @@ function JQueryStatic() { const jq: JQueryStatic = $; } - function constructor() { - function selector_object_callback() { - const jq = $ as JQueryStatic; - // $ExpectType JQuery - jq('div'); - } + function call_signature() { + // #ExpectType JQuery + $('

', new Document()); + + // #ExpectType JQuery + $('

', { + class: 'my-div', + on: { + touchstart() { + // Do something + } + } + }); + + // #ExpectType JQuery + $('span', new HTMLElement()); + + // #ExpectType JQuery + $('span', new Document()); + + // #ExpectType JQuery + $('span', $('p')); + + // #ExpectType JQuery + $('span'); + + // #ExpectType JQuery + $('

'); + + // #ExpectType JQuery + $(new HTMLElement()); + + // #ExpectType JQuery + $([new HTMLElement()]); + + // #ExpectType JQuery + $({ foo: 'bar', hello: 'world' }); + + // #ExpectType JQuery + $($('p')); + + // #ExpectType JQuery + $(function($) { + // #ExpectType Document + this; + // #ExpectType JQueryStatic + $; + }); + + // #ExpectType JQuery + $(); } function Callbacks() { - const cb = $.Callbacks(); + // #ExpectType Callbacks + $.Callbacks('once'); - cb.add(console.log); + // #ExpectType Callbacks + $.Callbacks(); } function Event() { @@ -3496,26 +3543,468 @@ function JQueryStatic() { } } + function ajax() { + // $ExpectType jqXHR + $.ajax('url', { + cache: true + }); + } + + function ajaxPrefilter() { + // $ExpectType void + $.ajaxPrefilter('dataTypes', (options, originalOptions, jqXHR) => { + // $ExpectType AjaxSettings + options; + // $ExpectType AjaxSettings + originalOptions; + // $ExpectType jqXHR + jqXHR; + + return 'filtered'; + }); + + // $ExpectType void + $.ajaxPrefilter('dataTypes', (options, originalOptions, jqXHR) => { + // $ExpectType AjaxSettings + options; + // $ExpectType AjaxSettings + originalOptions; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType void + $.ajaxPrefilter((options, originalOptions, jqXHR) => { + // $ExpectType AjaxSettings + options; + // $ExpectType AjaxSettings + originalOptions; + // $ExpectType jqXHR + jqXHR; + + return 'filtered'; + }); + + // $ExpectType void + $.ajaxPrefilter((options, originalOptions, jqXHR) => { + // $ExpectType AjaxSettings + options; + // $ExpectType AjaxSettings + originalOptions; + // $ExpectType jqXHR + jqXHR; + }); + } + + function ajaxSetup() { + // $ExpectType AjaxSettings + $.ajaxSetup({ + cache: true + }); + } + + function ajaxTransport() { + // $ExpectType void + $.ajaxTransport('dataTypes', (options, originalOptions, jqXHR) => { + // $ExpectType AjaxSettings + options; + // $ExpectType AjaxSettings + originalOptions; + // $ExpectType jqXHR + jqXHR; + + return { + send(headers, completeCallback) { + // $ExpectType PlainObject + headers; + // $ExpectType SuccessCallback + completeCallback; + }, + abort() { } + }; + }); + + // $ExpectType void + $.ajaxTransport('dataTypes', (options, originalOptions, jqXHR) => { + // $ExpectType AjaxSettings + options; + // $ExpectType AjaxSettings + originalOptions; + // $ExpectType jqXHR + jqXHR; + }); + } + + function contains() { + // $ExpectType boolean + $.contains(new HTMLElement(), new HTMLElement()); + } + + function css() { + // $ExpectType any + $.css(new HTMLElement(), {}); + } + + function data() { + // $ExpectType any + $.data(new HTMLElement(), 'myKey', undefined); + + // $ExpectType "myValue" + $.data(new HTMLElement(), 'myKey', 'myValue'); + + // $ExpectType any + $.data(new HTMLElement(), 'myKey'); + + // $ExpectType any + $.data(new HTMLElement()); + } + + function dequeue() { + // $ExpectType void + $.dequeue(new HTMLElement(), 'myQueue'); + + // $ExpectType void + $.dequeue(new HTMLElement()); + } + function each() { - function arrayLike() { - $.each({ length: 3 }, (index, val) => { - index === 3; - }); - } + // $ExpectType ArrayLike + $.each(['myVal1', 'myVal2'], function(index, val) { + // $ExpectType string + this; + // $ExpectType number + index; + // $ExpectType string + val; + + return false; + }); + + // $ExpectType ArrayLike + $.each(['myVal1', 'myVal2'], function(index, val) { + // $ExpectType string + this; + // $ExpectType number + index; + // $ExpectType string + val; + + return 10; + }); + + // $ExpectType ArrayLike + $.each(['myVal1', 'myVal2'], function(index, val) { + // $ExpectType string + this; + // $ExpectType number + index; + // $ExpectType string + val; + }); + + // $ExpectType { myVal1: boolean; myVal2: () => 10; myVal3: string; } + $.each({ + myVal1: false, + myVal2: () => { + return 10; + }, + myVal3: 'myVal3' + }, function(propertyName, valueOfProperty) { + // $ExpectType string | boolean | (() => 10) + this; + // $ExpectType "myVal1" | "myVal2" | "myVal3" + propertyName; + // $ExpectType string | boolean | (() => 10) + valueOfProperty; + + return false; + }); + + // $ExpectType { myVal1: boolean; myVal2: () => 10; myVal3: string; } + $.each({ + myVal1: false, + myVal2: () => { + return 10; + }, + myVal3: 'myVal3' + }, function(propertyName, valueOfProperty) { + // $ExpectType string | boolean | (() => 10) + this; + // $ExpectType "myVal1" | "myVal2" | "myVal3" + propertyName; + // $ExpectType string | boolean | (() => 10) + valueOfProperty; + + return 10; + }); + + // $ExpectType { myVal1: boolean; myVal2: () => 10; myVal3: string; } + $.each({ + myVal1: false, + myVal2: () => { + return 10; + }, + myVal3: 'myVal3' + }, function(propertyName, valueOfProperty) { + // $ExpectType string | boolean | (() => 10) + this; + // $ExpectType "myVal1" | "myVal2" | "myVal3" + propertyName; + // $ExpectType string | boolean | (() => 10) + valueOfProperty; + }); + } + + function error() { + jQuery.error = console.error; + } + + function escapeSelector() { + // $ExpectType string + $.escapeSelector('span'); + } + + function extend() { + const t = { name: 'myObj' }; + const u = new EventTarget(); + const v = new Node(); + const w = new Comment(); + const x = new Text(); + const y = new Element(); + const z = new HTMLElement(); + const a = new SVGElement(); + + // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element & HTMLElement + $.extend(true, t, u, v, w, x, y, z); + + // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element + $.extend(true, t, u, v, w, x, y); + + // $ExpectType { name: string; } & EventTarget & Node & Comment & Text + $.extend(true, t, u, v, w, x); + + // $ExpectType { name: string; } & EventTarget & Node & Comment + $.extend(true, t, u, v, w); + + // $ExpectType { name: string; } & EventTarget & Node + $.extend(true, t, u, v); + + // $ExpectType { name: string; } & EventTarget + $.extend(true, t, u); + + // $ExpectType any + $.extend(true, t, u, v, w, x, y, z, a); + + // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element & HTMLElement + $.extend(t, u, v, w, x, y, z); + + // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element + $.extend(t, u, v, w, x, y); + + // $ExpectType { name: string; } & EventTarget & Node & Comment & Text + $.extend(t, u, v, w, x); + + // $ExpectType { name: string; } & EventTarget & Node & Comment + $.extend(t, u, v, w); + + // $ExpectType { name: string; } & EventTarget & Node + $.extend(t, u, v); + + // $ExpectType { name: string; } & EventTarget + $.extend(t, u); + + // $ExpectType any + $.extend(t, u, v, w, x, y, z, a); + } + + function get() { + // $ExpectType jqXHR + $.get('url', { myData: 'myData' }, (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.get('url', 'myData', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.get('url', { myData: 'myData' }, null, 'script'); + + // $ExpectType jqXHR + $.get('url', 'myData', null, 'script'); + + // $ExpectType jqXHR + $.get('url', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.get('url', null, 'script'); + + // $ExpectType jqXHR + $.get('url', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.get('url', { myData: 'myData' }); + + // $ExpectType jqXHR + $.get('url', 'myData'); + + // $ExpectType jqXHR + $.get('url'); + + // $ExpectType jqXHR + $.get({ url: 'url' }); + + // $ExpectType jqXHR + $.get(); + } + + function getJSON() { + // $ExpectType jqXHR + $.getJSON('url', { myVal1: 'myVal1' }, (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType jqXHR + $.getJSON('url', 'myVal1', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType jqXHR + $.getJSON('url', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType jqXHR + $.getJSON('url', { myVal1: 'myVal1' }); + + // $ExpectType jqXHR + $.getJSON('url', 'myVal1'); + + // $ExpectType jqXHR + $.getJSON('url'); + } + + function getScript() { + // $ExpectType jqXHR + $.getScript('url', (data, textStatus, jqXHR) => { + // $ExpectType string | undefined + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + } + + function globalEval() { + // $ExpectType void + $.globalEval('throw new Error();'); + } + + function grep() { + // $ExpectType string[] + $.grep(['myVal1', 'myVal2'], (elementOfArray, indexInArray) => { + // $ExpectType string + elementOfArray; + // $ExpectType number + indexInArray; + + return true; + }, true); + + // $ExpectType string[] + $.grep(['myVal1', 'myVal2'], (elementOfArray, indexInArray) => { + // $ExpectType string + elementOfArray; + // $ExpectType number + indexInArray; + + return true; + }); + } + + function hasData() { + // $ExpectType boolean + $.hasData(new HTMLElement()); + } + + function holdReady() { + // $ExpectType void + $.holdReady(true); + } + + function htmlPrefilter() { + // $ExpectType string + $.htmlPrefilter(''); + } + + function inArray() { + // $ExpectType number + $.inArray(1, [1, 2], 1); + + // $ExpectType number + $.inArray(1, [1, 2]); } function isArray() { function type_guard(obj: object) { if ($.isArray(obj)) { - console.log(obj[0]); + // $ExpectType any[] + obj; } } } + function isEmptyObject() { + // $ExpectType boolean + $.isEmptyObject({}); + } + function isFunction() { function type_guard(obj: object) { if ($.isFunction(obj)) { - obj(); + // $ExpectType Function + obj; } } } @@ -3523,7 +4012,8 @@ function JQueryStatic() { function isNumeric() { function type_guard(obj: boolean) { if ($.isNumeric(obj)) { - obj.toFixed(); + // $ExpectType (true & number) | (false & number) + obj; } } } @@ -3531,7 +4021,8 @@ function JQueryStatic() { function isPlainObject() { function type_guard(obj: object) { if ($.isPlainObject(obj)) { - obj['key'] = true; + // $ExpectType PlainObject + obj; } } } @@ -3539,37 +4030,239 @@ function JQueryStatic() { function isWindow() { function type_guard(obj: object) { if ($.isWindow(obj)) { - obj.location.href === 'href'; + // $ExpectType Window + obj; } } } + function isXMLDoc() { + // $ExpectType boolean + $.isXMLDoc(new Node()); + } + + function makeArray() { + // $ExpectType number[] + $.makeArray([1, 2]); + } + function map() { - function object() { - const testObj = { - myProp: true, - name: 'Rogers', - }; + // $ExpectType number[] + $.map([1, 2, 3], (elementOfArray, indexInArray) => { + // $ExpectType number + elementOfArray; + // $ExpectType number + indexInArray; - const results = $.map(testObj, (propertyOfObject, key) => { - switch (key) { - case 'myProp': - return 1; - case 'name': - return false; - } - }); + return 200 + 10; + }); - for (const result of results) { - result === 1; + // $ExpectType (false | 1)[] + $.map({ + myProp: true, + name: 'Rogers', + }, (propertyOfObject, key) => { + // $ExpectType string | boolean + propertyOfObject; + // $ExpectType "myProp" | "name" + key; + + switch (key) { + case 'myProp': + return 1; + case 'name': + return false; } - } + }); + } + + function merge() { + // $ExpectType (string | number)[] + $.merge([1, 2, 3], ['myVal1', 'myVal2']); + } + + function noConflict() { + // $ExpectType JQueryStatic + $.noConflict(true); + + // $ExpectType JQueryStatic + $.noConflict(); + } + + function noop() { + // $ExpectType undefined + $.noop(); + } + + function now() { + // $ExpectType number + $.now(); + } + + function param() { + // $ExpectType string + $.param([true, 20], true); + + // $ExpectType string + $.param({ + myVal1: true, + myVal2: 20 + }, true); + + // $ExpectType string + $.param($('input'), true); + + // $ExpectType string + $.param([true, 20]); + + // $ExpectType string + $.param({ + myVal1: true, + myVal2: 20 + }); + + // $ExpectType string + $.param($('input')); + } + + function parseHTML() { + // $ExpectType Node[] + $.parseHTML('', document, true); + + // $ExpectType Node[] + $.parseHTML('', null, true); + + // $ExpectType Node[] + $.parseHTML('', undefined, true); + + // $ExpectType Node[] + $.parseHTML('', document); + + // $ExpectType Node[] + $.parseHTML('', null); + + // $ExpectType Node[] + $.parseHTML('', undefined); + + // $ExpectType Node[] + $.parseHTML('', false); + + // $ExpectType Node[] + $.parseHTML(''); + } + + function parseJSON() { + // $ExpectType any + $.parseJSON('{}'); + } + + function parseXML() { + // $ExpectType XMLDocument + $.parseXML(''); + } + + function post() { + // $ExpectType jqXHR + $.post('url', { myData: 'myData' }, (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.post('url', 'myData', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.post('url', { myData: 'myData' }, null, 'script'); + + // $ExpectType jqXHR + $.post('url', 'myData', null, 'script'); + + // $ExpectType jqXHR + $.post('url', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.post('url', null, 'script'); + + // $ExpectType jqXHR + $.post('url', (data, textStatus, jqXHR) => { + // $ExpectType any + data; + // $ExpectType SuccessTextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }, 'script'); + + // $ExpectType jqXHR + $.post('url', { myData: 'myData' }); + + // $ExpectType jqXHR + $.post('url', 'myData'); + + // $ExpectType jqXHR + $.post('url'); + + // $ExpectType jqXHR + $.post({ url: 'url' }); + + // $ExpectType jqXHR + $.post(); + } + + function proxy() { + // $ExpectType Function + $.proxy($.noop, {}, 1, 2); + + // $ExpectType Function + $.proxy($.noop, {}); + + // $ExpectType Function + $.proxy({ myFunc: $.noop }, 'myFunc', 1, 2); + + // $ExpectType Function + $.proxy({ myFunc: $.noop }, 'myFunc'); } function queue() { - const el = new HTMLElement(); - const queue = jQuery.queue(el); - queue[0] === 'inprogress'; + // $ExpectType Queue + $.queue(new HTMLElement(), 'myQueue', function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }); + + // $ExpectType Queue + $.queue(new HTMLElement(), 'myQueue', [function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }]); + + // $ExpectType Queue + $.queue(new HTMLElement(), 'myQueue'); + + // $ExpectType Queue + $.queue(new HTMLElement()); } function readyException() { @@ -3577,6 +4270,94 @@ function JQueryStatic() { console.error(error); }; } + + function removeData() { + // $ExpectType void + $.removeData(new HTMLElement(), 'test1'); + + // $ExpectType void + $.removeData(new HTMLElement()); + } + + function speed() { + // $ExpectType EffectsOptions + $.speed(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType EffectsOptions + $.speed(5000, 'linear'); + + // $ExpectType EffectsOptions + $.speed(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType EffectsOptions + $.speed(5000); + + // $ExpectType EffectsOptions + $.speed(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType EffectsOptions + $.speed({ + duration: 5000, + easing: 'linear', + complete() { + // $ExpectType HTMLElement + this; + } + }); + + // $ExpectType EffectsOptions + $.speed(); + } + + function trim() { + // $ExpectType string + $.trim('myStr'); + } + + function type() { + // $ExpectType "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" | "error" | "array" | "date" | "null" | "regexp" + $.type({}); + } + + function unique() { + // $ExpectType HTMLElement[] + $.unique([new HTMLElement()]); + } + + function uniqueSort() { + // $ExpectType HTMLElement[] + $.uniqueSort([new HTMLElement()]); + } + + function when() { + const t = $.ajax() as JQuery.jqXHR; + const u = $.ajax() as JQuery.jqXHR; + const v = $.ajax() as JQuery.jqXHR; + + // $ExpectType Promise<[string | number | boolean, string, jqXHR], any, any> + $.when(t, u, v); + + // $ExpectType Promise<[string | number, string, jqXHR], any, any> + $.when(t, u); + + // $ExpectType Promise, any, any> + $.when(t); + + // $ExpectType Promise + $.when($.Deferred()); + + // $ExpectType Promise + $.when(); + } } function EffectsOptions() { diff --git a/types/jquery/test/example-tests.ts b/types/jquery/test/example-tests.ts index bbb5d15d6c..f0e2e197f6 100644 --- a/types/jquery/test/example-tests.ts +++ b/types/jquery/test/example-tests.ts @@ -2434,7 +2434,7 @@ function examples() { } function jQuery_error_0() { - jQuery.error = console.error as any; + jQuery.error = console.error; } function jQuery_escape_selector_0() { From e5c7b40a2ba986ead460d7684c8fc95bcd7f3223 Mon Sep 17 00:00:00 2001 From: Bob Buehler Date: Fri, 23 Jun 2017 11:33:26 -0500 Subject: [PATCH 066/100] Restricting types for route-parser. --- types/route-parser/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/route-parser/index.d.ts b/types/route-parser/index.d.ts index 2f5dd84e8d..f7b013447c 100644 --- a/types/route-parser/index.d.ts +++ b/types/route-parser/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for route-parser 0.0 +// Type definitions for route-parser 0.1 // Project: https://github.com/rcs/route-parser -// Definitions by: Ian Ker-Seymer +// Definitions by: Ian Ker-Seymer , Bob Buehler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Route { @@ -23,7 +23,7 @@ declare class Route { * var route = new Route('/:one/:two') * route.match('/foo/bar/') // -> {one: 'foo', two: 'bar'} */ - match(pathname: string): { [i: string]: string } | boolean; + match(pathname: string): { [i: string]: string } | false; /** * Reverse a route specification to a path, returning false if it can't be @@ -32,7 +32,7 @@ declare class Route { * var route = new Route('/:one/:two') * route.reverse({one: 'foo', two: 'bar'}) -> '/foo/bar' */ - reverse(params: { [i: string]: any } ): string | boolean; + reverse(params: { [i: string]: any } ): string | false; } declare namespace Route {} From b44d933be6ba103b56f448c02c8c9f6ecae2089c Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Fri, 23 Jun 2017 13:18:42 -0400 Subject: [PATCH 067/100] [react-native-modalbox] Correct file in tsconfig --- types/react-native-modalbox/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-modalbox/tsconfig.json b/types/react-native-modalbox/tsconfig.json index d9e48e4d6a..b6de5592ff 100644 --- a/types/react-native-modalbox/tsconfig.json +++ b/types/react-native-modalbox/tsconfig.json @@ -19,6 +19,6 @@ }, "files": [ "index.d.ts", - "react-native-drawer-tests.tsx" + "react-native-modalbox-tests.tsx" ] } From 9847777efecb8d7969aa1c1b55eda67aab0ffef2 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 23 Jun 2017 10:42:53 -0700 Subject: [PATCH 068/100] Remove void from type argument of React.Component since it is already has default type parameters --- types/react-router-native/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/react-router-native/index.d.ts b/types/react-router-native/index.d.ts index 214e81b0d3..453d9b122a 100644 --- a/types/react-router-native/index.d.ts +++ b/types/react-router-native/index.d.ts @@ -23,25 +23,25 @@ import * as React from 'react'; import * as H from 'history'; export interface AndroidBackButtonProps { - children: Array>; + children: Array; } -export class AndroidBackButton extends React.Component {} +export class AndroidBackButton extends React.Component {} -export class DeepLinking extends React.Component<{}, {}> {} +export class DeepLinking extends React.Component {} export interface LinkProps { - component?: React.Component; + component?: React.Component; replace?: boolean; style?: any; to: H.LocationDescriptor; } -export class Link extends React.Component {} +export class Link extends React.Component {} export interface NativeRouterProps { getUserConfirmation?: Function; keyLength?: number; } -export class NativeRouter extends React.Component {} +export class NativeRouter extends React.Component {} From 95e2380571fc6904747c1dd32cf87a3927fb9e3d Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Fri, 23 Jun 2017 13:52:08 -0400 Subject: [PATCH 069/100] [react-native-modalbox] Fixed example --- types/react-native-modalbox/index.d.ts | 46 +++---- .../react-native-modalbox-tests.tsx | 121 ++++++++++++------ types/react-native-modalbox/tslint.json | 7 +- 3 files changed, 106 insertions(+), 68 deletions(-) diff --git a/types/react-native-modalbox/index.d.ts b/types/react-native-modalbox/index.d.ts index af99a04f4d..2c1c8e4fe3 100644 --- a/types/react-native-modalbox/index.d.ts +++ b/types/react-native-modalbox/index.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Typescript Version: 2.3.3 -import * as React from 'react' -import { ViewProperties } from 'react-native' +import * as React from 'react'; +import { ViewProperties } from 'react-native'; interface ModalProps extends ViewProperties { /** @@ -16,7 +16,7 @@ interface ModalProps extends ViewProperties { * @type {boolean} * @memberof ModalProps */ - isOpen?: boolean + isOpen?: boolean; /** * Checks if the modal is disabled @@ -26,7 +26,7 @@ interface ModalProps extends ViewProperties { * @type {boolean} * @memberof ModalProps */ - isDisabled?: boolean + isDisabled?: boolean; /** * If the modal can be closed by pressing on the backdrop @@ -36,7 +36,7 @@ interface ModalProps extends ViewProperties { * @type {boolean} * @memberof ModalProps */ - backdropPressToClose?: boolean + backdropPressToClose?: boolean; /** * If the modal can be closed by swiping @@ -46,7 +46,7 @@ interface ModalProps extends ViewProperties { * @type {boolean} * @memberof ModalProps */ - swipeToClose?: boolean + swipeToClose?: boolean; /** * The threshold to reach in pixels to close the modal @@ -56,7 +56,7 @@ interface ModalProps extends ViewProperties { * @type {number} * @memberof ModalProps */ - swipeThreshold?: number + swipeThreshold?: number; /** * The height in pixels of the swipeable area @@ -66,7 +66,7 @@ interface ModalProps extends ViewProperties { * @type {number} * @memberof ModalProps */ - swipeArea?: number + swipeArea?: number; /** * The final position of the modal. @@ -77,7 +77,7 @@ interface ModalProps extends ViewProperties { * @type {string} * @memberof ModalProps */ - position?: 'top' | 'center' | 'bottom' | string + position?: 'top' | 'center' | 'bottom' | string; /** * The direction modal enters from @@ -87,7 +87,7 @@ interface ModalProps extends ViewProperties { * @type {('top' | 'bottom' | string)} * @memberof ModalProps */ - entry?: 'top' | 'bottom' | string + entry?: 'top' | 'bottom' | string; /** * If a backdrop is displayed behind the modal @@ -97,7 +97,7 @@ interface ModalProps extends ViewProperties { * @type {boolean} * @memberof ModalProps */ - backdrop?: boolean + backdrop?: boolean; /** * Opacity of the backdrop @@ -107,7 +107,7 @@ interface ModalProps extends ViewProperties { * @type {number} * @memberof ModalProps */ - backdropOpacity?: number + backdropOpacity?: number; /** * Background color of the backdrop @@ -117,7 +117,7 @@ interface ModalProps extends ViewProperties { * @type {string} * @memberof ModalProps */ - backdropColor?: string + backdropColor?: string; /** * Add an element in the backdrop (a close button for example) @@ -127,7 +127,7 @@ interface ModalProps extends ViewProperties { * @type {JSX.Element} * @memberof ModalProps */ - backdropContent?: JSX.Element + backdropContent?: React.ReactNode; /** * Duration of the animation @@ -137,7 +137,7 @@ interface ModalProps extends ViewProperties { * @type {number} * @memberof ModalProps */ - animationDuration?: number + animationDuration?: number; /** * (Android only) Close modal when receiving back button event @@ -147,7 +147,7 @@ interface ModalProps extends ViewProperties { * @type {boolean} * @memberof ModalProps */ - backButtonClose?: boolean + backButtonClose?: boolean; /** * If the modal should appear open without animation upon first mount @@ -157,21 +157,21 @@ interface ModalProps extends ViewProperties { * @type {boolean} * @memberof ModalProps */ - startOpen?: boolean + startOpen?: boolean; /** * Event fired when the modal is closed and the animation is complete * * @memberof ModalProps */ - onClosed?(): void + onClosed?(): void; /** * Event fired when the modal is opened and the animation is complete * * @memberof ModalProps */ - onOpen?(): void + onOpened?(): void; /** * When the state of the swipe to close feature has changed @@ -181,10 +181,10 @@ interface ModalProps extends ViewProperties { * * @memberof ModalProps */ - onClosingState?(state: boolean): void + onClosingState?(state: boolean): void; } -export default class Modal extends React.Component { +export default class Modal extends React.Component { /** * Open the modal * @@ -192,7 +192,7 @@ export default class Modal extends React.Component { * * @memberof Modal */ - static open(): void + open(): void; /** * Close the modal @@ -201,5 +201,5 @@ export default class Modal extends React.Component { * * @memberof Modal */ - static close(): void + close(): void; } diff --git a/types/react-native-modalbox/react-native-modalbox-tests.tsx b/types/react-native-modalbox/react-native-modalbox-tests.tsx index 01a937aea7..c8ae1785e7 100644 --- a/types/react-native-modalbox/react-native-modalbox-tests.tsx +++ b/types/react-native-modalbox/react-native-modalbox-tests.tsx @@ -1,26 +1,28 @@ -// Test taken from project repo https://github.com/maxs15/react-native-modalbox/blob/master/Example/index.ios.js - import * as React from 'react'; -import Modal from 'react-native-modalbox'; -import Button from 'react-native-button'; -import Slider from 'react-native-slider'; - import { Text, StyleSheet, ScrollView, View, - Dimensions + Dimensions, + Button } from 'react-native'; +import Modal from 'react-native-modalbox'; interface State { isOpen: boolean; isDisabled: boolean; swipeToClose: boolean; - slideValue: boolean; + sliderValue: number; } class Example extends React.Component<{}, State> { + modal1: Modal; + modal2: Modal; + modal3: Modal; + modal4: Modal; + modal6: Modal; + constructor() { super(); @@ -40,7 +42,7 @@ class Example extends React.Component<{}, State> { console.log('Modal just openned'); } - onClosingState(state) { + onClosingState() { console.log('the open/close of the swipeToClose just changed'); } @@ -55,47 +57,88 @@ class Example extends React.Component<{}, State> { } render() { - var BContent = ; + const BContent = ( + - - - - - + + +