From a02acb4da8a2bf72e49533956e7a24253a82d915 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sat, 7 Oct 2017 17:38:07 +0200 Subject: [PATCH 001/181] Updated d3-geo to reflect version 1.9.0: added fitWidth and fitHeight methods --- types/d3-geo/index.d.ts | 61 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index 6860031224..75f23d94a2 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for D3JS d3-geo module 1.8 +// Type definitions for D3JS d3-geo module 1.9 // Project: https://github.com/d3/d3-geo/ // Definitions by: Hugues Stefanski , Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 1.8.1 +// Last module patch version validated against: 1.9.0 import * as GeoJSON from 'geojson'; @@ -804,7 +804,62 @@ export interface GeoProjection extends GeoStreamWrapper { * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). */ fitSize(size: [number, number], object: ExtendedGeometryCollection): this; - + /** + *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * + * @param width The width of the extent. + * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). + */ + fitWidth(width: number, object: ExtendedFeature): this; + /** + *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * + * @param width The width of the extent. + * @param object A GeoJson Geometry Object or GeoSphere object supported by d3-geo (An extension of GeoJSON). + */ + fitWidth(width: number, object: ExtendedFeatureCollection>): this; + /** + *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * + * @param width The width of the extent. + * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). + */ + fitWidth(width: number, object: GeoGeometryObjects): this; + /** + *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * + * @param width The width of the extent. + * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). + */ + fitWidth(width: number, object: ExtendedGeometryCollection): this; + /** + *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * + * @param height The height of the extent. + * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). + */ + fitHeight(height: number, object: ExtendedFeature): this; + /** + *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * + * @param height The height of the extent. + * @param object A GeoJson Geometry Object or GeoSphere object supported by d3-geo (An extension of GeoJSON). + */ + fitHeight(height: number, object: ExtendedFeatureCollection>): this; + /** + *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * + * @param height The height of the extent. + * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). + */ + fitHeight(height: number, object: GeoGeometryObjects): this; + /** + *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * + * @param height The height of the extent. + * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). + */ + fitHeight(height: number, object: ExtendedGeometryCollection): this; /** * Returns a new array [longitude, latitude] in degrees representing the unprojected point of the given projected point. * May return null if the specified point has no defined projected position, such as when the point is outside the clipping bounds of the projection. From 1194c013de62f1aa8092de15fbbf426c1f92523b Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sat, 7 Oct 2017 19:32:08 +0200 Subject: [PATCH 002/181] Fix asterisk position --- types/d3-geo/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index 75f23d94a2..1a3ae3d295 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -806,56 +806,56 @@ export interface GeoProjection extends GeoStreamWrapper { fitSize(size: [number, number], object: ExtendedGeometryCollection): this; /** *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. - * + * * @param width The width of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitWidth(width: number, object: ExtendedFeature): this; /** *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. - * + * * @param width The width of the extent. * @param object A GeoJson Geometry Object or GeoSphere object supported by d3-geo (An extension of GeoJSON). */ fitWidth(width: number, object: ExtendedFeatureCollection>): this; /** *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. - * + * * @param width The width of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitWidth(width: number, object: GeoGeometryObjects): this; /** *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. - * + * * @param width The width of the extent. * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). */ fitWidth(width: number, object: ExtendedGeometryCollection): this; /** *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. - * + * * @param height The height of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitHeight(height: number, object: ExtendedFeature): this; /** *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. - * + * * @param height The height of the extent. * @param object A GeoJson Geometry Object or GeoSphere object supported by d3-geo (An extension of GeoJSON). */ fitHeight(height: number, object: ExtendedFeatureCollection>): this; /** *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. - * + * * @param height The height of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitHeight(height: number, object: GeoGeometryObjects): this; /** *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. - * + * * @param height The height of the extent. * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). */ From 9fba8310108c681596ea5ec70fcd290fca72a92c Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sat, 7 Oct 2017 19:53:36 +0200 Subject: [PATCH 003/181] Missing space --- types/d3-geo/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index 1a3ae3d295..4d9def3565 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -805,56 +805,56 @@ export interface GeoProjection extends GeoStreamWrapper { */ fitSize(size: [number, number], object: ExtendedGeometryCollection): this; /** - *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. * * @param width The width of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitWidth(width: number, object: ExtendedFeature): this; /** - *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. * * @param width The width of the extent. * @param object A GeoJson Geometry Object or GeoSphere object supported by d3-geo (An extension of GeoJSON). */ fitWidth(width: number, object: ExtendedFeatureCollection>): this; /** - *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. * * @param width The width of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitWidth(width: number, object: GeoGeometryObjects): this; /** - *A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. + * A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. * * @param width The width of the extent. * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). */ fitWidth(width: number, object: ExtendedGeometryCollection): this; /** - *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. * * @param height The height of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitHeight(height: number, object: ExtendedFeature): this; /** - *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. * * @param height The height of the extent. * @param object A GeoJson Geometry Object or GeoSphere object supported by d3-geo (An extension of GeoJSON). */ fitHeight(height: number, object: ExtendedFeatureCollection>): this; /** - *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. * * @param height The height of the extent. * @param object A geographic feature supported by d3-geo (An extension of GeoJSON feature). */ fitHeight(height: number, object: GeoGeometryObjects): this; /** - *A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. + * A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. * * @param height The height of the extent. * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). From c4fdefb8d39e84b0d17d3b34a0e447829df9137e Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sat, 7 Oct 2017 22:26:28 +0200 Subject: [PATCH 004/181] Added spacing between methods --- types/d3-geo/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index 4d9def3565..40ec500f90 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -804,6 +804,7 @@ export interface GeoProjection extends GeoStreamWrapper { * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). */ fitSize(size: [number, number], object: ExtendedGeometryCollection): this; + /** * A convenience method for projection.fitSize where the height is automatically chosen from the aspect ratio of object and the given constraint on width. * @@ -832,6 +833,7 @@ export interface GeoProjection extends GeoStreamWrapper { * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). */ fitWidth(width: number, object: ExtendedGeometryCollection): this; + /** * A convenience method for projection.fitSize where the width is automatically chosen from the aspect ratio of object and the given constraint on height. * @@ -860,6 +862,7 @@ export interface GeoProjection extends GeoStreamWrapper { * @param object A geographic geometry collection supported by d3-geo (An extension of GeoJSON geometry collection). */ fitHeight(height: number, object: ExtendedGeometryCollection): this; + /** * Returns a new array [longitude, latitude] in degrees representing the unprojected point of the given projected point. * May return null if the specified point has no defined projected position, such as when the point is outside the clipping bounds of the projection. From 8b26070d2a557744ec6581df8338f758263fe1bc Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sun, 8 Oct 2017 10:06:28 +0200 Subject: [PATCH 005/181] Added tests for d3-geo `fitHeight` and `fitWidth` --- types/d3-geo/d3-geo-tests.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/types/d3-geo/d3-geo-tests.ts b/types/d3-geo/d3-geo-tests.ts index 4d423aa5a3..876461e3e9 100644 --- a/types/d3-geo/d3-geo-tests.ts +++ b/types/d3-geo/d3-geo-tests.ts @@ -422,6 +422,26 @@ constructedProjection = constructedProjection.fitSize([960, 500], sampleExtended constructedProjection = constructedProjection.fitSize([960, 500], sampleFeatureCollection); constructedProjection = constructedProjection.fitSize([960, 500], sampleExtendedFeatureCollection); +constructedProjection = constructedProjection.fitWidth(960, samplePolygon); +constructedProjection = constructedProjection.fitWidth(960, sampleSphere); +constructedProjection = constructedProjection.fitWidth(960, sampleGeometryCollection); +constructedProjection = constructedProjection.fitWidth(960, sampleExtendedGeometryCollection); +constructedProjection = constructedProjection.fitWidth(960, sampleFeature); +constructedProjection = constructedProjection.fitWidth(960, sampleExtendedFeature1); +constructedProjection = constructedProjection.fitWidth(960, sampleExtendedFeature2); +constructedProjection = constructedProjection.fitWidth(960, sampleFeatureCollection); +constructedProjection = constructedProjection.fitWidth(960, sampleExtendedFeatureCollection); + +constructedProjection = constructedProjection.fitHeight(500, samplePolygon); +constructedProjection = constructedProjection.fitHeight(500, sampleSphere); +constructedProjection = constructedProjection.fitHeight(500, sampleGeometryCollection); +constructedProjection = constructedProjection.fitHeight(500, sampleExtendedGeometryCollection); +constructedProjection = constructedProjection.fitHeight(500, sampleFeature); +constructedProjection = constructedProjection.fitHeight(500, sampleExtendedFeature1); +constructedProjection = constructedProjection.fitHeight(500, sampleExtendedFeature2); +constructedProjection = constructedProjection.fitHeight(500, sampleFeatureCollection); +constructedProjection = constructedProjection.fitHeight(500, sampleExtendedFeatureCollection); + // ---------------------------------------------------------------------- // GeoConicProjection interface // ---------------------------------------------------------------------- From 2a858618c3f721512c52cbf8bbe943d8b7be4931 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 20:44:25 +0100 Subject: [PATCH 006/181] Backbone for d3-fetch --- types/d3-fetch/d3-fetch-tests.ts | 0 types/d3-fetch/index.d.ts | 5 +++++ types/d3-fetch/tsconfig.json | 22 ++++++++++++++++++++++ types/d3-fetch/tslint.json | 1 + 4 files changed, 28 insertions(+) create mode 100644 types/d3-fetch/d3-fetch-tests.ts create mode 100644 types/d3-fetch/index.d.ts create mode 100644 types/d3-fetch/tsconfig.json create mode 100644 types/d3-fetch/tslint.json diff --git a/types/d3-fetch/d3-fetch-tests.ts b/types/d3-fetch/d3-fetch-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts new file mode 100644 index 0000000000..f5b195ca04 --- /dev/null +++ b/types/d3-fetch/index.d.ts @@ -0,0 +1,5 @@ +// Type definitions for d3-fetch 1.0.1 +// Project: https://d3js.org/d3-fetch/ +// Definitions by: Hugues Stefanski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + diff --git a/types/d3-fetch/tsconfig.json b/types/d3-fetch/tsconfig.json new file mode 100644 index 0000000000..d4e382e338 --- /dev/null +++ b/types/d3-fetch/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", + "d3-fetch-tests.ts" + ] +} diff --git a/types/d3-fetch/tslint.json b/types/d3-fetch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/d3-fetch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d25d2ee1b42624281a7a36bbe2daf7970ecb02a8 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 21:12:59 +0100 Subject: [PATCH 007/181] Completed fetch API --- types/d3-fetch/d3-fetch-tests.ts | 15 ++++++++++++ types/d3-fetch/index.d.ts | 42 ++++++++++++++++++++++++++++++++ types/d3-fetch/tsconfig.json | 3 ++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/types/d3-fetch/d3-fetch-tests.ts b/types/d3-fetch/d3-fetch-tests.ts index e69de29bb2..b82ea8ffbe 100644 --- a/types/d3-fetch/d3-fetch-tests.ts +++ b/types/d3-fetch/d3-fetch-tests.ts @@ -0,0 +1,15 @@ +import * as d3Fetch from 'd3-fetch'; + +interface MyType { + foo: string; +} + +let promise: Promise; +const url = 'foo.bar'; + +const init: RequestInit = {}; + +promise = d3Fetch.blob(url); +promise = d3Fetch.blob(url, init); +promise = d3Fetch.buffer(url); +promise = d3Fetch.buffer(url, init); diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts index f5b195ca04..f46a779003 100644 --- a/types/d3-fetch/index.d.ts +++ b/types/d3-fetch/index.d.ts @@ -3,3 +3,45 @@ // Definitions by: Hugues Stefanski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/**Fetches the binary file at the specified input URL as a Blob. */ +export function blob(input: string): Promise; +/**Fetches the binary file at the specified input URL as a Blob. Passes init along to the underlying call to fetch. */ +export function blob(input: string, init: RequestInit): Promise; +/**Fetches the binary file at the specified input URL as an ArrayBuffer. */ +export function buffer(input: string): Promise; +/**Fetches the binary file at the specified input URL as an ArrayBuffer. Passes init along to the underlying call to fetch. */ +export function buffer(input: string, init: RequestInit): Promise; + +/**Equivalent to d3.dsv with the comma character as the delimiter. */ +export function csv(input: string): Promise; +/**Equivalent to d3.dsv with the comma character as the delimiter. */ +export function csv(input: string, init: RequestInit): Promise; +/**Equivalent to d3.dsv with the comma character as the delimiter. */ +export function csv(input: string, init: RequestInit, row: (d: any) => any): Promise; + +/**Fetches the DSV file at the specified input URL. */ +export function dsv(delimiter: string, input: string): Promise; +export function dsv(delimiter: string, input: string, init: RequestInit): Promise; +export function dsv(delimiter: string, input: string, init: RequestInit, row: any): Promise; + +/**Fetches the image at the specified input URL. */ +export function image(input: string): Promise; +/**Fetches the image at the specified input URL. Passes init along to the underlying call to fetch. */ +export function image(input: string, init: RequestInit): Promise; + +/**Fetches the json file at the specified input URL. */ +export function json(input: string): Promise; +/**Fetches the json file at the specified input URL. Passes init along to the underlying call to fetch. */ +export function json(input: string, init: RequestInit): Promise; + +/**Fetches the text file at the specified input URL. */ +export function text(input: string): Promise; +/**Fetches the text file at the specified input URL. Passes init along to the underlying call to fetch. */ +export function text(input: string, init: RequestInit): Promise; + +/**Equivalent to d3.dsv with the tab character as the delimiter. */ +export function tsv(input: string): Promise; +/**Equivalent to d3.dsv with the tab character as the delimiter. */ +export function tsv(input: string, init: RequestInit): Promise; +/**Equivalent to d3.dsv with the tab character as the delimiter. */ +export function tsv(input: string, init: RequestInit, row: (d: any) => any): Promise; diff --git a/types/d3-fetch/tsconfig.json b/types/d3-fetch/tsconfig.json index d4e382e338..4d18bd9ade 100644 --- a/types/d3-fetch/tsconfig.json +++ b/types/d3-fetch/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es2017", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, From a1e32e69642cd3ca0f7a80946412e138d5649982 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 21:23:56 +0100 Subject: [PATCH 008/181] Strong typings of parsing methods --- types/d3-fetch/index.d.ts | 55 +++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts index f46a779003..6a62630808 100644 --- a/types/d3-fetch/index.d.ts +++ b/types/d3-fetch/index.d.ts @@ -3,45 +3,62 @@ // Definitions by: Hugues Stefanski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv'; + /**Fetches the binary file at the specified input URL as a Blob. */ -export function blob(input: string): Promise; +export function blob(url: string): Promise; /**Fetches the binary file at the specified input URL as a Blob. Passes init along to the underlying call to fetch. */ -export function blob(input: string, init: RequestInit): Promise; +export function blob(url: string, init: RequestInit): Promise; /**Fetches the binary file at the specified input URL as an ArrayBuffer. */ -export function buffer(input: string): Promise; +export function buffer(url: string): Promise; /**Fetches the binary file at the specified input URL as an ArrayBuffer. Passes init along to the underlying call to fetch. */ -export function buffer(input: string, init: RequestInit): Promise; +export function buffer(url: string, init: RequestInit): Promise; /**Equivalent to d3.dsv with the comma character as the delimiter. */ -export function csv(input: string): Promise; +export function csv(url: string): Promise>; /**Equivalent to d3.dsv with the comma character as the delimiter. */ -export function csv(input: string, init: RequestInit): Promise; +export function csv(url: string, init: RequestInit): Promise>; /**Equivalent to d3.dsv with the comma character as the delimiter. */ -export function csv(input: string, init: RequestInit, row: (d: any) => any): Promise; +export function csv( + url: string, + init: RequestInit, + row: (d: DSVRowAny) => ParsedRow +): Promise>; /**Fetches the DSV file at the specified input URL. */ -export function dsv(delimiter: string, input: string): Promise; -export function dsv(delimiter: string, input: string, init: RequestInit): Promise; -export function dsv(delimiter: string, input: string, init: RequestInit, row: any): Promise; +export function dsv(delimiter: string, url: string): Promise>; +/**Fetches the DSV file at the specified input URL. */ +export function dsv(delimiter: string, url: string, init: RequestInit): Promise>; +/**Fetches the DSV file at the specified input URL. */ +export function dsv( + delimiter: string, + url: string, + init: RequestInit, + row: (d: DSVRowAny) => ParsedRow +): Promise>; /**Fetches the image at the specified input URL. */ -export function image(input: string): Promise; +export function image(url: string): Promise; /**Fetches the image at the specified input URL. Passes init along to the underlying call to fetch. */ -export function image(input: string, init: RequestInit): Promise; +export function image(url: string, init: RequestInit): Promise; /**Fetches the json file at the specified input URL. */ -export function json(input: string): Promise; +export function json(url: string): Promise; /**Fetches the json file at the specified input URL. Passes init along to the underlying call to fetch. */ -export function json(input: string, init: RequestInit): Promise; +export function json(url: string, init: RequestInit): Promise; /**Fetches the text file at the specified input URL. */ -export function text(input: string): Promise; +export function text(url: string): Promise; /**Fetches the text file at the specified input URL. Passes init along to the underlying call to fetch. */ -export function text(input: string, init: RequestInit): Promise; +export function text(url: string, init: RequestInit): Promise; /**Equivalent to d3.dsv with the tab character as the delimiter. */ -export function tsv(input: string): Promise; +export function tsv(url: string): Promise>; /**Equivalent to d3.dsv with the tab character as the delimiter. */ -export function tsv(input: string, init: RequestInit): Promise; +export function tsv(url: string, init: RequestInit): Promise>; /**Equivalent to d3.dsv with the tab character as the delimiter. */ -export function tsv(input: string, init: RequestInit, row: (d: any) => any): Promise; +export function tsv( + url: string, + init: RequestInit, + row: (d: DSVRowAny) => ParsedRow +): Promise>; From 1d9a51fd97c2496378fb4507c390aa46ec75db7f Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 21:29:16 +0100 Subject: [PATCH 009/181] Partial d3-fetch tests --- types/d3-fetch/d3-fetch-tests.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/d3-fetch/d3-fetch-tests.ts b/types/d3-fetch/d3-fetch-tests.ts index b82ea8ffbe..9c88ed8674 100644 --- a/types/d3-fetch/d3-fetch-tests.ts +++ b/types/d3-fetch/d3-fetch-tests.ts @@ -13,3 +13,10 @@ promise = d3Fetch.blob(url); promise = d3Fetch.blob(url, init); promise = d3Fetch.buffer(url); promise = d3Fetch.buffer(url, init); + +promise = d3Fetch.image(url); +promise = d3Fetch.image(url, init); +promise = d3Fetch.json(url); +promise = d3Fetch.json(url, init); +let myString: Promise = d3Fetch.text(url); +myString = d3Fetch.text(url, init); From 24c16d91da489001a967cc03e9fdb5915c6ec66b Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 21:36:08 +0100 Subject: [PATCH 010/181] Completed tests for d3-fetch --- types/d3-fetch/d3-fetch-tests.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/types/d3-fetch/d3-fetch-tests.ts b/types/d3-fetch/d3-fetch-tests.ts index 9c88ed8674..1dfff0e04f 100644 --- a/types/d3-fetch/d3-fetch-tests.ts +++ b/types/d3-fetch/d3-fetch-tests.ts @@ -1,4 +1,5 @@ import * as d3Fetch from 'd3-fetch'; +import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv'; interface MyType { foo: string; @@ -13,10 +14,26 @@ promise = d3Fetch.blob(url); promise = d3Fetch.blob(url, init); promise = d3Fetch.buffer(url); promise = d3Fetch.buffer(url, init); - promise = d3Fetch.image(url); promise = d3Fetch.image(url, init); promise = d3Fetch.json(url); promise = d3Fetch.json(url, init); -let myString: Promise = d3Fetch.text(url); + +let myString: Promise; +myString = d3Fetch.text(url); myString = d3Fetch.text(url, init); + +const parseRow = (d: {}) => { + const myType: MyType = { foo: 'foo' }; + return myType; +}; +let promise2: Promise>; +promise2 = d3Fetch.csv(url); +promise2 = d3Fetch.csv(url, init); +promise2 = d3Fetch.csv(url, init, parseRow); +promise2 = d3Fetch.dsv(';', url); +promise2 = d3Fetch.dsv(';', url, init); +promise2 = d3Fetch.dsv(';', url, init, parseRow); +promise2 = d3Fetch.tsv(url); +promise2 = d3Fetch.tsv(url, init); +promise2 = d3Fetch.tsv(url, init, parseRow); From 86f5c0fe17177d25f20ed82aefb71b29366b8a67 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 21:40:18 +0100 Subject: [PATCH 011/181] Reste library to es6 in d3-fetch --- types/d3-fetch/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/d3-fetch/tsconfig.json b/types/d3-fetch/tsconfig.json index 4d18bd9ade..ea7938966e 100644 --- a/types/d3-fetch/tsconfig.json +++ b/types/d3-fetch/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es2017", + "es6", "dom" ], "noImplicitAny": true, From e8920bb7a943e2cc28a4f62f5192be9961bf4a5b Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 22:04:52 +0100 Subject: [PATCH 012/181] Fix linting errors --- types/d3-fetch/index.d.ts | 62 ++++++++++++------------------------ types/d3-fetch/tsconfig.json | 1 + 2 files changed, 21 insertions(+), 42 deletions(-) diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts index 6a62630808..6d4d4c7303 100644 --- a/types/d3-fetch/index.d.ts +++ b/types/d3-fetch/index.d.ts @@ -1,64 +1,42 @@ -// Type definitions for d3-fetch 1.0.1 +// Type definitions for d3-fetch 1.0 // Project: https://d3js.org/d3-fetch/ // Definitions by: Hugues Stefanski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv'; -/**Fetches the binary file at the specified input URL as a Blob. */ -export function blob(url: string): Promise; -/**Fetches the binary file at the specified input URL as a Blob. Passes init along to the underlying call to fetch. */ -export function blob(url: string, init: RequestInit): Promise; -/**Fetches the binary file at the specified input URL as an ArrayBuffer. */ -export function buffer(url: string): Promise; -/**Fetches the binary file at the specified input URL as an ArrayBuffer. Passes init along to the underlying call to fetch. */ -export function buffer(url: string, init: RequestInit): Promise; +/** Fetches the binary file at the specified input URL as a Blob. If init is specified, it is passed along to the underlying call to fetch. */ +export function blob(url: string, init?: RequestInit): Promise; +/** Fetches the binary file at the specified input URL as an ArrayBuffer. If init is specified, it is passed along to the underlying call to fetch. */ +export function buffer(url: string, init?: RequestInit): Promise; -/**Equivalent to d3.dsv with the comma character as the delimiter. */ -export function csv(url: string): Promise>; -/**Equivalent to d3.dsv with the comma character as the delimiter. */ -export function csv(url: string, init: RequestInit): Promise>; -/**Equivalent to d3.dsv with the comma character as the delimiter. */ +/** Equivalent to d3.dsv with the comma character as the delimiter. */ export function csv( url: string, - init: RequestInit, - row: (d: DSVRowAny) => ParsedRow + init?: RequestInit, + row?: (d: DSVRowAny) => ParsedRow ): Promise>; -/**Fetches the DSV file at the specified input URL. */ -export function dsv(delimiter: string, url: string): Promise>; -/**Fetches the DSV file at the specified input URL. */ -export function dsv(delimiter: string, url: string, init: RequestInit): Promise>; -/**Fetches the DSV file at the specified input URL. */ +/** Fetches the DSV file at the specified input URL. */ export function dsv( delimiter: string, url: string, - init: RequestInit, - row: (d: DSVRowAny) => ParsedRow + init?: RequestInit, + row?: (d: DSVRowAny) => ParsedRow ): Promise>; -/**Fetches the image at the specified input URL. */ -export function image(url: string): Promise; -/**Fetches the image at the specified input URL. Passes init along to the underlying call to fetch. */ -export function image(url: string, init: RequestInit): Promise; +/** Fetches the image at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */ +export function image(url: string, init?: RequestInit): Promise; -/**Fetches the json file at the specified input URL. */ -export function json(url: string): Promise; -/**Fetches the json file at the specified input URL. Passes init along to the underlying call to fetch. */ -export function json(url: string, init: RequestInit): Promise; +/** Fetches the json file at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */ +export function json(url: string, init?: RequestInit): Promise; -/**Fetches the text file at the specified input URL. */ -export function text(url: string): Promise; -/**Fetches the text file at the specified input URL. Passes init along to the underlying call to fetch. */ -export function text(url: string, init: RequestInit): Promise; +/** Fetches the text file at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */ +export function text(url: string, init?: RequestInit): Promise; -/**Equivalent to d3.dsv with the tab character as the delimiter. */ -export function tsv(url: string): Promise>; -/**Equivalent to d3.dsv with the tab character as the delimiter. */ -export function tsv(url: string, init: RequestInit): Promise>; -/**Equivalent to d3.dsv with the tab character as the delimiter. */ +/** Equivalent to d3.dsv with the tab character as the delimiter. */ export function tsv( url: string, - init: RequestInit, - row: (d: DSVRowAny) => ParsedRow + init?: RequestInit, + row?: (d: DSVRowAny) => ParsedRow ): Promise>; diff --git a/types/d3-fetch/tsconfig.json b/types/d3-fetch/tsconfig.json index ea7938966e..f9b9d190dd 100644 --- a/types/d3-fetch/tsconfig.json +++ b/types/d3-fetch/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 0134384872fa0cbc434c25de5d8af358c491dd5e Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 29 Jan 2018 22:11:21 +0100 Subject: [PATCH 013/181] tentative fix TS 2.1 --- types/d3-fetch/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts index 6d4d4c7303..103f0f505c 100644 --- a/types/d3-fetch/index.d.ts +++ b/types/d3-fetch/index.d.ts @@ -2,7 +2,7 @@ // Project: https://d3js.org/d3-fetch/ // Definitions by: Hugues Stefanski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - +// TypeScript Version: 2.2 import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv'; /** Fetches the binary file at the specified input URL as a Blob. If init is specified, it is passed along to the underlying call to fetch. */ From ba310edd776755af165cac8b52a9b74ede22e135 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Wed, 31 Jan 2018 21:27:37 +0100 Subject: [PATCH 014/181] Specific types for d3-fetch --- types/d3-fetch/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts index 103f0f505c..16cce19e70 100644 --- a/types/d3-fetch/index.d.ts +++ b/types/d3-fetch/index.d.ts @@ -6,9 +6,9 @@ import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv'; /** Fetches the binary file at the specified input URL as a Blob. If init is specified, it is passed along to the underlying call to fetch. */ -export function blob(url: string, init?: RequestInit): Promise; +export function blob(url: string, init?: RequestInit): Promise; /** Fetches the binary file at the specified input URL as an ArrayBuffer. If init is specified, it is passed along to the underlying call to fetch. */ -export function buffer(url: string, init?: RequestInit): Promise; +export function buffer(url: string, init?: RequestInit): Promise; /** Equivalent to d3.dsv with the comma character as the delimiter. */ export function csv( @@ -26,7 +26,7 @@ export function dsv( ): Promise>; /** Fetches the image at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */ -export function image(url: string, init?: RequestInit): Promise; +export function image(url: string, init?: RequestInit): Promise; /** Fetches the json file at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */ export function json(url: string, init?: RequestInit): Promise; From 284c05386176ddd79c1aeab96d002186b1d0dea3 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Wed, 31 Jan 2018 21:32:28 +0100 Subject: [PATCH 015/181] Fix test on d3-fetch --- types/d3-fetch/d3-fetch-tests.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/d3-fetch/d3-fetch-tests.ts b/types/d3-fetch/d3-fetch-tests.ts index 1dfff0e04f..dc4729fced 100644 --- a/types/d3-fetch/d3-fetch-tests.ts +++ b/types/d3-fetch/d3-fetch-tests.ts @@ -10,12 +10,12 @@ const url = 'foo.bar'; const init: RequestInit = {}; -promise = d3Fetch.blob(url); -promise = d3Fetch.blob(url, init); -promise = d3Fetch.buffer(url); -promise = d3Fetch.buffer(url, init); -promise = d3Fetch.image(url); -promise = d3Fetch.image(url, init); +let p1: Promise = d3Fetch.blob(url); +p1 = d3Fetch.blob(url, init); +let p2: Promise = d3Fetch.buffer(url); +p2 = d3Fetch.buffer(url, init); +let p3: Promise = d3Fetch.image(url); +p3 = d3Fetch.image(url, init); promise = d3Fetch.json(url); promise = d3Fetch.json(url, init); From 1c607f2fc49ccf15b10a06d1b05f55b193c74175 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Wed, 31 Jan 2018 21:40:53 +0100 Subject: [PATCH 016/181] Removed generic used only once for json function in d3-fetch --- types/d3-fetch/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts index 16cce19e70..9fd19fe8ed 100644 --- a/types/d3-fetch/index.d.ts +++ b/types/d3-fetch/index.d.ts @@ -29,7 +29,7 @@ export function dsv( export function image(url: string, init?: RequestInit): Promise; /** Fetches the json file at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */ -export function json(url: string, init?: RequestInit): Promise; +export function json(url: string, init?: RequestInit): Promise<{}>; /** Fetches the text file at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */ export function text(url: string, init?: RequestInit): Promise; From 06b18847055218f1bbea97461d4d80fd215d25fa Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Wed, 31 Jan 2018 21:41:43 +0100 Subject: [PATCH 017/181] Fix d3-fetch test --- types/d3-fetch/d3-fetch-tests.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/types/d3-fetch/d3-fetch-tests.ts b/types/d3-fetch/d3-fetch-tests.ts index dc4729fced..24c6783997 100644 --- a/types/d3-fetch/d3-fetch-tests.ts +++ b/types/d3-fetch/d3-fetch-tests.ts @@ -5,7 +5,6 @@ interface MyType { foo: string; } -let promise: Promise; const url = 'foo.bar'; const init: RequestInit = {}; @@ -16,8 +15,8 @@ let p2: Promise = d3Fetch.buffer(url); p2 = d3Fetch.buffer(url, init); let p3: Promise = d3Fetch.image(url); p3 = d3Fetch.image(url, init); -promise = d3Fetch.json(url); -promise = d3Fetch.json(url, init); +let p4: Promise = d3Fetch.json(url); +p4 = d3Fetch.json(url, init); let myString: Promise; myString = d3Fetch.text(url); From 570c7db5d8b02755269dc32e2faf97088d418fc5 Mon Sep 17 00:00:00 2001 From: Andrea Ascari Date: Wed, 7 Feb 2018 17:34:36 +0100 Subject: [PATCH 018/181] Created react-native-auth0 types --- types/react-native-auth0/index.d.ts | 171 ++++++++++++++++++ .../react-native-auth0-tests.ts | 66 +++++++ types/react-native-auth0/tsconfig.json | 17 ++ types/react-native-auth0/tslint.json | 7 + 4 files changed, 261 insertions(+) create mode 100644 types/react-native-auth0/index.d.ts create mode 100644 types/react-native-auth0/react-native-auth0-tests.ts create mode 100644 types/react-native-auth0/tsconfig.json create mode 100644 types/react-native-auth0/tslint.json diff --git a/types/react-native-auth0/index.d.ts b/types/react-native-auth0/index.d.ts new file mode 100644 index 0000000000..45016da9ca --- /dev/null +++ b/types/react-native-auth0/index.d.ts @@ -0,0 +1,171 @@ +// Type definitions for react-native 1.2 +// Project: https://github.com/auth0/react-native-auth0 +// Definitions by: Andrea Ascari +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * Auth + */ + +export interface AuthorizationUrlParams { + responseType: string; + redirectUri: string; + state: string; +} + +export interface CreateUserParams { + email: string; + username?: string; + password: string; + connection: string; + metadata?: T; +} + +export interface CreateUserResponse { + Id: string; + emailVerified: boolean; + email: string; +} + +export interface ExchangeParams { + code: string; + redirectUri: string; + verifier: string; +} + +export interface LogoutParams { + federated: boolean; + clientId?: string; + returnTo?: string; +} + +export interface PasswordRealmParams { + username: string; + password: string; + realm: string; + audience?: string; + scope?: string; +} + +export interface PasswordRealmResponse { + accessToken: string; + expiresIn: number; + idToken: string; + scope: string; + tokenType: "Bearer"; +} + +export interface RefreshTokenParams { + refreshToken: string; + scope?: string; +} + +export interface RevokeParams { + refreshToken: string; +} + +export interface UserInfoParams { + token: string; +} + +export interface UserInfo { + email: string; + emailVerified: boolean; + name: string; + nickname: string; + picture: string; + sub: string; + updatedAt: string; +} +export class Auth { + authorizationUrl(params: AuthorizationUrlParams): string; + createUser(user: CreateUserParams): Promise; + exchange(params: ExchangeParams): Promise; + logoutUrl(params: LogoutParams): string; + passwordRealm(params: PasswordRealmParams): Promise; + + refreshToken(params: RefreshTokenParams): Promise; + revoke(params: RevokeParams): Promise; + userInfo(params: UserInfoParams): Promise; +} + +/** + * Users + */ +export interface Auth0User { + created_at: string; + email: string; + emailVerified: boolean; + identities: any[]; + last_ip?: string; + last_login?: string; + logins_count: number; + name: string; + nickname: string; + picture?: string; + updated_at: string; + userId: string; + userMetadata?: T; +} + +export interface GetUserParams { + id: string; +} + +export interface PatchUserParams { + id: string; + metadata: T; +} + +export class Users { + constructor(options: UsersOptions); + /* tslint:disable-next-line no-unnecessary-generics */ + getUser(parameters: GetUserParams): Promise>; + patchUser( + parameters: PatchUserParams + ): Promise>; +} + +export const users: Users; + +/** + * Web Auth + */ +export interface AuthorizeParams { + state?: string; + nonce?: string; + audience?: string; + scope?: string; +} + +export interface ClearSessionParams { + federated: boolean; +} + +export class WebAuth { + authorize(parameters: AuthorizeParams): Promise; + clearSession(parameters: ClearSessionParams): Promise; +} + +export interface UsersOptions { + baseUrl: Options["domain"]; + token: string; +} + +export interface Options { + domain: string; + clientId: string; +} + +/** + * Auth0 + */ + +export default class Auth0 { + auth: Auth; + webAuth: WebAuth; + constructor(options: Options); + + users(token: string): Users; +} diff --git a/types/react-native-auth0/react-native-auth0-tests.ts b/types/react-native-auth0/react-native-auth0-tests.ts new file mode 100644 index 0000000000..53eca829eb --- /dev/null +++ b/types/react-native-auth0/react-native-auth0-tests.ts @@ -0,0 +1,66 @@ +import Auth0, { UserInfo } from "react-native-auth0"; + +const auth0 = new Auth0({ + domain: "definitely-typed", + clientId: "definitely-typed" +}); + +auth0.auth.createUser({ + email: "me@example.com", + username: "johndoe", + password: "password", + connection: "db-connection" +}); + +auth0.auth.authorizationUrl({ + responseType: "json", + redirectUri: "http://localhost:3000", + state: "my-state" +}); + +auth0.auth.exchange({ + code: "my-code", + redirectUri: "http://localhost:3000", + verifier: "verifier" +}); + +auth0.auth.logoutUrl({ + federated: true, + clientId: "client-id", + returnTo: "http://localhost:3000" +}); + +auth0.auth.passwordRealm({ + username: "me@example.com", + password: "password", + realm: "realm", + audience: "user-info" +}); + +auth0.auth.refreshToken({ + refreshToken: "refresh-token", + scope: "openid" +}); + +auth0.auth.revoke({ + refreshToken: "refresh-token" +}); + +auth0.auth.userInfo({ + token: "token" +}); + +auth0.webAuth.authorize({ + state: "state", + nonce: "nonce", + scope: "openid" +}); + +auth0.webAuth.clearSession({ federated: false }); + +auth0.users("token").getUser({ id: "userId" }); + +auth0.users("token").patchUser<{ firstName: string; lastName: string }>({ + id: "userId", + metadata: { firstName: "John", lastName: "Dow" } +}); diff --git a/types/react-native-auth0/tsconfig.json b/types/react-native-auth0/tsconfig.json new file mode 100644 index 0000000000..f694a107be --- /dev/null +++ b/types/react-native-auth0/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "react-native-auth0-tests.ts"] +} diff --git a/types/react-native-auth0/tslint.json b/types/react-native-auth0/tslint.json new file mode 100644 index 0000000000..fd90cce501 --- /dev/null +++ b/types/react-native-auth0/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // Lowercase `object` is available in TypeScript 2.2 only. + "ban-types": false + } +} From 9f14ab9919d4b18bcf9252288285ababbf448b16 Mon Sep 17 00:00:00 2001 From: Wayne Dela Cruz Date: Mon, 12 Feb 2018 23:02:55 +0800 Subject: [PATCH 019/181] Create filter query typing --- types/mongodb/index.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index dd4f44f38a..a2a30c9f1e 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -635,6 +635,21 @@ export interface Collection { watch(pipeline?: Object[], options?: ChangeStreamOptions & { session?: ClientSession }): ChangeStream; } +type FilterQuery = { + [P in keyof T]?: T[P] | { + $eq?: T[P]; + $gt?: T[P]; + $gte?: T[P]; + $in?: T[P][]; + $lt?: T[P]; + $lte?: T[P]; + $ne?: T[P]; + $nin?: T[P][]; + $and?: FilterQuery[]; + $not?: FilterQuery[] | T[P]; + }; +}; + // Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ export interface CollStats { // Namespace. From 3a4de187b2edaf2d09e60e6269c05e5509005e49 Mon Sep 17 00:00:00 2001 From: Wayne Dela Cruz Date: Mon, 12 Feb 2018 23:06:36 +0800 Subject: [PATCH 020/181] Collection use filter query --- types/mongodb/index.d.ts | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index a2a30c9f1e..d9d6a21bdc 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -482,13 +482,13 @@ export interface Collection { createIndexes(indexSpecs: Object[], options?: {session?: ClientSession}): Promise; createIndexes(indexSpecs: Object[], options: {session?: ClientSession}, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#deleteMany */ - deleteMany(filter: Object, callback: MongoCallback): void; - deleteMany(filter: Object, options?: CommonOptions): Promise; - deleteMany(filter: Object, options: CommonOptions, callback: MongoCallback): void; + deleteMany(filter: FilterQuery, callback: MongoCallback): void; + deleteMany(filter: FilterQuery, options?: CommonOptions): Promise; + deleteMany(filter: FilterQuery, options: CommonOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#deleteOne */ - deleteOne(filter: Object, callback: MongoCallback): void; - deleteOne(filter: Object, options?: CommonOptions & { bypassDocumentValidation?: boolean }): Promise; - deleteOne(filter: Object, options: CommonOptions & { bypassDocumentValidation?: boolean }, callback: MongoCallback): void; + deleteOne(filter: FilterQuery, callback: MongoCallback): void; + deleteOne(filter: FilterQuery, options?: CommonOptions & { bypassDocumentValidation?: boolean }): Promise; + deleteOne(filter: FilterQuery, options: CommonOptions & { bypassDocumentValidation?: boolean }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#distinct */ distinct(key: string, query: Object, callback: MongoCallback): void; distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number, session?: ClientSession }): Promise; @@ -510,21 +510,21 @@ export interface Collection { /** @deprecated */ find(query: Object, options?: FindOneOptions): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOne */ - findOne(filter: Object, callback: MongoCallback): void; - findOne(filter: Object, options?: FindOneOptions): Promise; - findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; + findOne(filter: FilterQuery, callback: MongoCallback): void; + findOne(filter: FilterQuery, options?: FindOneOptions): Promise; + findOne(filter: FilterQuery, options: FindOneOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndDelete */ - findOneAndDelete(filter: Object, callback: MongoCallback>): void; - findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }): Promise>; - findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }, callback: MongoCallback>): void; + findOneAndDelete(filter: FilterQuery, callback: MongoCallback>): void; + findOneAndDelete(filter: FilterQuery, options?: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }): Promise>; + findOneAndDelete(filter: FilterQuery, options: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }, callback: MongoCallback>): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndReplace */ - findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback>): void; - findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise>; - findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; + findOneAndReplace(filter: FilterQuery, replacement: Object, callback: MongoCallback>): void; + findOneAndReplace(filter: FilterQuery, replacement: Object, options?: FindOneAndReplaceOption): Promise>; + findOneAndReplace(filter: FilterQuery, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndUpdate */ - findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback>): void; - findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise>; - findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; + findOneAndUpdate(filter: FilterQuery, update: Object, callback: MongoCallback>): void; + findOneAndUpdate(filter: FilterQuery, update: Object, options?: FindOneAndReplaceOption): Promise>; + findOneAndUpdate(filter: FilterQuery, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#geoHaystackSearch */ geoHaystackSearch(x: number, y: number, callback: MongoCallback): void; geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise; @@ -602,9 +602,9 @@ export interface Collection { rename(newName: string, options?: { dropTarget?: boolean, session?: ClientSession }): Promise>; rename(newName: string, options: { dropTarget?: boolean, session?: ClientSession }, callback: MongoCallback>): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#replaceOne */ - replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; - replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; - replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; + replaceOne(filter: FilterQuery, doc: Object, callback: MongoCallback): void; + replaceOne(filter: FilterQuery, doc: Object, options?: ReplaceOneOptions): Promise; + replaceOne(filter: FilterQuery, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#save */ /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ save(doc: Object, callback: MongoCallback): void; @@ -618,19 +618,19 @@ export interface Collection { stats(options: { scale: number, session?: ClientSession }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#update */ /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, callback: MongoCallback): void; + update(filter: FilterQuery, update: Object, callback: MongoCallback): void; /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; + update(filter: FilterQuery, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; + update(filter: FilterQuery, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#updateMany */ - updateMany(filter: Object, update: Object, callback: MongoCallback): void; - updateMany(filter: Object, update: Object, options?: CommonOptions & { upsert?: boolean }): Promise; - updateMany(filter: Object, update: Object, options: CommonOptions & { upsert?: boolean }, callback: MongoCallback): void; + updateMany(filter: FilterQuery, update: Object, callback: MongoCallback): void; + updateMany(filter: FilterQuery, update: Object, options?: CommonOptions & { upsert?: boolean }): Promise; + updateMany(filter: FilterQuery, update: Object, options: CommonOptions & { upsert?: boolean }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#updateOne */ - updateOne(filter: Object, update: Object, callback: MongoCallback): void; - updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise; - updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; + updateOne(filter: FilterQuery, update: Object, callback: MongoCallback): void; + updateOne(filter: FilterQuery, update: Object, options?: ReplaceOneOptions): Promise; + updateOne(filter: FilterQuery, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#watch */ watch(pipeline?: Object[], options?: ChangeStreamOptions & { session?: ClientSession }): ChangeStream; } From cad9bcefb7eca399a54ec52d774f70ad011c6da6 Mon Sep 17 00:00:00 2001 From: Wayne Dela Cruz Date: Mon, 12 Feb 2018 23:31:22 +0800 Subject: [PATCH 021/181] Add more typings --- types/mongodb/index.d.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index d9d6a21bdc..cebf31e32c 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -645,8 +645,30 @@ type FilterQuery = { $lte?: T[P]; $ne?: T[P]; $nin?: T[P][]; - $and?: FilterQuery[]; - $not?: FilterQuery[] | T[P]; + $and?: (FilterQuery | T[P])[]; + $not?: (FilterQuery | T[P])[] | T[P]; + $expr?: any; + $jsonSchema?: any; + $mod?: [number, number]; + $regex?: RegExp; + $options?: string; + $text?: { + $search: string; + $language?: string; + $caseSensitive?: boolean; + $diacraticSensitive?: boolean; + }; + $where: Object; + $geoIntersects?: Object; + $geoWithin?: Object; + $near?: Object; + $nearSphere?: Object; + $elemMatch?: Object; + $size?: number; + $bitsAllClear?: Object; + $bitsAllSet?: Object; + $bitsAnyClear?: Object; + $bitsAnySet?: Object; }; }; From 685800783ac53ef976dba890a039f1b55334c9f2 Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Thu, 15 Feb 2018 13:04:43 +0100 Subject: [PATCH 022/181] node: Add child_process Windows options Add `windowsHide` to the appropriate options interfaces for node's `child_process` functions. Following the documentation for node v9.5.0. --- types/node/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 717b906b28..53d8d67702 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2104,6 +2104,7 @@ declare module "child_process" { killSignal?: string; uid?: number; gid?: number; + windowsHide?: boolean; } export interface ExecOptionsWithStringEncoding extends ExecOptions { @@ -2150,6 +2151,7 @@ declare module "child_process" { killSignal?: string; uid?: number; gid?: number; + windowsHide?: boolean; windowsVerbatimArguments?: boolean; } export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { @@ -2233,6 +2235,7 @@ declare module "child_process" { maxBuffer?: number; encoding?: string; shell?: boolean | string; + windowsHide?: boolean; windowsVerbatimArguments?: boolean; } export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { @@ -2270,6 +2273,7 @@ declare module "child_process" { killSignal?: string; maxBuffer?: number; encoding?: string; + windowsHide?: boolean; } export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { encoding: BufferEncoding; @@ -2293,6 +2297,7 @@ declare module "child_process" { killSignal?: string; maxBuffer?: number; encoding?: string; + windowsHide?: boolean; } export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { encoding: BufferEncoding; From 3f9d7f0bca2951025adbd46046bee8fece7804fa Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Thu, 15 Feb 2018 13:08:20 +0100 Subject: [PATCH 023/181] node: Add test for windowsHide option Test for commit 685800783ac53ef976dba890a039f1b55334c9f2 --- types/node/node-tests.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 0572c58fea..1eb6539b09 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -2049,14 +2049,17 @@ namespace string_decoder_tests { namespace child_process_tests { { childProcess.exec("echo test"); + childProcess.exec("echo test", {windowsHide: true}); childProcess.spawnSync("echo test"); + childProcess.spawnSync("echo test", {windowsVerbatimArguments: false}); } { childProcess.execFile("npm", () => {}); + childProcess.execFile("npm", { windowsHide: true }, () => {}); childProcess.execFile("npm", ["-v"], () => {}); - childProcess.execFile("npm", ["-v"], { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); }); - childProcess.execFile("npm", ["-v"], { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); }); + childProcess.execFile("npm", ["-v"], { windowsHide: true, encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); }); + childProcess.execFile("npm", ["-v"], { windowsHide: true, encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); }); childProcess.execFile("npm", { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); }); childProcess.execFile("npm", { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); }); } From bc951f40501c233005ff1a586c3043756008edc2 Mon Sep 17 00:00:00 2001 From: Andrea Ascari Date: Sat, 17 Feb 2018 11:15:51 +0100 Subject: [PATCH 024/181] Added 'esModuleInterop' in tsconfig, removed the 'ban-types' rule from lint config --- types/react-native-auth0/tsconfig.json | 1 + types/react-native-auth0/tslint.json | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/types/react-native-auth0/tsconfig.json b/types/react-native-auth0/tsconfig.json index f694a107be..407210c6b1 100644 --- a/types/react-native-auth0/tsconfig.json +++ b/types/react-native-auth0/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "lib": ["es6"], "target": "es6", + "esModuleInterop": true, "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, diff --git a/types/react-native-auth0/tslint.json b/types/react-native-auth0/tslint.json index fd90cce501..f93cf8562a 100644 --- a/types/react-native-auth0/tslint.json +++ b/types/react-native-auth0/tslint.json @@ -1,7 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - // Lowercase `object` is available in TypeScript 2.2 only. - "ban-types": false - } + "extends": "dtslint/dt.json" } From 1280dde3802b034659f854c74f1ea18103ac5b1b Mon Sep 17 00:00:00 2001 From: Keegan Shay Date: Mon, 19 Feb 2018 18:01:11 -0600 Subject: [PATCH 025/181] Add sqlMessage field to MySqlError --- types/mysql/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/mysql/index.d.ts b/types/mysql/index.d.ts index 7d3281218f..1e827a7d37 100644 --- a/types/mysql/index.d.ts +++ b/types/mysql/index.d.ts @@ -521,6 +521,11 @@ export interface MysqlError extends Error { * SQL of failed query */ sql?: string; + + /** + * Error message from MySQL + */ + sqlMessage?: string; } export const enum Types { From 7589ddfcbc30151bf9990fa3babf57dd6d1a5381 Mon Sep 17 00:00:00 2001 From: Greg Zapp Date: Mon, 19 Feb 2018 19:06:40 -0600 Subject: [PATCH 026/181] Correct row documentation and add original property. --- types/react-table/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/react-table/index.d.ts b/types/react-table/index.d.ts index 2ab2d2a821..341bb103cb 100644 --- a/types/react-table/index.d.ts +++ b/types/react-table/index.d.ts @@ -601,9 +601,12 @@ export interface RowRenderProps extends Partial { } export interface RowInfo { - /** Original row from your data */ + /** Materialized row of data */ row: any; + /** Original row from your data */ + original: any; + /** The post-accessed values from the original row */ rowValues: any; From c69f7de87e14887ea2fb903235737c82d64b8f97 Mon Sep 17 00:00:00 2001 From: Almir Kadric Date: Wed, 21 Feb 2018 02:31:55 +0900 Subject: [PATCH 027/181] added missing properties to NativeRouter and fixed Link component type --- types/react-router-native/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/react-router-native/index.d.ts b/types/react-router-native/index.d.ts index 4a14dce8dc..7adbdcf4f3 100644 --- a/types/react-router-native/index.d.ts +++ b/types/react-router-native/index.d.ts @@ -31,7 +31,7 @@ export class AndroidBackButton extends React.Component { export class DeepLinking extends React.Component {} export interface LinkProps { - component?: React.Component; + component?: React.Component | React.ComponentClass; replace?: boolean; style?: any; to: H.LocationDescriptor; @@ -40,6 +40,8 @@ export interface LinkProps { export class Link extends React.Component {} export interface NativeRouterProps { + initialEntries?: string[]; + initialIndex?: number; getUserConfirmation?: Function; keyLength?: number; } From ddd58d8476490dc32ce78026839336b735ab5dd8 Mon Sep 17 00:00:00 2001 From: Almir Kadric Date: Wed, 21 Feb 2018 02:51:22 +0900 Subject: [PATCH 028/181] fixed Link type to accept any property as it will proxy them to the given component --- types/react-router-native/index.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/types/react-router-native/index.d.ts b/types/react-router-native/index.d.ts index 7adbdcf4f3..600ac53ce9 100644 --- a/types/react-router-native/index.d.ts +++ b/types/react-router-native/index.d.ts @@ -37,7 +37,14 @@ export interface LinkProps { to: H.LocationDescriptor; } -export class Link extends React.Component {} +/** + * Disable the "no-any-union" rule here as the Link component can accept any property. + * It will feed them to the given component. However if we just use any we will lose + * autocomplete on known properties. So it is better to disable this rule in this one + * instance. + */ +// tslint:disable-next-line:no-any-union +export class Link extends React.Component {} export interface NativeRouterProps { initialEntries?: string[]; From d7ee161569535bbac6ba3cb2af3dc59633f459e4 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 20 Feb 2018 20:23:41 +0100 Subject: [PATCH 029/181] New typings for csv2json --- types/csv2json/csv2json-tests.ts | 8 ++++++++ types/csv2json/index.d.ts | 15 +++++++++++++++ types/csv2json/tsconfig.json | 23 +++++++++++++++++++++++ types/csv2json/tslint.json | 1 + 4 files changed, 47 insertions(+) create mode 100644 types/csv2json/csv2json-tests.ts create mode 100644 types/csv2json/index.d.ts create mode 100644 types/csv2json/tsconfig.json create mode 100644 types/csv2json/tslint.json diff --git a/types/csv2json/csv2json-tests.ts b/types/csv2json/csv2json-tests.ts new file mode 100644 index 0000000000..269d4c2dfe --- /dev/null +++ b/types/csv2json/csv2json-tests.ts @@ -0,0 +1,8 @@ +import csv2json from "csv2json"; +import fs from "fs"; + +fs.createReadStream('data.csv') + .pipe(csv2json({ + separator: ';' + })) + .pipe(fs.createWriteStream('data.json')); diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts new file mode 100644 index 0000000000..f1c08c3e7c --- /dev/null +++ b/types/csv2json/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for csv2json 1.4 +// Project: https://github.com/julien-f/csv2json +// Definitions by: Piotr Roszatycki +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Writable } from "stream"; + +export interface CSV2JSONOptions { + dynamicTyping?: boolean; + separator?: string; +} + +export default function csv2json (options: CSV2JSONOptions): Writable; diff --git a/types/csv2json/tsconfig.json b/types/csv2json/tsconfig.json new file mode 100644 index 0000000000..e9840faef7 --- /dev/null +++ b/types/csv2json/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "csv2json-tests.ts" + ] +} diff --git a/types/csv2json/tslint.json b/types/csv2json/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/csv2json/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 20be1b2329f13c8b8f8a42d07cad308a999e27d8 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 20 Feb 2018 20:43:12 +0100 Subject: [PATCH 030/181] linter clean --- types/csv2json/index.d.ts | 3 ++- types/csv2json/tsconfig.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts index f1c08c3e7c..1ea9d5c6eb 100644 --- a/types/csv2json/index.d.ts +++ b/types/csv2json/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/julien-f/csv2json // Definitions by: Piotr Roszatycki // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.7 /// @@ -12,4 +13,4 @@ export interface CSV2JSONOptions { separator?: string; } -export default function csv2json (options: CSV2JSONOptions): Writable; +export default function csv2json(options: CSV2JSONOptions): Writable; diff --git a/types/csv2json/tsconfig.json b/types/csv2json/tsconfig.json index e9840faef7..79a635ca7d 100644 --- a/types/csv2json/tsconfig.json +++ b/types/csv2json/tsconfig.json @@ -6,6 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, + "strictFunctionTypes": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ From f602a6db7619a426bd9e814b38a9439c4fb44f31 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 20 Feb 2018 21:12:37 +0100 Subject: [PATCH 031/181] This typings is for TypeScript 2.7 only but Microsoft/definitelytyped-header-parser#11 is not fixed --- types/csv2json/csv2json-tests.ts | 2 +- types/csv2json/index.d.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/csv2json/csv2json-tests.ts b/types/csv2json/csv2json-tests.ts index 269d4c2dfe..9e4e6cbdd3 100644 --- a/types/csv2json/csv2json-tests.ts +++ b/types/csv2json/csv2json-tests.ts @@ -1,5 +1,5 @@ import csv2json from "csv2json"; -import fs from "fs"; +import fs = require("fs"); fs.createReadStream('data.csv') .pipe(csv2json({ diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts index 1ea9d5c6eb..713f4a05bc 100644 --- a/types/csv2json/index.d.ts +++ b/types/csv2json/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/julien-f/csv2json // Definitions by: Piotr Roszatycki // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.7 /// From 79e131eedb00e9ff7a4f72c9cf9d71a7c29c39c7 Mon Sep 17 00:00:00 2001 From: Andrea Ascari Date: Wed, 21 Feb 2018 16:33:57 +0100 Subject: [PATCH 032/181] Removed default base type for inferred types --- types/react-native-auth0/index.d.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/types/react-native-auth0/index.d.ts b/types/react-native-auth0/index.d.ts index 45016da9ca..152da0655c 100644 --- a/types/react-native-auth0/index.d.ts +++ b/types/react-native-auth0/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-native 1.2 +// Type definitions for react-native-auth0 1.2 // Project: https://github.com/auth0/react-native-auth0 // Definitions by: Andrea Ascari // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -14,7 +14,7 @@ export interface AuthorizationUrlParams { state: string; } -export interface CreateUserParams { +export interface CreateUserParams { email: string; username?: string; password: string; @@ -80,7 +80,7 @@ export interface UserInfo { } export class Auth { authorizationUrl(params: AuthorizationUrlParams): string; - createUser(user: CreateUserParams): Promise; + createUser(user: CreateUserParams): Promise; exchange(params: ExchangeParams): Promise; logoutUrl(params: LogoutParams): string; passwordRealm(params: PasswordRealmParams): Promise; @@ -121,10 +121,8 @@ export interface PatchUserParams { export class Users { constructor(options: UsersOptions); /* tslint:disable-next-line no-unnecessary-generics */ - getUser(parameters: GetUserParams): Promise>; - patchUser( - parameters: PatchUserParams - ): Promise>; + getUser(parameters: GetUserParams): Promise>; + patchUser(parameters: PatchUserParams): Promise>; } export const users: Users; @@ -145,7 +143,7 @@ export interface ClearSessionParams { export class WebAuth { authorize(parameters: AuthorizeParams): Promise; - clearSession(parameters: ClearSessionParams): Promise; + clearSession(parameters?: ClearSessionParams): Promise; } export interface UsersOptions { From 433cfd71382c4c31d376525b2461edc01d54e25d Mon Sep 17 00:00:00 2001 From: Andrea Ascari Date: Wed, 21 Feb 2018 16:40:29 +0100 Subject: [PATCH 033/181] Add test for clearSession invoked without params --- types/react-native-auth0/react-native-auth0-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-native-auth0/react-native-auth0-tests.ts b/types/react-native-auth0/react-native-auth0-tests.ts index 53eca829eb..3f659cbdee 100644 --- a/types/react-native-auth0/react-native-auth0-tests.ts +++ b/types/react-native-auth0/react-native-auth0-tests.ts @@ -57,6 +57,7 @@ auth0.webAuth.authorize({ }); auth0.webAuth.clearSession({ federated: false }); +auth0.webAuth.clearSession(); auth0.users("token").getUser({ id: "userId" }); From 38f5479744a0f81236af6f4c86bde62eead501c1 Mon Sep 17 00:00:00 2001 From: Aluan Haddad Date: Wed, 21 Feb 2018 18:01:41 -0500 Subject: [PATCH 034/181] fix import in window module test --- types/jquery/test/jquery-window-module-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jquery/test/jquery-window-module-tests.ts b/types/jquery/test/jquery-window-module-tests.ts index 71e20bc4a0..6bc5486fb9 100644 --- a/types/jquery/test/jquery-window-module-tests.ts +++ b/types/jquery/test/jquery-window-module-tests.ts @@ -1,4 +1,4 @@ -import * as jq from 'jquery'; +import jq = require('jquery'); const $window = jq(window); // $ExpectType JQuery From 8acf1ae42963dcfe82e0ebb74a897c4a6a5aa033 Mon Sep 17 00:00:00 2001 From: Aluan Haddad Date: Wed, 21 Feb 2018 18:10:15 -0500 Subject: [PATCH 035/181] fix import in another test --- types/jquery/test/jquery-slim-window-module-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jquery/test/jquery-slim-window-module-tests.ts b/types/jquery/test/jquery-slim-window-module-tests.ts index 76870e7a04..b47707cb23 100644 --- a/types/jquery/test/jquery-slim-window-module-tests.ts +++ b/types/jquery/test/jquery-slim-window-module-tests.ts @@ -1,4 +1,4 @@ -import * as jq from 'jquery/dist/jquery.slim'; +import jq = require('jquery/dist/jquery.slim'); const $window = jq(window); // $ExpectType JQuery From cb7659eedfdcfbf8622dbcfc7e6f2296e7b4dbbd Mon Sep 17 00:00:00 2001 From: Andrew Pinkham Date: Fri, 23 Feb 2018 17:37:14 -0500 Subject: [PATCH 036/181] leaflet: add methods and properties The goal is to make writing plugins easier for developers by adding private methods and properties. --- types/leaflet/index.d.ts | 27 +++++++++++++++++++ types/leaflet/leaflet-tests.ts | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index eabb98c710..922b9ab686 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -182,6 +182,10 @@ export class Point { y: number; } +export interface Coords extends Point { + z: number; +} + export type PointExpression = Point | PointTuple; export function point(x: number, y: number, round?: boolean): Point; @@ -388,6 +392,7 @@ export interface InteractiveLayerOptions extends LayerOptions { } export class Layer extends Evented { + _map: Map; constructor(options?: LayerOptions); addTo(map: Map|LayerGroup): this; remove(): this; @@ -439,6 +444,17 @@ export interface GridLayerOptions { keepBuffer?: number; } +export interface InternalTiles { + [key: string]: { + active?: boolean, + coords: Coords, + current: boolean, + el: HTMLElement, + loaded?: Date, + retain?: boolean, + }; +} + export class GridLayer extends Layer { constructor(options?: GridLayerOptions); bringToFront(): this; @@ -449,6 +465,11 @@ export class GridLayer extends Layer { isLoading(): boolean; redraw(): this; getTileSize(): Point; + + _tileCoordsToKey(coords: Coords): string; + + _tiles: InternalTiles; + _tileZoom?: number; } export function gridLayer(options?: GridLayerOptions): GridLayer; @@ -468,10 +489,16 @@ export interface TileLayerOptions extends GridLayerOptions { [name: string]: any; } +export type DoneCallback = (error?: Error, tile?: HTMLElement) => void; + export class TileLayer extends GridLayer { constructor(urlTemplate: string, options?: TileLayerOptions); + createTile(coords: Coords, done: DoneCallback): HTMLElement; setUrl(url: string, noRedraw?: boolean): this; + _abortLoading(): void; + _getZoomForUrl(): number; + options: TileLayerOptions; } diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index c4f73e5b84..a22ab91248 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -510,3 +510,50 @@ lg = new L.LayerGroup([new L.Layer(), new L.Layer()], { pane: 'overlayPane', attribution: 'test' }); + +// adapted from GridLayer documentation +const CanvasLayer = L.GridLayer.extend({ + createTile(coords: L.Coords, done: L.DoneCallback) { + const tile = (L.DomUtil.create('canvas', 'leaflet-tile') as HTMLCanvasElement); + const size = this.getTileSize(); + tile.width = size.x; + tile.height = size.y; + return tile; + } +}); + +// adapted from GridLayer documentation +const AsyncCanvasLayer = L.GridLayer.extend({ + createTile(coords: L.Coords, done: L.DoneCallback) { + const tile = (L.DomUtil.create('canvas', 'leaflet-tile') as HTMLCanvasElement); + const size = this.getTileSize(); + tile.width = size.x; + tile.height = size.y; + setTimeout(() => done(undefined, tile), 1000); + return tile; + } +}); + +export class ExtendedTileLayer extends L.TileLayer { + options: L.TileLayerOptions; + createTile(coords: L.Coords, done: L.DoneCallback) { + const newCoords: L.Coords = (new L.Point(coords.x, coords.y) as L.Coords); + newCoords.z = coords.z; + return super.createTile(newCoords, done); + } + _abortLoading() { + // adapted from TileLayer's implementation + for (const i in this._tiles) { + if (this._tiles[i].coords.z !== this._tileZoom) { + const tile = this._tiles[i].el; + tile.onload = L.Util.falseFn; + tile.onerror = L.Util.falseFn; + if (tile instanceof HTMLImageElement && !tile.complete) { + tile.src = L.Util.emptyImageUrl; + L.DomUtil.remove(tile); + this._tiles[i] = undefined; + } + } + } + } +} From 77a857abff084c942de362fdf2c9fce68f882b23 Mon Sep 17 00:00:00 2001 From: Phil Nova Date: Mon, 26 Feb 2018 13:58:54 -0800 Subject: [PATCH 037/181] Add tag to SortEvent In order to check if the event target is a hyperlink and cancel sort if the user clicks a link, the recommended pattern is to check SortEvent.target.tagName. (see https://stackoverflow.com/questions/15661343/check-if-event-target-is-hyperlink). However, the typings do not support this pattern as SortEvent.target does not expect a tag attribute. --- types/react-sortable-hoc/index.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/react-sortable-hoc/index.d.ts b/types/react-sortable-hoc/index.d.ts index 851170036d..dbf402599f 100644 --- a/types/react-sortable-hoc/index.d.ts +++ b/types/react-sortable-hoc/index.d.ts @@ -18,6 +18,14 @@ export interface SortStart { export type SortEvent = React.MouseEvent | React.TouchEvent; +interface Tag extends React.EventTarget { + tagName: string; +} + +export interface SortEventWithTag extends SortEvent { + target: Tag; +} + export type SortStartHandler = (sort: SortStart, event: SortEvent) => void; export type SortMoveHandler = (event: SortEvent) => void; @@ -45,7 +53,7 @@ export interface SortableContainerProps { pressDelay?: number; pressThreshold?: number; distance?: number; - shouldCancelStart?: (event: SortEvent) => boolean; + shouldCancelStart?: (event: SortEvent | SortEventWithTag) => boolean; onSortStart?: SortStartHandler; onSortMove?: SortMoveHandler; onSortEnd?: SortEndHandler; From 51fd12ef41191e4444a8153eb953ac169265aaa9 Mon Sep 17 00:00:00 2001 From: yushulx Date: Tue, 27 Feb 2018 10:16:49 +0800 Subject: [PATCH 038/181] Add addon API test --- types/dwt/dwt-tests.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/dwt/dwt-tests.ts b/types/dwt/dwt-tests.ts index b1a5cc6b09..16a56f1cd2 100644 --- a/types/dwt/dwt-tests.ts +++ b/types/dwt/dwt-tests.ts @@ -99,3 +99,13 @@ function downloadImage() { DWObject.HTTPDownload("www.dynamsoft.com", "img.png", () => {}, (errorCode: number, errorString: string) => {}); } } + +function loadPDF() { + const DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer'); + if (DWObject) { + DWObject.Addon.PDF.SetResolution(200); + DWObject.Addon.PDF.SetConvertMode(1); + DWObject.IfShowFileDialog = true; + DWObject.LoadImageEx(" ", 5); + } +} From 9b593e264d25ac6351ce959bb06a4e5c1cdd613f Mon Sep 17 00:00:00 2001 From: Dennis George Date: Tue, 27 Feb 2018 13:43:11 -0600 Subject: [PATCH 039/181] updated for webpack 4.0 --- types/webpack/index.d.ts | 48 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index d6102808b6..06483792cd 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack 3.8 +// Type definitions for webpack 4.0 // Project: https://github.com/webpack/webpack // Definitions by: Qubo // Benjamin Lim @@ -35,6 +35,8 @@ declare function webpack(options: webpack.Configuration[]): webpack.MultiCompile declare namespace webpack { interface Configuration { + /** Specify which set of defaults to use. */ + mode?: "development" | "production"; /** Name of the configuration. Used when loading multiple configurations. */ name?: string; /** @@ -105,6 +107,9 @@ declare namespace webpack { performance?: Options.Performance; /** Limit the number of parallel processed modules. Can be used to fine tune performance or to get more reliable profiling results */ parallelism?: number; + + /** Optimization options */ + optimization?: Options.Optimization; } interface Entry { @@ -496,6 +501,47 @@ declare namespace webpack { } type Stats = Stats.ToStringOptions; type WatchOptions = ICompiler.WatchOptions; + + interface Optimization { + /** Modules are removed from chunks when they are already available in all parent chunk groups. + * This reduces asset size. Smaller assets also result in faster builds since less code generation has to be performed. */ + removeAvailableModules?: boolean; + /** Empty chunks are removed. This reduces load in filesystem and results in faster builds. */ + removeEmptyChunks?: boolean; + /** Equal chunks are merged. This results in less code generation and faster builds. */ + mergeDuplicateChunks?: boolean; + /** Chunks which are subsets of other chunks are determined and flagged in a way that subsets don’t have to be loaded when the bigger chunk has been loaded. */ + flagIncludedChunks?: boolean; + /** Give more often used ids smaller (shorter) values. */ + occurrenceOrder?: boolean; + /** Determine exports for each module when possible. This information is used by other optimizations or code generation. I. e. to generate more efficient code for export * from. */ + providedExports?: boolean; + /** Determine used exports for each module. This depends on optimization.providedExports. This information is used by other optimizations or code generation. + * I. e. exports are not generated for unused exports, export names are mangled to single char identifiers when all usages are compatible. DCE in minimizers will benefit from this and can remove unused exports. */ + usedExports?: boolean; + /** Recognise the sideEffects flag in package.json or rules to eliminate modules. This depends on optimization.providedExports and optimization.usedExports. + * These dependencies have a cost, but eliminating modules has positive impact on performance because of less code generation. It depends on your codebase. + * Try it for possible performance wins. */ + sideEffects?: boolean; + /** Tries to find segments of the module graph which can be safely concatenated into a single module. Depends on optimization.providedExports and optimization.usedExports. */ + concatenateModules?: boolean; + /** Finds modules which are shared between chunk and splits them into separate chunks to reduce duplication or separate vendor modules from application modules. */ + splitChunks?: boolean; + /** Create a separate chunk for the webpack runtime code and chunk manifest. This chunk should be inlined into the HTML */ + runtimeChunk?: boolean; + /** Don’t write output assets when compilation errors. */ + noEmitOnErrors?: boolean; + /** Instead of numeric ids, give modules useful names. */ + namedModules?: boolean; + /** Instead of numeric ids, give chunks useful names. */ + namedChunks?: boolean; + /** Defines the process.env.NODE_ENV constant to a compile-time-constant value. This allows to remove development only code from code. */ + nodeEnv?: boolean; + /** Use the minimizer (optimization.minimizer, by default uglify-js) to minimize output assets. */ + minimize?: boolean; + /** Identifiers used in records are relative to context directory. */ + portableRecords?: boolean; + } } // tslint:disable-next-line:interface-name From ee6770df50f6e893d2a47e3e41510378963893cc Mon Sep 17 00:00:00 2001 From: Dennis George Date: Tue, 27 Feb 2018 13:51:14 -0600 Subject: [PATCH 040/181] updated webpack 4.0 optimization options comments for linter --- types/webpack/index.d.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 06483792cd..fbc0d9f636 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -503,8 +503,10 @@ declare namespace webpack { type WatchOptions = ICompiler.WatchOptions; interface Optimization { - /** Modules are removed from chunks when they are already available in all parent chunk groups. - * This reduces asset size. Smaller assets also result in faster builds since less code generation has to be performed. */ + /** + * Modules are removed from chunks when they are already available in all parent chunk groups. + * This reduces asset size. Smaller assets also result in faster builds since less code generation has to be performed. + */ removeAvailableModules?: boolean; /** Empty chunks are removed. This reduces load in filesystem and results in faster builds. */ removeEmptyChunks?: boolean; @@ -516,12 +518,17 @@ declare namespace webpack { occurrenceOrder?: boolean; /** Determine exports for each module when possible. This information is used by other optimizations or code generation. I. e. to generate more efficient code for export * from. */ providedExports?: boolean; - /** Determine used exports for each module. This depends on optimization.providedExports. This information is used by other optimizations or code generation. - * I. e. exports are not generated for unused exports, export names are mangled to single char identifiers when all usages are compatible. DCE in minimizers will benefit from this and can remove unused exports. */ + /** + * Determine used exports for each module. This depends on optimization.providedExports. This information is used by other optimizations or code generation. + * I. e. exports are not generated for unused exports, export names are mangled to single char identifiers when all usages are compatible. + * DCE in minimizers will benefit from this and can remove unused exports. + */ usedExports?: boolean; - /** Recognise the sideEffects flag in package.json or rules to eliminate modules. This depends on optimization.providedExports and optimization.usedExports. + /** + * Recognise the sideEffects flag in package.json or rules to eliminate modules. This depends on optimization.providedExports and optimization.usedExports. * These dependencies have a cost, but eliminating modules has positive impact on performance because of less code generation. It depends on your codebase. - * Try it for possible performance wins. */ + * Try it for possible performance wins. + */ sideEffects?: boolean; /** Tries to find segments of the module graph which can be safely concatenated into a single module. Depends on optimization.providedExports and optimization.usedExports. */ concatenateModules?: boolean; From be525690a83492681ee6e28d45839ccffbfb82b4 Mon Sep 17 00:00:00 2001 From: Dennis George Date: Tue, 27 Feb 2018 14:18:59 -0600 Subject: [PATCH 041/181] updated for webpack 4.0 added optimization.minimizer option --- types/webpack/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index fbc0d9f636..f704797f58 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -546,6 +546,8 @@ declare namespace webpack { nodeEnv?: boolean; /** Use the minimizer (optimization.minimizer, by default uglify-js) to minimize output assets. */ minimize?: boolean; + /** Configure minimzers and options TODO: add type for this */ + minimizer?: any; /** Identifiers used in records are relative to context directory. */ portableRecords?: boolean; } From 76cfb34e13ca0edc556d3fc48096fbf4b79fe186 Mon Sep 17 00:00:00 2001 From: Dennis George Date: Tue, 27 Feb 2018 15:48:32 -0600 Subject: [PATCH 042/181] updated webpack to be 4.0 specific; added v3 subfolder for old version --- types/webpack/index.d.ts | 98 +-- types/webpack/v3/index.d.ts | 1301 +++++++++++++++++++++++++++++ types/webpack/v3/package.json | 6 + types/webpack/v3/tsconfig.json | 26 + types/webpack/v3/tslint.json | 3 + types/webpack/v3/webpack-tests.ts | 667 +++++++++++++++ 6 files changed, 2025 insertions(+), 76 deletions(-) create mode 100644 types/webpack/v3/index.d.ts create mode 100644 types/webpack/v3/package.json create mode 100644 types/webpack/v3/tsconfig.json create mode 100644 types/webpack/v3/tslint.json create mode 100644 types/webpack/v3/webpack-tests.ts diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index f704797f58..9b84ff7731 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -187,9 +187,13 @@ declare namespace webpack { sourcePrefix?: string; /** This option enables cross-origin loading of chunks. */ crossOriginLoading?: string | boolean; + /** A Constructor to a custom hash function. You can provide a non-crypto hash function for performance reasons */ + hashFunction?: (algorithm: string, options?: any) => any; + /** Allow to choose the global object reference in runtime exitCode. */ + globalObject?: any; } - interface BaseModule { + interface Module { /** A array of applied pre loaders. */ preLoaders?: Rule[]; /** A array of applied post loaders. */ @@ -208,18 +212,10 @@ declare namespace webpack { wrappedContextRecursive?: boolean; wrappedContextCritical?: boolean; strictExportPresence?: boolean; - } - interface OldModule extends BaseModule { - /** An array of automatically applied loaders. */ - loaders: Rule[]; - } - interface NewModule extends BaseModule { /** An array of rules applied for modules. */ rules: Rule[]; } - type Module = OldModule | NewModule; - interface Resolve { /** * A list of directories to resolve modules from. @@ -381,7 +377,10 @@ declare namespace webpack { options?: { [name: string]: any }; } type Loader = string | OldLoader | NewLoader; - + interface ParserOptions { + [optName: string]: any; + system?: boolean; + } /** * There are direct and delegate rules. Direct Rules need a test, Delegate rules delegate to subrules bringing their own. * Direct rules can optionally contain delegate keys (oneOf, rules). @@ -421,11 +420,17 @@ declare namespace webpack { * For each different parser options object a new parser is created and plugins can apply plugins depending on the parser options. * Many of the default plugins apply their parser plugins only if a property in the parser options is not set or true. */ - parser?: { [optName: string]: any }; + parser?: ParserOptions; /** An array of Rules that is also used when the Rule matches. */ rules?: Rule[]; /** An array of Rules from which only the first matching Rule is used when the Rule matches. */ oneOf?: Rule[]; + /** Configures module resolving. */ + resolve?: Resolve; + /** Configures the module type. */ + type?: "javascript/auto" | "javascript/esm" | "javascript/dynamic" | "json" | "webassembly/experimental"; + /** TODO: Update this when the v4 documentation is complete. */ + sideEffects?: any; } interface BaseDirectRule extends BaseRule { /** A condition that must be met */ @@ -884,6 +889,7 @@ declare namespace webpack { constructor(options: any); } + /** @deprecated use config.optimization.namedModules */ class NamedModulesPlugin extends Plugin { constructor(); } @@ -892,15 +898,12 @@ declare namespace webpack { constructor(nameResolver?: (chunk: any) => string | null); } + /** @deprecated use config.optimization.noEmitOnErrors */ class NoEmitOnErrorsPlugin extends Plugin { constructor(); } /** @deprecated use webpack.NoEmitOnErrorsPlugin */ - class NoErrorsPlugin extends Plugin { - constructor(); - } - class NormalModuleReplacementPlugin extends Plugin { constructor(resourceRegExp: any, newResource: any); } @@ -954,6 +957,7 @@ declare namespace webpack { } namespace optimize { + /** @deprecated use config.optimization.concatenateModules */ class ModuleConcatenationPlugin extends Plugin { } class AggressiveMergingPlugin extends Plugin { constructor(options?: AggressiveMergingPlugin.Options); @@ -980,62 +984,6 @@ declare namespace webpack { } } - class CommonsChunkPlugin extends Plugin { - constructor(options?: CommonsChunkPlugin.Options); - } - - namespace CommonsChunkPlugin { - type MinChunksFn = (module: any, count: number) => boolean; - - interface Options { - /** - * The chunk name of the commons chunk. An existing chunk can be selected by passing a name of an existing chunk. - * If an array of strings is passed this is equal to invoking the plugin multiple times for each chunk name. - * If omitted and `options.async` or `options.children` is set all chunks are used, - * otherwise `options.filename` is used as chunk name. - */ - name?: string; - names?: string[]; - - /** - * The filename template for the commons chunk. Can contain the same placeholders as `output.filename`. - * If omitted the original filename is not modified (usually `output.filename` or `output.chunkFilename`). - */ - filename?: string; - - /** - * The minimum number of chunks which need to contain a module before it's moved into the commons chunk. - * The number must be greater than or equal 2 and lower than or equal to the number of chunks. - * Passing `Infinity` just creates the commons chunk, but moves no modules into it. - * By providing a `function` you can add custom logic. (Defaults to the number of chunks) - */ - minChunks?: number | MinChunksFn; - - /** - * Select the source chunks by chunk names. The chunk must be a child of the commons chunk. - * If omitted all entry chunks are selected. - */ - chunks?: string[]; - - /** - * If `true` all children of the commons chunk are selected - */ - children?: boolean; - - /** - * If `true` a new async commons chunk is created as child of `options.name` and sibling of `options.chunks`. - * It is loaded in parallel with `options.chunks`. It is possible to change the name of the output file - * by providing the desired string instead of `true`. - */ - async?: boolean | string; - - /** - * Minimum size of all common module before a commons chunk is created. - */ - minSize?: number; - } - } - /** @deprecated */ class DedupePlugin extends Plugin { constructor(); @@ -1252,11 +1200,6 @@ declare namespace webpack { */ inputValue: any; - /** - * The options passed to the Compiler. - */ - options: any; - /** * A boolean flag. It is set when in debug mode. */ @@ -1311,6 +1254,9 @@ declare namespace webpack { * Hacky access to the Module object being loaded. */ _module: any; + + /** Flag if HMR is enabled */ + hot: boolean; } } diff --git a/types/webpack/v3/index.d.ts b/types/webpack/v3/index.d.ts new file mode 100644 index 0000000000..ee3a291d02 --- /dev/null +++ b/types/webpack/v3/index.d.ts @@ -0,0 +1,1301 @@ +// Type definitions for webpack 3.8 +// Project: https://github.com/webpack/webpack +// Definitions by: Qubo +// Benjamin Lim +// Boris Cherny +// Tommy Troy Lin +// Mohsen Azimi +// Jonathan Creamer +// Ahmed T. Ali +// Alan Agius +// Spencer Elliott +// Jason Cheatham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import Tapable = require('tapable'); +import * as UglifyJS from 'uglify-js'; +import { RawSourceMap } from 'source-map'; + +export = webpack; + +declare function webpack( + options: webpack.Configuration, + handler: webpack.Compiler.Handler +): webpack.Compiler.Watching | webpack.Compiler; +declare function webpack(options?: webpack.Configuration): webpack.Compiler; + +declare function webpack( + options: webpack.Configuration[], + handler: webpack.MultiCompiler.Handler +): webpack.MultiWatching | webpack.MultiCompiler; +declare function webpack(options: webpack.Configuration[]): webpack.MultiCompiler; + +declare namespace webpack { + interface Configuration { + /** Name of the configuration. Used when loading multiple configurations. */ + name?: string; + /** + * The base directory (absolute path!) for resolving the `entry` option. + * If `output.pathinfo` is set, the included pathinfo is shortened to this directory. + */ + context?: string; + entry?: string | string[] | Entry | EntryFunc; + /** Choose a style of source mapping to enhance the debugging process. These values can affect build and rebuild speed dramatically. */ + devtool?: Options.Devtool; + /** Options affecting the output. */ + output?: Output; + /** Options affecting the normal modules (NormalModuleFactory) */ + module?: Module; + /** Options affecting the resolving of modules. */ + resolve?: Resolve; + /** Like resolve but for loaders. */ + resolveLoader?: ResolveLoader; + /** + * Specify dependencies that shouldn’t be resolved by webpack, but should become dependencies of the resulting bundle. + * The kind of the dependency depends on output.libraryTarget. + */ + externals?: ExternalsElement | ExternalsElement[]; + /** + *
    + *
  • "web" Compile for usage in a browser-like environment (default)
  • + *
  • "webworker" Compile as WebWorker
  • + *
  • "node" Compile for usage in a node.js-like environment (use require to load chunks)
  • + *
  • "async-node" Compile for usage in a node.js-like environment (use fs and vm to load chunks async)
  • + *
  • "node-webkit" Compile for usage in webkit, uses jsonp chunk loading but also supports builtin node.js modules plus require(“nw.gui”) (experimental)
  • + *
  • "atom" Compile for usage in electron (formerly known as atom-shell), supports require for modules necessary to run Electron.
  • + *
  • "electron-renderer" Compile for Electron for renderer process, providing a target using JsonpTemplatePlugin, FunctionModulePlugin + * for browser environments and NodeTargetPlugin and ExternalsPlugin for CommonJS and Electron built-in modules.
  • + *
  • "electron-main" Compile for Electron for main process.
  • + *
  • "atom" Alias for electron-main
  • + *
  • "electron" Alias for electron-main
  • + *
      + */ + target?: 'web' | 'webworker' | 'node' | 'async-node' | 'node-webkit' | 'atom' | 'electron' | 'electron-renderer' | 'electron-main' | ((compiler?: any) => void); + /** Report the first error as a hard error instead of tolerating it. */ + bail?: boolean; + /** Capture timing information for each module. */ + profile?: boolean; + /** Cache generated modules and chunks to improve performance for multiple incremental builds. */ + cache?: boolean | object; + /** Enter watch mode, which rebuilds on file change. */ + watch?: boolean; + watchOptions?: Options.WatchOptions; + /** Switch loaders to debug mode. */ + debug?: boolean; + /** Can be used to configure the behaviour of webpack-dev-server when the webpack config is passed to webpack-dev-server CLI. */ + devServer?: any; // TODO: Type this + /** Include polyfills or mocks for various node stuff */ + node?: Node; + /** Set the value of require.amd and define.amd. */ + amd?: { [moduleName: string]: boolean }; + /** Used for recordsInputPath and recordsOutputPath */ + recordsPath?: string; + /** Load compiler state from a json file. */ + recordsInputPath?: string; + /** Store compiler state to a json file. */ + recordsOutputPath?: string; + /** Add additional plugins to the compiler. */ + plugins?: Plugin[]; + /** Stats options for logging */ + stats?: Options.Stats; + /** Performance options */ + performance?: Options.Performance; + /** Limit the number of parallel processed modules. Can be used to fine tune performance or to get more reliable profiling results */ + parallelism?: number; + } + + interface Entry { + [name: string]: string | string[]; + } + + type EntryFunc = () => (string | string[] | Promise); + + interface DevtoolModuleFilenameTemplateInfo { + identifier: string; + shortIdentifier: string; + resource: any; + resourcePath: string; + absoluteResourcePath: string; + allLoaders: any[]; + query: string; + moduleId: string; + hash: string; + } + + interface Output { + /** The output directory as absolute path (required). */ + path?: string; + /** The filename of the entry chunk as relative path inside the output.path directory. */ + filename?: string; + /** The filename of non-entry chunks as relative path inside the output.path directory. */ + chunkFilename?: string; + /** The filename of the SourceMaps for the JavaScript files. They are inside the output.path directory. */ + sourceMapFilename?: string; + /** Filename template string of function for the sources array in a generated SourceMap. */ + devtoolModuleFilenameTemplate?: string | ((info: DevtoolModuleFilenameTemplateInfo) => string); + /** Similar to output.devtoolModuleFilenameTemplate, but used in the case of duplicate module identifiers. */ + devtoolFallbackModuleFilenameTemplate?: string | ((info: DevtoolModuleFilenameTemplateInfo) => string); + /** + * Enable line to line mapped mode for all/specified modules. + * Line to line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source. + * It’s a performance optimization. Only use it if your performance need to be better and you are sure that input lines match which generated lines. + * true enables it for all modules (not recommended) + */ + devtoolLineToLine?: boolean; + /** The filename of the Hot Update Chunks. They are inside the output.path directory. */ + hotUpdateChunkFilename?: string; + /** The filename of the Hot Update Main File. It is inside the output.path directory. */ + hotUpdateMainFilename?: string; + /** The output.path from the view of the Javascript / HTML page. */ + publicPath?: string; + /** The JSONP function used by webpack for asnyc loading of chunks. */ + jsonpFunction?: string; + /** The JSONP function used by webpack for async loading of hot update chunks. */ + hotUpdateFunction?: string; + /** Include comments with information about the modules. */ + pathinfo?: boolean; + /** If set, export the bundle as library. output.library is the name. */ + library?: string | string[]; + /** + * Which format to export the library: + *
        + *
      • "var" - Export by setting a variable: var Library = xxx (default)
      • + *
      • "this" - Export by setting a property of this: this["Library"] = xxx
      • + *
      • "commonjs" - Export by setting a property of exports: exports["Library"] = xxx
      • + *
      • "commonjs2" - Export by setting module.exports: module.exports = xxx
      • + *
      • "amd" - Export to AMD (optionally named)
      • + *
      • "umd" - Export to AMD, CommonJS2 or as property in root
      • + *
      • "window" - Assign to widnow
      • + *
      • "assign" - Assign to a global variable
      • + *
      • "jsonp" - Generate Webpack JSONP module
      • + *
      + */ + libraryTarget?: 'var' | 'this' | 'commonjs' | 'commonjs2' | 'amd' | 'umd' | 'window' | 'assign' | 'jsonp'; + /** Configure which module or modules will be exposed via the `libraryTarget` */ + libraryExport?: string | string[]; + /** If output.libraryTarget is set to umd and output.library is set, setting this to true will name the AMD module. */ + umdNamedDefine?: boolean; + /** Prefixes every line of the source in the bundle with this string. */ + sourcePrefix?: string; + /** This option enables cross-origin loading of chunks. */ + crossOriginLoading?: string | boolean; + } + + interface BaseModule { + /** A array of applied pre loaders. */ + preLoaders?: Rule[]; + /** A array of applied post loaders. */ + postLoaders?: Rule[]; + /** A RegExp or an array of RegExps. Don’t parse files matching. */ + noParse?: RegExp | RegExp[] | ((content: string) => boolean); + unknownContextRequest?: string; + unknownContextRecursive?: boolean; + unknownContextRegExp?: RegExp; + unknownContextCritical?: boolean; + exprContextRequest?: string; + exprContextRegExp?: RegExp; + exprContextRecursive?: boolean; + exprContextCritical?: boolean; + wrappedContextRegExp?: RegExp; + wrappedContextRecursive?: boolean; + wrappedContextCritical?: boolean; + strictExportPresence?: boolean; + } + interface OldModule extends BaseModule { + /** An array of automatically applied loaders. */ + loaders: Rule[]; + } + interface NewModule extends BaseModule { + /** An array of rules applied for modules. */ + rules: Rule[]; + } + + type Module = OldModule | NewModule; + + interface Resolve { + /** + * A list of directories to resolve modules from. + * + * Absolute paths will be searched once. + * + * If an entry is relative, will be resolved using node's resolution algorithm + * relative to the requested file. + * + * Defaults to `["node_modules"]` + */ + modules?: string[]; + + /** + * A list of package description files to search for. + * + * Defaults to `["package.json"]` + */ + descriptionFiles?: string[]; + + /** + * A list of fields in a package description object to use for finding + * the entry point. + * + * Defaults to `["browser", "module", "main"]` or `["module", "main"]`, + * depending on the value of the `target` `Configuration` value. + */ + mainFields?: string[]; + + /** + * A list of fields in a package description object to try to parse + * in the same format as the `alias` resolve option. + * + * Defaults to `["browser"]` or `[]`, depending on the value of the + * `target` `Configuration` value. + * + * @see alias + */ + aliasFields?: string[]; + + /** + * A list of file names to search for when requiring directories that + * don't contain a package description file. + * + * Defaults to `["index"]`. + */ + mainFiles?: string[]; + + /** + * A list of file extensions to try when requesting files. + * + * An empty string is considered invalid. + */ + extensions?: string[]; + + /** + * If true, requires that all requested paths must use an extension + * from `extensions`. + */ + enforceExtension?: boolean; + + /** + * Replace the given module requests with other modules or paths. + * + * @see aliasFields + */ + alias?: { [key: string]: string; }; + + /** + * Whether to use a cache for resolving, or the specific object + * to use for caching. Sharing objects may be useful when running + * multiple webpack compilers. + * + * Defaults to `true`. + */ + unsafeCache?: {} | boolean; + + /** + * A function used to decide whether to cache the given resolve request. + * + * Defaults to `() => true`. + */ + cachePredicate?(data: { path: string, request: string }): boolean; + + /** + * A list of additional resolve plugins which should be applied. + */ + plugins?: ResolvePlugin[]; + + /** + * Whether to resolve symlinks to their symlinked location. + * + * Defaults to `true` + */ + symlinks?: boolean; + } + + interface ResolveLoader extends Resolve { + /** + * List of strings to append to a loader's name when trying to resolve it. + */ + moduleExtensions?: string[]; + + enforceModuleExtension?: boolean; + } + + type ExternalsElement = string | RegExp | ExternalsObjectElement | ExternalsFunctionElement; + + interface ExternalsObjectElement { + [key: string]: boolean | string; + } + + type ExternalsFunctionElement = (context: any, request: any, callback: (error: any, result: any) => void) => any; + + interface Node { + console?: boolean; + global?: boolean; + process?: boolean; + Buffer?: boolean; + __filename?: boolean | string; + __dirname?: boolean | string; + [nodeBuiltin: string]: boolean | string | undefined; + } + + interface BaseConditionSpec { + /** The Condition must match. The convention is the provide a string or array of strings here, but it's not enforced. */ + include?: Condition; + /** The Condition must NOT match. The convention is the provide a string or array of strings here, but it's not enforced. */ + exclude?: Condition; + } + interface TestConditionSpec extends BaseConditionSpec { + /** The Condition must match. The convention is the provide a RegExp or array of RegExps here, but it's not enforced. */ + test: Condition; + } + interface AndConditionSpec extends BaseConditionSpec { + /** All Conditions must match. */ + and: Condition[]; + } + interface OrConditionSpec extends BaseConditionSpec { + /** Any Condition must match. */ + or: Condition[]; + } + interface NotConditionSpec extends BaseConditionSpec { + /** The Condition must NOT match. */ + not: Condition; + } + type ConditionSpec = TestConditionSpec | OrConditionSpec | AndConditionSpec | NotConditionSpec; + + // tslint:disable-next-line:no-empty-interface + interface ConditionArray extends Array { } + type Condition = string | RegExp | ((absPath: string) => boolean) | ConditionSpec | ConditionArray; + + interface OldLoader { + loader: string; + query?: { [name: string]: any }; + } + interface NewLoader { + loader: string; + options?: { [name: string]: any }; + } + type Loader = string | OldLoader | NewLoader; + + /** + * There are direct and delegate rules. Direct Rules need a test, Delegate rules delegate to subrules bringing their own. + * Direct rules can optionally contain delegate keys (oneOf, rules). + * + * These types exist to enforce that a rule has the keys `((loader XOR loaders) AND test) OR oneOf OR rules` + */ + interface BaseRule { + /** + * Specifies the category of the loader. No value means normal loader. + * + * There is also an additional category "inlined loader" which are loaders applied inline of the import/require. + * + * All loaders are sorted in the order post, inline, normal, pre and used in this order. + * + * All normal loaders can be omitted (overridden) by prefixing ! in the request. + * + * All normal and pre loaders can be omitted (overridden) by prefixing -! in the request. + * + * All normal, post and pre loaders can be omitted (overridden) by prefixing !! in the request. + * + * Inline loaders and ! prefixes should not be used as they are non-standard. They may be use by loader generated code. + */ + enforce?: 'pre' | 'post'; + /** A condition that must be met */ + test?: Condition | Condition[]; + /** A condition that must not be met */ + exclude?: Condition | Condition[]; + /** A condition that must be met */ + include?: Condition | Condition[]; + /** A Condition matched with the resource. */ + resource?: Condition | Condition[]; + /** A condition matched with the issuer */ + issuer?: Condition | Condition[]; + /** + * An object with parser options. All applied parser options are merged. + * + * For each different parser options object a new parser is created and plugins can apply plugins depending on the parser options. + * Many of the default plugins apply their parser plugins only if a property in the parser options is not set or true. + */ + parser?: { [optName: string]: any }; + /** An array of Rules that is also used when the Rule matches. */ + rules?: Rule[]; + /** An array of Rules from which only the first matching Rule is used when the Rule matches. */ + oneOf?: Rule[]; + } + interface BaseDirectRule extends BaseRule { + /** A condition that must be met */ + test: Condition | Condition[]; + } + // Direct Rules + interface BaseSingleLoaderRule extends BaseDirectRule { + /** Loader name or an object with name and options */ + loader: Loader; + } + interface OldLoaderRule extends BaseSingleLoaderRule { + /** + * Loader options + * @deprecated: + */ + query?: { [name: string]: any }; + } + interface NewLoaderRule extends BaseSingleLoaderRule { + options?: { [name: string]: any }; + } + type LoaderRule = OldLoaderRule | NewLoaderRule; + interface OldUseRule extends BaseDirectRule { + /** + * A array of loaders. + * @deprecated use `use` instead + */ + loaders: string[]; + } + interface NewUseRule extends BaseDirectRule { + /** A loader or array of loaders */ + use: Loader | Loader[]; + } + type UseRule = OldUseRule | NewUseRule; + + // Delegate Rules + interface RulesRule extends BaseRule { + /** An array of Rules that is also used when the Rule matches. */ + rules: Rule[]; + } + interface OneOfRule extends BaseRule { + oneOf: Rule[]; + } + type Rule = LoaderRule | UseRule | RulesRule | OneOfRule; + + namespace Options { + // tslint:disable-next-line:max-line-length + type Devtool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' | 'cheap-module-eval-source-map' | 'cheap-module-source-map' | 'eval-source-map' | 'source-map' | + 'nosources-source-map' | 'hidden-source-map' | 'nosources-source-map' | '@eval' | '@inline-source-map' | '@cheap-eval-source-map' | '@cheap-source-map' | '@cheap-module-eval-source-map' | + '@cheap-module-source-map' | '@eval-source-map' | '@source-map' | '@nosources-source-map' | '@hidden-source-map' | '@nosources-source-map' | '#eval' | '#inline-source-map' | + '#cheap-eval-source-map' | '#cheap-source-map' | '#cheap-module-eval-source-map' | '#cheap-module-source-map' | '#eval-source-map' | '#source-map' | '#nosources-source-map' | + '#hidden-source-map' | '#nosources-source-map' | '#@eval' | '#@inline-source-map' | '#@cheap-eval-source-map' | '#@cheap-source-map' | '#@cheap-module-eval-source-map' | + '#@cheap-module-source-map' | '#@eval-source-map' | '#@source-map' | '#@nosources-source-map' | '#@hidden-source-map' | '#@nosources-source-map' | boolean; + + interface Performance { + /** This property allows webpack to control what files are used to calculate performance hints. */ + assetFilter?(assetFilename: string): boolean; + /** + * Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are + * found. This property is set to "warning" by default. + */ + hints?: 'warning' | 'error' | false; + /** + * An asset is any emitted file from webpack. This option controls when webpack emits a performance hint + * based on individual asset size. The default value is 250000 (bytes). + */ + maxAssetSize?: number; + /** + * An entrypoint represents all assets that would be utilized during initial load time for a specific entry. + * This option controls when webpack should emit performance hints based on the maximum entrypoint size. + * The default value is 250000 (bytes). + */ + maxEntrypointSize?: number; + } + type Stats = Stats.ToStringOptions; + type WatchOptions = ICompiler.WatchOptions; + } + + // tslint:disable-next-line:interface-name + interface ICompiler { + run(handler: ICompiler.Handler): void; + watch(watchOptions: ICompiler.WatchOptions, handler: ICompiler.Handler): Watching; + } + + namespace ICompiler { + type Handler = (err: Error, stats: Stats) => void; + + interface WatchOptions { + /** + * Add a delay before rebuilding once the first file changed. This allows webpack to aggregate any other + * changes made during this time period into one rebuild. + * Pass a value in milliseconds. Default: 300. + */ + aggregateTimeout?: number; + /** + * For some systems, watching many file systems can result in a lot of CPU or memory usage. + * It is possible to exclude a huge folder like node_modules. + * It is also possible to use anymatch patterns. + */ + ignored?: string | string[] | RegExp; + /** Turn on polling by passing true, or specifying a poll interval in milliseconds. */ + poll?: boolean | number; + } + } + + interface Watching { + close(callback: () => void): void; + invalidate(): void; + } + + class Compiler extends Tapable implements ICompiler { + constructor(); + + name: string; + options: Configuration; + outputFileSystem: any; + run(handler: Compiler.Handler): void; + watch(watchOptions: Compiler.WatchOptions, handler: Compiler.Handler): Compiler.Watching; + } + + namespace Compiler { + type Handler = ICompiler.Handler; + type WatchOptions = ICompiler.WatchOptions; + + class Watching implements Watching { + constructor(compiler: Compiler, watchOptions: Watching.WatchOptions, handler: Watching.Handler); + + close(callback: () => void): void; + invalidate(): void; + } + + namespace Watching { + type WatchOptions = ICompiler.WatchOptions; + type Handler = ICompiler.Handler; + } + } + + abstract class MultiCompiler extends Tapable implements ICompiler { + compilers: ICompiler[]; + run(handler: MultiCompiler.Handler): void; + watch(watchOptions: MultiCompiler.WatchOptions, handler: MultiCompiler.Handler): MultiWatching; + } + + namespace MultiCompiler { + type Handler = ICompiler.Handler; + type WatchOptions = ICompiler.WatchOptions; + } + + abstract class MultiWatching implements Watching { + close(callback: () => void): void; + invalidate(): void; + } + + abstract class Plugin implements Tapable.Plugin { + apply(compiler: Compiler): void; + } + + abstract class ResolvePlugin implements Tapable.Plugin { + apply(resolver: any /* EnhancedResolve.Resolver */): void; + } + + abstract class Stats { + /** Returns true if there were errors while compiling. */ + hasErrors(): boolean; + /** Returns true if there were warnings while compiling. */ + hasWarnings(): boolean; + /** Returns compilation information as a JSON object. */ + toJson(options?: Stats.ToJsonOptions): any; + /** Returns a formatted string of the compilation information (similar to CLI output). */ + toString(options?: Stats.ToStringOptions): string; + } + + namespace Stats { + type Preset + = boolean + | 'errors-only' + | 'minimal' + | 'none' + | 'normal' + | 'verbose'; + + interface ToJsonOptionsObject { + /** Add asset Information */ + assets?: boolean; + /** Sort assets by a field */ + assetsSort?: string; + /** Add information about cached (not built) modules */ + cached?: boolean; + /** Show cached assets (setting this to `false` only shows emitted files) */ + cachedAssets?: boolean; + /** Add children information */ + children?: boolean; + /** Add built modules information to chunk information */ + chunkModules?: boolean; + /** Add the origins of chunks and chunk merging info */ + chunkOrigins?: boolean; + /** Add chunk information (setting this to `false` allows for a less verbose output) */ + chunks?: boolean; + /** Sort the chunks by a field */ + chunksSort?: string; + /** Context directory for request shortening */ + context?: string; + /** Display the distance from the entry point for each module */ + depth?: boolean; + /** Display the entry points with the corresponding bundles */ + entrypoints?: boolean; + /** Add --env information */ + env?: boolean; + /** Add errors */ + errors?: boolean; + /** Add details to errors (like resolving log) */ + errorDetails?: boolean; + /** Exclude assets from being displayed in stats */ + excludeAssets?: StatsExcludeFilter; + /** Exclude modules from being displayed in stats */ + excludeModules?: StatsExcludeFilter; + /** See excludeModules */ + exclude?: StatsExcludeFilter; + /** Add the hash of the compilation */ + hash?: boolean; + /** Set the maximum number of modules to be shown */ + maxModules?: number; + /** Add built modules information */ + modules?: boolean; + /** Sort the modules by a field */ + modulesSort?: string; + /** Show dependencies and origin of warnings/errors */ + moduleTrace?: boolean; + /** Add public path information */ + publicPath?: boolean; + /** Add information about the reasons why modules are included */ + reasons?: boolean; + /** Add the source code of modules */ + source?: boolean; + /** Add timing information */ + timings?: boolean; + /** Add webpack version information */ + version?: boolean; + /** Add warnings */ + warnings?: boolean; + /** Show which exports of a module are used */ + usedExports?: boolean; + /** Filter warnings to be shown */ + warningsFilter?: string | RegExp | Array | ((warning: string) => boolean); + /** Show performance hint when file size exceeds `performance.maxAssetSize` */ + performance?: boolean; + /** Show the exports of the modules */ + providedExports?: boolean; + } + + type ToJsonOptions = Preset | ToJsonOptionsObject; + + type StatsExcludeFilter = string | string[] | RegExp | RegExp[] | ((assetName: string) => boolean) | Array<(assetName: string) => boolean>; + + interface ToStringOptionsObject extends ToJsonOptionsObject { + /** `webpack --colors` equivalent */ + colors?: boolean; + } + + type ToStringOptions = Preset | ToStringOptionsObject; + } + + /** + * Plugins + */ + + class BannerPlugin extends Plugin { + constructor(options: string | BannerPlugin.Options); + } + + namespace BannerPlugin { + type Filter = string | RegExp; + + interface Options { + banner: string; + entryOnly?: boolean; + exclude?: Filter | Filter[]; + include?: Filter | Filter[]; + raw?: boolean; + test?: Filter | Filter[]; + } + } + + class ContextReplacementPlugin extends Plugin { + constructor(resourceRegExp: any, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any); + } + + class DefinePlugin extends Plugin { + constructor(definitions: { [key: string]: any }); + } + + class DllPlugin extends Plugin { + constructor(options: DllPlugin.Options | DllPlugin.Options[]); + } + + namespace DllPlugin { + interface Options { + /** + * The context of requests in the manifest file. + * + * Defaults to the webpack context. + */ + context?: string; + + /** + * The name of the exposed DLL function (keep consistent with `output.library`). + */ + name: string; + + /** + * The absolute path to the manifest json file (output). + */ + path: string; + } + } + + class DllReferencePlugin extends Plugin { + constructor(options: DllReferencePlugin.Options); + } + + namespace DllReferencePlugin { + interface Options { + /** + * The mappings from the request to module ID. + * + * Defaults to `manifest.content`. + */ + content?: any; + + /** + * The context of requests in the manifest (or content property). + * + * This is an absolute path. + */ + context: string; + + /** + * An object containing `content` and `name`. + */ + manifest: { content: string, name: string } | string; + + /** + * The name where the DLL is exposed. + * + * Defaults to `manifest.name`. + * + * See also `externals`. + */ + name?: string; + + /** + * The prefix which is used for accessing the content of the DLL. + */ + scope?: string; + + /** + * The type how the DLL is exposed. + * + * Defaults to `"var"`. + * + * See also `externals`. + */ + sourceType?: string; + } + } + + class EvalSourceMapDevToolPlugin extends Plugin { + constructor(options?: false | string | EvalSourceMapDevToolPlugin.Options); + } + + namespace EvalSourceMapDevToolPlugin { + interface Options { + append?: false | string; + columns?: boolean; + lineToLine?: boolean | { + exclude?: Condition | Condition[]; + include?: Condition | Condition[]; + test?: Condition | Condition[]; + }; + module?: boolean; + moduleFilenameTemplate?: string; + sourceRoot?: string; + } + } + + class ExtendedAPIPlugin extends Plugin { + constructor(); + } + + class HashedModuleIdsPlugin extends Plugin { + constructor(options?: { + hashFunction?: string, + hashDigest?: string, + hashDigestLength?: number + }); + } + + class HotModuleReplacementPlugin extends Plugin { + constructor(options?: any); + } + + class IgnorePlugin extends Plugin { + constructor(requestRegExp: any, contextRegExp?: any); + } + + class LoaderOptionsPlugin extends Plugin { + constructor(options: any); + } + + class NamedModulesPlugin extends Plugin { + constructor(); + } + + class NamedChunksPlugin extends Plugin { + constructor(nameResolver?: (chunk: any) => string | null); + } + + class NoEmitOnErrorsPlugin extends Plugin { + constructor(); + } + + /** @deprecated use webpack.NoEmitOnErrorsPlugin */ + class NoErrorsPlugin extends Plugin { + constructor(); + } + + class NormalModuleReplacementPlugin extends Plugin { + constructor(resourceRegExp: any, newResource: any); + } + + class PrefetchPlugin extends Plugin { + // tslint:disable-next-line:unified-signatures + constructor(context: any, request: any); + constructor(request: any); + } + + class ProgressPlugin extends Plugin { + constructor(options?: (percentage: number, msg: string, moduleProgress?: string, activeModules?: string, moduleName?: string) => void); + } + + class EnvironmentPlugin extends Plugin { + constructor(envs: string[] | { [key: string]: any }); + } + + class ProvidePlugin extends Plugin { + constructor(definitions: { [key: string]: any }); + } + + class SourceMapDevToolPlugin extends Plugin { + constructor(options?: null | false | string | SourceMapDevToolPlugin.Options); + } + + namespace SourceMapDevToolPlugin { + /** @todo extend EvalSourceMapDevToolPlugin.Options */ + interface Options { + append?: false | string; + columns?: boolean; + exclude?: Condition | Condition[]; + fallbackModuleFilenameTemplate?: string; + filename?: null | false | string; + include?: Condition | Condition[]; + lineToLine?: boolean | { + exclude?: Condition | Condition[]; + include?: Condition | Condition[]; + test?: Condition | Condition[]; + }; + module?: boolean; + moduleFilenameTemplate?: string; + noSources?: boolean; + sourceRoot?: null | string; + test?: Condition | Condition[]; + } + } + + class WatchIgnorePlugin extends Plugin { + constructor(paths: Array); + } + + namespace optimize { + class ModuleConcatenationPlugin extends Plugin { } + class AggressiveMergingPlugin extends Plugin { + constructor(options?: AggressiveMergingPlugin.Options); + } + + namespace AggressiveMergingPlugin { + interface Options { + /** + * When options.moveToParents is set, moving to an entry chunk is more expensive. + * Defaults to 10, which means moving to an entry chunk is ten times more expensive than moving to a + * normal chunk. + */ + entryChunkMultiplicator?: number; + /** + * A factor which defines the minimum required size reduction for chunk merging. + * Defaults to 1.5 which means that the total size needs to be reduced by 50% for chunk merging. + */ + minSizeReduce?: number; + /** + * When set, modules that are not in both merged chunks are moved to all parents of the chunk. + * Defaults to false. + */ + moveToParents?: boolean; + } + } + + class CommonsChunkPlugin extends Plugin { + constructor(options?: CommonsChunkPlugin.Options); + } + + namespace CommonsChunkPlugin { + type MinChunksFn = (module: any, count: number) => boolean; + + interface Options { + /** + * The chunk name of the commons chunk. An existing chunk can be selected by passing a name of an existing chunk. + * If an array of strings is passed this is equal to invoking the plugin multiple times for each chunk name. + * If omitted and `options.async` or `options.children` is set all chunks are used, + * otherwise `options.filename` is used as chunk name. + */ + name?: string; + names?: string[]; + + /** + * The filename template for the commons chunk. Can contain the same placeholders as `output.filename`. + * If omitted the original filename is not modified (usually `output.filename` or `output.chunkFilename`). + */ + filename?: string; + + /** + * The minimum number of chunks which need to contain a module before it's moved into the commons chunk. + * The number must be greater than or equal 2 and lower than or equal to the number of chunks. + * Passing `Infinity` just creates the commons chunk, but moves no modules into it. + * By providing a `function` you can add custom logic. (Defaults to the number of chunks) + */ + minChunks?: number | MinChunksFn; + + /** + * Select the source chunks by chunk names. The chunk must be a child of the commons chunk. + * If omitted all entry chunks are selected. + */ + chunks?: string[]; + + /** + * If `true` all children of the commons chunk are selected + */ + children?: boolean; + + /** + * If `true` a new async commons chunk is created as child of `options.name` and sibling of `options.chunks`. + * It is loaded in parallel with `options.chunks`. It is possible to change the name of the output file + * by providing the desired string instead of `true`. + */ + async?: boolean | string; + + /** + * Minimum size of all common module before a commons chunk is created. + */ + minSize?: number; + } + } + + /** @deprecated */ + class DedupePlugin extends Plugin { + constructor(); + } + + class LimitChunkCountPlugin extends Plugin { + constructor(options: any); + } + + class MinChunkSizePlugin extends Plugin { + constructor(options: any); + } + + class OccurrenceOrderPlugin extends Plugin { + constructor(preferEntry: boolean); + } + + class UglifyJsPlugin extends Plugin { + constructor(options?: UglifyJsPlugin.Options); + } + + namespace UglifyJsPlugin { + type CommentFilter = (astNode: any, comment: any) => boolean; + + interface Options extends UglifyJS.MinifyOptions { + beautify?: boolean; + comments?: boolean | RegExp | CommentFilter; + exclude?: Condition | Condition[]; + include?: Condition | Condition[]; + /** Parallelization can speedup your build significantly and is therefore highly recommended. */ + parallel?: boolean | { cache: boolean, workers: boolean | number }; + sourceMap?: boolean; + test?: Condition | Condition[]; + } + } + } + + namespace dependencies { + } + + namespace loader { + interface Loader extends Function { + (this: LoaderContext, source: string | Buffer, sourceMap?: RawSourceMap): string | Buffer | void | undefined; + + /** + * The order of chained loaders are always called from right to left. + * But, in some cases, loaders do not care about the results of the previous loader or the resource. + * They only care for metadata. The pitch method on the loaders is called from left to right before the loaders are called (from right to left). + * If a loader delivers a result in the pitch method the process turns around and skips the remaining loaders, + * continuing with the calls to the more left loaders. data can be passed between pitch and normal call. + */ + pitch?(remainingRequest: string, precedingRequest: string, data: any): any; + + /** + * By default, the resource file is treated as utf-8 string and passed as String to the loader. + * By setting raw to true the loader is passed the raw Buffer. + * Every loader is allowed to deliver its result as String or as Buffer. + * The compiler converts them between loaders. + */ + raw?: boolean; + } + + type loaderCallback = (err: Error | undefined | null, content?: string | Buffer, sourceMap?: RawSourceMap) => void; + + interface LoaderContext { + /** + * Loader API version. Currently 2. + * This is useful for providing backwards compatibility. + * Using the version you can specify custom logic or fallbacks for breaking changes. + */ + version: string; + + /** + * The directory of the module. Can be used as context for resolving other stuff. + * In the example: /abc because resource.js is in this directory + */ + context: string; + + /** + * The resolved request string. + * In the example: "/abc/loader1.js?xyz!/abc/node_modules/loader2/index.js!/abc/resource.js?rrr" + */ + request: string; + + /** + * A string or any object. The query of the request for the current loader. + */ + query: any; + + /** + * A data object shared between the pitch and the normal phase. + */ + data?: any; + + callback: loaderCallback; + + /** + * Make this loader async. + */ + async(): loaderCallback | undefined; + + /** + * Make this loader result cacheable. By default it's not cacheable. + * A cacheable loader must have a deterministic result, when inputs and dependencies haven't changed. + * This means the loader shouldn't have other dependencies than specified with this.addDependency. + * Most loaders are deterministic and cacheable. + */ + cacheable(flag?: boolean): void; + + /** + * loaders = [{request: string, path: string, query: string, module: function}] + * An array of all the loaders. It is writeable in the pitch phase. + * In the example: + * [ + * { request: "/abc/loader1.js?xyz", + * path: "/abc/loader1.js", + * query: "?xyz", + * module: [Function] + * }, + * { request: "/abc/node_modules/loader2/index.js", + * path: "/abc/node_modules/loader2/index.js", + * query: "", + * module: [Function] + * } + * ] + */ + loaders: any[]; + + /** + * The index in the loaders array of the current loader. + * In the example: in loader1: 0, in loader2: 1 + */ + loaderIndex: number; + + /** + * The resource part of the request, including query. + * In the example: "/abc/resource.js?rrr" + */ + resource: string; + + /** + * The resource file. + * In the example: "/abc/resource.js" + */ + resourcePath: string; + + /** + * The query of the resource. + * In the example: "?rrr" + */ + resourceQuery: string; + + /** + * Emit a warning. + */ + emitWarning(message: string | Error): void; + + /** + * Emit a error. + */ + emitError(message: string | Error): void; + + /** + * Execute some code fragment like a module. + * + * Don't use require(this.resourcePath), use this function to make loaders chainable! + * + */ + exec(code: string, filename: string): any; + + /** + * Resolve a request like a require expression. + */ + resolve(context: string, request: string, callback: (err: Error, result: string) => void): any; + + /** + * Resolve a request like a require expression. + */ + resolveSync(context: string, request: string): string; + + /** + * Adds a file as dependency of the loader result in order to make them watchable. + * For example, html-loader uses this technique as it finds src and src-set attributes. + * Then, it sets the url's for those attributes as dependencies of the html file that is parsed. + */ + addDependency(file: string): void; + + /** + * Adds a file as dependency of the loader result in order to make them watchable. + * For example, html-loader uses this technique as it finds src and src-set attributes. + * Then, it sets the url's for those attributes as dependencies of the html file that is parsed. + */ + dependency(file: string): void; + + /** + * Add a directory as dependency of the loader result. + */ + addContextDependency(directory: string): void; + + /** + * Remove all dependencies of the loader result. Even initial dependencies and these of other loaders. Consider using pitch. + */ + clearDependencies(): void; + + /** + * Pass values to the next loader. + * If you know what your result exports if executed as module, set this value here (as a only element array). + */ + value: any; + + /** + * Passed from the last loader. + * If you would execute the input argument as module, consider reading this variable for a shortcut (for performance). + */ + inputValue: any; + + /** + * The options passed to the Compiler. + */ + options: any; + + /** + * A boolean flag. It is set when in debug mode. + */ + debug: boolean; + + /** + * Should the result be minimized. + */ + minimize: boolean; + + /** + * Should a SourceMap be generated. + */ + sourceMap: boolean; + + /** + * Target of compilation. Passed from configuration options. + * Example values: "web", "node" + */ + target: 'web' | 'webworker' | 'async-node' | 'node' | 'electron-main' | 'electron-renderer' | 'node-webkit' | string; + + /** + * This boolean is set to true when this is compiled by webpack. + * + * Loaders were originally designed to also work as Babel transforms. + * Therefore if you write a loader that works for both, you can use this property to know if + * there is access to additional loaderContext and webpack features. + */ + webpack: boolean; + + /** + * Emit a file. This is webpack-specific. + */ + emitFile(name: string, content: Buffer | string, sourceMap: any): void; + + /** + * Access to the compilation's inputFileSystem property. + */ + fs: any; + + /** + * Hacky access to the Compilation object of webpack. + */ + _compilation: any; + + /** + * Hacky access to the Compiler object of webpack. + */ + _compiler: Compiler; + + /** + * Hacky access to the Module object being loaded. + */ + _module: any; + } + } + + /** @deprecated */ + namespace compiler { + /** @deprecated use webpack.Compiler */ + // tslint:disable-next-line:no-unnecessary-qualifier + type Compiler = webpack.Compiler; + + /** @deprecated use webpack.Compiler.Watching */ + type Watching = Compiler.Watching; + + /** @deprecated use webpack.Compiler.WatchOptions */ + + type WatchOptions = Compiler.WatchOptions; + + /** @deprecated use webpack.Stats */ + // tslint:disable-next-line:no-unnecessary-qualifier + type Stats = webpack.Stats; + + /** @deprecated use webpack.Stats.ToJsonOptions */ + type StatsOptions = Stats.ToJsonOptions; + + /** @deprecated use webpack.Stats.ToStringOptions */ + type StatsToStringOptions = Stats.ToStringOptions; + + /** @deprecated use webpack.Compiler.Handler */ + type CompilerCallback = Compiler.Handler; + } + + /** @deprecated use webpack.Options.Performance */ + type PerformanceOptions = Options.Performance; + /** @deprecated use webpack.Options.WatchOptions */ + type WatchOptions = Options.WatchOptions; + /** @deprecated use webpack.EvalSourceMapDevToolPlugin.Options */ + type EvalSourceMapDevToolPluginOptions = EvalSourceMapDevToolPlugin.Options; + /** @deprecated use webpack.SourceMapDevToolPlugin.Options */ + type SourceMapDevToolPluginOptions = SourceMapDevToolPlugin.Options; + /** @deprecated use webpack.optimize.UglifyJsPlugin.CommentFilter */ + type UglifyCommentFunction = optimize.UglifyJsPlugin.CommentFilter; + /** @deprecated use webpack.optimize.UglifyJsPlugin.Options */ + type UglifyPluginOptions = optimize.UglifyJsPlugin.Options; +} \ No newline at end of file diff --git a/types/webpack/v3/package.json b/types/webpack/v3/package.json new file mode 100644 index 0000000000..59c231c54c --- /dev/null +++ b/types/webpack/v3/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "source-map": "^0.6.0" + } +} diff --git a/types/webpack/v3/tsconfig.json b/types/webpack/v3/tsconfig.json new file mode 100644 index 0000000000..a6671e38b4 --- /dev/null +++ b/types/webpack/v3/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "webpack": ["webpack/v3"] + } + }, + "files": [ + "index.d.ts", + "webpack-tests.ts" + ] +} \ No newline at end of file diff --git a/types/webpack/v3/tslint.json b/types/webpack/v3/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/webpack/v3/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/webpack/v3/webpack-tests.ts b/types/webpack/v3/webpack-tests.ts new file mode 100644 index 0000000000..f56dbb84b6 --- /dev/null +++ b/types/webpack/v3/webpack-tests.ts @@ -0,0 +1,667 @@ +import webpack = require('webpack'); +import { RawSourceMap } from 'source-map'; + +const { + optimize, +} = webpack; + +let plugins: webpack.Plugin[]; + +/** + * Plugins + */ + +/** + * optimize + */ + +const { + AggressiveMergingPlugin, +} = optimize; + +plugins = [ + new AggressiveMergingPlugin(), + new AggressiveMergingPlugin({}), + new AggressiveMergingPlugin({ + entryChunkMultiplicator: 10, + minSizeReduce: 1.5, + moveToParents: false, + }), +]; + +let configuration: webpack.Configuration; +let rule: webpack.Rule; +let plugin: webpack.Plugin; +declare const __dirname: string; + +// +// https://webpack.github.io/docs/using-loaders.html +// + +configuration = { + module: { + loaders: [ + { test: /\.jade$/, loader: "jade" }, + // => "jade" loader is used for ".jade" files + + { test: /\.css$/, loader: "style!css" }, + // => "style" and "css" loader is used for ".css" files + // Alternative syntax: + { test: /\.css$/, loaders: ["style", "css"] }, + ] + } +}; + +rule = { test: /\.png$/, loader: "url-loader?mimetype=image/png" }; + +rule = { + test: /\.png$/, + loader: "url-loader", + query: { mimetype: "image/png" } +}; + +// +// http://webpack.github.io/docs/tutorials/getting-started/ +// + +configuration = { + entry: "./entry.js", + output: { + path: __dirname, + filename: "bundle.js" + }, + module: { + loaders: [ + { test: /\.css$/, loader: "style!css" } + ] + } +}; + +// +// https://webpack.js.org/configuration/entry-context/#dynamic-entry +// + +configuration = { + entry: () => './demo' +}; + +configuration = { + entry: () => ['./demo', './demo2'] +}; + +configuration = { + entry: () => new Promise((resolve) => resolve('./demo')) +}; + +configuration = { + entry: () => new Promise((resolve) => resolve(['./demo', './demo2'])) +}; + +// +// https://webpack.github.io/docs/code-splitting.html +// + +configuration = { + entry: { + app: "./app.js", + vendor: ["jquery", "underscore"], + }, + output: { + filename: "bundle.js" + }, + plugins: [ + new webpack.optimize.CommonsChunkPlugin({ + name: "vendor", + filename: "vendor.bundle.js", + }), + ] +}; + +configuration = { + entry: { a: "./a", b: "./b" }, + output: { filename: "[name].js" }, + plugins: [new webpack.optimize.CommonsChunkPlugin({ name: "init.js" })] +}; + +// +// https://webpack.github.io/docs/stylesheets.html +// + +configuration = { + // ... + module: { + loaders: [ + { test: /\.css$/, loader: "style-loader!css-loader" } + ] + } +}; + +// +// https://webpack.github.io/docs/optimization.html +// + +configuration = { + entry: { + p1: "./page1", + p2: "./page2", + p3: "./page3" + }, + output: { + filename: "[name].entry.chunk.js" + } +}; + +const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin; +configuration = { + entry: { + p1: "./page1", + p2: "./page2", + p3: "./page3" + }, + output: { + filename: "[name].entry.chunk.js" + }, + plugins: [ + new CommonsChunkPlugin({ name: "commons.chunk.js" }) + ] +}; + +configuration = { + entry: { + p1: "./page1", + p2: "./page2", + p3: "./page3", + ap1: "./admin/page1", + ap2: "./admin/page2" + }, + output: { + filename: "[name].js" + }, +}; +//