From 9d6c0c12f4b2846790db5e5a42f300176721bc19 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 1 May 2017 11:56:54 -0700 Subject: [PATCH 01/58] Fixing breaking form 2.3 by using default type paramters instead --- types/react-leaflet/index.d.ts | 34 ++++++++++----------- types/react-leaflet/react-leaflet-tests.tsx | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index da829ff2cc..d59527932b 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -143,7 +143,7 @@ export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateO zoom?: number; } -export class Map

extends MapComponent { +export class Map

extends MapComponent { className?: string; container: HTMLDivElement; getChildContext(): { layerContainer: E, map: E }; @@ -165,7 +165,7 @@ export interface PaneProps { export interface PaneState { name?: string; } -export class Pane

extends React.Component { +export class Pane

extends React.Component { getChildContext(): { pane: string }; createPane(props: P): void; removePane(): void; @@ -196,13 +196,13 @@ export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOption children?: Children; url: string; } -export class TileLayer

extends GridLayer { } +export class TileLayer

extends GridLayer { } export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { children?: Children; url: string; } -export class WMSTileLayer

extends GridLayer { } +export class WMSTileLayer

extends GridLayer { } export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { bounds: Leaflet.LatLngBoundsExpression; @@ -224,7 +224,7 @@ export interface MarkerProps extends MarkerEvents, Leaflet.MarkerOptions { children?: Children; position: Leaflet.LatLngExpression; } -export class Marker

extends MapLayer { +export class Marker

extends MapLayer { getChildContext(): { popupContainer: E }; } @@ -241,19 +241,19 @@ export interface CircleProps extends PathEvents, Leaflet.CircleMarkerOptions { children?: Children; radius: number; } -export class Circle

extends Path { } +export class Circle

extends Path { } export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; children?: Children; radius: number; } -export class CircleMarker

extends Path { } +export class CircleMarker

extends Path { } export interface FeatureGroupProps extends FeatureGroupEvents, Leaflet.PathOptions { children?: Children; } -export class FeatureGroup

extends Path { +export class FeatureGroup

extends Path { getChildContext(): { layerContainer: E, popupContainer: E }; } @@ -268,27 +268,27 @@ export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; } -export class Polyline

extends Path { } +export class Polyline

extends Path { } export interface PolygonProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; popupContainer?: Leaflet.FeatureGroup; positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][]; } -export class Polygon

extends Path { } +export class Polygon

extends Path { } export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; bounds: Leaflet.LatLngBoundsExpression; popupContainer?: Leaflet.FeatureGroup; } -export class Rectangle

extends Path { } +export class Rectangle

extends Path { } export interface PopupProps extends Leaflet.PopupOptions { children?: Children; position?: Leaflet.LatLngExpression; } -export class Popup

extends MapComponent { +export class Popup

extends MapComponent { onPopupOpen(arg: { popup: E }): void; onPopupClose(arg: { popup: E }): void; renderPopupContent(): void; @@ -298,7 +298,7 @@ export class Popup

extends MapCom export interface TooltipProps extends Leaflet.TooltipOptions { children?: Children; } -export class Tooltip

extends MapComponent { +export class Tooltip

extends MapComponent { onTooltipOpen(arg: { tooltip: E }): void; onTooltipClose(arg: { tooltip: E }): void; renderTooltipContent(): void; @@ -320,7 +320,7 @@ export interface LayersControlProps extends LayersControlEvents, Leaflet.Control children?: Children; overlays?: Leaflet.Control.LayersObject; } -export class LayersControl

extends MapControl { } +export class LayersControl

extends MapControl { } export namespace LayersControl { interface BaseControlledLayerProps { @@ -340,12 +340,12 @@ export namespace LayersControl { addLayer(): void; removeLayer(layer: Leaflet.Layer): void; } - class BaseLayer

extends ControlledLayer

{ } - class Overlay

extends ControlledLayer

{ } + class BaseLayer

extends ControlledLayer

{ } + class Overlay

extends ControlledLayer

{ } } export type ScaleControlProps = Leaflet.Control.ScaleOptions; export class ScaleControl

extends MapControl { } export type ZoomControlProps = Leaflet.Control.ZoomOptions; -export class ZoomControl

extends MapControl { } +export class ZoomControl

extends MapControl { } diff --git a/types/react-leaflet/react-leaflet-tests.tsx b/types/react-leaflet/react-leaflet-tests.tsx index 667d92d6ea..d87d4f995e 100644 --- a/types/react-leaflet/react-leaflet-tests.tsx +++ b/types/react-leaflet/react-leaflet-tests.tsx @@ -686,7 +686,7 @@ class CenterControl extends MapControl { // n const centerControl = new L.Control({ position: 'bottomright' }); // see http://leafletjs.com/reference.html#control-positions for other positions const jsx = ( // PUT YOUR JSX FOR THE COMPONENT HERE: -

+
{/* add your JSX */}
); @@ -713,7 +713,7 @@ class LegendControl extends MapControl +
{this.props.children}
); From 42a15de2ebbd752c47cc5faefe1e3b2e7717027f Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 2 May 2017 10:27:11 -0700 Subject: [PATCH 02/58] Address PR : add type parameter --- types/react-leaflet/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index d59527932b..aac671947d 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/PaulLeCam/react-leaflet // Definitions by: Dave Leaver , David Schneider // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import * as Leaflet from 'leaflet'; import * as React from 'react'; @@ -202,7 +202,7 @@ export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { children?: Children; url: string; } -export class WMSTileLayer

extends GridLayer { } +export class WMSTileLayer

extends GridLayer { } export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { bounds: Leaflet.LatLngBoundsExpression; @@ -320,7 +320,7 @@ export interface LayersControlProps extends LayersControlEvents, Leaflet.Control children?: Children; overlays?: Leaflet.Control.LayersObject; } -export class LayersControl

extends MapControl { } +export class LayersControl

extends MapControl { } export namespace LayersControl { interface BaseControlledLayerProps { @@ -348,4 +348,4 @@ export type ScaleControlProps = Leaflet.Control.ScaleOptions; export class ScaleControl

extends MapControl { } export type ZoomControlProps = Leaflet.Control.ZoomOptions; -export class ZoomControl

extends MapControl { } +export class ZoomControl

extends MapControl { } From b596befb5ad07f5fd9c9d6386baa538b0a385c45 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 2 May 2017 10:29:10 -0700 Subject: [PATCH 03/58] Address PR: add type parameter --- types/react-leaflet/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index aac671947d..8c36af705e 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -196,7 +196,7 @@ export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOption children?: Children; url: string; } -export class TileLayer

extends GridLayer { } +export class TileLayer

extends GridLayer { } export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { children?: Children; From 25dfb2fb8c3a718bbea0203ba682e10ae2e26bb1 Mon Sep 17 00:00:00 2001 From: Yui Date: Tue, 2 May 2017 13:13:30 -0700 Subject: [PATCH 04/58] Update header of the index.d.ts file --- types/react-leaflet/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 8c36af705e..ddbfc786e3 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-leaflet 1.1 // Project: https://github.com/PaulLeCam/react-leaflet -// Definitions by: Dave Leaver , David Schneider +// Definitions by: Dave Leaver , David Schneider , Yui T. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 5332c59958bcdf3220c211ce21530b12b7144dcc Mon Sep 17 00:00:00 2001 From: Geert Jansen Date: Mon, 29 May 2017 09:04:45 +0200 Subject: [PATCH 05/58] update methodNames parameter type on createSpyObj Adds missing Object type to the methodNames parameter on the jasmine.createSpyObj method. --- types/jasmine/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/jasmine/index.d.ts b/types/jasmine/index.d.ts index 11b0d1919c..4f57d976fe 100644 --- a/types/jasmine/index.d.ts +++ b/types/jasmine/index.d.ts @@ -58,8 +58,8 @@ declare namespace jasmine { function objectContaining(sample: Partial): ObjectContaining; function createSpy(name: string, originalFn?: Function): Spy; - function createSpyObj(baseName: string, methodNames: any[]): any; - function createSpyObj(baseName: string, methodNames: any[]): T; + function createSpyObj(baseName: string, methodNames: any[] | {[methodName: string]: any}): any; + function createSpyObj(baseName: string, methodNames: any[] | {[methodName: string]: any}): T; function pp(value: any): string; From 644f9e560d3c3c89917fd11740cac3d17732ed5e Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 1 Jun 2017 14:42:15 +0200 Subject: [PATCH 06/58] Update index.d.ts fixed curry right --- types/lodash/index.d.ts | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index b8ae248190..198bc528fd 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -10331,6 +10331,36 @@ declare namespace _ { (t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1; (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R; } + interface RightCurriedFunction1{ + ():RightCurriedFunction1 + (t1:T1):R + } + interface RightCurriedFunction2{ + ():RightCurriedFunction2 + (t2:T2):RightCurriedFunction1 + (t1:T1,t2:T2):R + } + interface RightCurriedFunction3{ + ():RightCurriedFunction3 + (t3:T3):RightCurriedFunction2 + (t2:T2,t3:T3):RightCurriedFunction1 + (t1:T1,t2:T2,t3:T3):R + } + interface RightCurriedFunction4{ + ():RightCurriedFunction4 + (t4:T4):RightCurriedFunction3 + (t3:T3,t4:T4):RightCurriedFunction2 + (t2:T2,t3:T3,t4:T4):RightCurriedFunction1 + (t1:T1,t2:T2,t3:T3,t4:T4):R + } + interface RightCurriedFunction5{ + ():RightCurriedFunction5 + (t5:T5):RightCurriedFunction4 + (t4:T4,t5:T5):RightCurriedFunction3 + (t3:T3,t4:T4,t5:T5):RightCurriedFunction2 + (t2:T2,t3:T3,t4:T4,t5:T5):RightCurriedFunction1 + (t1:T1,t2:T2,t3:T3,t4:T4,t5:T5):R + } interface LoDashImplicitObjectWrapper { /** @@ -10348,7 +10378,7 @@ declare namespace _ { * @return Returns the new curried function. */ curryRight(func: (t1: T1) => R): - CurriedFunction1; + RightCurriedFunction1; /** * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight * instead of _.partial. @@ -10356,7 +10386,7 @@ declare namespace _ { * @return Returns the new curried function. */ curryRight(func: (t1: T1, t2: T2) => R): - CurriedFunction2; + RightCurriedFunction2; /** * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight * instead of _.partial. @@ -10364,7 +10394,7 @@ declare namespace _ { * @return Returns the new curried function. */ curryRight(func: (t1: T1, t2: T2, t3: T3) => R): - CurriedFunction3; + RightCurriedFunction3; /** * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight * instead of _.partial. @@ -10372,7 +10402,7 @@ declare namespace _ { * @return Returns the new curried function. */ curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): - CurriedFunction4; + RightCurriedFunction4; /** * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight * instead of _.partial. @@ -10380,7 +10410,7 @@ declare namespace _ { * @return Returns the new curried function. */ curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R): - CurriedFunction5; + RightCurriedFunction5; /** * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight * instead of _.partial. From 4d2f91fcce89ce6343206c2c776e7e6f2a160cb2 Mon Sep 17 00:00:00 2001 From: Luke Libraro Date: Thu, 1 Jun 2017 12:10:55 -0500 Subject: [PATCH 07/58] Added noble callback function signatures --- types/noble/index.d.ts | 9 ++++++++- types/noble/noble-tests.ts | 4 ++++ types/noble/tsconfig.json | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/noble/index.d.ts b/types/noble/index.d.ts index 4e293993f7..e5fa57caa8 100644 --- a/types/noble/index.d.ts +++ b/types/noble/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for noble // Project: https://github.com/sandeepmistry/noble -// Definitions by: Seon-Wook Park , Hans Bakker , Shantanu Bhadoria +// Definitions by: Seon-Wook Park +// Hans Bakker +// Shantanu Bhadoria +// Luke Libraro // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -9,9 +12,13 @@ import events = require("events"); export declare function startScanning(): void; +export declare function startScanning(callback: Function): void; export declare function startScanning(serviceUUIDs: string[]): void; +export declare function startScanning(serviceUUIDs: string[], callback: Function): void; export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean): void; +export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback: Function): void; export declare function stopScanning(): void; +export declare function stopScanning(callback: Function): void; export declare function on(event: string, listener: Function): events.EventEmitter; export declare function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter; diff --git a/types/noble/noble-tests.ts b/types/noble/noble-tests.ts index 9c3f403944..2a2324fd33 100644 --- a/types/noble/noble-tests.ts +++ b/types/noble/noble-tests.ts @@ -4,14 +4,18 @@ import noble = require("noble"); function test_startScanning(): void { "use strict"; noble.startScanning(); + noble.startScanning(function(err: any) {}); noble.startScanning(["0x180d"]); + noble.startScanning(["0x180d"], function(err: any) {}); noble.startScanning(["0x180d"], true); + noble.startScanning(["0x180d"], true, function(err: any) {}); } test_startScanning(); function test_stopScanning(): void { "use strict"; noble.stopScanning(); + noble.stopScanning(function(err: any) {}); } test_stopScanning(); diff --git a/types/noble/tsconfig.json b/types/noble/tsconfig.json index 5821c4f99e..9b75c82d95 100644 --- a/types/noble/tsconfig.json +++ b/types/noble/tsconfig.json @@ -19,4 +19,4 @@ "index.d.ts", "noble-tests.ts" ] -} \ No newline at end of file +} From 3da30f09115a591f71d71f5fc4f1f71c696c102d Mon Sep 17 00:00:00 2001 From: Luke Libraro Date: Thu, 1 Jun 2017 13:02:20 -0500 Subject: [PATCH 08/58] changes based on feedback --- types/noble/index.d.ts | 12 ++++-------- types/noble/noble-tests.ts | 8 ++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/types/noble/index.d.ts b/types/noble/index.d.ts index e5fa57caa8..4f2b5f0b7c 100644 --- a/types/noble/index.d.ts +++ b/types/noble/index.d.ts @@ -11,14 +11,10 @@ import events = require("events"); -export declare function startScanning(): void; -export declare function startScanning(callback: Function): void; -export declare function startScanning(serviceUUIDs: string[]): void; -export declare function startScanning(serviceUUIDs: string[], callback: Function): void; -export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean): void; -export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback: Function): void; -export declare function stopScanning(): void; -export declare function stopScanning(callback: Function): void; +export declare function startScanning(callback?: (error?: Error) => void): void; +export declare function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void; +export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void; +export declare function stopScanning(callback?: () => void): void; export declare function on(event: string, listener: Function): events.EventEmitter; export declare function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter; diff --git a/types/noble/noble-tests.ts b/types/noble/noble-tests.ts index 2a2324fd33..5cba50632a 100644 --- a/types/noble/noble-tests.ts +++ b/types/noble/noble-tests.ts @@ -4,18 +4,18 @@ import noble = require("noble"); function test_startScanning(): void { "use strict"; noble.startScanning(); - noble.startScanning(function(err: any) {}); + noble.startScanning((err: Error) => {}); noble.startScanning(["0x180d"]); - noble.startScanning(["0x180d"], function(err: any) {}); + noble.startScanning(["0x180d"], (err: Error) => {}); noble.startScanning(["0x180d"], true); - noble.startScanning(["0x180d"], true, function(err: any) {}); + noble.startScanning(["0x180d"], true, (err: Error) => {}); } test_startScanning(); function test_stopScanning(): void { "use strict"; noble.stopScanning(); - noble.stopScanning(function(err: any) {}); + noble.stopScanning(() => {}); } test_stopScanning(); From 4ed9a56eb0c2a34aa3e6c594f0e9063db24e7d1f Mon Sep 17 00:00:00 2001 From: Luke Libraro Date: Thu, 1 Jun 2017 13:03:46 -0500 Subject: [PATCH 09/58] removed unnecessary Error types --- types/noble/noble-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/noble/noble-tests.ts b/types/noble/noble-tests.ts index 5cba50632a..baa65c5662 100644 --- a/types/noble/noble-tests.ts +++ b/types/noble/noble-tests.ts @@ -4,11 +4,11 @@ import noble = require("noble"); function test_startScanning(): void { "use strict"; noble.startScanning(); - noble.startScanning((err: Error) => {}); + noble.startScanning((err) => {}); noble.startScanning(["0x180d"]); - noble.startScanning(["0x180d"], (err: Error) => {}); + noble.startScanning(["0x180d"], (err) => {}); noble.startScanning(["0x180d"], true); - noble.startScanning(["0x180d"], true, (err: Error) => {}); + noble.startScanning(["0x180d"], true, (err) => {}); } test_startScanning(); From f527af6ed365e87058480e22577e3e191a13fb42 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Mon, 5 Jun 2017 15:10:34 -0400 Subject: [PATCH 10/58] Annotate `react-redux` more explicitly --- types/react-redux/index.d.ts | 22 ++++----- types/react-redux/react-redux-tests.tsx | 62 +++++++++++++++++++------ types/redux-form/redux-form-tests.tsx | 4 +- 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index bf810575cb..112b7e9c95 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -15,12 +15,12 @@ type Store = Redux.Store; type Dispatch = Redux.Dispatch; type ActionCreator = Redux.ActionCreator; -export interface DispatchProp { - dispatch: Dispatch +export interface DispatchProp { + dispatch: Dispatch; } -interface ComponentDecorator { - (component: Component<(TOwnProps & TMergedProps) | TOwnProps>): ComponentClass; +interface ComponentDecorator { + (component: Component): ComponentClass; } interface ComponentMergeDecorator { @@ -46,21 +46,21 @@ interface ComponentMergeDecorator { * @param mergeProps * @param options */ -export declare function connect(): ComponentDecorator>; +export declare function connect(): ComponentDecorator, {}>; export declare function connect( mapStateToProps: MapStateToPropsParam -): ComponentDecorator & TStateProps>; +): ComponentDecorator & TStateProps, TOwnProps>; export declare function connect( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam -): ComponentDecorator; +): ComponentDecorator; export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam -): ComponentDecorator; +): ComponentDecorator; export declare function connect( mapStateToProps: MapStateToPropsParam, @@ -91,21 +91,21 @@ export declare function connect( mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: Options -): ComponentDecorator & TStateProps & TOwnProps>; +): ComponentDecorator & TStateProps, TOwnProps>; export declare function connect( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, options: Options -): ComponentDecorator; +): ComponentDecorator; export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, options: Options -): ComponentDecorator; +): ComponentDecorator; export declare function connect( mapStateToProps: MapStateToPropsParam, diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index d6742a3e43..5875fe9291 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -108,12 +108,7 @@ declare var store: Store; class MyRootComponent extends Component { } -class TodoApp extends Component, any> { - render (): null { - this.props.dispatch({ type: 'test' }) - return null - } -} +class TodoApp extends Component {} interface TodoState { todos: string[]|string; } @@ -156,9 +151,10 @@ ReactDOM.render( // Inject just dispatch and don't listen to store -const WrappedTodoApp = connect()<{}>(TodoApp); +const AppWrap = (props: DispatchProp & { children?: React.ReactNode }) =>

+const WrappedApp = connect()(AppWrap); - + // Inject dispatch and every field in the global state @@ -281,7 +277,7 @@ interface TestState { isLoaded: boolean; state1: number; } -class TestComponent extends Component { } +class TestComponent extends Component, TestState> { } const WrappedTestComponent = connect()(TestComponent); // return value of the connect()(TestComponent) is of the type TestComponent @@ -290,7 +286,6 @@ ATestComponent = TestComponent; ATestComponent = WrappedTestComponent; let anElement: ReactElement; -; ; ; @@ -348,7 +343,7 @@ namespace TestTOwnPropsInference { state: string; } - class OwnPropsComponent extends React.Component { + class OwnPropsComponent extends React.Component, void> { render() { return
; } @@ -370,13 +365,13 @@ namespace TestTOwnPropsInference { // React.createElement(ConnectedWithoutOwnProps, { anything: 'goes!' }); // This compiles, as expected. - React.createElement(ConnectedWithOwnProps, { state: 'string', own: 'string' }); + React.createElement(ConnectedWithOwnProps, { own: 'string' }); // This should not compile, which is good. // React.createElement(ConnectedWithOwnProps, { anything: 'goes!' }); // This compiles, as expected. - React.createElement(ConnectedWithTypeHint, { state: 'string', own: 'string' }); + React.createElement(ConnectedWithTypeHint, { own: 'string' }); // This should not compile, which is good. // React.createElement(ConnectedWithTypeHint, { anything: 'goes!' }); @@ -438,3 +433,44 @@ namespace TestMergedPropsInference { }), )(MergedPropsComponent); } + +namespace Issue16652 { + interface PassedProps { + commentIds: string[]; + } + + interface GeneratedStateProps { + comments: ({ id: string } | undefined)[]; + } + + class CommentList extends React.Component, void> {} + + const mapStateToProps = (state: any, ownProps: PassedProps): GeneratedStateProps => { + return { + comments: ownProps.commentIds.map(id => ({ id })), + }; + }; + + const ConnectedCommentList = connect(mapStateToProps)( + CommentList + ); + + +} + +namespace Issue15463 { + interface ISpinnerProps{ + showGlobalSpinner: boolean; + } + class SpinnerClass extends React.Component, undefined> { + render() { + return (
); + } + } + + export const Spinner = connect((state: any) => { + return { showGlobalSpinner: true }; + })(SpinnerClass); + + +} diff --git a/types/redux-form/redux-form-tests.tsx b/types/redux-form/redux-form-tests.tsx index d14b7a35cd..7615824b53 100644 --- a/types/redux-form/redux-form-tests.tsx +++ b/types/redux-form/redux-form-tests.tsx @@ -84,7 +84,7 @@ reduxForm({ // adapted from: http://redux-form.com/6.0.0-alpha.4/examples/initializeFromState/ -import { connect } from 'react-redux' +import { connect, DispatchProp } from 'react-redux' const { DOM: { input } } = React interface DataShape { @@ -125,7 +125,7 @@ const ConnectedDecoratedInitializeFromStateFormFunction = connect( // React ComponentClass instead of StatelessComponent -class InitializeFromStateFormClass extends React.Component { +class InitializeFromStateFormClass extends React.Component, {}> { render() { return InitializeFromStateFormFunction(this.props); } From a5e5a19585a95b34388986493568cfd147180cd0 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 6 Jun 2017 10:27:15 -0700 Subject: [PATCH 11/58] Address PR: feedback --- types/react-leaflet/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index fe209f0327..d86a25d066 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -196,13 +196,13 @@ export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOption children?: Children; url: string; } -export class TileLayer

extends GridLayer { } +export class TileLayer

extends GridLayer { } export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { children?: Children; url: string; } -export class WMSTileLayer

extends GridLayer { } +export class WMSTileLayer

extends GridLayer { } export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { bounds: Leaflet.LatLngBoundsExpression; @@ -320,7 +320,7 @@ export interface LayersControlProps extends LayersControlEvents, Leaflet.Control children?: Children; overlays?: Leaflet.Control.LayersObject; } -export class LayersControl

extends MapControl { } +export class LayersControl

extends MapControl { } export namespace LayersControl { interface BaseControlledLayerProps { @@ -348,4 +348,4 @@ export type ScaleControlProps = Leaflet.Control.ScaleOptions; export class ScaleControl

extends MapControl { } export type ZoomControlProps = Leaflet.Control.ZoomOptions; -export class ZoomControl

extends MapControl { } +export class ZoomControl

extends MapControl { } From 1894877f40151983d301c551b30d0dfd7745a184 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 6 Jun 2017 10:27:41 -0700 Subject: [PATCH 12/58] Add missing options : http://leafletjs.com/reference-1.0.3.html#layer --- types/leaflet/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 135fa8b93f..80adf4bc3f 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -390,6 +390,7 @@ declare namespace L { interface LayerOptions { pane?: string; + attribution?: string; } interface InteractiveLayerOptions extends LayerOptions { From b1ecad76b7528a994b3e536b4abf9fe7cf0cd965 Mon Sep 17 00:00:00 2001 From: William Lohan Date: Tue, 6 Jun 2017 11:36:08 -0700 Subject: [PATCH 13/58] non-standard fields --- types/fullcalendar/fullcalendar-tests.ts | 5 +---- types/fullcalendar/index.d.ts | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/fullcalendar/fullcalendar-tests.ts b/types/fullcalendar/fullcalendar-tests.ts index 1e9e241ce8..c0a53a59f1 100644 --- a/types/fullcalendar/fullcalendar-tests.ts +++ b/types/fullcalendar/fullcalendar-tests.ts @@ -622,9 +622,6 @@ $('#calendar').fullCalendar({ eventColor: '#378006' }); -interface EventWithDescription extends FullCalendar.EventObject { - description: string; -} interface JQueryQTip extends JQuery { qtip(options: Object): JQuery; // dummy plugin interface } @@ -638,7 +635,7 @@ $('#calendar').fullCalendar({ } // more events here ], - eventRender(event: EventWithDescription, element: JQueryQTip, view: FullCalendar.ViewObject) { + eventRender(event: FullCalendar.EventObject, element: JQueryQTip, view: FullCalendar.ViewObject) { element.qtip({ content: event.description }); diff --git a/types/fullcalendar/index.d.ts b/types/fullcalendar/index.d.ts index 05ac6076e6..bed6396214 100644 --- a/types/fullcalendar/index.d.ts +++ b/types/fullcalendar/index.d.ts @@ -2,6 +2,7 @@ // Project: http://fullcalendar.io/ // Definitions by: Neil Stalker , Marcelo Camargo , Patrick Niemann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// @@ -229,6 +230,8 @@ export interface EventObject extends Timespan { backgroundColor?: string; borderColor?: string; textColor?: string; + // non-standard fields, see https://fullcalendar.io/docs/event_data/Event_Object/ and https://fullcalendar.io/docs/event_rendering/eventRender/ + [x: string]: any; } export interface ViewObject extends Timespan { From 0ee8e83ae3340d466f0ab03163fdee63a513de3f Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 6 Jun 2017 21:32:28 -0700 Subject: [PATCH 14/58] Address PR --- types/react-leaflet/index.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index d86a25d066..76a1be1125 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -196,13 +196,13 @@ export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOption children?: Children; url: string; } -export class TileLayer

extends GridLayer { } +export class TileLayer

extends GridLayer { } export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { children?: Children; url: string; } -export class WMSTileLayer

extends GridLayer { } +export class WMSTileLayer

extends GridLayer { } export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { bounds: Leaflet.LatLngBoundsExpression; @@ -224,7 +224,7 @@ export interface MarkerProps extends MarkerEvents, Leaflet.MarkerOptions { children?: Children; position: Leaflet.LatLngExpression; } -export class Marker

extends MapLayer { +export class Marker

extends MapLayer { getChildContext(): { popupContainer: E }; } @@ -241,14 +241,14 @@ export interface CircleProps extends PathEvents, Leaflet.CircleMarkerOptions { children?: Children; radius: number; } -export class Circle

extends Path { } +export class Circle

extends Path { } export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; children?: Children; radius: number; } -export class CircleMarker

extends Path { } +export class CircleMarker

extends Path { } export interface FeatureGroupProps extends FeatureGroupEvents, Leaflet.PathOptions { children?: Children; @@ -268,21 +268,21 @@ export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; } -export class Polyline

extends Path { } +export class Polyline

extends Path { } export interface PolygonProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; popupContainer?: Leaflet.FeatureGroup; positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][]; } -export class Polygon

extends Path { } +export class Polygon

extends Path { } export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; bounds: Leaflet.LatLngBoundsExpression; popupContainer?: Leaflet.FeatureGroup; } -export class Rectangle

extends Path { } +export class Rectangle

extends Path { } export interface PopupProps extends Leaflet.PopupOptions { children?: Children; @@ -320,7 +320,7 @@ export interface LayersControlProps extends LayersControlEvents, Leaflet.Control children?: Children; overlays?: Leaflet.Control.LayersObject; } -export class LayersControl

extends MapControl { } +export class LayersControl

extends MapControl { } export namespace LayersControl { interface BaseControlledLayerProps { @@ -341,11 +341,11 @@ export namespace LayersControl { removeLayer(layer: Leaflet.Layer): void; } class BaseLayer

extends ControlledLayer

{ } - class Overlay

extends ControlledLayer

{ } + class Overlay

extends ControlledLayer

{ } } export type ScaleControlProps = Leaflet.Control.ScaleOptions; export class ScaleControl

extends MapControl { } export type ZoomControlProps = Leaflet.Control.ZoomOptions; -export class ZoomControl

extends MapControl { } +export class ZoomControl

extends MapControl { } From ca4f0e634ba63a4e78303ac55627085e0a69a8c5 Mon Sep 17 00:00:00 2001 From: Eric Roos Date: Wed, 7 Jun 2017 15:38:33 +0200 Subject: [PATCH 15/58] fixed curryRight tests to not be the same as a mirrod curry --- types/lodash/lodash-tests.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 4f479eab83..44d6c834ac 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -5674,15 +5674,14 @@ curryResult0 = _.curryRight(testCurryRightFn)(1, 2, 3); curryResult2 = _.curryRight(testCurryRightFn)(1); curryResult0 = _(testCurryRightFn).curryRight().value()(1, 2, 3); curryResult2 = _(testCurryRightFn).curryRight().value()(1); - -let curryResult7: _.CurriedFunction1; -let curryResult8: _.CurriedFunction2; -let curryResult9: _.CurriedFunction3; -curryResult3 = _.curryRight(testCurry2)(true, 2, "1"); -curryResult3 = _.curryRight(testCurry2)(true, 2)("1"); -curryResult3 = _.curryRight(testCurry2)(true)(2, "1"); +let curryResult7: _.RightCurriedFunction1; +let curryResult8: _.RightCurriedFunction2; +let curryResult9: _.RightCurriedFunction3; +curryResult3 = _.curryRight(testCurry2)("1", 2, true); +curryResult3 = _.curryRight(testCurry2)( 2,true)("1"); +curryResult3 = _.curryRight(testCurry2)(true)( "1",2); curryResult3 = _.curryRight(testCurry2)(true)(2)("1"); -curryResult7 = _.curryRight(testCurry2)(true, 2); +curryResult7 = _.curryRight(testCurry2)(2,true); curryResult7 = _.curryRight(testCurry2)(true)(2); curryResult8 = _.curryRight(testCurry2)(true); curryResult9 = _.curryRight(testCurry2); From 4e4d4d3879e87f181dcaff62036bfa2f5cb51327 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 10 Jun 2017 20:33:46 -0700 Subject: [PATCH 16/58] constraint type parameter in Map and Pane --- types/react-leaflet/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 76a1be1125..9c70a79ddf 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -143,7 +143,7 @@ export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateO zoom?: number; } -export class Map

extends MapComponent { +export class Map

extends MapComponent { className?: string; container: HTMLDivElement; getChildContext(): { layerContainer: E, map: E }; @@ -165,7 +165,7 @@ export interface PaneProps { export interface PaneState { name?: string; } -export class Pane

extends React.Component { +export class Pane

extends React.Component { getChildContext(): { pane: string }; createPane(props: P): void; removePane(): void; From c818a5296e123449454d5160e8530fcb461d965a Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 10 Jun 2017 20:48:12 -0700 Subject: [PATCH 17/58] add missing constraint --- types/react-leaflet/index.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 9c70a79ddf..8af2bbd14b 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -224,7 +224,7 @@ export interface MarkerProps extends MarkerEvents, Leaflet.MarkerOptions { children?: Children; position: Leaflet.LatLngExpression; } -export class Marker

extends MapLayer { +export class Marker

extends MapLayer { getChildContext(): { popupContainer: E }; } @@ -248,12 +248,12 @@ export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptio children?: Children; radius: number; } -export class CircleMarker

extends Path { } +export class CircleMarker

extends Path { } export interface FeatureGroupProps extends FeatureGroupEvents, Leaflet.PathOptions { children?: Children; } -export class FeatureGroup

extends Path { +export class FeatureGroup

extends Path { getChildContext(): { layerContainer: E, popupContainer: E }; } @@ -268,14 +268,14 @@ export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; } -export class Polyline

extends Path { } +export class Polyline

extends Path { } export interface PolygonProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; popupContainer?: Leaflet.FeatureGroup; positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][]; } -export class Polygon

extends Path { } +export class Polygon

extends Path { } export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; @@ -288,7 +288,7 @@ export interface PopupProps extends Leaflet.PopupOptions { children?: Children; position?: Leaflet.LatLngExpression; } -export class Popup

extends MapComponent { +export class Popup

extends MapComponent { onPopupOpen(arg: { popup: E }): void; onPopupClose(arg: { popup: E }): void; renderPopupContent(): void; @@ -298,7 +298,7 @@ export class Popup

extends MapComponent export interface TooltipProps extends Leaflet.TooltipOptions { children?: Children; } -export class Tooltip

extends MapComponent { +export class Tooltip

extends MapComponent { onTooltipOpen(arg: { tooltip: E }): void; onTooltipClose(arg: { tooltip: E }): void; renderTooltipContent(): void; From 3417d93fdc3179adc5edecb5c09a071b8de0048b Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 10 Jun 2017 20:51:35 -0700 Subject: [PATCH 18/58] add more missing constraint --- types/react-leaflet/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 8af2bbd14b..618fcd5c73 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -241,7 +241,7 @@ export interface CircleProps extends PathEvents, Leaflet.CircleMarkerOptions { children?: Children; radius: number; } -export class Circle

extends Path { } +export class Circle

extends Path { } export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; @@ -282,7 +282,7 @@ export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions { bounds: Leaflet.LatLngBoundsExpression; popupContainer?: Leaflet.FeatureGroup; } -export class Rectangle

extends Path { } +export class Rectangle

extends Path { } export interface PopupProps extends Leaflet.PopupOptions { children?: Children; @@ -298,7 +298,7 @@ export class Popup

extends MapComponent { +export class Tooltip

extends MapComponent { onTooltipOpen(arg: { tooltip: E }): void; onTooltipClose(arg: { tooltip: E }): void; renderTooltipContent(): void; From be064f6e2f98d29d5af2e3eecfbadaaa3a193c73 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 20:57:06 -0700 Subject: [PATCH 19/58] Add rudimentary `hubot` type definitions --- types/hubot/index.d.ts | 53 +++++++++++++++++++++++++++++++++++++++ types/hubot/tsconfig.json | 21 ++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 types/hubot/index.d.ts create mode 100644 types/hubot/tsconfig.json diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts new file mode 100644 index 0000000000..6e81398a33 --- /dev/null +++ b/types/hubot/index.d.ts @@ -0,0 +1,53 @@ +// Type definitions for hubot 2.19.0 +// Project: https://hubot.github.com +// Definitions by: Dirk Gadsden +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'hubot' { + interface Brain { + userForId: (id: any) => any + } + + interface User { + id: any + name: string + } + + interface Message { + user: User + text: string + id: string + } + + interface Response { + match: RegExpMatchArray + message: Message + send: (...strings: string[]) => void + reply: (...strings: string[]) => void + random: (items: T[]) => T + } + + interface ListenerCallback { + (response: Response): void + } + + interface HearWithOptions { + (regex: RegExp, options: any, callback: ListenerCallback): void + } + interface HearWithoutOptions { + (regex: RegExp, callback: ListenerCallback): void + } + + interface RespondWithOptions { + (regex: RegExp, options: any, callback: ListenerCallback): void + } + interface RespondWithoutOptions { + (regex: RegExp, callback: ListenerCallback): void + } + + export interface Robot { + brain: Brain + hear: HearWithOptions & HearWithoutOptions + respond: RespondWithOptions & RespondWithoutOptions + } +} diff --git a/types/hubot/tsconfig.json b/types/hubot/tsconfig.json new file mode 100644 index 0000000000..7a0988e344 --- /dev/null +++ b/types/hubot/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es5" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} From e65b10905d5ec66f9fcae5c5d69160a9e9057e97 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 21:09:49 -0700 Subject: [PATCH 20/58] Add semicolons to match style --- types/hubot/index.d.ts | 50 ++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index 6e81398a33..b3c58947ba 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -3,51 +3,53 @@ // Definitions by: Dirk Gadsden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module 'hubot' { - interface Brain { - userForId: (id: any) => any +declare namespace Hubot { + class Brain { + userForId: (id: any) => any; } - interface User { - id: any - name: string + class User { + id: any; + name: string; } - interface Message { - user: User - text: string - id: string + class Message { + user: User; + text: string; + id: string; } - interface Response { - match: RegExpMatchArray - message: Message - send: (...strings: string[]) => void - reply: (...strings: string[]) => void - random: (items: T[]) => T + class Response { + match: RegExpMatchArray; + message: Message; + send: (...strings: string[]) => void; + reply: (...strings: string[]) => void; + random: (items: T[]) => T; } interface ListenerCallback { - (response: Response): void + (response: Response): void; } interface HearWithOptions { - (regex: RegExp, options: any, callback: ListenerCallback): void + (regex: RegExp, options: any, callback: ListenerCallback): void; } interface HearWithoutOptions { - (regex: RegExp, callback: ListenerCallback): void + (regex: RegExp, callback: ListenerCallback): void; } interface RespondWithOptions { - (regex: RegExp, options: any, callback: ListenerCallback): void + (regex: RegExp, options: any, callback: ListenerCallback): void; } interface RespondWithoutOptions { - (regex: RegExp, callback: ListenerCallback): void + (regex: RegExp, callback: ListenerCallback): void; } export interface Robot { - brain: Brain - hear: HearWithOptions & HearWithoutOptions - respond: RespondWithOptions & RespondWithoutOptions + brain: Brain; + hear: HearWithOptions & HearWithoutOptions; + respond: RespondWithOptions & RespondWithoutOptions; } } + +export = Hubot; From 0cdc06e03f287d97f313b3427151fd0df5df1da4 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 21:14:57 -0700 Subject: [PATCH 21/58] Add more complete type definitions for classes' methods --- types/hubot/index.d.ts | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index b3c58947ba..f136d88ceb 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -5,7 +5,8 @@ declare namespace Hubot { class Brain { - userForId: (id: any) => any; + userForId(id: any): any; + userForName(name: string): any; } class User { @@ -22,33 +23,24 @@ declare namespace Hubot { class Response { match: RegExpMatchArray; message: Message; - send: (...strings: string[]) => void; - reply: (...strings: string[]) => void; - random: (items: T[]) => T; + + constructor(robot: Robot, message: Message, match: RegExpMatchArray); + send(...strings: string[]): void; + reply(...strings: string[]): void; + random(items: T[]): T; } interface ListenerCallback { (response: Response): void; } - interface HearWithOptions { - (regex: RegExp, options: any, callback: ListenerCallback): void; - } - interface HearWithoutOptions { - (regex: RegExp, callback: ListenerCallback): void; - } - - interface RespondWithOptions { - (regex: RegExp, options: any, callback: ListenerCallback): void; - } - interface RespondWithoutOptions { - (regex: RegExp, callback: ListenerCallback): void; - } - export interface Robot { brain: Brain; - hear: HearWithOptions & HearWithoutOptions; - respond: RespondWithOptions & RespondWithoutOptions; + + hear(regex: RegExp, callback: ListenerCallback): void; + hear(regex: RegExp, options: any, callback: ListenerCallback): void; + response(regex: RegExp, callback: ListenerCallback): void; + response(regex: RegExp, options: any, callback: ListenerCallback): void; } } From 9bb3726120be4d4c0da629fb37943541fb848df8 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 21:21:53 -0700 Subject: [PATCH 22/58] Convert to class definition for `Robot` --- types/hubot/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index f136d88ceb..2126f7a2ff 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -34,9 +34,10 @@ declare namespace Hubot { (response: Response): void; } - export interface Robot { + class Robot { brain: Brain; + constructor(adapterPath: string, adapter: string, httpd: boolean, name: string, alias?: string); hear(regex: RegExp, callback: ListenerCallback): void; hear(regex: RegExp, options: any, callback: ListenerCallback): void; response(regex: RegExp, callback: ListenerCallback): void; From a2e65d34905fb1a0f36c6c9ecbb99d60251912b3 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 21:22:12 -0700 Subject: [PATCH 23/58] Add basic tests file for `hubot` --- types/hubot/hubot-tests.ts | 13 +++++++++++++ types/hubot/tsconfig.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 types/hubot/hubot-tests.ts diff --git a/types/hubot/hubot-tests.ts b/types/hubot/hubot-tests.ts new file mode 100644 index 0000000000..98307f1097 --- /dev/null +++ b/types/hubot/hubot-tests.ts @@ -0,0 +1,13 @@ +import * as Hubot from "hubot"; + +var brain = new Hubot.Brain(); // $ExpectType Hubot.Brain +brain.userForName('someone'); // $ExpectType any + +// $ExpectType Hubot.Robot +var robot = new Hubot.Robot( + 'src/adapters', + 'slack', + false, + 'hubot', +); +robot.hear(/hello/, () => null); // $ExpectType void diff --git a/types/hubot/tsconfig.json b/types/hubot/tsconfig.json index 7a0988e344..3477a2bde8 100644 --- a/types/hubot/tsconfig.json +++ b/types/hubot/tsconfig.json @@ -16,6 +16,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "hubot-tests.ts" ] } From c34ad711717c8df439438c38a7640da6cc82c766 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 21:28:25 -0700 Subject: [PATCH 24/58] `dts-gen` template for type definitions for `hubot` --- types/hubot/hubot-tests.ts | 0 types/hubot/index.d.ts | 4 ++++ types/hubot/tsconfig.json | 22 ++++++++++++++++++++++ types/hubot/tslint.json | 1 + 4 files changed, 27 insertions(+) create mode 100644 types/hubot/hubot-tests.ts create mode 100644 types/hubot/index.d.ts create mode 100644 types/hubot/tsconfig.json create mode 100644 types/hubot/tslint.json diff --git a/types/hubot/hubot-tests.ts b/types/hubot/hubot-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts new file mode 100644 index 0000000000..220809d09d --- /dev/null +++ b/types/hubot/index.d.ts @@ -0,0 +1,4 @@ +// Type definitions for hubot 2.19 +// Project: https://github.com/github/hubot +// Definitions by: Dirk Gadsden +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/hubot/tsconfig.json b/types/hubot/tsconfig.json new file mode 100644 index 0000000000..0e3faa4c35 --- /dev/null +++ b/types/hubot/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", + "hubot-tests.ts" + ] +} diff --git a/types/hubot/tslint.json b/types/hubot/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hubot/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b1b4c8a64f3d881c73ef08cc39b330108235cbc8 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 21:43:26 -0700 Subject: [PATCH 25/58] Reorder export and fix function type --- types/hubot/index.d.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index f0daff69b6..bf21fd6160 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Dirk Gadsden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = Hubot; + declare namespace Hubot { class Brain { userForId(id: any): any; @@ -30,9 +32,7 @@ declare namespace Hubot { random(items: T[]): T; } - interface ListenerCallback { - (response: Response): void; - } + type ListenerCallback = (response: Response) => void; class Robot { brain: Brain; @@ -44,5 +44,3 @@ declare namespace Hubot { response(regex: RegExp, options: any, callback: ListenerCallback): void; } } - -export = Hubot; From 8e110b17d0e02f148a25bae1afb907f6be513bcf Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 21:43:49 -0700 Subject: [PATCH 26/58] Improve tests for `hubot` definitions --- types/hubot/hubot-tests.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types/hubot/hubot-tests.ts b/types/hubot/hubot-tests.ts index 98307f1097..9c5e832bc2 100644 --- a/types/hubot/hubot-tests.ts +++ b/types/hubot/hubot-tests.ts @@ -1,13 +1,14 @@ import * as Hubot from "hubot"; -var brain = new Hubot.Brain(); // $ExpectType Hubot.Brain +const brain = new Hubot.Brain(); +brain; // $ExpectType Brain brain.userForName('someone'); // $ExpectType any -// $ExpectType Hubot.Robot -var robot = new Hubot.Robot( +const robot = new Hubot.Robot( 'src/adapters', 'slack', false, 'hubot', ); +robot; // $ExpectType Robot robot.hear(/hello/, () => null); // $ExpectType void From 79c97393ebe7ca776d41fb603dade05f37035948 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 22:04:57 -0700 Subject: [PATCH 27/58] Maintain compatibility with CommonJS export pattern from `hubot`'s CoffeeScript --- types/hubot/index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index bf21fd6160..6ed71de50c 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Dirk Gadsden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = Hubot; - declare namespace Hubot { class Brain { userForId(id: any): any; @@ -44,3 +42,8 @@ declare namespace Hubot { response(regex: RegExp, options: any, callback: ListenerCallback): void; } } + +// Compatibility with CommonJS syntax exported by Hubot's CoffeeScript. +// tslint:disable-next-line export-just-namespace +export = Hubot; +export as namespace Hubot; From 1aed6f7d4ef58d0088aa99d1559a7cfe42b14b28 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sat, 10 Jun 2017 22:07:41 -0700 Subject: [PATCH 28/58] Fix typo for `Hubot.Robot` --- types/hubot/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index 6ed71de50c..e0a809f69a 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -38,8 +38,8 @@ declare namespace Hubot { constructor(adapterPath: string, adapter: string, httpd: boolean, name: string, alias?: string); hear(regex: RegExp, callback: ListenerCallback): void; hear(regex: RegExp, options: any, callback: ListenerCallback): void; - response(regex: RegExp, callback: ListenerCallback): void; - response(regex: RegExp, options: any, callback: ListenerCallback): void; + respond(regex: RegExp, callback: ListenerCallback): void; + respond(regex: RegExp, options: any, callback: ListenerCallback): void; } } From 640742de3b44921d7b282b4c331329cc9d32f793 Mon Sep 17 00:00:00 2001 From: clarenceh Date: Sun, 11 Jun 2017 15:43:56 +0800 Subject: [PATCH 29/58] Add and fix types definition for massive js 3.0 --- types/massive/index.d.ts | 46 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/types/massive/index.d.ts b/types/massive/index.d.ts index 1ed6b62ac6..1bf0550b2c 100644 --- a/types/massive/index.d.ts +++ b/types/massive/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for massive 3.x +// Type definitions for massive 3.0 // Project: https://github.com/dmfay/massive-js.git // Definitions by: Pascal Birchler // Clarence Ho @@ -10,7 +10,7 @@ export = massive; declare function massive( - connection: object | string, + connection: massive.ConnectionInfo | string, loaderConfig?: object, driverConfig?: object): Promise; @@ -26,17 +26,55 @@ declare namespace massive { fallback_application_name?: boolean; } + interface QueryOptions { + columns?: string[]; + limit?: number; + offset?: number; + only?: boolean; + order?: string[]; + orderBody?: boolean; + build?: boolean; + document?: boolean; + single?: boolean; + stream?: boolean; + } + + interface SearchCriteria { + fields: string[]; + term: string; + } + + interface Table { + find(criteria: object | {}, queryOptions?: QueryOptions): Promise; + findOne(criteria: number | object, queryOptions?: QueryOptions): Promise; + count(criteria: object): Promise; + where(query: string, params: any[] | object): Promise; + search(criteria: SearchCriteria, queryOptions?: QueryOptions): Promise; + save(data: object): Promise; + insert(data: object): Promise; + update(dataOrCriteria: object, changesMap?: object): Promise; + destroy(criteria: object): Promise; + } + + interface Document { + countDoc(criteria: object): Promise; + findDoc(criteria: number | string| object): Promise; + searchDoc(criteria: SearchCriteria): Promise; + saveDoc(doc: object): Promise; + modify(docId: number | string, doc: object, fieldName?: string): Promise; + } + interface Database { attach(ctor: any, ...sources: any[]): Promise; detach(entity: string, collection: string): void; reload(): void; query(query: any, params: any, options: any): Promise; - saveDoc(collection: any, doc: any): any; + saveDoc(collectionName: string, doc: object): Promise; createDocumentTable(path: any): Promise; getObject(path: any, collection: any): object; dropTable(table: string, options: any): void; createSchema(schemaName: string): void; dropSchema(schemaName: string, options: any): void; - [name: string]: any; + run(query: string, params: any[] | object): Promise; } } From feff9f9c3813b2a285a1fd31e0a672507fd92ee9 Mon Sep 17 00:00:00 2001 From: afractal Date: Sun, 11 Jun 2017 19:29:58 +0200 Subject: [PATCH 30/58] add declarations for sharp-timer --- types/sharp-timer/index.d.ts | 52 ++++++++++++++++++++++++++ types/sharp-timer/sharp-timer-tests.ts | 11 ++++++ types/sharp-timer/tsconfig.json | 22 +++++++++++ types/sharp-timer/tslint.json | 3 ++ 4 files changed, 88 insertions(+) create mode 100644 types/sharp-timer/index.d.ts create mode 100644 types/sharp-timer/sharp-timer-tests.ts create mode 100644 types/sharp-timer/tsconfig.json create mode 100644 types/sharp-timer/tslint.json diff --git a/types/sharp-timer/index.d.ts b/types/sharp-timer/index.d.ts new file mode 100644 index 0000000000..65cf798feb --- /dev/null +++ b/types/sharp-timer/index.d.ts @@ -0,0 +1,52 @@ +// Type definitions for sharp-timer 0.3 +// Project: https://github.com/afractal/SharpTimer +// Definitions by: Hermes Gjini - afractal +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export type ElapsedEvent = () => void; +export type ElapsingEvent = (intervalValue: number) => void; + +export class Timer { + private _enabled; + private _stopped; + private _interval; + private _intervalElapsedEvents; + private _intervalElapsingEvents; + constructor(interval: number); + readonly enabled: boolean; + readonly stopped: boolean; + interval: number; + start(): void; + pause(): void; + resume(): void; + stop(): void; + onIntervalElapsed(intervalElapsedHandler: any): void; + onIntervalElapsing(intervalElapsingHandler: any): void; + toString(): string; + private getDoubleDigit(number); + private checkForValidInterval(interval); +} + +export class Stopwatch { + private _isRunning; + private _elapsedMilliseconds; + private _startedTimeInMillis; + private _intervalIds; + private static readonly millisPerSecond; + private static readonly millisPerMinute; + private static readonly millisPerHour; + constructor(); + readonly elapsed: string; + readonly elapsedMilliseconds: number; + readonly elapsedSeconds: number; + readonly elapsedMinutes: number; + readonly elapsedHours: number; + readonly isRunning: boolean; + static startNew(): Stopwatch; + start(): void; + stop(): void; + reset(): void; + restart(): void; + dispose(): void; + private getDoubleDigit(num); +} diff --git a/types/sharp-timer/sharp-timer-tests.ts b/types/sharp-timer/sharp-timer-tests.ts new file mode 100644 index 0000000000..685bf1b1d9 --- /dev/null +++ b/types/sharp-timer/sharp-timer-tests.ts @@ -0,0 +1,11 @@ +import { Timer, Stopwatch } from 'sharp-timer'; + +let timer = new Timer(10); + +timer.onIntervalElapsing(i => { }); +timer.onIntervalElapsed(() => { + timer.stop(); + timer = null; +}); + +timer.start(); diff --git a/types/sharp-timer/tsconfig.json b/types/sharp-timer/tsconfig.json new file mode 100644 index 0000000000..851bf69389 --- /dev/null +++ b/types/sharp-timer/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sharp-timer-tests.ts" + ] +} diff --git a/types/sharp-timer/tslint.json b/types/sharp-timer/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/sharp-timer/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From bec4cf3ed07fd50e6a0d85bb4f7b627a99272f7c Mon Sep 17 00:00:00 2001 From: clarenceh Date: Mon, 12 Jun 2017 09:26:29 +0800 Subject: [PATCH 31/58] Updated Table type to support generics --- types/massive/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/massive/index.d.ts b/types/massive/index.d.ts index 1bf0550b2c..67be093bb0 100644 --- a/types/massive/index.d.ts +++ b/types/massive/index.d.ts @@ -44,16 +44,16 @@ declare namespace massive { term: string; } - interface Table { - find(criteria: object | {}, queryOptions?: QueryOptions): Promise; - findOne(criteria: number | object, queryOptions?: QueryOptions): Promise; + interface Table { + find(criteria: object | {}, queryOptions?: QueryOptions): Promise; + findOne(criteria: number | object, queryOptions?: QueryOptions): Promise; count(criteria: object): Promise; - where(query: string, params: any[] | object): Promise; + where(query: string, params: any[] | object): Promise; search(criteria: SearchCriteria, queryOptions?: QueryOptions): Promise; - save(data: object): Promise; - insert(data: object): Promise; - update(dataOrCriteria: object, changesMap?: object): Promise; - destroy(criteria: object): Promise; + save(data: object): Promise; + insert(data: object): Promise; + update(dataOrCriteria: object, changesMap?: object): Promise; + destroy(criteria: object): Promise; } interface Document { From 465f8b7798e59f7549c9009b9dc8b79366926c74 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 11 Jun 2017 19:36:57 -0700 Subject: [PATCH 32/58] Add default parameter --- types/react-leaflet/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 618fcd5c73..db3dc44e7c 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -181,7 +181,7 @@ export interface LayerContainer { addLayer(layer: Leaflet.Layer): this; removeLayer(layer: number | Leaflet.Layer): this; } -export class MapLayer

extends MapComponent { +export class MapLayer

extends MapComponent { createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; readonly layerContainer: LayerContainer | Leaflet.Map; @@ -190,7 +190,7 @@ export class MapLayer

extends export interface GridLayerProps extends Leaflet.GridLayerOptions { children?: Children; } -export class GridLayer

extends MapLayer {} +export class GridLayer

extends MapLayer {} export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOptions { children?: Children; @@ -209,14 +209,14 @@ export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { children?: Children; url: string; } -export class ImageOverlay

extends MapLayer { +export class ImageOverlay

extends MapLayer { getChildContext(): { popupContainer: E }; } export interface LayerGroupProps { children?: Children; } -export class LayerGroup

extends MapLayer { +export class LayerGroup

extends MapLayer { getChildContext(): { layerContainer: E }; } @@ -262,7 +262,7 @@ export interface GeoJSONProps extends FeatureGroupEvents, Leaflet.GeoJSONOptions data: GeoJSON.GeoJsonObject; style?: Leaflet.StyleFunction; } -export class GeoJSON

extends Path { } +export class GeoJSON

extends Path { } export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions { children?: Children; @@ -306,14 +306,14 @@ export class Tooltip

extends React.Component { +export class MapControl

extends React.Component { leafletElement: E; createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; } export type AttributionControlProps = Leaflet.Control.AttributionOptions; -export class AttributionControl

extends MapControl { } +export class AttributionControl

extends MapControl { } export interface LayersControlProps extends LayersControlEvents, Leaflet.Control.LayersOptions { baseLayers?: Leaflet.Control.LayersObject; @@ -334,18 +334,18 @@ export namespace LayersControl { addOverlay?(layer: Leaflet.Layer, name: string, checked: boolean): void; name: string; } - class ControlledLayer

extends React.Component { + class ControlledLayer

extends React.Component { layer?: Leaflet.Layer; getChildContext(): { layerContainer: LayerContainer }; addLayer(): void; removeLayer(layer: Leaflet.Layer): void; } - class BaseLayer

extends ControlledLayer

{ } + class BaseLayer

extends ControlledLayer

{ } class Overlay

extends ControlledLayer

{ } } export type ScaleControlProps = Leaflet.Control.ScaleOptions; -export class ScaleControl

extends MapControl { } +export class ScaleControl

extends MapControl { } export type ZoomControlProps = Leaflet.Control.ZoomOptions; export class ZoomControl

extends MapControl { } From 05ddcaf6c234ee861b0f59d5f6b27acc4b914cfe Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 11 Jun 2017 20:46:11 -0700 Subject: [PATCH 33/58] Update Cordova breaking on 2.4 --- .../cordova-plugin-battery-status/index.d.ts | 119 +++--------------- types/cordova-plugin-inappbrowser/index.d.ts | 95 +------------- 2 files changed, 18 insertions(+), 196 deletions(-) diff --git a/types/cordova-plugin-battery-status/index.d.ts b/types/cordova-plugin-battery-status/index.d.ts index 9baedc8cb0..60480135df 100644 --- a/types/cordova-plugin-battery-status/index.d.ts +++ b/types/cordova-plugin-battery-status/index.d.ts @@ -6,114 +6,25 @@ // Copyright (c) Microsoft Open Technologies Inc // Licensed under the MIT license. +interface WindowEventMap { + /** + * batterystatus: event fires when the percentage of battery charge changes by at least 1 percent, or if the device is plugged in or unplugged. + */ + "batterystatus" : BatteryStatusEvent; + /** + * batterycritical: event fires when the percentage of battery charge has reached the critical battery threshold. The value is device-specific. + */ + "batterycritical": BatteryStatusEvent; + /** + * batterylow: event fires when the percentage of battery charge has reached the low battery threshold, device-specific value. + */ + "batterylow": BatteryStatusEvent; +} + interface Window { onbatterystatus: (type: BatteryStatusEvent) => void; onbatterycritical: (type: BatteryStatusEvent) => void; onbatterylow: (type: BatteryStatusEvent) => void; - /** - * Adds a listener for an event from the BatteryStatus plugin. - * @param type the event to listen for - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param listener the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - addEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; - /** - * Adds a listener for an event from the BatteryStatus plugin. - * @param type the event to listen for - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param listener the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - addEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; - /** - * Adds a listener for an event from the BatteryStatus plugin. - * @param type the event to listen for - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param listener the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - addEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; - /** - * Adds a listener for an event from the BatteryStatus plugin. - * @param type the event to listen for - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param listener the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void; - /** - * Removes a listener for an event from the BatteryStatus plugin. - * @param type The event to stop listening for. - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param callback the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - removeEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; - /** - * Removes a listener for an event from the BatteryStatus plugin. - * @param type The event to stop listening for. - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param callback the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - removeEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; - /** - * Removes a listener for an event from the BatteryStatus plugin. - * @param type The event to stop listening for. - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param callback the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - removeEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; - /** - * Removes a listener for an event from the BatteryStatus plugin. - * @param type The event to stop listening for. - * batterystatus: event fires when the percentage of battery charge - * changes by at least 1 percent, or if the device is plugged in or unplugged. - * batterycritical: event fires when the percentage of battery charge has reached - * the critical battery threshold. The value is device-specific. - * batterylow: event fires when the percentage of battery charge has - * reached the low battery threshold, device-specific value. - * @param callback the function that executes when the event fires. The function is - * passed an BatteryStatusEvent object as a parameter. - */ - removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void; } /** Object, that passed into battery event listener */ diff --git a/types/cordova-plugin-inappbrowser/index.d.ts b/types/cordova-plugin-inappbrowser/index.d.ts index ea3d3adba8..78859d4209 100644 --- a/types/cordova-plugin-inappbrowser/index.d.ts +++ b/types/cordova-plugin-inappbrowser/index.d.ts @@ -57,59 +57,14 @@ interface InAppBrowser extends Window { // addEventListener overloads /** * Adds a listener for an event from the InAppBrowser. - * @param type the event to listen for - * loadstart: event fires when the InAppBrowser starts to load a URL. + * @param type loadstart: event fires when the InAppBrowser starts to load a URL. * loadstop: event fires when the InAppBrowser finishes loading a URL. * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. * exit: event fires when the InAppBrowser window is closed. * @param callback the function that executes when the event fires. The function is * passed an InAppBrowserEvent object as a parameter. */ - addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void; - /** - * Adds a listener for an event from the InAppBrowser. - * @param type the event to listen for - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an InAppBrowserEvent object as a parameter. - */ - addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void; - /** - * Adds a listener for an event from the InAppBrowser. - * @param type the event to listen for - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an InAppBrowserEvent object as a parameter. - */ - addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void; - /** - * Adds a listener for an event from the InAppBrowser. - * @param type the event to listen for - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an InAppBrowserEvent object as a parameter. - */ - addEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void; - /** - * Adds a listener for an event from the InAppBrowser. - * @param type the event to listen for - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an Event object as a parameter. - */ - addEventListener(type: string, callback: (event: Event) => void): void; + addEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void; // removeEventListener overloads /** * Removes a listener for an event from the InAppBrowser. @@ -121,51 +76,7 @@ interface InAppBrowser extends Window { * @param callback the function that executes when the event fires. The function is * passed an InAppBrowserEvent object as a parameter. */ - removeEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void; - /** - * Removes a listener for an event from the InAppBrowser. - * @param type The event to stop listening for. - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an InAppBrowserEvent object as a parameter. - */ - removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void; - /** - * Removes a listener for an event from the InAppBrowser. - * @param type The event to stop listening for. - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an InAppBrowserEvent object as a parameter. - */ - removeEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void; - /** - * Removes a listener for an event from the InAppBrowser. - * @param type The event to stop listening for. - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an InAppBrowserEvent object as a parameter. - */ - removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void; - /** - * Removes a listener for an event from the InAppBrowser. - * @param type The event to stop listening for. - * loadstart: event fires when the InAppBrowser starts to load a URL. - * loadstop: event fires when the InAppBrowser finishes loading a URL. - * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. - * exit: event fires when the InAppBrowser window is closed. - * @param callback the function that executes when the event fires. The function is - * passed an Event object as a parameter. - */ - removeEventListener(type: string, callback: (event: Event) => void): void; + removeEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void; /** Closes the InAppBrowser window. */ close(): void; /** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */ From 127ed8a779e7f6d7c84c09134be141a3122524bc Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 11 Jun 2017 20:46:21 -0700 Subject: [PATCH 34/58] Update tests --- .../cordova-plugin-battery-status-tests.ts | 10 ++++++++-- .../cordova-plugin-inappbrowser-tests.ts | 11 ++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts index 1c62521293..4d31c36a7f 100644 --- a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts +++ b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts @@ -1,5 +1,11 @@ -window.addEventListener('batterystatus', - (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); }); +/// +window.addEventListener('batterystatus', (ev) => { console.log('Battery level is ' + ev.level); }); +window.addEventListener('batterycritical', (ev) => { console.log('Battery is critical: ' + ev.level); }); +window.addEventListener('batterylow', (ev) => { console.log('Battery is low: ' + ev.level); }); + +window.removeEventListener('batterystatus', (ev) => { console.log('Remove: Battery level is ' + ev.level); }); +window.removeEventListener('batterycritical', (ev) => { console.log('Remove: Battery is critical: ' + ev.level); }); +window.removeEventListener('batterylow', (ev) => { console.log('Remove: Battery is low: ' + ev.level); }); window.addEventListener('batterycritical', () => { alert('Battery is critical low!'); }); \ No newline at end of file diff --git a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts index cef288c921..ec98249893 100644 --- a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts +++ b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts @@ -1,3 +1,4 @@ +/// // InAppBrowser plugin //---------------------------------------------------------------------- @@ -5,7 +6,15 @@ // is similar to native window.open signature, so the compiler can's // select proper overload, but we cast result to InAppBrowser manually. var iab = window.open('google.com', '_self'); -iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); }); +iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); }); +iab.addEventListener('loadstop', (ev) => { console.log('loadstop' + ev.code); }); +iab.addEventListener('loaderror', (ev) => { console.log('loaderror' + ev.code); }); +iab.addEventListener('exit', (ev) => { console.log('exit' + ev.code); }); + +iab.removeEventListener('loadstart', (ev) => { console.log('Remove loadstart' + ev.url); }); +iab.removeEventListener('loadstop', (ev) => { console.log('Remove loadstop ' + ev.code); }); +iab.removeEventListener('loaderror', (ev) => { console.log('Remove loaderror ' + ev.code); }); +iab.removeEventListener('exit', (ev) => { console.log('Remove exit ' + ev.code); }); iab.show(); iab.executeScript( { code: "console.log('Injected script in action')" }, From d898918cc6eda557a3a874434397d5529c585ef4 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 11 Jun 2017 21:09:56 -0700 Subject: [PATCH 35/58] Add removeEventListener --- types/cordova-plugin-battery-status/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/cordova-plugin-battery-status/index.d.ts b/types/cordova-plugin-battery-status/index.d.ts index 60480135df..4bf3115fe4 100644 --- a/types/cordova-plugin-battery-status/index.d.ts +++ b/types/cordova-plugin-battery-status/index.d.ts @@ -25,6 +25,8 @@ interface Window { onbatterystatus: (type: BatteryStatusEvent) => void; onbatterycritical: (type: BatteryStatusEvent) => void; onbatterylow: (type: BatteryStatusEvent) => void; + removeEventListener(type: K, listener: (ev: WindowEventMap[K]) => any, useCapture?: boolean): void; + removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void; } /** Object, that passed into battery event listener */ From 16cb5a4a1436787091b7f8a589beaff13af8fb7d Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 11 Jun 2017 21:23:41 -0700 Subject: [PATCH 36/58] Remove test failure cause --- .../cordova-plugin-inappbrowser-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts index ec98249893..d381f52375 100644 --- a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts +++ b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts @@ -1,4 +1,3 @@ -/// // InAppBrowser plugin //---------------------------------------------------------------------- From 86e7e14c723a59c30c7ad5ef2fc5cdaf4a7813b2 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 11 Jun 2017 21:27:18 -0700 Subject: [PATCH 37/58] Remove test failure cause --- .../cordova-plugin-battery-status-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts index 4d31c36a7f..e0433bf89b 100644 --- a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts +++ b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts @@ -1,4 +1,3 @@ -/// window.addEventListener('batterystatus', (ev) => { console.log('Battery level is ' + ev.level); }); window.addEventListener('batterycritical', (ev) => { console.log('Battery is critical: ' + ev.level); }); window.addEventListener('batterylow', (ev) => { console.log('Battery is low: ' + ev.level); }); From 61dd4d34f82c5a0f2bb86bd444c0fdd8a1d2255a Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 11 Jun 2017 21:43:52 -0700 Subject: [PATCH 38/58] Add Typescript Version 2.3 --- types/cordova-plugin-battery-status/index.d.ts | 3 ++- types/cordova-plugin-inappbrowser/index.d.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/cordova-plugin-battery-status/index.d.ts b/types/cordova-plugin-battery-status/index.d.ts index 4bf3115fe4..f120d3d7e9 100644 --- a/types/cordova-plugin-battery-status/index.d.ts +++ b/types/cordova-plugin-battery-status/index.d.ts @@ -4,7 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // // Copyright (c) Microsoft Open Technologies Inc -// Licensed under the MIT license. +// Licensed under the MIT license. +// TypeScript Version: 2.3 interface WindowEventMap { /** diff --git a/types/cordova-plugin-inappbrowser/index.d.ts b/types/cordova-plugin-inappbrowser/index.d.ts index 78859d4209..91dc61314f 100644 --- a/types/cordova-plugin-inappbrowser/index.d.ts +++ b/types/cordova-plugin-inappbrowser/index.d.ts @@ -5,6 +5,7 @@ // // Copyright (c) Microsoft Open Technologies Inc // Licensed under the MIT license. +// TypeScript Version: 2.3 interface Window { /** From e77bb4a004e634f6649b75109b1d978026314e88 Mon Sep 17 00:00:00 2001 From: Christopher Mckay Date: Mon, 12 Jun 2017 15:39:11 +1000 Subject: [PATCH 39/58] ramda find functions can return undefined http://ramdajs.com/docs/#find --- types/ramda/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 79d1b1f6cf..4d6be6138f 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -587,8 +587,8 @@ declare namespace R { * Returns the first element of the list which matches the predicate, or `undefined` if no * element matches. */ - find(fn: (a: T) => boolean, list: T[]): T; - find(fn: (a: T) => boolean): (list: T[]) => T; + find(fn: (a: T) => boolean, list: T[]): T | undefined; + find(fn: (a: T) => boolean): (list: T[]) => T | undefined; /** @@ -602,8 +602,8 @@ declare namespace R { * Returns the last element of the list which matches the predicate, or `undefined` if no * element matches. */ - findLast(fn: (a: T) => boolean, list: T[]): T; - findLast(fn: (a: T) => boolean): (list: T[]) => T; + findLast(fn: (a: T) => boolean, list: T[]): T | undefined; + findLast(fn: (a: T) => boolean): (list: T[]) => T | undefined; /** * Returns the index of the last element of the list which matches the predicate, or From dc4db8db5668cad7d50209f2438fa84954b9036d Mon Sep 17 00:00:00 2001 From: afractal Date: Mon, 12 Jun 2017 10:58:49 +0200 Subject: [PATCH 40/58] update definitions for sharp-timer --- types/sharp-timer/index.d.ts | 4 ++-- types/sharp-timer/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/sharp-timer/index.d.ts b/types/sharp-timer/index.d.ts index 65cf798feb..928a47eed7 100644 --- a/types/sharp-timer/index.d.ts +++ b/types/sharp-timer/index.d.ts @@ -20,8 +20,8 @@ export class Timer { pause(): void; resume(): void; stop(): void; - onIntervalElapsed(intervalElapsedHandler: any): void; - onIntervalElapsing(intervalElapsingHandler: any): void; + onIntervalElapsed(intervalElapsedHandler: ElapsedEvent): void; + onIntervalElapsing(intervalElapsingHandler: ElapsingEvent): void; toString(): string; private getDoubleDigit(number); private checkForValidInterval(interval); diff --git a/types/sharp-timer/tsconfig.json b/types/sharp-timer/tsconfig.json index 851bf69389..3306511dec 100644 --- a/types/sharp-timer/tsconfig.json +++ b/types/sharp-timer/tsconfig.json @@ -4,7 +4,7 @@ "lib": [ "es6" ], - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": false, "strictNullChecks": false, "baseUrl": "../", From c9e01b3e760ee7e2f93a7c9052d432f6713347c8 Mon Sep 17 00:00:00 2001 From: Michiel de Bruijne Date: Mon, 12 Jun 2017 15:56:21 +0200 Subject: [PATCH 41/58] [node] improve type definitions in cluster, http, https, process modules (#16705) * [node] fix headers and trailers in interface IncomingMessage * [node] set correct type to requestListener in https.createServer * [node] export required interfaces in https * [node] add process events * [node] make worker and workers optional in cluster module cluster.worker is not available in the master process cluster.workers is not available in the worker process * [node] add string[] to headers type to account for the set-cookie exception * [node] set TypeScript version to 2.2 to enable Promise support --- types/node/index.d.ts | 96 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 88 insertions(+), 8 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 1b121efb2d..2fd023b56b 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -7,6 +7,7 @@ // Christian Vaagland Tellnes // Wilco Bakker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /************************************************ * * @@ -377,6 +378,12 @@ declare namespace NodeJS { | 'sunos' | 'win32'; + type Signals = + "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" | + "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" | + "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" | + "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ"; + export interface Socket extends ReadWriteStream { isTTY?: true; } @@ -449,6 +456,73 @@ declare namespace NodeJS { send?(message: any, sendHandle?: any): void; disconnect(): void; connected: boolean; + + /** + * EventEmitter + * 1. beforeExit + * 2. disconnect + * 3. exit + * 4. message + * 5. rejectionHandled + * 6. uncaughtException + * 7. unhandledRejection + * 8. warning + * 9. + */ + + addListener(event: "beforeExit", listener: (code: number) => void): this; + addListener(event: "disconnect", listener: () => void): this; + addListener(event: "exit", listener: (code: number) => void): this; + addListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; + addListener(event: "uncaughtException", listener: (error: Error) => void): this; + addListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; + addListener(event: "warning", listener: (warning: Error) => void): this; + addListener(event: Signals, listener: () => void): this; + + emit(event: "beforeExit", listener: (code: number) => void): boolean; + emit(event: "disconnect", listener: () => void): boolean; + emit(event: "exit", listener: (code: number) => void): boolean; + emit(event: "rejectionHandled", listener: (promise: Promise) => void): boolean; + emit(event: "uncaughtException", listener: (error: Error) => void): boolean; + emit(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): boolean; + emit(event: "warning", listener: (warning: Error) => void): boolean; + emit(event: Signals, listener: () => void): boolean; + + on(event: "beforeExit", listener: (code: number) => void): this; + on(event: "disconnect", listener: () => void): this; + on(event: "exit", listener: (code: number) => void): this; + on(event: "rejectionHandled", listener: (promise: Promise) => void): this; + on(event: "uncaughtException", listener: (error: Error) => void): this; + on(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; + on(event: "warning", listener: (warning: Error) => void): this; + on(event: Signals, listener: () => void): this; + + once(event: "beforeExit", listener: (code: number) => void): this; + once(event: "disconnect", listener: () => void): this; + once(event: "exit", listener: (code: number) => void): this; + once(event: "rejectionHandled", listener: (promise: Promise) => void): this; + once(event: "uncaughtException", listener: (error: Error) => void): this; + once(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; + once(event: "warning", listener: (warning: Error) => void): this; + once(event: Signals, listener: () => void): this; + + prependListener(event: "beforeExit", listener: (code: number) => void): this; + prependListener(event: "disconnect", listener: () => void): this; + prependListener(event: "exit", listener: (code: number) => void): this; + prependListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; + prependListener(event: "uncaughtException", listener: (error: Error) => void): this; + prependListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; + prependListener(event: "warning", listener: (warning: Error) => void): this; + prependListener(event: Signals, listener: () => void): this; + + prependOnceListener(event: "beforeExit", listener: (code: number) => void): this; + prependOnceListener(event: "disconnect", listener: () => void): this; + prependOnceListener(event: "exit", listener: (code: number) => void): this; + prependOnceListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; + prependOnceListener(event: "uncaughtException", listener: (error: Error) => void): this; + prependOnceListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; + prependOnceListener(event: "warning", listener: (warning: Error) => void): this; + prependOnceListener(event: Signals, listener: () => void): this; } export interface Global { @@ -734,10 +808,10 @@ declare module "http" { httpVersionMajor: number; httpVersionMinor: number; connection: net.Socket; - headers: any; + headers: { [key: string]: string | string[] }; rawHeaders: string[]; - trailers: any; - rawTrailers: any; + trailers: { [key: string]: string }; + rawTrailers: string[]; setTimeout(msecs: number, callback: Function): NodeJS.Timer; /** * Only valid for request obtained from http.Server. @@ -920,8 +994,8 @@ declare module "cluster" { // TODO: cluster.schedulingPolicy settings: ClusterSettings; setupMaster(settings?: ClusterSetupMasterSettings): void; - worker: Worker; - workers: { + worker?: Worker; + workers?: { [index: string]: Worker }; @@ -1391,6 +1465,12 @@ declare module "https" { secureProtocol?: string; } + export interface ClientRequest extends http.ClientRequest {} + + export interface IncomingMessage extends http.IncomingMessage {} + + export interface ServerResponse extends http.ServerResponse { } + export interface Agent extends http.Agent { } export interface AgentOptions extends http.AgentOptions { @@ -1409,9 +1489,9 @@ declare module "https" { new (options?: AgentOptions): Agent; }; export interface Server extends tls.Server { } - export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export function createServer(options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server; + export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export function get(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; export var globalAgent: Agent; } From d0e32728038891ef24559d819affc53699a5cc1d Mon Sep 17 00:00:00 2001 From: Albert Kurniawan Date: Mon, 12 Jun 2017 23:06:46 +1000 Subject: [PATCH 42/58] Updated RedisStoreOptions in @types/connect-redis --- types/connect-redis/connect-redis-tests.ts | 6 ++++++ types/connect-redis/index.d.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/types/connect-redis/connect-redis-tests.ts b/types/connect-redis/connect-redis-tests.ts index 3c50074117..11cd583a74 100644 --- a/types/connect-redis/connect-redis-tests.ts +++ b/types/connect-redis/connect-redis-tests.ts @@ -2,3 +2,9 @@ import * as connectRedis from "connect-redis"; import * as session from "express-session"; let RedisStore = connectRedis(session); +const store = new RedisStore({ + host: 'localhost', + port: 6379, + logErrors: error => console.warn(error), + scanCount: 80, +}); diff --git a/types/connect-redis/index.d.ts b/types/connect-redis/index.d.ts index f66314a083..b5084609a2 100644 --- a/types/connect-redis/index.d.ts +++ b/types/connect-redis/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for connect-redis // Project: https://npmjs.com/package/connect-redis // Definitions by: Xavier Stouder +// Albert Kurniawan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -32,6 +33,8 @@ declare module "connect-redis" { prefix?: string; unref?: boolean; serializer?: Serializer | JSON; + logErrors?: boolean | ((error: string) => void); + scanCount?: number; } interface Serializer { stringify: Function; From d807e9544ab77f97ef2bfab336161def61bc113f Mon Sep 17 00:00:00 2001 From: esplo Date: Tue, 13 Jun 2017 01:06:28 +0900 Subject: [PATCH 43/58] [material-ui] add iconStyle to CardHeader --- types/material-ui/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/material-ui/index.d.ts b/types/material-ui/index.d.ts index 7308c0f089..560b21f2ca 100644 --- a/types/material-ui/index.d.ts +++ b/types/material-ui/index.d.ts @@ -832,6 +832,7 @@ declare namespace __MaterialUI { className?: string; openIcon?: React.ReactNode; closeIcon?: React.ReactNode; + iconStyle?: React.CSSProperties; } export class CardHeader extends React.Component { } From 2b9d93ec88f7da5e427ab7f81910dbdf7946e2e5 Mon Sep 17 00:00:00 2001 From: krister Date: Mon, 12 Jun 2017 21:57:51 +0300 Subject: [PATCH 44/58] Enable linting --- types/react-intl/index.d.ts | 64 +++++++++++++-------------- types/react-intl/react-intl-tests.tsx | 28 +++++++----- types/react-intl/tslint.json | 1 + 3 files changed, 49 insertions(+), 44 deletions(-) create mode 100644 types/react-intl/tslint.json diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 9777987c8d..644e9c9450 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -1,22 +1,22 @@ -// Type definitions for react-intl 2.2 +// Type definitions for react-intl 2.3 // Project: http://formatjs.io/react/ // Definitions by: Bruno Grieder , // Christian Droulers , // Fedor Nezhivoi , // Till Wolff , // Karol Janyst , -// Brian Houser +// Brian Houser , +// Krister Kari // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 declare namespace ReactIntl { - type DateSource = Date | string | number; interface Locale { locale: string; - fields?: { [key: string]: string }, - pluralRuleFunction?: (n: number, ord: boolean) => string; + fields?: { [key: string]: string }; + pluralRuleFunction?(n: number, ord: boolean): string; } type LocaleData = Locale[]; @@ -26,7 +26,7 @@ declare namespace ReactIntl { withRef?: boolean; } - type ComponentConstructor

= React.ComponentClass

| React.StatelessComponent

+ type ComponentConstructor

= React.ComponentClass

| React.StatelessComponent

; function injectIntl

(component: ComponentConstructor

, options?: InjectIntlConfig): React.ComponentClass

& { WrappedComponent: ComponentConstructor

}; @@ -34,7 +34,7 @@ declare namespace ReactIntl { function addLocaleData(data: Locale[] | Locale): void; interface Messages { - [key: string]: FormattedMessage.MessageDescriptor + [key: string]: FormattedMessage.MessageDescriptor; } function defineMessages(messages: T): T; @@ -64,19 +64,19 @@ declare namespace ReactIntl { const intlShape: IntlShape; interface InjectedIntl { - formatDate: (value: DateSource, options?: FormattedDate.PropsBase) => string; - formatTime: (value: DateSource, options?: FormattedTime.PropsBase) => string; - formatRelative: (value: DateSource, options?: FormattedRelative.PropsBase & { now?: any }) => string; - formatNumber: (value: number, options?: FormattedNumber.PropsBase) => string; - formatPlural: (value: number, options?: FormattedPlural.Base) => keyof FormattedPlural.PropsBase; - formatMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number}) => string; - formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string}) => string; + formatDate(value: DateSource, options?: FormattedDate.PropsBase): string; + formatTime(value: DateSource, options?: FormattedTime.PropsBase): string; + formatRelative(value: DateSource, options?: FormattedRelative.PropsBase & { now?: any }): string; + formatNumber(value: number, options?: FormattedNumber.PropsBase): string; + formatPlural(value: number, options?: FormattedPlural.Base): keyof FormattedPlural.PropsBase; + formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number}): string; + formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string}): string; locale: string; formats: any; messages: { [id: string]: string }; defaultLocale: string; defaultFormats: any; - now : () => number; + now(): number; } interface InjectedIntlProps { @@ -90,9 +90,9 @@ declare namespace ReactIntl { } namespace FormattedDate { - export interface PropsBase extends IntlComponent.DateTimeFormatProps {} + type PropsBase = IntlComponent.DateTimeFormatProps; - export interface Props extends PropsBase { + interface Props extends PropsBase { value: DateSource; } } @@ -100,16 +100,16 @@ declare namespace ReactIntl { class FormattedDate extends React.Component { } namespace FormattedTime { - export interface PropsBase extends IntlComponent.DateTimeFormatProps {} + type PropsBase = IntlComponent.DateTimeFormatProps; - export interface Props extends PropsBase { + interface Props extends PropsBase { value: DateSource; } } class FormattedTime extends React.Component { } namespace FormattedRelative { - export interface PropsBase { + interface PropsBase { /* * one of "second", "minute", "hour", "day", "month" or "year" */ @@ -123,7 +123,7 @@ declare namespace ReactIntl { initialNow?: any; } - export interface Props extends PropsBase { + interface Props extends PropsBase { value: DateSource; } } @@ -131,13 +131,13 @@ declare namespace ReactIntl { class FormattedRelative extends React.Component { } namespace FormattedMessage { - export interface MessageDescriptor { + interface MessageDescriptor { id: string; description?: string; defaultMessage?: string; } - export interface Props extends MessageDescriptor { + interface Props extends MessageDescriptor { values?: {[key: string]: string | number | JSX.Element}; tagName?: string; } @@ -147,26 +147,25 @@ declare namespace ReactIntl { class FormattedHTMLMessage extends React.Component { } namespace FormattedNumber { - export interface PropsBase extends Intl.NumberFormatOptions { + interface PropsBase extends Intl.NumberFormatOptions { format?: string; } - export interface Props extends PropsBase { + interface Props extends PropsBase { value: number; } } class FormattedNumber extends React.Component { } - namespace FormattedPlural { - export interface Base { + interface Base { /* * one of "cardinal" (default) | "ordinal" */ style?: "cardinal" | "ordinal"; } - export interface PropsBase extends Base { + interface PropsBase extends Base { other?: any; zero?: any; one?: any; @@ -175,15 +174,14 @@ declare namespace ReactIntl { many?: any; } - export interface Props extends PropsBase { + interface Props extends PropsBase { value: number; } } class FormattedPlural extends React.Component { } - namespace IntlProvider { - export interface Props { + interface Props { locale?: string; formats?: any; messages?: any; @@ -196,12 +194,12 @@ declare namespace ReactIntl { class IntlProvider extends React.Component { getChildContext(): { intl: InjectedIntl; - } + }; } } declare module "react-intl" { - export = ReactIntl + export = ReactIntl; } declare module "react-intl/locale-data/af" { diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index 8b21ef8651..42305ef571 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -3,8 +3,8 @@ * Updated by Fedor Nezhivoi */ -import * as React from "react" -import * as reactMixin from "react-mixin" +import * as React from "react"; +import * as reactMixin from "react-mixin"; import { IntlProvider, @@ -21,14 +21,14 @@ import { FormattedPlural, FormattedDate, FormattedTime -} from "react-intl" +} from "react-intl"; import reactIntlEn = require("react-intl/locale-data/en"); addLocaleData(reactIntlEn); interface SomeComponentProps { - className: string + className: string; } const SomeFunctionalComponentWithIntl: React.ComponentClass = injectIntl(({ @@ -51,7 +51,10 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass const formattedNumber = formatNumber(123, { format: "short" }); const formattedPlural = formatPlural(1, { style: "ordinal" }); const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); - const formattedMessagePlurals = formatMessage({ id: "hello", defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, { name: "Roger", unreadCount: 123 }); + const formattedMessagePlurals = formatMessage({ + id: "hello", + defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, + { name: "Roger", unreadCount: 123 }); const formattedHTMLMessage = formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); return (

@@ -71,7 +74,10 @@ class SomeComponent extends React.Component{name}!" }, { name: "Roger" }); return
{formattedNum} )} -
+
; } } @@ -230,14 +236,14 @@ const SomeComponentWithIntl = injectIntl(SomeComponent); class TestApp extends React.Component<{}, {}> { render(): React.ReactElement<{}> { const definedMessages = defineMessages({ - "sup": { + sup: { id: "sup", defaultMessage: "Hai mom" } }); const messages = { - "hello": "Hello, {name}!" + hello: "Hello, {name}!" }; return ( @@ -250,9 +256,9 @@ class TestApp extends React.Component<{}, {}> { const intlProvider = new IntlProvider({ locale: 'en' }, {}); const { intl } = intlProvider.getChildContext(); -const wrappedComponent = +const wrappedComponent = ; export default { TestApp, SomeComponent: SomeComponentWithIntl -} +}; diff --git a/types/react-intl/tslint.json b/types/react-intl/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-intl/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 81e990d1d742f9f2a4e8f1b9cf787624a77327fd Mon Sep 17 00:00:00 2001 From: krister Date: Mon, 12 Jun 2017 22:08:09 +0300 Subject: [PATCH 45/58] Allow booleans, dates and numbers when formatting a message --- types/react-intl/index.d.ts | 4 ++-- types/react-intl/react-intl-tests.tsx | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 644e9c9450..f52fbc1cbc 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -69,8 +69,8 @@ declare namespace ReactIntl { formatRelative(value: DateSource, options?: FormattedRelative.PropsBase & { now?: any }): string; formatNumber(value: number, options?: FormattedNumber.PropsBase): string; formatPlural(value: number, options?: FormattedPlural.Base): keyof FormattedPlural.PropsBase; - formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number}): string; - formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string}): string; + formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string; + formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string; locale: string; formats: any; messages: { [id: string]: string }; diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index 42305ef571..1550aafcbe 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -74,11 +74,17 @@ class SomeComponent extends React.Component{name}!" }, { name: "Roger" }); + const formattedHTMLMessageNumber = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello {num}!" }, { num: 1 }); + const formattedHTMLMessageDate = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello {date}!" }, { date: new Date() }); + const formattedHTMLMessageBool = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello {bool}!" }, { bool: true }); return
Date: Mon, 12 Jun 2017 23:52:00 +0300 Subject: [PATCH 46/58] add jasmine-given --- types/jasmine-given/index.d.ts | 10 ++++++++++ types/jasmine-given/jasmine-given-tests.ts | 9 +++++++++ types/jasmine-given/tsconfig.json | 22 ++++++++++++++++++++++ types/jasmine-given/tslint.json | 1 + 4 files changed, 42 insertions(+) create mode 100644 types/jasmine-given/index.d.ts create mode 100644 types/jasmine-given/jasmine-given-tests.ts create mode 100644 types/jasmine-given/tsconfig.json create mode 100644 types/jasmine-given/tslint.json diff --git a/types/jasmine-given/index.d.ts b/types/jasmine-given/index.d.ts new file mode 100644 index 0000000000..70a23d7e07 --- /dev/null +++ b/types/jasmine-given/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for jasmine-given 2.6 +// Project: https://github.com/searls/jasmine-given +// Definitions by: Shai Reznik +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function Given(func: () => void): void; +declare function When(func: () => void): void; +declare function Then(func: () => void): void; +declare function And(func: () => void): void; +declare function Invariant(func: () => void): void; diff --git a/types/jasmine-given/jasmine-given-tests.ts b/types/jasmine-given/jasmine-given-tests.ts new file mode 100644 index 0000000000..8a994ecbbe --- /dev/null +++ b/types/jasmine-given/jasmine-given-tests.ts @@ -0,0 +1,9 @@ +Given(() => { }); + +When(() => { }); + +Then(() => { }); + +And(() => { }); + +Invariant(() => {}); diff --git a/types/jasmine-given/tsconfig.json b/types/jasmine-given/tsconfig.json new file mode 100644 index 0000000000..cb1571590b --- /dev/null +++ b/types/jasmine-given/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", + "jasmine-given-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jasmine-given/tslint.json b/types/jasmine-given/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/jasmine-given/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From cd62ed775dc310f22d841c283748be8c8723bed3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 12 Jun 2017 16:36:37 -0700 Subject: [PATCH 47/58] Add 'message' to process.on (#17137) It was omitted by mistake in #16705 --- types/node/index.d.ts | 1 + types/node/node-tests.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 2fd023b56b..178a8920e1 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -495,6 +495,7 @@ declare namespace NodeJS { on(event: "uncaughtException", listener: (error: Error) => void): this; on(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; on(event: "warning", listener: (warning: Error) => void): this; + on(event: "message", listener: (message: any, sendHandle: any) => void): this; on(event: Signals, listener: () => void): this; once(event: "beforeExit", listener: (code: number) => void): this; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index de401eb0fc..35260b138b 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1890,6 +1890,9 @@ namespace process_tests { var module: NodeModule | undefined; module = process.mainModule; } + { + process.on("message", (req: any) => { }); + } } /////////////////////////////////////////////////////////// From d2af6a8f5a937f3764eacee4f01f1f4c54ff60d0 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 12 Jun 2017 17:17:49 -0700 Subject: [PATCH 48/58] Add Type annotation to tests --- .../cordova-plugin-battery-status-tests.ts | 2 ++ .../cordova-plugin-inappbrowser-tests.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts index e0433bf89b..bc2d516697 100644 --- a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts +++ b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts @@ -1,7 +1,9 @@ +window.addEventListener('batterystatus', (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); }); window.addEventListener('batterystatus', (ev) => { console.log('Battery level is ' + ev.level); }); window.addEventListener('batterycritical', (ev) => { console.log('Battery is critical: ' + ev.level); }); window.addEventListener('batterylow', (ev) => { console.log('Battery is low: ' + ev.level); }); +window.removeEventListener('batterystatus', (ev: BatteryStatusEvent) => { console.log('Remove: Battery level is ' + ev.level); }); window.removeEventListener('batterystatus', (ev) => { console.log('Remove: Battery level is ' + ev.level); }); window.removeEventListener('batterycritical', (ev) => { console.log('Remove: Battery is critical: ' + ev.level); }); window.removeEventListener('batterylow', (ev) => { console.log('Remove: Battery is low: ' + ev.level); }); diff --git a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts index d381f52375..12914e4110 100644 --- a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts +++ b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts @@ -5,11 +5,13 @@ // is similar to native window.open signature, so the compiler can's // select proper overload, but we cast result to InAppBrowser manually. var iab = window.open('google.com', '_self'); +iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); }); iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); }); iab.addEventListener('loadstop', (ev) => { console.log('loadstop' + ev.code); }); iab.addEventListener('loaderror', (ev) => { console.log('loaderror' + ev.code); }); iab.addEventListener('exit', (ev) => { console.log('exit' + ev.code); }); +iab.removeEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Remove loadstart' + ev.url); }); iab.removeEventListener('loadstart', (ev) => { console.log('Remove loadstart' + ev.url); }); iab.removeEventListener('loadstop', (ev) => { console.log('Remove loadstop ' + ev.code); }); iab.removeEventListener('loaderror', (ev) => { console.log('Remove loaderror ' + ev.code); }); From 58875cb0cd86570e684e196f5e05e1cb8d467887 Mon Sep 17 00:00:00 2001 From: afractal Date: Tue, 13 Jun 2017 12:14:28 +0200 Subject: [PATCH 49/58] update sharp-timer types to be more strict --- types/sharp-timer/sharp-timer-tests.ts | 1 - types/sharp-timer/tsconfig.json | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/sharp-timer/sharp-timer-tests.ts b/types/sharp-timer/sharp-timer-tests.ts index 685bf1b1d9..5d8976e474 100644 --- a/types/sharp-timer/sharp-timer-tests.ts +++ b/types/sharp-timer/sharp-timer-tests.ts @@ -5,7 +5,6 @@ let timer = new Timer(10); timer.onIntervalElapsing(i => { }); timer.onIntervalElapsed(() => { timer.stop(); - timer = null; }); timer.start(); diff --git a/types/sharp-timer/tsconfig.json b/types/sharp-timer/tsconfig.json index 3306511dec..ffaeaf9685 100644 --- a/types/sharp-timer/tsconfig.json +++ b/types/sharp-timer/tsconfig.json @@ -5,8 +5,8 @@ "es6" ], "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, + "noImplicitThis": true, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From eb7cfc536a90c8bbf0274d255b31f9b796fb15f1 Mon Sep 17 00:00:00 2001 From: Parvez Date: Tue, 13 Jun 2017 08:12:21 -0700 Subject: [PATCH 50/58] Added a missing type on Question interface (#17094) --- types/inquirer/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index dd2f4ad3c7..2a0b9f60f4 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Inquirer.js // Project: https://github.com/SBoudrias/Inquirer.js // Definitions by: Qubo +// Parvez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -110,6 +111,10 @@ declare namespace inquirer { * Change the number of lines that will be rendered when using list, rawList, expand or checkbox. */ pageSize?: number; + /** + * Add a mask when password will entered + */ + mask?: string; } /** From 8ccaae4e400bca76a9c5b09c44f4342935d58728 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 13 Jun 2017 11:21:40 -0700 Subject: [PATCH 51/58] Update tests --- .../cordova-plugin-battery-status-tests.ts | 29 +++++++++++++++---- .../cordova-plugin-battery-status/index.d.ts | 2 -- .../cordova-plugin-inappbrowser-tests.ts | 21 ++++++++++---- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts index bc2d516697..dbad990b8d 100644 --- a/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts +++ b/types/cordova-plugin-battery-status/cordova-plugin-battery-status-tests.ts @@ -1,12 +1,29 @@ +function eventCallBack(ev: BatteryStatusEvent) { + console.log('Battery level is ' + ev.level); +} window.addEventListener('batterystatus', (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); }); window.addEventListener('batterystatus', (ev) => { console.log('Battery level is ' + ev.level); }); window.addEventListener('batterycritical', (ev) => { console.log('Battery is critical: ' + ev.level); }); window.addEventListener('batterylow', (ev) => { console.log('Battery is low: ' + ev.level); }); -window.removeEventListener('batterystatus', (ev: BatteryStatusEvent) => { console.log('Remove: Battery level is ' + ev.level); }); -window.removeEventListener('batterystatus', (ev) => { console.log('Remove: Battery level is ' + ev.level); }); -window.removeEventListener('batterycritical', (ev) => { console.log('Remove: Battery is critical: ' + ev.level); }); -window.removeEventListener('batterylow', (ev) => { console.log('Remove: Battery is low: ' + ev.level); }); +window.addEventListener('baterystatus', eventCallBack); +window.addEventListener('batterycritical', eventCallBack); +window.addEventListener('batterylow', eventCallBack); -window.addEventListener('batterycritical', - () => { alert('Battery is critical low!'); }); \ No newline at end of file +window.removeEventListener('batterystatus', eventCallBack); +window.removeEventListener('batterycritical', eventCallBack); +window.removeEventListener('batterylow', eventCallBack); + +window.addEventListener('batterycritical', () => { alert('Battery is critical low!'); }); +window.addEventListener('batterylow', () => { alert('Battery is low!'); }); + +function batteryCriticalCallback() { + alert('Battery is critical low!'); +} + +function batteryLowCallback() { + alert('Battery is critical low!'); +} + +window.addEventListener('batterycritical', batteryCriticalCallback); +window.addEventListener('batterylow', batteryLowCallback); \ No newline at end of file diff --git a/types/cordova-plugin-battery-status/index.d.ts b/types/cordova-plugin-battery-status/index.d.ts index f120d3d7e9..0cdf729d30 100644 --- a/types/cordova-plugin-battery-status/index.d.ts +++ b/types/cordova-plugin-battery-status/index.d.ts @@ -26,8 +26,6 @@ interface Window { onbatterystatus: (type: BatteryStatusEvent) => void; onbatterycritical: (type: BatteryStatusEvent) => void; onbatterylow: (type: BatteryStatusEvent) => void; - removeEventListener(type: K, listener: (ev: WindowEventMap[K]) => any, useCapture?: boolean): void; - removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void; } /** Object, that passed into battery event listener */ diff --git a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts index 12914e4110..d717e85ea4 100644 --- a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts +++ b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts @@ -5,17 +5,28 @@ // is similar to native window.open signature, so the compiler can's // select proper overload, but we cast result to InAppBrowser manually. var iab = window.open('google.com', '_self'); + iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); }); iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); }); iab.addEventListener('loadstop', (ev) => { console.log('loadstop' + ev.code); }); iab.addEventListener('loaderror', (ev) => { console.log('loaderror' + ev.code); }); iab.addEventListener('exit', (ev) => { console.log('exit' + ev.code); }); -iab.removeEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Remove loadstart' + ev.url); }); -iab.removeEventListener('loadstart', (ev) => { console.log('Remove loadstart' + ev.url); }); -iab.removeEventListener('loadstop', (ev) => { console.log('Remove loadstop ' + ev.code); }); -iab.removeEventListener('loaderror', (ev) => { console.log('Remove loaderror ' + ev.code); }); -iab.removeEventListener('exit', (ev) => { console.log('Remove exit ' + ev.code); }); +function inAppBrowserCallBack(ev: InAppBrowserEvent) { + console.log('InAppBrowser callback ' + ev.url); +} + +iab.addEventListener('loadstart', inAppBrowserCallBack); +iab.addEventListener('loadstart', inAppBrowserCallBack); +iab.addEventListener('loadstop', inAppBrowserCallBack); +iab.addEventListener('loaderror', inAppBrowserCallBack); +iab.addEventListener('exit', inAppBrowserCallBack); + +iab.removeEventListener('loadstart', inAppBrowserCallBack); +iab.removeEventListener('loadstop', inAppBrowserCallBack); +iab.removeEventListener('loaderror', inAppBrowserCallBack); +iab.removeEventListener('exit', inAppBrowserCallBack); + iab.show(); iab.executeScript( { code: "console.log('Injected script in action')" }, From 3ca9d88f92bc03e5f3a397896c4b6fb1213d7c9c Mon Sep 17 00:00:00 2001 From: Amrit Kahlon Date: Tue, 13 Jun 2017 18:55:21 -0700 Subject: [PATCH 52/58] Namespaced stripe v2 and added stripe v3 types --- types/stripe-checkout/index.d.ts | 2 +- types/stripe/index.d.ts | 334 ++++++++++++++++--------------- types/stripe/stripe-tests.ts | 60 +++--- types/stripe/tsconfig.json | 2 +- types/stripe/v2/index.d.ts | 170 ++++++++++++++++ types/stripe/v2/stripe-tests.ts | 25 +++ types/stripe/v2/tsconfig.json | 26 +++ types/stripe/v2/tslint.json | 1 + 8 files changed, 438 insertions(+), 182 deletions(-) create mode 100644 types/stripe/v2/index.d.ts create mode 100644 types/stripe/v2/stripe-tests.ts create mode 100644 types/stripe/v2/tsconfig.json create mode 100644 types/stripe/v2/tslint.json diff --git a/types/stripe-checkout/index.d.ts b/types/stripe-checkout/index.d.ts index 41f94f3a2c..b546ef1851 100644 --- a/types/stripe-checkout/index.d.ts +++ b/types/stripe-checkout/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Chris Wrench // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// interface StripeCheckoutStatic { configure(options: StripeCheckoutOptions): StripeCheckoutHandler; diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index cc486b5d5b..f58d5e602f 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe 2.x +// Type definitions for stripe 3.0 // Project: https://stripe.com/ // Definitions by: Andy Hawkins // Eric J. Smith @@ -7,164 +7,184 @@ // Justin Leider // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare const Stripe: StripeStatic; +export function Stripe(stripePublicKey: string): stripe.StripeStatic; -interface StripeStatic { - applePay: StripeApplePay; - setPublishableKey(key: string): void; - validateCardNumber(cardNumber: string): boolean; - validateExpiry(month: string, year: string): boolean; - validateCVC(cardCVC: string): boolean; - cardType(cardNumber: string): StripeCardDataBrand; - getToken(token: string, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void; - card: StripeCard; - createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void; - bankAccount: StripeBankAccount; -} +export namespace stripe { + interface StripeStatic { + elements(options?: elements.ElementsCreateOptions): elements.Elements; + createToken(element: elements.Element, options?: TokenOptions): Promise; + } -interface StripeCardTokenData { - number: string; - exp_month?: number; - exp_year?: number; - exp?: string; - cvc?: string; - name?: string; - address_line1?: string; - address_line2?: string; - address_city?: string; - address_state?: string; - address_zip?: string; - address_country?: string; -} + interface TokenOptions { + name?: string; + address_line1?: string; + address_line2?: string; + address_city?: string; + address_state?: string; + address_zip?: string; + address_country?: string; + currency?: string; + } -interface StripeTokenResponse { - id: string; - client_ip: string; - created: number; - livemode: boolean; - object: string; - type: string; - used: boolean; - error?: StripeError; -} - -interface StripeCardTokenResponse extends StripeTokenResponse { - card: StripeCard; -} - -interface StripeError { - type: string; - code: string; - message: string; - param?: string; -} - -type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover' | 'JCB' | 'Diners Club' | 'Unknown'; - -type StripeCardDataFunding = 'credit' | 'debit' | 'prepaid' | 'unknown'; - -interface StripeCard { - object: string; - last4: string; - exp_month: number; - exp_year: number; - country?: string; - name?: string; - address_line1?: string; - address_line2?: string; - address_city?: string; - address_state?: string; - address_zip?: string; - address_country?: string; - brand?: StripeCardDataBrand; - funding?: StripeCardDataFunding; - createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void; - validateCardNumber(cardNumber: string): boolean; - validateExpiry(month: string, year: string): boolean; - validateCVC(cardCVC: string): boolean; -} - -interface StripeBankAccount { - createToken(params: StripeBankTokenParams, stripeResponseHandler: (status: number, response: StripeBankTokenResponse) => void): void; - validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; - validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; -} - -interface StripeBankTokenParams { - country: string; - currency: string; - account_number: number | string; - routing_number?: number | string; - account_holder_name: string; - account_holder_type: string; -} - -interface StripeBankTokenResponse extends StripeTokenResponse { - bank_account: { - country: string; - bank_name: string; - last4: number; - validated: boolean; + interface Token { + id: string; object: string; - }; + bank_account?: BankAccount; + card?: Card; + client_ip: string; + created: number; + livemode: boolean; + type: string; + used: boolean; + } + + interface TokenResponse { + token?: Token; + error?: Error; + } + + interface Error { + type: string; + charge: string; + message?: string; + code?: string; + declined_code?: string; + param?: string; + } + + type statusType = 'new' | 'validated' | 'verified' | 'verification_failed' | 'errored'; + interface BankAccount { + id: string; + object: string; + account_holder_name: string; + account_holder_type: string; + bank_name: string; + country: string; + currency: string; + fingerprint: string; + last4: string; + routing_number: string; + status: statusType; + } + + type brandType = 'Visa' | 'American Express' | 'MasterCard' | 'Discover' | 'JCB' | 'Diners Club' | 'Unknown'; + type checkType = 'pass' | 'fail' | 'unavailable' | 'unchecked'; + type fundingType = 'credit' | 'debit' | 'prepaid' | 'unknown'; + type tokenizationType = 'apple_pay' | 'android_pay'; + interface Card { + id: string; + object: string; + address_city?: string; + address_country?: string; + address_line1?: string; + address_line1_check?: checkType; + address_line2?: string; + address_state?: string; + address_zip?: string; + address_zip_check?: checkType; + brand: brandType; + country: string; + currency?: string; + cvc_check?: checkType; + dynamic_last4: string; + exp_month: number; + exp_year: number; + fingerprint: string; + funding: fundingType; + last4: string; + metadata: any; + name?: string; + tokenization_method?: tokenizationType; + } + + // Container for all elements related types + namespace elements { + interface ElementsCreateOptions { + fonts?: elements.Font[]; + locale?: string; + } + + type handler = (response?: ElementChangeResponse) => void; + type eventTypes = 'blur' | 'change' | 'focus' | 'ready'; + interface Element { + // HTMLElement keeps giving this error for some reason: + // Cannot find name 'HTMLElement' + mount(domElement: string | any): void; + on(event: eventTypes, handler: handler): void; + blur(): void; + clear(): void; + unmount(): void; + update(options: ElementsOptions): void; + } + + interface ElementChangeResponse { + brand: string; + complete: boolean; + empty: boolean; + value?: { postalCode: string | number }; + error?: Error; + } + + interface ElementOptions { + fonts?: elements.Font[]; + locale?: string; + } + + type elementsType = 'card' | 'cardNumber' | 'cardExpiry' | 'cardCvc' | 'postalCode'; + interface Elements { + create(type: elementsType, options: ElementsOptions): Element; + } + + interface ElementsOptions { + classes?: { + base?: string; + complete?: string; + empty?: string; + focus?: string; + invalid?: string; + webkitAutofill?: string; + }; + hidePostalCode?: boolean; + hideIcon?: boolean; + iconStyle?: 'solid' | 'default'; + style?: { + base?: Style; + complete?: Style; + empty?: Style; + invalid?: Style; + }; + value?: string | {[objectKey: string]: string; }; + } + + interface Style extends StyleOptions { + ':hover'?: StyleOptions; + ':focus'?: StyleOptions; + '::placeholder'?: StyleOptions; + '::selection'?: StyleOptions; + ':-webkit-autofill'?: StyleOptions; + } + + interface Font { + family?: string; + src?: string; + style?: string; + unicodeRange?: string; + weight?: string; + } + + interface StyleOptions { + color?: string; + fontFamily?: string; + fontSize?: string; + fontSmoothing?: string; + fontStyle?: string; + fontVariant?: string; + iconColor?: string; + lineHeight?: string; + letterSpacing?: string; + textDecoration?: string; + textShadow?: string; + textTransform?: string; + } + } } - -interface StripeApplePay { - checkAvailability(resopnseHandler: (result: boolean) => void): void; - buildSession(data: StripeApplePayPaymentRequest, - onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void, - onErrorHanlder: (error: { message: string }) => void): any; -} - -type StripeApplePayBillingContactField = 'postalAddress' | 'name'; -type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email'; -type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup'; - -interface StripeApplePayPaymentRequest { - billingContact: StripeApplePayPaymentContact; - countryCode: string; - currencyCode: string; - total: StripeApplePayLineItem; - lineItems?: StripeApplePayLineItem[]; - requiredBillingContactFields?: StripeApplePayBillingContactField[]; - requiredShippingContactFields?: StripeApplePayShippingContactField[]; - shippingContact?: StripeApplePayPaymentContact; - shippingMethods?: StripeApplePayShippingMethod[]; - shippingType?: StripeApplePayShipping[]; -} - -// https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types -interface StripeApplePayLineItem { - type: 'pending' | 'final'; - label: string; - amount: number; -} - -interface StripeApplePaySessionResult { - token: StripeCardTokenResponse; - shippingContact?: StripeApplePayPaymentContact; - shippingMethod?: StripeApplePayShippingMethod; -} - -interface StripeApplePayShippingMethod { - label: string; - detail: string; - amount: number; - identifier: string; -} - -interface StripeApplePayPaymentContact { - emailAddress: string; - phoneNumber: string; - givenName: string; - familyName: string; - addressLines: string[]; - locality: string; - administrativeArea: string; - postalCode: string; - countryCode: string; -} - -// The Stripe client side APIs are not made available to package managers for direct installation. -// As explained compliance reasons. Source: https://github.com/stripe/stripe-node/blob/master/README.md#these-are-serverside-bindings-only -// A release date versioning schema is used to version these APIs. diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 56e6343f5c..f777c0eb34 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -1,25 +1,39 @@ -function success(card: StripeCard) { - console.log(card.brand && card.brand.toString()); -} +import {stripe, Stripe} from 'stripe'; -const cardNumber = '4242424242424242'; - -const isValid = Stripe.validateCardNumber(cardNumber); -if (isValid) { - const tokenData: StripeCardTokenData = { - number: cardNumber, - exp_month: 1, - exp_year: 2100, - cvc: '111' - }; - Stripe.card.createToken(tokenData, (status, response) => { - if (response.error) { - console.error(response.error.message); - if (response.error.param) { - console.error(response.error.param); - } - } else { - success(response.card); +const stripe = Stripe('public-key'); +const elements = stripe.elements(); +const style = { + base: { + color: '#32325d', + lineHeight: '24px', + fontFamily: 'Roboto, "Helvetica Neue", sans-serif', + fontSmoothing: 'antialiased', + fontSize: '16px', + '::placeholder': { + color: '#aab7c4' } - }); -} + }, + invalid: { + color: '#B71C1C', + iconColor: '#B71C1C' + } +}; +const card = elements.create('card', {hidePostalCode: true, style}); +card.mount(document.createElement('div')); +card.on('ready', () => { + console.log('ready'); +}); +card.on('change', (resp: stripe.elements.ElementChangeResponse) => { + console.log(resp.brand); +}); +stripe.createToken(card, { + name: 'Jimmy', + address_city: 'Toronto', + address_country: 'Canada' +}) +.then((result: stripe.TokenResponse) => { + console.log(result.token); +}, +(error: stripe.Error) => { + console.error(error); +}); diff --git a/types/stripe/tsconfig.json b/types/stripe/tsconfig.json index 7ea61e6327..c15aeceae9 100644 --- a/types/stripe/tsconfig.json +++ b/types/stripe/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "stripe-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/stripe/v2/index.d.ts b/types/stripe/v2/index.d.ts new file mode 100644 index 0000000000..cc486b5d5b --- /dev/null +++ b/types/stripe/v2/index.d.ts @@ -0,0 +1,170 @@ +// Type definitions for stripe 2.x +// Project: https://stripe.com/ +// Definitions by: Andy Hawkins +// Eric J. Smith +// Amrit Kahlon +// Adam Cmiel +// Justin Leider +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare const Stripe: StripeStatic; + +interface StripeStatic { + applePay: StripeApplePay; + setPublishableKey(key: string): void; + validateCardNumber(cardNumber: string): boolean; + validateExpiry(month: string, year: string): boolean; + validateCVC(cardCVC: string): boolean; + cardType(cardNumber: string): StripeCardDataBrand; + getToken(token: string, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void; + card: StripeCard; + createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void; + bankAccount: StripeBankAccount; +} + +interface StripeCardTokenData { + number: string; + exp_month?: number; + exp_year?: number; + exp?: string; + cvc?: string; + name?: string; + address_line1?: string; + address_line2?: string; + address_city?: string; + address_state?: string; + address_zip?: string; + address_country?: string; +} + +interface StripeTokenResponse { + id: string; + client_ip: string; + created: number; + livemode: boolean; + object: string; + type: string; + used: boolean; + error?: StripeError; +} + +interface StripeCardTokenResponse extends StripeTokenResponse { + card: StripeCard; +} + +interface StripeError { + type: string; + code: string; + message: string; + param?: string; +} + +type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover' | 'JCB' | 'Diners Club' | 'Unknown'; + +type StripeCardDataFunding = 'credit' | 'debit' | 'prepaid' | 'unknown'; + +interface StripeCard { + object: string; + last4: string; + exp_month: number; + exp_year: number; + country?: string; + name?: string; + address_line1?: string; + address_line2?: string; + address_city?: string; + address_state?: string; + address_zip?: string; + address_country?: string; + brand?: StripeCardDataBrand; + funding?: StripeCardDataFunding; + createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void; + validateCardNumber(cardNumber: string): boolean; + validateExpiry(month: string, year: string): boolean; + validateCVC(cardCVC: string): boolean; +} + +interface StripeBankAccount { + createToken(params: StripeBankTokenParams, stripeResponseHandler: (status: number, response: StripeBankTokenResponse) => void): void; + validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; + validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; +} + +interface StripeBankTokenParams { + country: string; + currency: string; + account_number: number | string; + routing_number?: number | string; + account_holder_name: string; + account_holder_type: string; +} + +interface StripeBankTokenResponse extends StripeTokenResponse { + bank_account: { + country: string; + bank_name: string; + last4: number; + validated: boolean; + object: string; + }; +} + +interface StripeApplePay { + checkAvailability(resopnseHandler: (result: boolean) => void): void; + buildSession(data: StripeApplePayPaymentRequest, + onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void, + onErrorHanlder: (error: { message: string }) => void): any; +} + +type StripeApplePayBillingContactField = 'postalAddress' | 'name'; +type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email'; +type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup'; + +interface StripeApplePayPaymentRequest { + billingContact: StripeApplePayPaymentContact; + countryCode: string; + currencyCode: string; + total: StripeApplePayLineItem; + lineItems?: StripeApplePayLineItem[]; + requiredBillingContactFields?: StripeApplePayBillingContactField[]; + requiredShippingContactFields?: StripeApplePayShippingContactField[]; + shippingContact?: StripeApplePayPaymentContact; + shippingMethods?: StripeApplePayShippingMethod[]; + shippingType?: StripeApplePayShipping[]; +} + +// https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types +interface StripeApplePayLineItem { + type: 'pending' | 'final'; + label: string; + amount: number; +} + +interface StripeApplePaySessionResult { + token: StripeCardTokenResponse; + shippingContact?: StripeApplePayPaymentContact; + shippingMethod?: StripeApplePayShippingMethod; +} + +interface StripeApplePayShippingMethod { + label: string; + detail: string; + amount: number; + identifier: string; +} + +interface StripeApplePayPaymentContact { + emailAddress: string; + phoneNumber: string; + givenName: string; + familyName: string; + addressLines: string[]; + locality: string; + administrativeArea: string; + postalCode: string; + countryCode: string; +} + +// The Stripe client side APIs are not made available to package managers for direct installation. +// As explained compliance reasons. Source: https://github.com/stripe/stripe-node/blob/master/README.md#these-are-serverside-bindings-only +// A release date versioning schema is used to version these APIs. diff --git a/types/stripe/v2/stripe-tests.ts b/types/stripe/v2/stripe-tests.ts new file mode 100644 index 0000000000..56e6343f5c --- /dev/null +++ b/types/stripe/v2/stripe-tests.ts @@ -0,0 +1,25 @@ +function success(card: StripeCard) { + console.log(card.brand && card.brand.toString()); +} + +const cardNumber = '4242424242424242'; + +const isValid = Stripe.validateCardNumber(cardNumber); +if (isValid) { + const tokenData: StripeCardTokenData = { + number: cardNumber, + exp_month: 1, + exp_year: 2100, + cvc: '111' + }; + Stripe.card.createToken(tokenData, (status, response) => { + if (response.error) { + console.error(response.error.message); + if (response.error.param) { + console.error(response.error.param); + } + } else { + success(response.card); + } + }); +} diff --git a/types/stripe/v2/tsconfig.json b/types/stripe/v2/tsconfig.json new file mode 100644 index 0000000000..5917b8206d --- /dev/null +++ b/types/stripe/v2/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "stripe": ["stripe/v2"] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "stripe-tests.ts" + ] +} diff --git a/types/stripe/v2/tslint.json b/types/stripe/v2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/stripe/v2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 7db839923efa764661e06119548dad9ee05bd874 Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Wed, 14 Jun 2017 14:15:46 +0200 Subject: [PATCH 53/58] Make type for nodes and marks more specific --- types/prosemirror-model/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/prosemirror-model/index.d.ts b/types/prosemirror-model/index.d.ts index ff281cb2f9..3ede724248 100644 --- a/types/prosemirror-model/index.d.ts +++ b/types/prosemirror-model/index.d.ts @@ -236,8 +236,8 @@ declare module "prosemirror-model" { export class Schema { constructor(spec: SchemaSpec) spec: SchemaSpec; - nodes: Object; - marks: Object; + nodes: {[key: string]: NodeType}; + marks: {[key: string]: MarkType}; cached: Object; topNodeType: NodeType; node(type: string | NodeType, attrs?: Object, content?: Fragment | ProsemirrorNode | ProsemirrorNode[], marks?: Mark[]): ProsemirrorNode @@ -252,8 +252,8 @@ declare module "prosemirror-model" { } export class DOMSerializer { constructor(nodes: Object, marks: Object) - nodes: Object; - marks: Object; + nodes: {[key: string]: NodeType}; + marks: {[key: string]: MarkType}; serializeFragment(fragment: Fragment, options?: Object): DocumentFragment serializeNode(node: ProsemirrorNode, options?: Object): Node static renderSpec(doc: Document, structure: DOMOutputSpec): { dom: Node, contentDOM?: Node } @@ -263,4 +263,4 @@ declare module "prosemirror-model" { } -} \ No newline at end of file +} From 232926fd1c244090ba7e56cb672e1fbc9442ea20 Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Wed, 14 Jun 2017 10:47:31 -0400 Subject: [PATCH 54/58] [d3-sankey] Update to Minor 0.7 (#17166) * [d3-sankey] Update to Minor 0.7 * [FEATURE] `nodeId(...)` Add ability to configure node id accessor function * [FEATURE] `nodeAlign(...)` Add ability to configure horizontal alignment of layout * [FEATURE] Add pre-build layout alignment functions * [CHORE] Bump minor version number. * [d3-sankey] [FIX] Add `height` property to node. --- types/d3-sankey/d3-sankey-tests.ts | 150 +++++++++++++++++++++++++---- types/d3-sankey/index.d.ts | 88 +++++++++++++++-- 2 files changed, 210 insertions(+), 28 deletions(-) diff --git a/types/d3-sankey/d3-sankey-tests.ts b/types/d3-sankey/d3-sankey-tests.ts index c270011528..abf61775b8 100644 --- a/types/d3-sankey/d3-sankey-tests.ts +++ b/types/d3-sankey/d3-sankey-tests.ts @@ -7,7 +7,7 @@ */ import * as d3Sankey from 'd3-sankey'; -import {select, Selection} from 'd3-selection'; +import { select, Selection } from 'd3-selection'; import { Link } from 'd3-shape'; // --------------------------------------------------------------------------- @@ -18,38 +18,44 @@ import { Link } from 'd3-shape'; // the Sankey layout generator. The latter are reflected in the SankeyNode and SankeyLink interfaces provided // by the definitions file interface SNodeExtra { - nodeId: number; - name: string; + name: string; +} + +interface SNodeExtraCustomId { + nodeId: string; + name: string; } interface SLinkExtra { - uom: string; + uom: string; } // For convenience type SNode = d3Sankey.SankeyNode; +type SNodeCustomId = d3Sankey.SankeyNode; type SLink = d3Sankey.SankeyLink; +type SLinkCustomId = d3Sankey.SankeyLink; interface DAG { - customNodes: SNode[]; - customLinks: SLink[]; + customNodes: SNode[]; + customLinks: SLink[]; } -const graph: DAG = { +interface DAGCustomId { + customNodes: SNodeCustomId[]; + customLinks: SLinkCustomId[]; +} + +const graphDefault: DAG = { customNodes: [{ - nodeId: 0, name: "node0" }, { - nodeId: 1, name: "node1" }, { - nodeId: 2, name: "node2" }, { - nodeId: 3, name: "node3" }, { - nodeId: 4, name: "node4" }], customLinks: [{ @@ -90,6 +96,61 @@ const graph: DAG = { }] }; +const graphCustomId: DAGCustomId = { + customNodes: [{ + nodeId: "n0", + name: "node0" + }, { + nodeId: "n1", + name: "node1" + }, { + nodeId: "n2", + name: "node2" + }, { + nodeId: "n3", + name: "node3" + }, { + nodeId: "n4", + name: "node4" + }], + customLinks: [{ + source: "n0", + target: "n2", + value: 2, + uom: 'Widget(s)' + }, { + source: "n1", + target: "n2", + value: 2, + uom: 'Widget(s)' + }, { + source: "n1", + target: "n3", + value: 2, + uom: 'Widget(s)' + }, { + source: "n0", + target: "n4", + value: 2, + uom: 'Widget(s)' + }, { + source: "n2", + target: "n3", + value: 2, + uom: 'Widget(s)' + }, { + source: "n2", + target: "n4", + value: 2, + uom: 'Widget(s)' + }, { + source: "n3", + target: "n4", + value: 4, + uom: 'Widget(s)' + }] +}; + let sNodes: SNode[]; let sLinks: SLink[]; @@ -109,6 +170,7 @@ let sGraph: d3Sankey.SankeyGraph; let slgDefault: d3Sankey.SankeyLayout, {}, {}> = d3Sankey.sankey(); let slgDAG: d3Sankey.SankeyLayout = d3Sankey.sankey(); +let slgDAGCustomId: d3Sankey.SankeyLayout = d3Sankey.sankey(); // --------------------------------------------------------------------------- // NodeWidth @@ -175,6 +237,54 @@ slgDAG = slgDAG.iterations(40); num = slgDAG.iterations(); +// --------------------------------------------------------------------------- +// Node Id +// --------------------------------------------------------------------------- + +// Set ----------------------------------------------------------------------- + +slgDAGCustomId = slgDAGCustomId.nodeId((d) => { + const node: SNodeCustomId = d; + return d.nodeId; +}); + +// Get ----------------------------------------------------------------------- + +let nodeIdAccessor: (d: SNodeCustomId) => string | number; + +nodeIdAccessor = slgDAGCustomId.nodeId(); + +// --------------------------------------------------------------------------- +// Node Alignment +// --------------------------------------------------------------------------- + +// Set ----------------------------------------------------------------------- + +declare const testNode: SNode; + +// Test pre-defined alignment functions +slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyLeft); +num = d3Sankey.sankeyLeft(testNode, 10); +slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyRight); +num = d3Sankey.sankeyRight(testNode, 10); +slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyCenter); +num = d3Sankey.sankeyCenter(testNode, 10); +slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyJustify); +num = d3Sankey.sankeyJustify(testNode, 10); + +// Test custom +slgDAG = slgDAG.nodeAlign((node, maxN) => { + const n: SNode = node; + const mN: number = maxN; + return node.depth || 0; +}); + +// Get ----------------------------------------------------------------------- + +let nodeAlignmentFn: (d: SNode, n: number) => number; + +nodeAlignmentFn = slgDAG.nodeAlign(); + // --------------------------------------------------------------------------- // Nodes // --------------------------------------------------------------------------- @@ -182,7 +292,7 @@ num = slgDAG.iterations(); // Set ----------------------------------------------------------------------- // Use array and test return type for chainability -slgDAG = slgDAG.nodes(graph.customNodes); +slgDAG = slgDAG.nodes(graphDefault.customNodes); // Use accessor function and test return type for chainability slgDAG = slgDAG.nodes(d => d.customNodes); @@ -198,7 +308,7 @@ let nodesAccessor: (d: DAG) => SNode[] = slgDAG.nodes(); // Set ----------------------------------------------------------------------- // test return type for chainability -slgDAG = slgDAG.links(graph.customLinks); +slgDAG = slgDAG.links(graphDefault.customLinks); // Use accessor function and test return type for chainability slgDAG = slgDAG.links(d => d.customLinks); @@ -211,9 +321,9 @@ let linksAccessor: (d: DAG) => SLink[] = slgDAG.links(); // Compute Initial Layout // --------------------------------------------------------------------------- -sGraph = slgDAG(graph); +sGraph = slgDAG(graphDefault); // With additional arguments, although here unused. -sGraph = slgDAG(graph, "foo", 50); +sGraph = slgDAG(graphDefault, "foo", 50); // --------------------------------------------------------------------------- // Update Layout @@ -255,7 +365,6 @@ let sNode = sNodes[0]; // User-specified extra properties: -num = sNode.nodeId; str = sNode.name; // Sankey Layout calculated (if layout has been run, otherwise undefined): @@ -267,6 +376,7 @@ numMaybe = sNode.y1; numMaybe = sNode.value; numMaybe = sNode.index; numMaybe = sNode.depth; +numMaybe = sNode.height; let linksArrMaybe: SLink[] | undefined; @@ -290,10 +400,10 @@ num = sLink.value; // layout(...) was invoked, the source and target nodes may be numbers // objects without the Sankey layout coordinates, or objects with calculated // information -let numOrSankeyNode: number | SNode; +let numStringOrSankeyNode: number | string | SNode; -numOrSankeyNode = sLink.source; -numOrSankeyNode = sLink.target; +numStringOrSankeyNode = sLink.source; +numStringOrSankeyNode = sLink.target; // Sankey Layout calculated (if layout has been run, otherwise undefined): diff --git a/types/d3-sankey/index.d.ts b/types/d3-sankey/index.d.ts index 55c2934c13..46a80b2671 100644 --- a/types/d3-sankey/index.d.ts +++ b/types/d3-sankey/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for D3JS d3-sankey module 0.6 +// Type definitions for D3JS d3-sankey module 0.7 // Project: https://github.com/d3/d3-sankey/ // Definitions by: Tom Wanzek , Alex Ford // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 0.6 +// Last module patch version validated against: 0.7 import { Link } from 'd3-shape'; @@ -50,6 +50,10 @@ export interface SankeyNodeMinimal { /** - * Link's source node. For convenience, when initializing a Sankey layout, + * Link's source node. For convenience, when initializing a Sankey layout using the default node id accessor, * source may be the zero-based index of the corresponding node in the nodes array - * returned by the nodes accessor of the Sankey layout generator rather than object references. + * returned by the nodes accessor of the Sankey layout generator rather than object references. Alternatively, + * the Sankey layout can be configured with a custom node ID accessor to resolve the source node of the link upon initialization. * * Once the Sankey generator is invoked to return the Sankey graph object, * the numeric index will be replaced with the corresponding source node object. */ - source: number | SankeyNode; + source: number | string | SankeyNode; /** - * Link's target node. For convenience, when initializing a Sankey layout, + * Link's target node. For convenience, when initializing a Sankey layout using the default node id accessor, * target may be the zero-based index of the corresponding node in the nodes array - * returned by the nodes accessor of the Sankey layout generator rather than object references. + * returned by the nodes accessor of the Sankey layout generator rather than object references. Alternatively, + * the Sankey layout can be configured with a custom node ID accessor to resolve the target node of the link upon initialization. * * Once the Sankey generator is invoked to return the Sankey graph object, * the numeric index will be replaced with the corresponding target node object. */ - target: number | SankeyNode; + target: number | string | SankeyNode; /** * Link's numeric value */ @@ -244,6 +250,34 @@ export interface SankeyLayout Array>): this; + /** + * Return the current node id accessor. + * The default accessor is a function being passed in a Sankey layout node and returning its numeric node.index. + */ + nodeId(): (node: SankeyNode) => string | number; + /** + * Set the node id accessor to the specified function and return this Sankey layout generator. + * + * The default accessor is a function being passed in a Sankey layout node and returning its numeric node.index. + * The default id accessor allows each link’s source and target to be specified as a zero-based index into the nodes array. + * + * @param nodeId A node id accessor function being passed a node in the Sankey graph and returning its id. + */ + nodeId(nodeId: (node: SankeyNode) => string | number): this; + + /** + * Return the current node alignment method, which defaults to d3.sankeyLeft. + */ + nodeAlign(): (node: SankeyNode, n: number) => number; + /** + * Set the node alignment method the specified function and return this Sankey layout generator. + * + * @param nodeAlign A node alignment function which is evaluated for each input node in order, + * being passed the current node and the total depth n of the graph (one plus the maximum node.depth), + * and must return an integer between 0 and n - 1 that indicates the desired horizontal position of the node in the generated Sankey diagram. + */ + nodeAlign(nodeAlign: (node: SankeyNode, n: number) => number): this; + /** * Return the current node width, which defaults to 24. */ @@ -346,6 +380,44 @@ export function sankey(): SankeyLayout; +/** + * Compute the horizontal node position of a node in a Sankey layout with left alignment. + * Returns (node.depth) to indicate the desired horizontal position of the node in the generated Sankey diagram. + * + * @param node Sankey node for which to calculate the horizontal node position. + * @param n Total depth n of the graph (one plus the maximum node.depth) + */ +export function sankeyLeft(node: SankeyNode<{}, {}>, n: number): number; + +/** + * Compute the horizontal node position of a node in a Sankey layout with right alignment. + * Returns (n - 1 - node.height) to indicate the desired horizontal position of the node in the generated Sankey diagram. + * + * @param node Sankey node for which to calculate the horizontal node position. + * @param n Total depth n of the graph (one plus the maximum node.depth) + */ +export function sankeyRight(node: SankeyNode<{}, {}>, n: number): number; + +/** + * Compute the horizontal node position of a node in a Sankey layout with center alignment. + * Like d3.sankeyLeft, except that nodes without any incoming links are moved as right as possible. + * Returns an integer between 0 and n - 1 that indicates the desired horizontal position of the node in the generated Sankey diagram. + * + * @param node Sankey node for which to calculate the horizontal node position. + * @param n Total depth n of the graph (one plus the maximum node.depth) + */ +export function sankeyCenter(node: SankeyNode<{}, {}>, n: number): number; + +/** + * Compute the horizontal node position of a node in a Sankey layout with justified alignment. + * Like d3.sankeyLeft, except that nodes without any outgoing links are moved to the far right. + * Returns an integer between 0 and n - 1 that indicates the desired horizontal position of the node in the generated Sankey diagram. + * + * @param node Sankey node for which to calculate the horizontal node position. + * @param n Total depth n of the graph (one plus the maximum node.depth) + */ +export function sankeyJustify(node: SankeyNode<{}, {}>, n: number): number; + /** * Get a horizontal link shape suitable for a Sankey diagram. * Source and target accessors are pre-configured and work with the From a8f5fe1bc6ac8b8338c3e7d1f9fb2a95f2cb7607 Mon Sep 17 00:00:00 2001 From: Ashish Shubham Date: Wed, 14 Jun 2017 19:57:37 -0700 Subject: [PATCH 55/58] Add toCharacterRange method. --- types/rangy/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/rangy/index.d.ts b/types/rangy/index.d.ts index b6615b9aad..4a3afc08a1 100644 --- a/types/rangy/index.d.ts +++ b/types/rangy/index.d.ts @@ -31,6 +31,7 @@ interface RangyRange extends Range { equals(range:RangyRange):boolean; refresh():any; select():any; + toCharacterRange(containerNode:Node):{start:number, end:number}; } interface RangySelection extends Selection { From 93f2ea1a7eddfdec59be82ef978f8e486e345f6c Mon Sep 17 00:00:00 2001 From: Ashish Shubham Date: Wed, 14 Jun 2017 19:59:19 -0700 Subject: [PATCH 56/58] tests for toCharacterRange --- types/rangy/rangy-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/rangy/rangy-tests.ts b/types/rangy/rangy-tests.ts index de2ec468f0..3b177a46b3 100644 --- a/types/rangy/rangy-tests.ts +++ b/types/rangy/rangy-tests.ts @@ -74,6 +74,7 @@ function testRangyRange() { rangyRange.splitBoundaries(); assertString(rangyRange.toHtml()); assertRangyRange(rangyRange.union(rangyRange)); + let characterRange:{start:number, end:number} = rangyRange.toCharacterRange(new Node); } function testSelection() { From 854aebe0fe5a686ce07ea438f494f1224d4d2159 Mon Sep 17 00:00:00 2001 From: Andrew Linfoot Date: Wed, 14 Jun 2017 20:09:14 -0700 Subject: [PATCH 57/58] Add support for key on reset action --- types/react-navigation/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index e343d092c6..8be0e2ecc5 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -268,6 +268,7 @@ export interface NavigationInitAction { export interface NavigationResetAction { type?: 'Navigation/RESET', index: number, + key?: string | null, actions: NavigationNavigateAction[], } From b9ff8d230eb58d33fcb814469eb2491a0ee755c2 Mon Sep 17 00:00:00 2001 From: Andrew Linfoot Date: Wed, 14 Jun 2017 20:48:16 -0700 Subject: [PATCH 58/58] Add support for NavigationActions.init() action creator See https://github.com/react-community/react-navigation/blob/master/src/NavigationActions.js#L70 --- types/react-navigation/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 8be0e2ecc5..f4179a19ce 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -320,6 +320,7 @@ export type NavigationAction = | NavigationTabAction export namespace NavigationActions { + function init(options?: NavigationInitAction): NavigationInitAction; function navigate(options: NavigationNavigateAction): NavigationNavigateAction; function reset(options: NavigationResetAction): NavigationResetAction; function back(options?: NavigationBackAction): NavigationBackAction;