diff --git a/types/amqplib/index.d.ts b/types/amqplib/index.d.ts index a6e5aec204..45b5e6e3ca 100644 --- a/types/amqplib/index.d.ts +++ b/types/amqplib/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/squaremo/amqp.node // Definitions by: Michael Nahkies , Ab Reitsma , Nicolás Fantone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index d77c18fa37..fbcce34e81 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -367,8 +367,7 @@ namespace TestQ { let result: angular.IPromise; result = $q.resolve(tResult); result = $q.resolve(promiseTResult); - result = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); - result = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); + let result2: angular.IPromise = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); } // $q.when @@ -378,7 +377,8 @@ namespace TestQ { } { let result: angular.IPromise; - let resultOther: angular.IPromise; + let other: angular.IPromise; + let resultOther: angular.IPromise; result = $q.when(tResult); result = $q.when(promiseTResult); @@ -388,20 +388,21 @@ namespace TestQ { result = $q.when(tValue, (result: TValue) => tResult, (any) => any, (any) => any); result = $q.when(promiseTValue, (result: TValue) => tResult); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (any) => any); result = $q.when(tValue, (result: TValue) => promiseTResult); result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any); result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any, (any) => any); result = $q.when(promiseTValue, (result: TValue) => promiseTResult); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any); } } @@ -547,7 +548,7 @@ namespace TestPromise { assertPromiseType(promise.then((result) => result, (any) => any, (any) => any)); assertPromiseType(promise.then((result) => result, (any) => reject, (any) => any)); - assertPromiseType(promise.then((result) => anyOf2(reject, result))); + assertPromiseType | TResult>(promise.then((result) => anyOf2(reject, result))); assertPromiseType(promise.then((result) => anyOf3(result, tresultPromise, reject))); assertPromiseType(promise.then( (result) => anyOf3(reject, result, tresultPromise), @@ -557,7 +558,7 @@ namespace TestPromise { assertPromiseType>(promise.then((result) => tresultHttpPromise)); assertPromiseType(promise.then((result) => result, (any) => tother)); - assertPromiseType(promise.then( + assertPromiseType | angular.IPromise | TOther | angular.IPromise>(promise.then( (result) => anyOf3(reject, result, totherPromise), (reason) => anyOf3(reject, tother, tresultPromise) )); @@ -588,7 +589,7 @@ namespace TestPromise { assertPromiseType(promise.catch((err) => err)); assertPromiseType(promise.catch((err) => any)); assertPromiseType(promise.catch((err) => tresult)); - assertPromiseType(promise.catch((err) => anyOf2(tresult, reject))); + assertPromiseType>(promise.catch((err) => anyOf2(tresult, reject))); assertPromiseType(promise.catch((err) => anyOf3(tresult, tresultPromise, reject))); assertPromiseType(promise.catch((err) => tresultPromise)); assertPromiseType>(promise.catch((err) => tresultHttpPromise)); diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index d0e2d978dc..727f1cdd7c 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1049,6 +1049,10 @@ declare namespace angular { * @param value Value or a promise */ resolve(value: IPromise|T): IPromise; + /** + * @deprecated Since TS 2.4, inference is stricter and no longer produces the desired type when T1 !== T2. + * To use resolve with two different types, pass a union type to the single-type-argument overload. + */ resolve(value: IPromise|T2): IPromise; /** * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. @@ -1846,6 +1850,10 @@ declare namespace angular { * different in Angular 1 there is no direct mapping and care should be taken when upgrading. */ $postLink?(): void; + + // IController implementations frequently do not implement any of its methods. + // A string indexer indicates to TypeScript not to issue a weak type error in this case. + [s: string]: any; } /** diff --git a/types/anydb-sql-migrations/index.d.ts b/types/anydb-sql-migrations/index.d.ts index 5db740c70f..ae922c37ae 100644 --- a/types/anydb-sql-migrations/index.d.ts +++ b/types/anydb-sql-migrations/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/spion/anydb-sql-migrations // Definitions by: Gorgi Kosev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import Promise = require('bluebird'); import { Column, Table, Transaction, AnydbSql } from 'anydb-sql'; diff --git a/types/asana/index.d.ts b/types/asana/index.d.ts index 364980b66c..ede3bc99f9 100644 --- a/types/asana/index.d.ts +++ b/types/asana/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Asana/node-asana // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index a8a6242bb4..0e810f8ae5 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/auth0/node-auth0 // Definitions by: Wilson Hobbs , Seth Westphal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as Promise from 'bluebird'; diff --git a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts index 0a4052b147..cc525509c6 100644 --- a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts +++ b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts @@ -1,24 +1,24 @@ -import "./index" -namespace BMapTests { - export class TestFixture { - //document: http://lbsyun.baidu.com/index.php?title=jspopular - public createMap(container: string | HTMLElement) { - navigator.geolocation.getCurrentPosition((position: Position) => { - let point = new BMap.Point(position.coords.longitude, position.coords.latitude); - let map = new BMap.Map(container); - map.centerAndZoom(point, 15); - }, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); - } - public addControl(map: BMap.Map) { - map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT })); - map.addControl(new BMap.NavigationControl()); - map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] })); - map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); - } - public addMarker(map: BMap.Map, point: BMap.Point) { - var marker = new BMap.Marker(point); - map.addOverlay(marker); - marker.setAnimation(BMAP_ANIMATION_BOUNCE); - } - } -} +import "./index" +namespace BMapTests { + export class TestFixture { + //document: http://lbsyun.baidu.com/index.php?title=jspopular + public createMap(container: string | HTMLElement) { + navigator.geolocation.getCurrentPosition((position: Position) => { + let point = new BMap.Point(position.coords.longitude, position.coords.latitude); + let map = new BMap.Map(container); + map.centerAndZoom(point, 15); + }, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); + } + public addControl(map: BMap.Map) { + map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT })); + map.addControl(new BMap.NavigationControl()); + map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] })); + map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); + } + public addMarker(map: BMap.Map, point: BMap.Point) { + var marker = new BMap.Marker(point); + map.addOverlay(marker); + marker.setAnimation(BMAP_ANIMATION_BOUNCE); + } + } +} diff --git a/types/baidumap-web-sdk/baidumap.base.d.ts b/types/baidumap-web-sdk/baidumap.base.d.ts index 4bea8ad872..9dc07a9377 100644 --- a/types/baidumap-web-sdk/baidumap.base.d.ts +++ b/types/baidumap-web-sdk/baidumap.base.d.ts @@ -1,56 +1,56 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -declare namespace BMap { - class Point { - constructor (lng: number, lat: number) - lng: number - lat: number - equals(other: Point): boolean - } - class Pixel { - constructor (x: number, y: number) - x: number - y: number - equals(other: Pixel): boolean - } - class Size { - constructor (width: number, height: number) - width: number - height: number - equals(other: Size): boolean - } - class Bounds { - constructor (minX: number, minY: number, maxX: number, maxY: number) - constructor (sw: Point, ne: Point) - minX: number - minY: number - maxX: number - maxY: number - equals(other: Bounds): boolean - containsPoint(point: Point): boolean - containsBounds(bounds: Bounds): boolean - intersects(other: Bounds): boolean - extend(point: Point): void - getCenter(): Point - isEmpty(): boolean - getSouthWest(): Point - getNorthEast(): Point - toSpan(): Point - } +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +declare namespace BMap { + class Point { + constructor (lng: number, lat: number) + lng: number + lat: number + equals(other: Point): boolean + } + class Pixel { + constructor (x: number, y: number) + x: number + y: number + equals(other: Pixel): boolean + } + class Size { + constructor (width: number, height: number) + width: number + height: number + equals(other: Size): boolean + } + class Bounds { + constructor (minX: number, minY: number, maxX: number, maxY: number) + constructor (sw: Point, ne: Point) + minX: number + minY: number + maxX: number + maxY: number + equals(other: Bounds): boolean + containsPoint(point: Point): boolean + containsBounds(bounds: Bounds): boolean + intersects(other: Bounds): boolean + extend(point: Point): void + getCenter(): Point + isEmpty(): boolean + getSouthWest(): Point + getNorthEast(): Point + toSpan(): Point + } } \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.control.d.ts b/types/baidumap-web-sdk/baidumap.control.d.ts index 2eb4344dc9..6e3fb771be 100644 --- a/types/baidumap-web-sdk/baidumap.control.d.ts +++ b/types/baidumap-web-sdk/baidumap.control.d.ts @@ -1,132 +1,132 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - class Control { - constructor() - defaultAnchor: ControlAnchor - defaultOffset: Size - initialize(map: Map): HTMLElement - setAnchor(anchor: ControlAnchor): void - getAnchor(): ControlAnchor - setOffset(offset: Size): void - getOffset(): Size - show(): void - hide(): void - isVisible(): boolean - } - interface NavigationControlOptions { - anchor?: ControlAnchor - offset?: Size - type?: NavigationControlType - showZoomInfo?: boolean - enableGeolocation?: boolean - } - interface ScaleControlOptions { - anchor?: ControlAnchor - offset?: Size - } - interface CopyrightControlOptions { - anchor?: ControlAnchor - offset?: Size - } - type ControlAnchor = number - class OverviewMapControl extends Control { - constructor(opts: OverviewMapControlOptions) - changeView(): void - setSize(size: Size): void - getSize(): Size - onviewchanged: (event: { type: string, target: any, isOpen: boolean }) => void - onviewchanging: (event: { type: string, target: any }) => void - } - type LengthUnit = string - class MapTypeControl extends Control { - constructor(opts?: MapTypeControlOptions) - } - class NavigationControl extends Control { - constructor(opts?: NavigationControlOptions) - getType(): NavigationControlOptions - setType(type: NavigationControlType): void - } - interface OverviewMapControlOptions { - anchor?: ControlAnchor - offset?: Size - size?: Size - isOpen?: boolean - } - class CopyrightControl extends Control { - constructor(opts?: CopyrightControlOptions) - addCopyright(copyright: Copyright): void - removeCopyright(id: number): void - getCopyright(id: number): Copyright - getCopyrightCollection(): Copyright[] - } - interface MapTypeControlOptions { - type?: MapTypeControlType, - mapTypes?: MapType[] - } - type NavigationControlType = number - class ScaleControl extends Control { - constructor(opts?: ScaleControlOptions) - getUnit(): LengthUnit - setUnit(unit: LengthUnit): void - } - interface Copyright { - id?: number - content?: string - bounds?: Bounds - } - type MapTypeControlType = number - class GeolocationControl extends Control { - constructor(opts?: GeolocationControlOptions) - } - interface GeolocationControlOptions { - anchor?: ControlAnchor - offset?: Size - showAddressBar?: boolean - enableAutoLocation?: boolean - locationIcon?: Icon - } - type StatusCode = number - class PanoramaControl extends Control { - constructor() - } -} -declare const BMAP_UNIT_METRIC: BMap.LengthUnit -declare const BMAP_UNIT_IMPERIAL: BMap.LengthUnit - -declare const BMAP_ANCHOR_TOP_LEFT: BMap.ControlAnchor -declare const BMAP_ANCHOR_TOP_RIGHT: BMap.ControlAnchor -declare const BMAP_ANCHOR_BOTTOM_LEFT: BMap.ControlAnchor -declare const BMAP_ANCHOR_BOTTOM_RIGHT: BMap.ControlAnchor - -declare const BMAP_NAVIGATION_CONTROL_LARGE: BMap.NavigationControlType -declare const BMAP_NAVIGATION_CONTROL_SMALL: BMap.NavigationControlType -declare const BMAP_NAVIGATION_CONTROL_PAN: BMap.NavigationControlType -declare const BMAP_NAVIGATION_CONTROL_ZOOM: BMap.NavigationControlType - -declare const BMAP_MAPTYPE_CONTROL_HORIZONTAL: BMap.MapTypeControlType -declare const BMAP_MAPTYPE_CONTROL_DROPDOWN: BMap.MapTypeControlType -declare const BMAP_MAPTYPE_CONTROL_MAP: BMap.MapTypeControlType - -declare const BMAP_STATUS_PERMISSION_DENIED: BMap.StatusCode -declare const BMAP_STATUS_SERVICE_UNAVAILABLE: BMap.StatusCode +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + class Control { + constructor() + defaultAnchor: ControlAnchor + defaultOffset: Size + initialize(map: Map): HTMLElement + setAnchor(anchor: ControlAnchor): void + getAnchor(): ControlAnchor + setOffset(offset: Size): void + getOffset(): Size + show(): void + hide(): void + isVisible(): boolean + } + interface NavigationControlOptions { + anchor?: ControlAnchor + offset?: Size + type?: NavigationControlType + showZoomInfo?: boolean + enableGeolocation?: boolean + } + interface ScaleControlOptions { + anchor?: ControlAnchor + offset?: Size + } + interface CopyrightControlOptions { + anchor?: ControlAnchor + offset?: Size + } + type ControlAnchor = number + class OverviewMapControl extends Control { + constructor(opts: OverviewMapControlOptions) + changeView(): void + setSize(size: Size): void + getSize(): Size + onviewchanged: (event: { type: string, target: any, isOpen: boolean }) => void + onviewchanging: (event: { type: string, target: any }) => void + } + type LengthUnit = string + class MapTypeControl extends Control { + constructor(opts?: MapTypeControlOptions) + } + class NavigationControl extends Control { + constructor(opts?: NavigationControlOptions) + getType(): NavigationControlOptions + setType(type: NavigationControlType): void + } + interface OverviewMapControlOptions { + anchor?: ControlAnchor + offset?: Size + size?: Size + isOpen?: boolean + } + class CopyrightControl extends Control { + constructor(opts?: CopyrightControlOptions) + addCopyright(copyright: Copyright): void + removeCopyright(id: number): void + getCopyright(id: number): Copyright + getCopyrightCollection(): Copyright[] + } + interface MapTypeControlOptions { + type?: MapTypeControlType, + mapTypes?: MapType[] + } + type NavigationControlType = number + class ScaleControl extends Control { + constructor(opts?: ScaleControlOptions) + getUnit(): LengthUnit + setUnit(unit: LengthUnit): void + } + interface Copyright { + id?: number + content?: string + bounds?: Bounds + } + type MapTypeControlType = number + class GeolocationControl extends Control { + constructor(opts?: GeolocationControlOptions) + } + interface GeolocationControlOptions { + anchor?: ControlAnchor + offset?: Size + showAddressBar?: boolean + enableAutoLocation?: boolean + locationIcon?: Icon + } + type StatusCode = number + class PanoramaControl extends Control { + constructor() + } +} +declare const BMAP_UNIT_METRIC: BMap.LengthUnit +declare const BMAP_UNIT_IMPERIAL: BMap.LengthUnit + +declare const BMAP_ANCHOR_TOP_LEFT: BMap.ControlAnchor +declare const BMAP_ANCHOR_TOP_RIGHT: BMap.ControlAnchor +declare const BMAP_ANCHOR_BOTTOM_LEFT: BMap.ControlAnchor +declare const BMAP_ANCHOR_BOTTOM_RIGHT: BMap.ControlAnchor + +declare const BMAP_NAVIGATION_CONTROL_LARGE: BMap.NavigationControlType +declare const BMAP_NAVIGATION_CONTROL_SMALL: BMap.NavigationControlType +declare const BMAP_NAVIGATION_CONTROL_PAN: BMap.NavigationControlType +declare const BMAP_NAVIGATION_CONTROL_ZOOM: BMap.NavigationControlType + +declare const BMAP_MAPTYPE_CONTROL_HORIZONTAL: BMap.MapTypeControlType +declare const BMAP_MAPTYPE_CONTROL_DROPDOWN: BMap.MapTypeControlType +declare const BMAP_MAPTYPE_CONTROL_MAP: BMap.MapTypeControlType + +declare const BMAP_STATUS_PERMISSION_DENIED: BMap.StatusCode +declare const BMAP_STATUS_SERVICE_UNAVAILABLE: BMap.StatusCode declare const BMAP_STATUS_TIMEOUT: BMap.StatusCode \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.core.d.ts b/types/baidumap-web-sdk/baidumap.core.d.ts index f736013589..24d1aed9f0 100644 --- a/types/baidumap-web-sdk/baidumap.core.d.ts +++ b/types/baidumap-web-sdk/baidumap.core.d.ts @@ -1,154 +1,154 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - class Map { - constructor(container: string | HTMLElement, opts?: MapOptions) - enableDragging(): void - disableDragging(): void - enableScrollWheelZoom(): void - disableScrollWheelZoom(): void - enableDoubleClickZoom(): void - disableDoubleClickZoom(): void - enableKeyboard(): void - disableKeyboard(): void - enableInertialDragging(): void - disableInertialDragging(): void - enableContinuousZoom(): void - disableContinuousZoom(): void - enablePinchToZoom(): void - disablePinchToZoom(): void - enableAutoResize(): void - disableAutoResize(): void - setDefaultCursor(cursor: string): void - getDefaultCursor(): string - setDraggingCursor(cursor: string): void - getDraggingCursor(): string - setMinZoom(zoom: number): void - setMaxZoom(zoom: number): void - setMapStyle(mapStyle: MapStyle): void - setPanorama(pano: Panorama): void - disable3DBuilding(): void - getBounds(): Bounds - getCenter(): Point - getDistance(start: Point, end: Point): number - getMapType(): MapType - getSize(): Size - getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport - getZoom(): number - getPanorama(): Panorama - centerAndZoom(center: Point, zoom: number): void - panTo(center: Point, opts?: PanOptions): void - panBy(x: number, y: number, opts?: PanOptions): void - reset(): void - setCenter(center: Point | string): void - setCurrentCity(city: string): void - setMapType(mapType: MapType): void - setViewport(view: Point[], viewportOptions?: ViewportOptions): void - setZoom(zoom: number): void - highResolutionEnabled(): boolean - zoomIn(): void - zoomOut(): void - addHotspot(hotspot: Hotspot): void - removeHotspot(hotspot: Hotspot): void - clearHotspots(): void - addControl(control: Control): void - removeControl(control: Control): void - getContainer(): HTMLElement - addContextMenu(menu: ContextMenu): void - removeContextMenu(menu: ContextMenu): void - addOverlay(overlay: Overlay): void - removeOverlay(overlay: Overlay): void - clearOverlays(): void - openInfoWindow(infoWnd: InfoWindow, point: Point): void - closeInfoWindow(): void - pointToOverlayPixel(point: Point): Pixel - overlayPixelToPoint(pixel: Pixel): Point - getInfoWindow(): InfoWindow - getOverlays(): Overlay[] - getPanes(): MapPanes - addTileLayer(tileLayer: TileLayer): void - removeTileLayer(tilelayer: TileLayer): void - getTileLayer(mapType: string): TileLayer - pixelToPoint(pixel: Pixel): Point - pointToPixel(point: Point): Pixel - onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onmaptypechange: (event: { type: string, target: any }) => void - onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onmouseover: (event: { type: string, target: any }) => void - onmouseout: (event: { type: string, target: any }) => void - onmovestart: (event: { type: string, target: any }) => void - onmoving: (event: { type: string, target: any }) => void - onmoveend: (event: { type: string, target: any }) => void - onzoomstart: (event: { type: string, target: any }) => void - onzoomend: (event: { type: string, target: any }) => void - onaddoverlay: (event: { type: string, target: any }) => void - onaddcontrol: (event: { type: string, target: any }) => void - onremovecontrol: (event: { type: string, target: any }) => void - onremoveoverlay: (event: { type: string, target: any }) => void - onclearoverlays: (event: { type: string, target: any }) => void - ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onaddtilelayer: (event: { type: string, target: any }) => void - onremovetilelayer: (event: { type: string, target: any }) => void - onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void - onresize: (event: { type: string, target: any, size: Size }) => void - onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void - onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void - onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void - ontilesloaded: (event: { type: string, target: any }) => void - ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - } - interface PanOptions { - noAnimation?: boolean - } - interface MapOptions { - minZoom?: number - maxZoom?: number - mapType?: MapType - enableHighResolution?: boolean - enableAutoResize?: boolean - enableMapClick?: boolean - } - interface Viewport { - center: Point - zoom: number - } - interface ViewportOptions { - enableAnimation?: boolean - margins?: number[] - zoomFactor?: number - delay?: number - } - type APIVersion = number - interface MapStyle { - features: any[] - style: string - } -} +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + class Map { + constructor(container: string | HTMLElement, opts?: MapOptions) + enableDragging(): void + disableDragging(): void + enableScrollWheelZoom(): void + disableScrollWheelZoom(): void + enableDoubleClickZoom(): void + disableDoubleClickZoom(): void + enableKeyboard(): void + disableKeyboard(): void + enableInertialDragging(): void + disableInertialDragging(): void + enableContinuousZoom(): void + disableContinuousZoom(): void + enablePinchToZoom(): void + disablePinchToZoom(): void + enableAutoResize(): void + disableAutoResize(): void + setDefaultCursor(cursor: string): void + getDefaultCursor(): string + setDraggingCursor(cursor: string): void + getDraggingCursor(): string + setMinZoom(zoom: number): void + setMaxZoom(zoom: number): void + setMapStyle(mapStyle: MapStyle): void + setPanorama(pano: Panorama): void + disable3DBuilding(): void + getBounds(): Bounds + getCenter(): Point + getDistance(start: Point, end: Point): number + getMapType(): MapType + getSize(): Size + getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport + getZoom(): number + getPanorama(): Panorama + centerAndZoom(center: Point, zoom: number): void + panTo(center: Point, opts?: PanOptions): void + panBy(x: number, y: number, opts?: PanOptions): void + reset(): void + setCenter(center: Point | string): void + setCurrentCity(city: string): void + setMapType(mapType: MapType): void + setViewport(view: Point[], viewportOptions?: ViewportOptions): void + setZoom(zoom: number): void + highResolutionEnabled(): boolean + zoomIn(): void + zoomOut(): void + addHotspot(hotspot: Hotspot): void + removeHotspot(hotspot: Hotspot): void + clearHotspots(): void + addControl(control: Control): void + removeControl(control: Control): void + getContainer(): HTMLElement + addContextMenu(menu: ContextMenu): void + removeContextMenu(menu: ContextMenu): void + addOverlay(overlay: Overlay): void + removeOverlay(overlay: Overlay): void + clearOverlays(): void + openInfoWindow(infoWnd: InfoWindow, point: Point): void + closeInfoWindow(): void + pointToOverlayPixel(point: Point): Pixel + overlayPixelToPoint(pixel: Pixel): Point + getInfoWindow(): InfoWindow + getOverlays(): Overlay[] + getPanes(): MapPanes + addTileLayer(tileLayer: TileLayer): void + removeTileLayer(tilelayer: TileLayer): void + getTileLayer(mapType: string): TileLayer + pixelToPoint(pixel: Pixel): Point + pointToPixel(point: Point): Pixel + onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onmaptypechange: (event: { type: string, target: any }) => void + onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onmouseover: (event: { type: string, target: any }) => void + onmouseout: (event: { type: string, target: any }) => void + onmovestart: (event: { type: string, target: any }) => void + onmoving: (event: { type: string, target: any }) => void + onmoveend: (event: { type: string, target: any }) => void + onzoomstart: (event: { type: string, target: any }) => void + onzoomend: (event: { type: string, target: any }) => void + onaddoverlay: (event: { type: string, target: any }) => void + onaddcontrol: (event: { type: string, target: any }) => void + onremovecontrol: (event: { type: string, target: any }) => void + onremoveoverlay: (event: { type: string, target: any }) => void + onclearoverlays: (event: { type: string, target: any }) => void + ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onaddtilelayer: (event: { type: string, target: any }) => void + onremovetilelayer: (event: { type: string, target: any }) => void + onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void + onresize: (event: { type: string, target: any, size: Size }) => void + onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void + onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void + onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void + ontilesloaded: (event: { type: string, target: any }) => void + ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + } + interface PanOptions { + noAnimation?: boolean + } + interface MapOptions { + minZoom?: number + maxZoom?: number + mapType?: MapType + enableHighResolution?: boolean + enableAutoResize?: boolean + enableMapClick?: boolean + } + interface Viewport { + center: Point + zoom: number + } + interface ViewportOptions { + enableAnimation?: boolean + margins?: number[] + zoomFactor?: number + delay?: number + } + type APIVersion = number + interface MapStyle { + features: any[] + style: string + } +} declare const BMAP_API_VERSION: BMap.APIVersion \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.maplayer.d.ts b/types/baidumap-web-sdk/baidumap.maplayer.d.ts index 4ed2230bfb..244fff0c7b 100644 --- a/types/baidumap-web-sdk/baidumap.maplayer.d.ts +++ b/types/baidumap-web-sdk/baidumap.maplayer.d.ts @@ -1,82 +1,82 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class TileLayer { - constructor(opts?: TileLayerOptions) - getTilesUrl(tileCoord: Pixel, zoom: number): string - getCopyright(): Copyright - isTransparentPng(): boolean - } - interface TileLayerOptions { - transparentPng?: boolean - tileUrlTemplate?: string - copyright?: Copyright - zIndex?: number - } - class TrafficLayer extends TileLayer { - constructor(opts?: TrafficLayerOptions) - } - interface TrafficLayerOptions { - predictDate?: PredictDate - } - interface PredictDate { - weekday: number - hour: number - } - class CustomLayer extends TileLayer { - constructor(opts: CustomLayerOptions) - onhotspotclick: (event: { type: string, target: any, content: any }) => void - } - interface Custompoi { - poiId: string - databoxId: string - title: string - address: string - phoneNumber: string - postcode: string - provinceCode: number - province: string - cityCode: number - city: string - districtCode: number - district: string - point: Point - tags: string[] - typeId: number - extendedData: any - } - class PanoramaCoverageLayer extends TileLayer { - constructor() - } - interface CustomLayerOptions { - databoxId?: string - geotableId?: string - q?: string - tags?: string - filter?: string - pointDensityType?: PointDensityType - } - type PointDensityType = number -} - -declare const BMAP_POINT_DENSITY_HIGH: BMap.PointDensityType -declare const BMAP_POINT_DENSITY_MEDIUM: BMap.PointDensityType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class TileLayer { + constructor(opts?: TileLayerOptions) + getTilesUrl(tileCoord: Pixel, zoom: number): string + getCopyright(): Copyright + isTransparentPng(): boolean + } + interface TileLayerOptions { + transparentPng?: boolean + tileUrlTemplate?: string + copyright?: Copyright + zIndex?: number + } + class TrafficLayer extends TileLayer { + constructor(opts?: TrafficLayerOptions) + } + interface TrafficLayerOptions { + predictDate?: PredictDate + } + interface PredictDate { + weekday: number + hour: number + } + class CustomLayer extends TileLayer { + constructor(opts: CustomLayerOptions) + onhotspotclick: (event: { type: string, target: any, content: any }) => void + } + interface Custompoi { + poiId: string + databoxId: string + title: string + address: string + phoneNumber: string + postcode: string + provinceCode: number + province: string + cityCode: number + city: string + districtCode: number + district: string + point: Point + tags: string[] + typeId: number + extendedData: any + } + class PanoramaCoverageLayer extends TileLayer { + constructor() + } + interface CustomLayerOptions { + databoxId?: string + geotableId?: string + q?: string + tags?: string + filter?: string + pointDensityType?: PointDensityType + } + type PointDensityType = number +} + +declare const BMAP_POINT_DENSITY_HIGH: BMap.PointDensityType +declare const BMAP_POINT_DENSITY_MEDIUM: BMap.PointDensityType declare const BMAP_POINT_DENSITY_LOW: BMap.PointDensityType \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.maptype.d.ts b/types/baidumap-web-sdk/baidumap.maptype.d.ts index 804b200cb1..01056212bc 100644 --- a/types/baidumap-web-sdk/baidumap.maptype.d.ts +++ b/types/baidumap-web-sdk/baidumap.maptype.d.ts @@ -1,51 +1,51 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class MapType { - constructor(name: string, layers: TileLayer | TileLayer[], opts?: MapTypeOptions) - getName(): string - getTileLayer(): TileLayer - getMinZoom(): number - getMaxZoom(): number - getProjection(): Projection - getTextColor(): string - getTips(): string - } - interface MapTypeOptions { - minZoom?: number - maxZoom?: number - errorImageUrl?: string - textColor?: number - tips?: string - } - interface Projection { - lngLatToPoint(lngLat: Point): Pixel - pointToLngLat(point: Pixel): Point - } - interface MercatorProjection extends Projection { - } - interface PerspectiveProjection extends Projection { - } -} -declare const BMAP_NORMAL_MAP: BMap.MapType -declare const BMAP_PERSPECTIVE_MAP: BMap.MapType -declare const BMAP_SATELLITE_MAP: BMap.MapType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class MapType { + constructor(name: string, layers: TileLayer | TileLayer[], opts?: MapTypeOptions) + getName(): string + getTileLayer(): TileLayer + getMinZoom(): number + getMaxZoom(): number + getProjection(): Projection + getTextColor(): string + getTips(): string + } + interface MapTypeOptions { + minZoom?: number + maxZoom?: number + errorImageUrl?: string + textColor?: number + tips?: string + } + interface Projection { + lngLatToPoint(lngLat: Point): Pixel + pointToLngLat(point: Pixel): Point + } + interface MercatorProjection extends Projection { + } + interface PerspectiveProjection extends Projection { + } +} +declare const BMAP_NORMAL_MAP: BMap.MapType +declare const BMAP_PERSPECTIVE_MAP: BMap.MapType +declare const BMAP_SATELLITE_MAP: BMap.MapType declare const BMAP_HYBRID_MAP: BMap.MapType \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.overlay.d.ts b/types/baidumap-web-sdk/baidumap.overlay.d.ts index 295c30ff8a..d723ac5e48 100644 --- a/types/baidumap-web-sdk/baidumap.overlay.d.ts +++ b/types/baidumap-web-sdk/baidumap.overlay.d.ts @@ -1,438 +1,438 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - interface Overlay { - initialize?(map: Map): HTMLElement - isVisible?(): boolean - draw?(): void - show?(): void - hide?(): void - } - type SymbolShapeType = number - interface PolylineOptions { - strokeColor?: string - strokeWeight?: number - strokeOpacity?: number - strokeStyle?: string - enableMassClear?: boolean - enableEditing?: boolean - enableClicking?: boolean - } - interface GroundOverlayOptions { - opacity?: number - imageURL?: string - displayOnMinLevel?: number - displayOnMaxLevel?: number - } - class Marker implements Overlay { - constructor(point: Point, opts?: MarkerOptions) - openInfoWindow(infoWnd: InfoWindow): void - closeInfoWindow(): void - setIcon(icon: Icon): void - getIcon(): Icon - setPosition(position: Point): void - getPosition(): Point - setOffset(offset: Size): void - getOffset(): Size - setLabel(label: Label): void - getLabel(): Label - setTitle(title: string): void - getTitle(): string - setTop(isTop: boolean): void - enableDragging(): void - disableDragging(): void - enableMassClear(): void - disableMassClear(): void - setZIndex(zIndex: number): void - getMap(): Map - addContextMenu(menu: ContextMenu): void - removeContextMenu(menu: ContextMenu): void - setAnimation(animation?: Animation): void - setRotation(rotation: number): void - getRotation(): number - setShadow(shadow: Icon): void - getShadow(): void - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - oninfowindowclose: (event: { type: string, target: any }) => void - oninfowindowopen: (event: { type: string, target: any }) => void - ondragstart: (event: { type: string, target: any }) => void - ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onrightclick: (event: { type: string, target: any }) => void - } - interface SymbolOptions { - anchor?: Size - fillColor?: string - fillOpacity?: number - scale?: number - rotation?: number - strokeColor?: string - strokeOpacity?: number - strokeWeight?: number - } - class IconSequence { - constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean) - } - class PointCollection implements Overlay { - constructor(points: Point[], opts?: PointCollectionOption) - setPoints(points: Point[]): void - setStyles(styles: PointCollectionOption): void - clear(): void - onclick: (event: { type: string, target: any, point: Point }) => void - onmouseover: (event: { type: string, target: any, point: Point }) => void - onmouseout: (event: { type: string, target: any, point: Point }) => void - } - interface MarkerOptions { - offset?: Size - icon?: Icon - enableMassClear?: boolean - enableDragging?: boolean - enableClicking?: boolean - raiseOnDrag?: boolean - draggingCursor?: string - rotation?: number - shadow?: Icon - title?: string - } - class InfoWindow implements Overlay { - constructor(content: string | HTMLElement, opts?: InfoWindowOptions) - setWidth(width: number): void - setHeight(height: number): void - redraw(): void - setTitle(title: string | HTMLElement): void - getTitle(): string | HTMLElement - setContent(content: string | HTMLElement): void - getContent(): string | HTMLElement - getPosition(): Point - enableMaximize(): void - disableMaximize(): void - isOpen(): boolean - setMaxContent(content: string): void - maximize(): void - restore(): void - enableAutoPan(): void - disableAutoPan(): void - enableCloseOnClick(): void - disableCloseOnClick(): void - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclose: (event: { type: string, target: any, point: Point }) => void - onopen: (event: { type: string, target: any, point: Point }) => void - onmaximize: (event: { type: string, target: any }) => void - onrestore: (event: { type: string, target: any }) => void - onclickclose: (event: { type: string, target: any }) => void - } - class Polygon implements Overlay { - constructor(points: Array, opts?: PolygonOptions) - setPath(path: Point[]): void - getPath(): Point[] - setStrokeColor(color: string): void - getStrokeColor(): string - setFillColor(color: string): void - getFillColor(): string - setStrokeOpacity(opacity: number): void - getStrokeOpacity(): number - setFillOpacity(opacity: number): void - getFillOpacity(): number - setStrokeWeight(weight: number): void - getStrokeWeight(): number - setStrokeStyle(style: string): void - getStrokeStyle(): string - getBounds(): Bounds - enableEditing(): void - disableEditing(): void - enableMassClear(): void - disableMassClear(): void - setPointAt(index: number, point: Point): void - setPositionAt(index: number, point: Point): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - onlineupdate: (event: { type: string, target: any }) => void - } - interface PointCollectionOption { - shape?: ShapeType - color?: string - size?: SizeType - } - type Animation = number - interface InfoWindowOptions { - width?: number - height?: number - maxWidth?: number - offset?: Size - title?: string - enableAutoPan?: boolean - enableCloseOnClick?: boolean - enableMessage?: boolean - message?: string - } - interface PolygonOptions { - strokeColor?: string - fillColor?: string - strokeWeight?: number - strokeOpacity?: number - fillOpacity?: number - strokeStyle?: number - enableMassClear?: boolean - enableEditing?: boolean - enableClicking?: boolean - } - type ShapeType = number - class Icon implements Overlay { - constructor(url: string, size: Size, opts?: IconOptions) - anchor: Size - size: Size - imageOffset: Size - imageSize: Size - imageUrl: Size - infoWindowAnchor: Size - printImageUrl: string - setImageUrl(imageUrl: string): void - setSize(size: Size): void - setImageSize(offset: Size): void - setAnchor(anchor: Size): void - setImageOffset(offset: Size): void - setInfoWindowAnchor(anchor: Size): void - setPrintImageUrl(url: string): void - } - class Label implements Overlay { - constructor(content: string, opts?: LabelOptions) - setStyle(styles: Object): void - setContent(content: string): void - setPosition(position: Point): void - getPosition(): Point - setOffset(offset: Size): void - getOffset(): Size - setTitle(title: string): void - getTitle(): string - enableMassClear(): void - disableMassClear(): void - setZIndex(zIndex: number): void - setPosition(position: Point): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any }) => void - onmousedown: (event: { type: string, target: any }) => void - onmouseup: (event: { type: string, target: any }) => void - onmouseout: (event: { type: string, target: any }) => void - onmouseover: (event: { type: string, target: any }) => void - onremove: (event: { type: string, target: any }) => void - onrightclick: (event: { type: string, target: any }) => void - } - class Circle implements Overlay { - constructor(center: Point, radius: number, opts?: CircleOptions) - setCenter(center: Point): void - getCenter(): Point - setRadius(radius: number): void - getRadius(): number - getBounds(): Bounds - setStrokeColor(color: string): void - getStrokeColor(): string - setFillColor(color: string): void - getFillColor(): string - setStrokeOpacity(opacity: number): void - getStrokeOpacity(): number - setFillOpacity(opacity: number): void - getFillOpacity(): number - setStrokeWeight(weight: number): void - getStrokeWeight(): number - setStrokeStyle(style: string): void - getStrokeStyle(): string - getBounds(): Bounds - enableEditing(): void - disableEditing(): void - enableMassClear(): void - disableMassClear(): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - onlineupdate: (event: { type: string, target: any }) => void - } - type SizeType = number - interface IconOptions { - anchor?: Size - imageOffset?: Size - infoWindowAnchor?: Size - printImageUrl?: string - } - interface LabelOptions { - offset?: Size - position?: Point - enableMassClear?: boolean - } - interface CircleOptions { - strokeColor?: string - fillColor?: string - strokeWeight?: number - strokeOpacity?: number - fillOpacity?: number - strokeStyle?: string - enableMassClear?: boolean - enableEditing?: boolean - enableClicking?: boolean - } - class Hotspot implements Overlay { - constructor(position: Point, opts?: HotspotOptions) - setPosition(position: Point): void - getPosition(): Point - setText(text: string): void - getText(): string - setUserData(data: any): void - getUserData(): any - } - class Symbol implements Overlay { - constructor(path: string | SymbolShapeType, opts?: SymbolOptions) - setPath(path: string | SymbolShapeType): void - setAnchor(anchor: Size): void - setRotation(rotation: number): void - setScale(scale: number): void - setStrokeWeight(strokeWeight: number): void - setStrokeColor(color: string): void - setStrokeOpacity(opacity: number): void - setFillOpacity(opacity: number): void - setFillColor(color: string): void - } - class Polyline implements Overlay { - constructor(points: Point[], opts?: PolylineOptions) - setPath(path: Point[]): void - getPath(): Point[] - setStrokeColor(color: string): void - getStrokeColor(): string - setFillColor(color: string): void - getFillColor(): string - setStrokeOpacity(opacity: number): void - getStrokeOpacity(): number - setFillOpacity(opacity: number): void - getFillOpacity(): number - setStrokeWeight(weight: number): void - getStrokeWeight(): number - setStrokeStyle(style: string): void - getStrokeStyle(): string - getBounds(): Bounds - enableEditing(): void - disableEditing(): void - enableMassClear(): void - disableMassClear(): void - setPointAt(index: number, point: Point): void - setPositionAt(index: number, point: Point): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - onlineupdate: (event: { type: string, target: any }) => void - } - class GroundOverlay implements Overlay { - constructor(bounds: Bounds, opts?: GroundOverlayOptions) - setBounds(bounds: Bounds): void - getBounds(): Bounds - setOpacity(opcity: number): void - getOpacity(): number - setImageURL(url: string): void - getImageURL(): string - setDisplayOnMinLevel(level: number): void - getDisplayOnMinLevel(): number - setDispalyOnMaxLevel(level: number): void - getDispalyOnMaxLevel(): number - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any }) => void - } - interface HotspotOptions { - text?: string - offsets?: number[] - userData?: any - minZoom?: number - maxZoom?: number - } - interface MapPanes { - floatPane?: HTMLElement - markerMouseTarget?: HTMLElement - floatShadow?: HTMLElement - labelPane?: HTMLElement - markerPane?: HTMLElement - markerShadow?: HTMLElement - mapPane?: HTMLElement - } -} - -declare const BMap_Symbol_SHAPE_CIRCLE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_RECTANGLE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_RHOMBUS: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_STAR: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_BACKWARD_CLOSED_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_FORWARD_CLOSED_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_BACKWARD_OPEN_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_FORWARD_OPEN_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_POINT: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_PLANE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_CAMERA: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_WARNING: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_SMILE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_CLOCK: BMap.SymbolShapeType - - -declare const BMAP_ANIMATION_DROP: BMap.Animation -declare const BMAP_ANIMATION_BOUNCE: BMap.Animation - -declare const BMAP_POINT_SHAPE_CIRCLE: BMap.ShapeType -declare const APE_STAR: BMap.ShapeType -declare const APE_SQUARE: BMap.ShapeType -declare const APE_RHOMBUS: BMap.ShapeType -declare const APE_WATERDROP: BMap.ShapeType - -declare const BMAP_POINT_SIZE_TINY: BMap.SizeType -declare const BMAP_POINT_SIZE_SMALLER: BMap.SizeType -declare const BMAP_POINT_SIZE_SMALL: BMap.SizeType -declare const BMAP_POINT_SIZE_NORMAL: BMap.SizeType -declare const BMAP_POINT_SIZE_BIG: BMap.SizeType -declare const BMAP_POINT_SIZE_BIGGER: BMap.SizeType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + interface Overlay { + initialize?(map: Map): HTMLElement + isVisible?(): boolean + draw?(): void + show?(): void + hide?(): void + } + type SymbolShapeType = number + interface PolylineOptions { + strokeColor?: string + strokeWeight?: number + strokeOpacity?: number + strokeStyle?: string + enableMassClear?: boolean + enableEditing?: boolean + enableClicking?: boolean + } + interface GroundOverlayOptions { + opacity?: number + imageURL?: string + displayOnMinLevel?: number + displayOnMaxLevel?: number + } + class Marker implements Overlay { + constructor(point: Point, opts?: MarkerOptions) + openInfoWindow(infoWnd: InfoWindow): void + closeInfoWindow(): void + setIcon(icon: Icon): void + getIcon(): Icon + setPosition(position: Point): void + getPosition(): Point + setOffset(offset: Size): void + getOffset(): Size + setLabel(label: Label): void + getLabel(): Label + setTitle(title: string): void + getTitle(): string + setTop(isTop: boolean): void + enableDragging(): void + disableDragging(): void + enableMassClear(): void + disableMassClear(): void + setZIndex(zIndex: number): void + getMap(): Map + addContextMenu(menu: ContextMenu): void + removeContextMenu(menu: ContextMenu): void + setAnimation(animation?: Animation): void + setRotation(rotation: number): void + getRotation(): number + setShadow(shadow: Icon): void + getShadow(): void + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + oninfowindowclose: (event: { type: string, target: any }) => void + oninfowindowopen: (event: { type: string, target: any }) => void + ondragstart: (event: { type: string, target: any }) => void + ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onrightclick: (event: { type: string, target: any }) => void + } + interface SymbolOptions { + anchor?: Size + fillColor?: string + fillOpacity?: number + scale?: number + rotation?: number + strokeColor?: string + strokeOpacity?: number + strokeWeight?: number + } + class IconSequence { + constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean) + } + class PointCollection implements Overlay { + constructor(points: Point[], opts?: PointCollectionOption) + setPoints(points: Point[]): void + setStyles(styles: PointCollectionOption): void + clear(): void + onclick: (event: { type: string, target: any, point: Point }) => void + onmouseover: (event: { type: string, target: any, point: Point }) => void + onmouseout: (event: { type: string, target: any, point: Point }) => void + } + interface MarkerOptions { + offset?: Size + icon?: Icon + enableMassClear?: boolean + enableDragging?: boolean + enableClicking?: boolean + raiseOnDrag?: boolean + draggingCursor?: string + rotation?: number + shadow?: Icon + title?: string + } + class InfoWindow implements Overlay { + constructor(content: string | HTMLElement, opts?: InfoWindowOptions) + setWidth(width: number): void + setHeight(height: number): void + redraw(): void + setTitle(title: string | HTMLElement): void + getTitle(): string | HTMLElement + setContent(content: string | HTMLElement): void + getContent(): string | HTMLElement + getPosition(): Point + enableMaximize(): void + disableMaximize(): void + isOpen(): boolean + setMaxContent(content: string): void + maximize(): void + restore(): void + enableAutoPan(): void + disableAutoPan(): void + enableCloseOnClick(): void + disableCloseOnClick(): void + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclose: (event: { type: string, target: any, point: Point }) => void + onopen: (event: { type: string, target: any, point: Point }) => void + onmaximize: (event: { type: string, target: any }) => void + onrestore: (event: { type: string, target: any }) => void + onclickclose: (event: { type: string, target: any }) => void + } + class Polygon implements Overlay { + constructor(points: Array, opts?: PolygonOptions) + setPath(path: Point[]): void + getPath(): Point[] + setStrokeColor(color: string): void + getStrokeColor(): string + setFillColor(color: string): void + getFillColor(): string + setStrokeOpacity(opacity: number): void + getStrokeOpacity(): number + setFillOpacity(opacity: number): void + getFillOpacity(): number + setStrokeWeight(weight: number): void + getStrokeWeight(): number + setStrokeStyle(style: string): void + getStrokeStyle(): string + getBounds(): Bounds + enableEditing(): void + disableEditing(): void + enableMassClear(): void + disableMassClear(): void + setPointAt(index: number, point: Point): void + setPositionAt(index: number, point: Point): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + onlineupdate: (event: { type: string, target: any }) => void + } + interface PointCollectionOption { + shape?: ShapeType + color?: string + size?: SizeType + } + type Animation = number + interface InfoWindowOptions { + width?: number + height?: number + maxWidth?: number + offset?: Size + title?: string + enableAutoPan?: boolean + enableCloseOnClick?: boolean + enableMessage?: boolean + message?: string + } + interface PolygonOptions { + strokeColor?: string + fillColor?: string + strokeWeight?: number + strokeOpacity?: number + fillOpacity?: number + strokeStyle?: number + enableMassClear?: boolean + enableEditing?: boolean + enableClicking?: boolean + } + type ShapeType = number + class Icon implements Overlay { + constructor(url: string, size: Size, opts?: IconOptions) + anchor: Size + size: Size + imageOffset: Size + imageSize: Size + imageUrl: Size + infoWindowAnchor: Size + printImageUrl: string + setImageUrl(imageUrl: string): void + setSize(size: Size): void + setImageSize(offset: Size): void + setAnchor(anchor: Size): void + setImageOffset(offset: Size): void + setInfoWindowAnchor(anchor: Size): void + setPrintImageUrl(url: string): void + } + class Label implements Overlay { + constructor(content: string, opts?: LabelOptions) + setStyle(styles: Object): void + setContent(content: string): void + setPosition(position: Point): void + getPosition(): Point + setOffset(offset: Size): void + getOffset(): Size + setTitle(title: string): void + getTitle(): string + enableMassClear(): void + disableMassClear(): void + setZIndex(zIndex: number): void + setPosition(position: Point): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any }) => void + onmousedown: (event: { type: string, target: any }) => void + onmouseup: (event: { type: string, target: any }) => void + onmouseout: (event: { type: string, target: any }) => void + onmouseover: (event: { type: string, target: any }) => void + onremove: (event: { type: string, target: any }) => void + onrightclick: (event: { type: string, target: any }) => void + } + class Circle implements Overlay { + constructor(center: Point, radius: number, opts?: CircleOptions) + setCenter(center: Point): void + getCenter(): Point + setRadius(radius: number): void + getRadius(): number + getBounds(): Bounds + setStrokeColor(color: string): void + getStrokeColor(): string + setFillColor(color: string): void + getFillColor(): string + setStrokeOpacity(opacity: number): void + getStrokeOpacity(): number + setFillOpacity(opacity: number): void + getFillOpacity(): number + setStrokeWeight(weight: number): void + getStrokeWeight(): number + setStrokeStyle(style: string): void + getStrokeStyle(): string + getBounds(): Bounds + enableEditing(): void + disableEditing(): void + enableMassClear(): void + disableMassClear(): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + onlineupdate: (event: { type: string, target: any }) => void + } + type SizeType = number + interface IconOptions { + anchor?: Size + imageOffset?: Size + infoWindowAnchor?: Size + printImageUrl?: string + } + interface LabelOptions { + offset?: Size + position?: Point + enableMassClear?: boolean + } + interface CircleOptions { + strokeColor?: string + fillColor?: string + strokeWeight?: number + strokeOpacity?: number + fillOpacity?: number + strokeStyle?: string + enableMassClear?: boolean + enableEditing?: boolean + enableClicking?: boolean + } + class Hotspot implements Overlay { + constructor(position: Point, opts?: HotspotOptions) + setPosition(position: Point): void + getPosition(): Point + setText(text: string): void + getText(): string + setUserData(data: any): void + getUserData(): any + } + class Symbol implements Overlay { + constructor(path: string | SymbolShapeType, opts?: SymbolOptions) + setPath(path: string | SymbolShapeType): void + setAnchor(anchor: Size): void + setRotation(rotation: number): void + setScale(scale: number): void + setStrokeWeight(strokeWeight: number): void + setStrokeColor(color: string): void + setStrokeOpacity(opacity: number): void + setFillOpacity(opacity: number): void + setFillColor(color: string): void + } + class Polyline implements Overlay { + constructor(points: Point[], opts?: PolylineOptions) + setPath(path: Point[]): void + getPath(): Point[] + setStrokeColor(color: string): void + getStrokeColor(): string + setFillColor(color: string): void + getFillColor(): string + setStrokeOpacity(opacity: number): void + getStrokeOpacity(): number + setFillOpacity(opacity: number): void + getFillOpacity(): number + setStrokeWeight(weight: number): void + getStrokeWeight(): number + setStrokeStyle(style: string): void + getStrokeStyle(): string + getBounds(): Bounds + enableEditing(): void + disableEditing(): void + enableMassClear(): void + disableMassClear(): void + setPointAt(index: number, point: Point): void + setPositionAt(index: number, point: Point): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + onlineupdate: (event: { type: string, target: any }) => void + } + class GroundOverlay implements Overlay { + constructor(bounds: Bounds, opts?: GroundOverlayOptions) + setBounds(bounds: Bounds): void + getBounds(): Bounds + setOpacity(opcity: number): void + getOpacity(): number + setImageURL(url: string): void + getImageURL(): string + setDisplayOnMinLevel(level: number): void + getDisplayOnMinLevel(): number + setDispalyOnMaxLevel(level: number): void + getDispalyOnMaxLevel(): number + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any }) => void + } + interface HotspotOptions { + text?: string + offsets?: number[] + userData?: any + minZoom?: number + maxZoom?: number + } + interface MapPanes { + floatPane?: HTMLElement + markerMouseTarget?: HTMLElement + floatShadow?: HTMLElement + labelPane?: HTMLElement + markerPane?: HTMLElement + markerShadow?: HTMLElement + mapPane?: HTMLElement + } +} + +declare const BMap_Symbol_SHAPE_CIRCLE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_RECTANGLE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_RHOMBUS: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_STAR: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_BACKWARD_CLOSED_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_FORWARD_CLOSED_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_BACKWARD_OPEN_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_FORWARD_OPEN_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_POINT: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_PLANE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_CAMERA: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_WARNING: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_SMILE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_CLOCK: BMap.SymbolShapeType + + +declare const BMAP_ANIMATION_DROP: BMap.Animation +declare const BMAP_ANIMATION_BOUNCE: BMap.Animation + +declare const BMAP_POINT_SHAPE_CIRCLE: BMap.ShapeType +declare const APE_STAR: BMap.ShapeType +declare const APE_SQUARE: BMap.ShapeType +declare const APE_RHOMBUS: BMap.ShapeType +declare const APE_WATERDROP: BMap.ShapeType + +declare const BMAP_POINT_SIZE_TINY: BMap.SizeType +declare const BMAP_POINT_SIZE_SMALLER: BMap.SizeType +declare const BMAP_POINT_SIZE_SMALL: BMap.SizeType +declare const BMAP_POINT_SIZE_NORMAL: BMap.SizeType +declare const BMAP_POINT_SIZE_BIG: BMap.SizeType +declare const BMAP_POINT_SIZE_BIGGER: BMap.SizeType declare const BMAP_POINT_SIZE_HUGE: BMap.SizeType \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.panorama.d.ts b/types/baidumap-web-sdk/baidumap.panorama.d.ts index 6b3e10f6b2..f087732fb4 100644 --- a/types/baidumap-web-sdk/baidumap.panorama.d.ts +++ b/types/baidumap-web-sdk/baidumap.panorama.d.ts @@ -1,121 +1,121 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class Panorama { - constructor(container: string | HTMLElement, opts?: PanoramaOptions) - getLinks(): PanoramaLink[] - getId(): string - getPosition(): Point - getPov(): PanoramaPov - getZoom(): number - setId(id: string): void - setPosition(position: Point): void - setPov(pov: PanoramaPov): void - setZoom(zoom: number): void - enableScrollWheelZoom(): void - disableScrollWheelZoom(): void - show(): void - hide(): void - addOverlay(overlay: PanoramaLabel): void - removeOverlay(overlay: PanoramaLabel): void - getSceneType(): PanoramaSceneType - setOptions(opts?: PanoramaOptions): void - setPanoramaPOIType(): PanoramaPOIType - onposition_changed: () => void - onlinks_changed: () => void - onpov_changed: () => void - onzoom_changed: () => void - onscene_type_changed: () => void - } - - interface PanoramaOptions { - navigationControl?: boolean - linksControl?: boolean - indoorSceneSwitchControl?: boolean - albumsControl?: boolean - albumsControlOptions?: AlbumsControlOptions - } - interface PanoramaLink { - description: string - heading: string - id: string - } - interface PanoramaPov { - heading: number - pitch: number - } - class PanoramaService { - constructor() - getPanoramaById(id: string, callback: (data: PanoramaData) => void): void - getPanoramaByLocation(point: Point, radius?: number, callback?: (data: PanoramaData) => void): void - } - interface PanoramaData { - id: string - description: string - links: PanoramaLink[] - position: Point - tiles: PanoramaTileData - } - interface PanoramaTileData { - centerHeading: number - tileSize: Size - worldSize: Size - } - class PanoramaLabel { - constructor(content: string, opts?: PanoramaLabelOptions) - setPosition(position: Point): void - getPosition(): Point - getPov(): PanoramaPov - setContent(content: string): void - getContent(): string - show(): void - hide(): void - setAltitude(altitude: number): void - getAltitude(): number - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - onmouseover: (event: { type: string, target: any }) => void - onmouseout: (event: { type: string, target: any }) => void - onremove: (event: { type: string, target: any }) => void - } - interface PanoramaLabelOptions { - position?: Point - altitude?: number - } - interface AlbumsControlOptions { - anchor?: ControlAnchor - offset?: Size - maxWidth?: number | string - imageHeight?: number - } - type PanoramaSceneType = string - type PanoramaPOIType = string -} -declare const BMAP_PANORAMA_INDOOR_SCENE: string -declare const BMAP_PANORAMA_STREET_SCENE: string - -declare const BMAP_PANORAMA_POI_HOTEL: string -declare const BMAP_PANORAMA_POI_CATERING: string -declare const BMAP_PANORAMA_POI_MOVIE: string -declare const BMAP_PANORAMA_POI_TRANSIT: string -declare const BMAP_PANORAMA_POI_INDOOR_SCENE: string -declare const BMAP_PANORAMA_POI_NONE: string +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class Panorama { + constructor(container: string | HTMLElement, opts?: PanoramaOptions) + getLinks(): PanoramaLink[] + getId(): string + getPosition(): Point + getPov(): PanoramaPov + getZoom(): number + setId(id: string): void + setPosition(position: Point): void + setPov(pov: PanoramaPov): void + setZoom(zoom: number): void + enableScrollWheelZoom(): void + disableScrollWheelZoom(): void + show(): void + hide(): void + addOverlay(overlay: PanoramaLabel): void + removeOverlay(overlay: PanoramaLabel): void + getSceneType(): PanoramaSceneType + setOptions(opts?: PanoramaOptions): void + setPanoramaPOIType(): PanoramaPOIType + onposition_changed: () => void + onlinks_changed: () => void + onpov_changed: () => void + onzoom_changed: () => void + onscene_type_changed: () => void + } + + interface PanoramaOptions { + navigationControl?: boolean + linksControl?: boolean + indoorSceneSwitchControl?: boolean + albumsControl?: boolean + albumsControlOptions?: AlbumsControlOptions + } + interface PanoramaLink { + description: string + heading: string + id: string + } + interface PanoramaPov { + heading: number + pitch: number + } + class PanoramaService { + constructor() + getPanoramaById(id: string, callback: (data: PanoramaData) => void): void + getPanoramaByLocation(point: Point, radius?: number, callback?: (data: PanoramaData) => void): void + } + interface PanoramaData { + id: string + description: string + links: PanoramaLink[] + position: Point + tiles: PanoramaTileData + } + interface PanoramaTileData { + centerHeading: number + tileSize: Size + worldSize: Size + } + class PanoramaLabel { + constructor(content: string, opts?: PanoramaLabelOptions) + setPosition(position: Point): void + getPosition(): Point + getPov(): PanoramaPov + setContent(content: string): void + getContent(): string + show(): void + hide(): void + setAltitude(altitude: number): void + getAltitude(): number + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + onmouseover: (event: { type: string, target: any }) => void + onmouseout: (event: { type: string, target: any }) => void + onremove: (event: { type: string, target: any }) => void + } + interface PanoramaLabelOptions { + position?: Point + altitude?: number + } + interface AlbumsControlOptions { + anchor?: ControlAnchor + offset?: Size + maxWidth?: number | string + imageHeight?: number + } + type PanoramaSceneType = string + type PanoramaPOIType = string +} +declare const BMAP_PANORAMA_INDOOR_SCENE: string +declare const BMAP_PANORAMA_STREET_SCENE: string + +declare const BMAP_PANORAMA_POI_HOTEL: string +declare const BMAP_PANORAMA_POI_CATERING: string +declare const BMAP_PANORAMA_POI_MOVIE: string +declare const BMAP_PANORAMA_POI_TRANSIT: string +declare const BMAP_PANORAMA_POI_INDOOR_SCENE: string +declare const BMAP_PANORAMA_POI_NONE: string diff --git a/types/baidumap-web-sdk/baidumap.rightmenu.d.ts b/types/baidumap-web-sdk/baidumap.rightmenu.d.ts index ef79b71641..b760c73561 100644 --- a/types/baidumap-web-sdk/baidumap.rightmenu.d.ts +++ b/types/baidumap-web-sdk/baidumap.rightmenu.d.ts @@ -1,47 +1,47 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// - -declare namespace BMap { - type ContextMenuIcon = string - interface MenuItemOptions { - width?: number - id?: string - iconUrl?: string - } - class MenuItem { - constructor(text: string, callback: (point: Point) => void, opts?: MenuItemOptions) - setText(text: string): void - setIcon(iconUrl: string): void - enable(): void - disable(): void - } - class ContextMenu { - constructor() - addItem(item: MenuItem): void - getItem(index: number): MenuItem - removeItem(item: MenuItem): void - addSeparator(): void - removeSeparator(index: number): void - onopen: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onclose: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - } -} -declare const BMAP_CONTEXT_MENU_ICON_ZOOMIN: string +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// + +declare namespace BMap { + type ContextMenuIcon = string + interface MenuItemOptions { + width?: number + id?: string + iconUrl?: string + } + class MenuItem { + constructor(text: string, callback: (point: Point) => void, opts?: MenuItemOptions) + setText(text: string): void + setIcon(iconUrl: string): void + enable(): void + disable(): void + } + class ContextMenu { + constructor() + addItem(item: MenuItem): void + getItem(index: number): MenuItem + removeItem(item: MenuItem): void + addSeparator(): void + removeSeparator(index: number): void + onopen: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onclose: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + } +} +declare const BMAP_CONTEXT_MENU_ICON_ZOOMIN: string declare const BMAP_CONTEXT_MENU_ICON_ZOOMOUT: string \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.service.d.ts b/types/baidumap-web-sdk/baidumap.service.d.ts index 54ca6f7e1d..dbff0b7dfe 100644 --- a/types/baidumap-web-sdk/baidumap.service.d.ts +++ b/types/baidumap-web-sdk/baidumap.service.d.ts @@ -1,432 +1,432 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class LocalSearch { - constructor(location: Map | Point | string, opts?: LocalSearchOptions) - search(keyword: string | Array, option?: Object): void - searchInBounds(keyword: string | Array, bounds: Bounds, option?: Object): void - searchNearby(keyword: string | Array, center: LocalResultPoi | string | Point, radius: number, option?: Object): void - getResults(): LocalResult | LocalResult[] - clearResults(): void - gotoPage(page: number): void - enableAutoViewport(): void - disableAutoViewport(): void - enableFirstResultSelection(): void - disableFirstResultSelection(): void - setLocation(location: Map | Point | string): void - setPageCapacity(capacity: number): void - getPageCapacity(): number - setSearchCompleteCallback(callback: (results: LocalResult | LocalResult[]) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - } - type LineType = number - interface WalkingRouteResult { - city: string - getStart(): LocalResultPoi - getEnd(): LocalResultPoi - getNumPlans(): number - getPlan(i: number): RoutePlan - } - class BusLineSearch { - constructor(location: Map | Point | string, opts?: BusLineSearchOptions) - getBusList(keyword: string): void - getBusLine(busLstItem: BusListItem): void - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setLocation(location: Map | Point | string): void - getStatus(): ServiceStatusCode - toString(): string - setGetBusListCompleteCallback(callback: (rs: BusListResult) => void): void - setGetBusLineCompleteCallback(callback: (rs: BusLine) => void): void - setBusListHtmlSetCallback(callback: (container: HTMLElement) => void): void - setBusLineHtmlSetCallback(callback: (container: HTMLElement) => void): void - setPolylinesSetCallback(callback: (ply: Polyline) => void): void - setMarkersSetCallback(callback: (markers: Marker[]) => void): void - } - interface LocalSearchOptions { - renderOptions?: RenderOptions - onMarkersSet?: (pois: LocalResultPoi[]) => void - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void - onResultsHtmlSet?: (container: HTMLElement) => void - pageCapacity?: number - onSearchComplete?: (results: LocalResult[]) => void - } - class DrivingRoute { - constructor(location: Map | Point | string, opts?: DrivingRouteOptions) - search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi, opts?: Object): void - getResults(): DrivingRouteResult - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setLocation(location: Map | Point | string): void - setPolicy(policy: DrivingPolicy): void - setSearchCompleteCallback(callback: (results: DrivingRouteResult) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setPolylinesSetCallback(callback: (routes: Route[]) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - toString(): string - } - class Geocoder { - constructor() - getPoint(address: string, callback: (point: Point) => void, city: string): void - getLocation(point: Point, callback: (result: GeocoderResult) => void, opts?: LocationOptions): void - } - interface BusLineSearchOptions { - renderOptions?: RenderOptions - onGetBusListComplete?: (rs: BusListResult) => void - onGetBusLineComplete?: (rs: BusLine) => void - onBusListHtmlSet?: (container: HTMLElement) => void - onBusLineHtmlSet?: (container: HTMLElement) => void - onPolylinesSet?: (ply: Polyline) => void - onMarkersSet?: (sts: Marker[]) => void - } - interface CustomData { - geotableId: number - tags: string - filter: string - } - interface DrivingRouteOptions { - renderOptions?: RenderOptions - policy?: DrivingPolicy - onSearchComplete?: (results: DrivingRouteResult) => void - onMarkersSet?: (pois: LocalResultPoi[]) => void - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void - onPolylinesSet?: (routes: Route[]) => void - onResultsHtmlSet?: (container: HTMLElement) => void - } - interface GeocoderResult { - point: Point - address: string - addressComponents: AddressComponent - surroundingPoi: LocalResultPoi[] - business: string - } - interface BusListResult { - keyword: string - city: string - moreResultsUrl: string - getNumBusList(): number - getBusListItem(i: number): BusListItem - } - interface RenderOptions { - map: Map - panel?: string | HTMLElement - selectFirstResult?: boolean - autoViewport?: boolean - highlightMode?: HighlightModes - } - type DrivingPolicy = number - interface AddressComponent { - streetNumber: string - street: string - district: string - city: string - province: string - } - interface BusLine { - name: string - startTime: string - endTime: string - company: string - getNumBusStations(): string - getBusStation(i: number): BusStation - getPath(): Point[] - getPolyline(): Polyline - } - interface LocalResult { - keyword: string - center: LocalResultPoi - radius: number - bounds: Bounds - city: string - moreResultsUrl: string - province: string - suggestions: string[] - getPoi(i: number): LocalResultPoi - getCurrentNumPois(): number - getNumPois(): number - getNumPages(): number - getPageIndex(): number - getCityList(): any[] - } - - interface DrivingRouteResult { - policy: DrivingPolicy - city: string - moreResultsUrl: string - taxiFare: TaxiFare - getStart(): LocalResultPoi - getEnd(): LocalResultPoi - getNumPlans(): number - getPlan(i: number): RoutePlan - } - interface LocationOptions { - poiRadius?: number - numPois?: number - } - interface BusListItem { - name: string - } - interface LocalResultPoi { - title: string - point: Point - url: string - address: string - city: string - phoneNumber: string - postcode: string - type: PoiType - isAccurate: boolean - province: string - tags: string[] - detailUrl: string - } - interface TaxiFare { - day: TaxiFareDetail - night: TaxiFareDetail - distance: number - remark: string - } - class LocalCity { - constructor(opts?: LocalCityOptions) - get(callback: (result: LocalCityResult) => void): void - } - interface BusStation { - name: string - position: Point - } - type PoiType = number - interface TaxiFareDetail { - initialFare: number - unitFare: number - totalFare: number - } - interface LocalCityOptions { - renderOptions?: RenderOptions - } - class Autocomplete { - constructor(opts?: AutocompleteOptions) - show(): void - hide(): void - setTypes(types: string[]): void - setLocation(location: string | Map | Point): void - search(keywords: string): void - getResults(): AutocompleteResult - setInputValue(keyword: string): void - dispose(): void - onconfirm: (event: { type: string, target: any, item: any }) => void - onhighlight: (event: { type: string, target: any, fromitem: any, toitem: any }) => void - } - class TransitRoute { - constructor(location: Map | Point | string, opts?: TransitRouteOptions) - search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void - getResults(): TransitRouteResult - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setPageCapacity(capacity: number): void - setLocation(location: Map | Point | string): void - setPolicy(policy: TransitPolicy): void - setSearchCompleteCallback(callback: (results: TransitRouteResult) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setPolylinesSetCallback(callback: (lines: Line[], routes: Route[]) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - toString(): string - } - interface RoutePlan { - getNumRoutes(): number - getRoute(i: number): Route - getDistance(format?: boolean): string | number - getDuration(format?: boolean): string | number - getDragPois(): LocalResultPoi[] - } - interface LocalCityResult { - center: Point - level: number - name: string - } - interface AutocompleteOptions { - location?: string | Map | Point - types?: string[] - onSearchComplete?: (result: AutocompleteResult) => void - input?: string | HTMLElement - } - interface TransitRouteOptions { - renderOptions?: RenderOptions - policy?: TransitPolicy - pageCapacity?: number - onSearchComplete?: (result: TransitRouteResult) => void - onMarkersSet?: (pois: LocalResultPoi[], transfers: LocalResultPoi[]) => void - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void - onPolylinesSet?: (lines: Line[]) => void - onResultsHtmlSet?: (container: HTMLElement) => void - } - interface Route { - getNumRoutes(): number - getStep(i: number): Step - getDistance(format?: boolean): string | number - getIndex(): number - getPolyline(): Polyline - getPoints(): Point[] - getPath(): Point[] - getRouteType(): RouteType - } - class TrafficControl { - constructor() - setPanelOffset(offset: Size): void - show(): void - hide(): void - } - interface AutocompleteResultPoi { - province: string - City: string//wtf - district: string - street: string - streetNumber: string - business: string - } - type TransitPolicy = number - type RouteType = number - class Geolocation { - constructor() - getCurrentPosition(callback: (result: GeolocationResult) => void, opts?: PositionOptions): void - getStatus(): ServiceStatusCode - } - interface AutocompleteResult { - keyword: string - getPoi(i: number): AutocompleteResultPoi - getNumPois(): number - } - interface TransitRouteResult { - policy: TransitPolicy - city: string - moreResultsUrl: string - getStart(): LocalResultPoi - getEnd(): LocalResultPoi - getNumPlans(): number - getPlan(i: number): TransitRoutePlan - } - interface Step { - getPoint(): Point - getPosition(): Point - getIndex(): number - getDescription(includeHtml: boolean): string - getDistance(format?: boolean): string | number - } - interface GeolocationResult { - point: Point - accuracy: number - } - class Boundary { - constructor() - get(name: string, callback: (result: string[]) => void): void - } - interface TransitRoutePlan { - getNumLines(): number - getLine(i: number): Line - getNumRoutes(): number - getRoute(i: number): Route - getDistance(format?: boolean): string | number - getDuration(format?: boolean): string | number - getDescription(includeHtml: boolean): string - } - class WalkingRoute { - constructor(location: Map | Point | string, opts?: WalkingRouteOptions) - search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void - getResults(): WalkingRouteResult - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setLocation(location: Map | Point | string): void - setSearchCompleteCallback(callback: (result: WalkingRouteResult) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setPolylinesSetCallback(callback: (routes: Route[]) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - toString(): string - } - interface PositionOptions { - enableHighAccuracy?: boolean - timeout?: number - maximumAge?: number - } - interface Line { - title: string - type: LineType - getNumViaStops(): number - getGetOnStop(): LocalResultPoi - getGetOffStop(): LocalResultPoi - getPoints(): Point[] - getPath(): Point[] - getPolyline(): Polyline - getDistance(format?: boolean): string | number - } - interface WalkingRouteOptions { - renderOptions?: RenderOptions, - onSearchComplete?: (result: WalkingRouteResult) => void, - onMarkersSet?: (pois: LocalResultPoi[]) => void, - onPolylinesSet?: (routes: Route[]) => void, - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void, - onResultsHtmlSet?: (container: HTMLElement) => void - } - type HighlightModes = number - type ServiceStatusCode = number -} - -declare const BMAP_LINE_TYPE_BUS: BMap.LineType -declare const BMAP_LINE_TYPE_SUBWAY: BMap.LineType -declare const BMAP_LINE_TYPE_FERRY: BMap.LineType - -declare const BMAP_DRIVING_POLICY_LEAST_TIME: BMap.DrivingPolicy -declare const BMAP_DRIVING_POLICY_LEAST_DISTANCE: BMap.DrivingPolicy -declare const BMAP_DRIVING_POLICY_AVOID_HIGHWAYS: BMap.DrivingPolicy - -declare const BMAP_POI_TYPE_NORMAL: BMap.PoiType -declare const BMAP_POI_TYPE_BUSSTOP: BMap.PoiType -declare const BMAP_POI_TYPE_SUBSTOP: BMap.PoiType - - -declare const BMAP_TRANSIT_POLICY_LEAST_TIME: BMap.TransitPolicy -declare const BMAP_TRANSIT_POLICY_LEAST_TRANSFER: BMap.TransitPolicy -declare const BMAP_TRANSIT_POLICY_LEAST_WALKING: BMap.TransitPolicy -declare const BMAP_TRANSIT_POLICY_AVOID_SUBWAYS: BMap.TransitPolicy - -declare const BMAP_ROUTE_TYPE_DRIVING: BMap.RouteType -declare const BMAP_ROUTE_TYPE_WALKING: BMap.RouteType - -declare const BMAP_HIGHLIGHT_STEP: BMap.HighlightModes -declare const BMAP_HIGHLIGHT_ROUTE: BMap.HighlightModes - -declare const BMAP_STATUS_SUCCESS: BMap.ServiceStatusCode -declare const BMAP_STATUS_CITY_LIST: BMap.ServiceStatusCode -declare const BMAP_STATUS_UNKNOWN_LOCATION: BMap.ServiceStatusCode -declare const BMAP_STATUS_UNKNOWN_ROUTE: BMap.ServiceStatusCode -declare const BMAP_STATUS_INVALID_KEY: BMap.ServiceStatusCode -declare const BMAP_STATUS_INVALID_REQUEST: BMap.ServiceStatusCode \ No newline at end of file +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class LocalSearch { + constructor(location: Map | Point | string, opts?: LocalSearchOptions) + search(keyword: string | Array, option?: Object): void + searchInBounds(keyword: string | Array, bounds: Bounds, option?: Object): void + searchNearby(keyword: string | Array, center: LocalResultPoi | string | Point, radius: number, option?: Object): void + getResults(): LocalResult | LocalResult[] + clearResults(): void + gotoPage(page: number): void + enableAutoViewport(): void + disableAutoViewport(): void + enableFirstResultSelection(): void + disableFirstResultSelection(): void + setLocation(location: Map | Point | string): void + setPageCapacity(capacity: number): void + getPageCapacity(): number + setSearchCompleteCallback(callback: (results: LocalResult | LocalResult[]) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + } + type LineType = number + interface WalkingRouteResult { + city: string + getStart(): LocalResultPoi + getEnd(): LocalResultPoi + getNumPlans(): number + getPlan(i: number): RoutePlan + } + class BusLineSearch { + constructor(location: Map | Point | string, opts?: BusLineSearchOptions) + getBusList(keyword: string): void + getBusLine(busLstItem: BusListItem): void + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setLocation(location: Map | Point | string): void + getStatus(): ServiceStatusCode + toString(): string + setGetBusListCompleteCallback(callback: (rs: BusListResult) => void): void + setGetBusLineCompleteCallback(callback: (rs: BusLine) => void): void + setBusListHtmlSetCallback(callback: (container: HTMLElement) => void): void + setBusLineHtmlSetCallback(callback: (container: HTMLElement) => void): void + setPolylinesSetCallback(callback: (ply: Polyline) => void): void + setMarkersSetCallback(callback: (markers: Marker[]) => void): void + } + interface LocalSearchOptions { + renderOptions?: RenderOptions + onMarkersSet?: (pois: LocalResultPoi[]) => void + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void + onResultsHtmlSet?: (container: HTMLElement) => void + pageCapacity?: number + onSearchComplete?: (results: LocalResult[]) => void + } + class DrivingRoute { + constructor(location: Map | Point | string, opts?: DrivingRouteOptions) + search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi, opts?: Object): void + getResults(): DrivingRouteResult + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setLocation(location: Map | Point | string): void + setPolicy(policy: DrivingPolicy): void + setSearchCompleteCallback(callback: (results: DrivingRouteResult) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setPolylinesSetCallback(callback: (routes: Route[]) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + toString(): string + } + class Geocoder { + constructor() + getPoint(address: string, callback: (point: Point) => void, city: string): void + getLocation(point: Point, callback: (result: GeocoderResult) => void, opts?: LocationOptions): void + } + interface BusLineSearchOptions { + renderOptions?: RenderOptions + onGetBusListComplete?: (rs: BusListResult) => void + onGetBusLineComplete?: (rs: BusLine) => void + onBusListHtmlSet?: (container: HTMLElement) => void + onBusLineHtmlSet?: (container: HTMLElement) => void + onPolylinesSet?: (ply: Polyline) => void + onMarkersSet?: (sts: Marker[]) => void + } + interface CustomData { + geotableId: number + tags: string + filter: string + } + interface DrivingRouteOptions { + renderOptions?: RenderOptions + policy?: DrivingPolicy + onSearchComplete?: (results: DrivingRouteResult) => void + onMarkersSet?: (pois: LocalResultPoi[]) => void + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void + onPolylinesSet?: (routes: Route[]) => void + onResultsHtmlSet?: (container: HTMLElement) => void + } + interface GeocoderResult { + point: Point + address: string + addressComponents: AddressComponent + surroundingPoi: LocalResultPoi[] + business: string + } + interface BusListResult { + keyword: string + city: string + moreResultsUrl: string + getNumBusList(): number + getBusListItem(i: number): BusListItem + } + interface RenderOptions { + map: Map + panel?: string | HTMLElement + selectFirstResult?: boolean + autoViewport?: boolean + highlightMode?: HighlightModes + } + type DrivingPolicy = number + interface AddressComponent { + streetNumber: string + street: string + district: string + city: string + province: string + } + interface BusLine { + name: string + startTime: string + endTime: string + company: string + getNumBusStations(): string + getBusStation(i: number): BusStation + getPath(): Point[] + getPolyline(): Polyline + } + interface LocalResult { + keyword: string + center: LocalResultPoi + radius: number + bounds: Bounds + city: string + moreResultsUrl: string + province: string + suggestions: string[] + getPoi(i: number): LocalResultPoi + getCurrentNumPois(): number + getNumPois(): number + getNumPages(): number + getPageIndex(): number + getCityList(): any[] + } + + interface DrivingRouteResult { + policy: DrivingPolicy + city: string + moreResultsUrl: string + taxiFare: TaxiFare + getStart(): LocalResultPoi + getEnd(): LocalResultPoi + getNumPlans(): number + getPlan(i: number): RoutePlan + } + interface LocationOptions { + poiRadius?: number + numPois?: number + } + interface BusListItem { + name: string + } + interface LocalResultPoi { + title: string + point: Point + url: string + address: string + city: string + phoneNumber: string + postcode: string + type: PoiType + isAccurate: boolean + province: string + tags: string[] + detailUrl: string + } + interface TaxiFare { + day: TaxiFareDetail + night: TaxiFareDetail + distance: number + remark: string + } + class LocalCity { + constructor(opts?: LocalCityOptions) + get(callback: (result: LocalCityResult) => void): void + } + interface BusStation { + name: string + position: Point + } + type PoiType = number + interface TaxiFareDetail { + initialFare: number + unitFare: number + totalFare: number + } + interface LocalCityOptions { + renderOptions?: RenderOptions + } + class Autocomplete { + constructor(opts?: AutocompleteOptions) + show(): void + hide(): void + setTypes(types: string[]): void + setLocation(location: string | Map | Point): void + search(keywords: string): void + getResults(): AutocompleteResult + setInputValue(keyword: string): void + dispose(): void + onconfirm: (event: { type: string, target: any, item: any }) => void + onhighlight: (event: { type: string, target: any, fromitem: any, toitem: any }) => void + } + class TransitRoute { + constructor(location: Map | Point | string, opts?: TransitRouteOptions) + search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void + getResults(): TransitRouteResult + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setPageCapacity(capacity: number): void + setLocation(location: Map | Point | string): void + setPolicy(policy: TransitPolicy): void + setSearchCompleteCallback(callback: (results: TransitRouteResult) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setPolylinesSetCallback(callback: (lines: Line[], routes: Route[]) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + toString(): string + } + interface RoutePlan { + getNumRoutes(): number + getRoute(i: number): Route + getDistance(format?: boolean): string | number + getDuration(format?: boolean): string | number + getDragPois(): LocalResultPoi[] + } + interface LocalCityResult { + center: Point + level: number + name: string + } + interface AutocompleteOptions { + location?: string | Map | Point + types?: string[] + onSearchComplete?: (result: AutocompleteResult) => void + input?: string | HTMLElement + } + interface TransitRouteOptions { + renderOptions?: RenderOptions + policy?: TransitPolicy + pageCapacity?: number + onSearchComplete?: (result: TransitRouteResult) => void + onMarkersSet?: (pois: LocalResultPoi[], transfers: LocalResultPoi[]) => void + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void + onPolylinesSet?: (lines: Line[]) => void + onResultsHtmlSet?: (container: HTMLElement) => void + } + interface Route { + getNumRoutes(): number + getStep(i: number): Step + getDistance(format?: boolean): string | number + getIndex(): number + getPolyline(): Polyline + getPoints(): Point[] + getPath(): Point[] + getRouteType(): RouteType + } + class TrafficControl { + constructor() + setPanelOffset(offset: Size): void + show(): void + hide(): void + } + interface AutocompleteResultPoi { + province: string + City: string//wtf + district: string + street: string + streetNumber: string + business: string + } + type TransitPolicy = number + type RouteType = number + class Geolocation { + constructor() + getCurrentPosition(callback: (result: GeolocationResult) => void, opts?: PositionOptions): void + getStatus(): ServiceStatusCode + } + interface AutocompleteResult { + keyword: string + getPoi(i: number): AutocompleteResultPoi + getNumPois(): number + } + interface TransitRouteResult { + policy: TransitPolicy + city: string + moreResultsUrl: string + getStart(): LocalResultPoi + getEnd(): LocalResultPoi + getNumPlans(): number + getPlan(i: number): TransitRoutePlan + } + interface Step { + getPoint(): Point + getPosition(): Point + getIndex(): number + getDescription(includeHtml: boolean): string + getDistance(format?: boolean): string | number + } + interface GeolocationResult { + point: Point + accuracy: number + } + class Boundary { + constructor() + get(name: string, callback: (result: string[]) => void): void + } + interface TransitRoutePlan { + getNumLines(): number + getLine(i: number): Line + getNumRoutes(): number + getRoute(i: number): Route + getDistance(format?: boolean): string | number + getDuration(format?: boolean): string | number + getDescription(includeHtml: boolean): string + } + class WalkingRoute { + constructor(location: Map | Point | string, opts?: WalkingRouteOptions) + search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void + getResults(): WalkingRouteResult + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setLocation(location: Map | Point | string): void + setSearchCompleteCallback(callback: (result: WalkingRouteResult) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setPolylinesSetCallback(callback: (routes: Route[]) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + toString(): string + } + interface PositionOptions { + enableHighAccuracy?: boolean + timeout?: number + maximumAge?: number + } + interface Line { + title: string + type: LineType + getNumViaStops(): number + getGetOnStop(): LocalResultPoi + getGetOffStop(): LocalResultPoi + getPoints(): Point[] + getPath(): Point[] + getPolyline(): Polyline + getDistance(format?: boolean): string | number + } + interface WalkingRouteOptions { + renderOptions?: RenderOptions, + onSearchComplete?: (result: WalkingRouteResult) => void, + onMarkersSet?: (pois: LocalResultPoi[]) => void, + onPolylinesSet?: (routes: Route[]) => void, + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void, + onResultsHtmlSet?: (container: HTMLElement) => void + } + type HighlightModes = number + type ServiceStatusCode = number +} + +declare const BMAP_LINE_TYPE_BUS: BMap.LineType +declare const BMAP_LINE_TYPE_SUBWAY: BMap.LineType +declare const BMAP_LINE_TYPE_FERRY: BMap.LineType + +declare const BMAP_DRIVING_POLICY_LEAST_TIME: BMap.DrivingPolicy +declare const BMAP_DRIVING_POLICY_LEAST_DISTANCE: BMap.DrivingPolicy +declare const BMAP_DRIVING_POLICY_AVOID_HIGHWAYS: BMap.DrivingPolicy + +declare const BMAP_POI_TYPE_NORMAL: BMap.PoiType +declare const BMAP_POI_TYPE_BUSSTOP: BMap.PoiType +declare const BMAP_POI_TYPE_SUBSTOP: BMap.PoiType + + +declare const BMAP_TRANSIT_POLICY_LEAST_TIME: BMap.TransitPolicy +declare const BMAP_TRANSIT_POLICY_LEAST_TRANSFER: BMap.TransitPolicy +declare const BMAP_TRANSIT_POLICY_LEAST_WALKING: BMap.TransitPolicy +declare const BMAP_TRANSIT_POLICY_AVOID_SUBWAYS: BMap.TransitPolicy + +declare const BMAP_ROUTE_TYPE_DRIVING: BMap.RouteType +declare const BMAP_ROUTE_TYPE_WALKING: BMap.RouteType + +declare const BMAP_HIGHLIGHT_STEP: BMap.HighlightModes +declare const BMAP_HIGHLIGHT_ROUTE: BMap.HighlightModes + +declare const BMAP_STATUS_SUCCESS: BMap.ServiceStatusCode +declare const BMAP_STATUS_CITY_LIST: BMap.ServiceStatusCode +declare const BMAP_STATUS_UNKNOWN_LOCATION: BMap.ServiceStatusCode +declare const BMAP_STATUS_UNKNOWN_ROUTE: BMap.ServiceStatusCode +declare const BMAP_STATUS_INVALID_KEY: BMap.ServiceStatusCode +declare const BMAP_STATUS_INVALID_REQUEST: BMap.ServiceStatusCode \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.tools.d.ts b/types/baidumap-web-sdk/baidumap.tools.d.ts index cd3ba6b619..c1bc6bf929 100644 --- a/types/baidumap-web-sdk/baidumap.tools.d.ts +++ b/types/baidumap-web-sdk/baidumap.tools.d.ts @@ -1,61 +1,61 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - class PushpinTool { - constructor(map: Map, opts?: PushpinToolOptions) - open(): boolean - close(): boolean - setIcon(icon: Icon): Icon - getIcon(): Icon - setCursor(cursor: string): string - getCursor(): string - toString(): string - onmarkend: (event: { type: string, target: any, marker: Marker }) => void - } - interface PushpinToolOptions { - icon?: Icon - cursor?: string - followText?: string - } - class DistanceTool { - constructor(map: Map) - open(): boolean - close(): void - toString(): string - ondrawend: (event: { type: string, target: any, points: Point[], polylines: Polyline[], distance: number }) => void - } - class DragAndZoomTool { - constructor(map: Map, opts?: DragAndZoomToolOptions) - open(): boolean - close(): void - toString(): string - ondrawend: (event: { type: string, target: any, bounds: Bounds[] }) => void - } - interface DragAndZoomToolOptions { - zoomType?: ZoomType, - autoClose?: boolean, - followText?: string - } - type ZoomType = number -} -declare const BMAP_ZOOM_IN: BMap.ZoomType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + class PushpinTool { + constructor(map: Map, opts?: PushpinToolOptions) + open(): boolean + close(): boolean + setIcon(icon: Icon): Icon + getIcon(): Icon + setCursor(cursor: string): string + getCursor(): string + toString(): string + onmarkend: (event: { type: string, target: any, marker: Marker }) => void + } + interface PushpinToolOptions { + icon?: Icon + cursor?: string + followText?: string + } + class DistanceTool { + constructor(map: Map) + open(): boolean + close(): void + toString(): string + ondrawend: (event: { type: string, target: any, points: Point[], polylines: Polyline[], distance: number }) => void + } + class DragAndZoomTool { + constructor(map: Map, opts?: DragAndZoomToolOptions) + open(): boolean + close(): void + toString(): string + ondrawend: (event: { type: string, target: any, bounds: Bounds[] }) => void + } + interface DragAndZoomToolOptions { + zoomType?: ZoomType, + autoClose?: boolean, + followText?: string + } + type ZoomType = number +} +declare const BMAP_ZOOM_IN: BMap.ZoomType declare const BMAP_ZOOM_OUT: BMap.ZoomType \ No newline at end of file diff --git a/types/baidumap-web-sdk/index.d.ts b/types/baidumap-web-sdk/index.d.ts index cfab71e884..ac8f27c87b 100644 --- a/types/baidumap-web-sdk/index.d.ts +++ b/types/baidumap-web-sdk/index.d.ts @@ -1,28 +1,28 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// \ No newline at end of file +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/types/baidumap-web-sdk/tslint.json b/types/baidumap-web-sdk/tslint.json new file mode 100644 index 0000000000..aab43caa1d --- /dev/null +++ b/types/baidumap-web-sdk/tslint.json @@ -0,0 +1,15 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // All are TODOs + "eofline": false, + "comment-format": false, + "dt-header": false, + "max-line-length": false, + "member-access": false, + "no-namespace": false, + "no-useless-files": false, + "no-var": false, + "semicolon": false + } +} diff --git a/types/bittorrent-protocol/index.d.ts b/types/bittorrent-protocol/index.d.ts index b5ef1a4a44..7c205edc33 100644 --- a/types/bittorrent-protocol/index.d.ts +++ b/types/bittorrent-protocol/index.d.ts @@ -81,7 +81,7 @@ declare namespace BittorrentProtocol { // TODO: bitfield is a bitfield instance on(event: 'bitfield', listener: (bitfield: any) => void): this; - on(event: string | 'keep-alive' | 'choke' | 'unchoke' | 'interested' | 'uninterested' | 'timeout', listener: () => void): this; + on(event: 'keep-alive' | 'choke' | 'unchoke' | 'interested' | 'uninterested' | 'timeout', listener: () => void): this; on(event: 'upload' | 'have' | 'download' | 'port', listener: (length: number) => void): this; on(event: 'handshake', listener: (infoHash: string, peerId: string, extensions: Extension[]) => void): this; on(event: 'request', listener: (index: number, offset: number, length: number, respond: () => void) => void): this; @@ -89,6 +89,7 @@ declare namespace BittorrentProtocol { on(event: 'cancel', listener: (index: number, offset: number, length: number) => void): this; on(event: 'extended', listener: (ext: 'handshake' | string, buf: any) => void): void; on(event: 'unknownmessage', listener: (buffer: Buffer) => void): this; + on(event: string, listener: (...args: any[]) => void): this; } } diff --git a/types/blue-tape/index.d.ts b/types/blue-tape/index.d.ts index 133968a165..c2d2d50ab5 100644 --- a/types/blue-tape/index.d.ts +++ b/types/blue-tape/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/spion/blue-tape // Definitions by: Haoqun Jiang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/bluebird-global/index.d.ts b/types/bluebird-global/index.d.ts index 835bc59c31..c0e220ce07 100644 --- a/types/bluebird-global/index.d.ts +++ b/types/bluebird-global/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/petkaantonov/bluebird // Definitions by: d-ph // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /* * 1. Why use `bluebird-global` instead of `bluebird`? @@ -117,19 +118,19 @@ declare global { * * @todo Duplication of code is never ideal. See whether there's a better way of achieving this. */ - catch(predicate: (error: any) => boolean, onReject: (error: any) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable): Bluebird; - catch(predicate: Object, onReject: (error: any) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; + catch(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Bluebird; + catch(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike): Bluebird; + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => T | PromiseLike | void | PromiseLike): Bluebird; + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | PromiseLike): Bluebird; + catch(predicate: Object, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Bluebird; + catch(predicate: Object, onReject: (error: any) => U | PromiseLike): Bluebird; } /* * Patch all static methods and the constructor */ interface PromiseConstructor { - new (callback: (resolve: (thenableOrResult?: T | Bluebird.Thenable) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Promise; + new (callback: (resolve: (thenableOrResult?: T | PromiseLike) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Promise; // all: typeof Bluebird.all; any: typeof Bluebird.any; diff --git a/types/bluebird-retry/index.d.ts b/types/bluebird-retry/index.d.ts index 63adc1476d..97d756524b 100644 --- a/types/bluebird-retry/index.d.ts +++ b/types/bluebird-retry/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jut-io/bluebird-retry // Definitions by: Pascal Vomhoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 5d1d5cfc81..451b23fa02 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/petkaantonov/bluebird // Definitions by: Leonard Hecker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /*! * The code following this comment originates from: @@ -34,30 +35,29 @@ * THE SOFTWARE. */ -declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection { +declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. * If promise cancellation is enabled, passed in function will receive one more function argument `onCancel` that allows to register an optional cancellation callback. */ - constructor(callback: (resolve: (thenableOrResult?: R | Bluebird.Thenable) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void); + constructor(callback: (resolve: (thenableOrResult?: R | PromiseLike) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void); /** * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. */ - then(onFulfill: (value: R) => U1 | Bluebird.Thenable, onReject: (error: any) => U2 | Bluebird.Thenable): Bluebird; - then(onFulfill: (value: R) => U | Bluebird.Thenable, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - then(onFulfill: (value: R) => U | Bluebird.Thenable): Bluebird; - then(): Bluebird; + // Based on PromiseLike.then, but returns a Bluebird instance. + then(onFulfill?: (value: R) => U | Bluebird.Thenable, onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; // For simpler signature help. + then(onfulfilled?: ((value: R) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Bluebird; /** * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ - catch(onReject?: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - caught(onReject?: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; - caught(onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; + catch(onReject?: (error: any) => R | PromiseLike | void | PromiseLike): Bluebird; + caught(onReject?: (error: any) => R | PromiseLike | void | PromiseLike): Bluebird; + catch(onReject?: (error: any) => U | PromiseLike): Bluebird; + caught(onReject?: (error: any) => U | PromiseLike): Bluebird; /** * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. @@ -74,7 +74,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -82,7 +82,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -90,7 +90,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -98,7 +98,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, ): Bluebird; catch( @@ -106,106 +106,106 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => U | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => U | Bluebird.Thenable, + onReject: (error: E1 | E2) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => U | Bluebird.Thenable, + onReject: (error: E1 | E2) => U | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => U | Bluebird.Thenable, + onReject: (error: E1) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => U | Bluebird.Thenable, + onReject: (error: E1) => U | PromiseLike, ): Bluebird; /** * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. */ - error(onReject: (reason: any) => U | Bluebird.Thenable): Bluebird; + error(onReject: (reason: any) => U | PromiseLike): Bluebird; /** * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. * * Alias `.lastly();` for compatibility with earlier ECMAScript version. */ - finally(handler: () => U | Bluebird.Thenable): Bluebird; + finally(handler: () => U | PromiseLike): Bluebird; - lastly(handler: () => U | Bluebird.Thenable): Bluebird; + lastly(handler: () => U | PromiseLike): Bluebird; /** * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. @@ -215,19 +215,19 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(onFulfilled?: (value: R) => U | Bluebird.Thenable, onRejected?: (error: any) => U | Bluebird.Thenable): void; + done(onFulfilled?: (value: R) => U | PromiseLike, onRejected?: (error: any) => U | PromiseLike): void; /** * Like `.finally()`, but not called for rejections. */ - tap(onFulFill: (value: R) => Bluebird.Thenable): Bluebird; + tap(onFulFill: (value: R) => PromiseLike): Bluebird; tap(onFulfill: (value: R) => U): Bluebird; /** * Like `.catch()` but rethrows the error * TODO: disallow non-objects */ - tapCatch(onReject: (error?: any) => U | Bluebird.Thenable): Bluebird; + tapCatch(onReject: (error?: any) => U | PromiseLike): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -235,29 +235,29 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => U | Bluebird.Thenable, + onReject: (error: E1 | E2) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => U | Bluebird.Thenable, + onReject: (error: E1) => U | PromiseLike, ): Bluebird; /** @@ -488,7 +488,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(fulfilledHandler: (...values: W[]) => U | Bluebird.Thenable): Bluebird; + spread(fulfilledHandler: (...values: W[]) => U | PromiseLike): Bluebird; spread(fulfilledHandler: Function): Bluebird; /** @@ -525,29 +525,29 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(mapper: (item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + map(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; /** * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - filter(filterer: (item: U, index: number, arrayLength: number) => boolean | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + filter(filterer: (item: U, index: number, arrayLength: number) => boolean | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Same as calling ``Bluebird.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - each(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + each(iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * Same as calling ``Bluebird.mapSeries(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - mapSeries(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + mapSeries(iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * Cancel this `promise`. Will not do anything if this promise is already settled or if the cancellation feature has not been enabled @@ -568,8 +568,8 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(fn: () => R | Bluebird.Thenable): Bluebird; - static attempt(fn: () => R | Bluebird.Thenable): Bluebird; + static try(fn: () => R | PromiseLike): Bluebird; + static attempt(fn: () => R | PromiseLike): Bluebird; /** * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. @@ -581,7 +581,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection; - static resolve(value: R | Bluebird.Thenable): Bluebird; + static resolve(value: R | PromiseLike): Bluebird; /** * Create a promise that is rejected with the given `reason`. @@ -597,7 +597,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(value: R | Bluebird.Thenable): Bluebird; + static cast(value: R | PromiseLike): Bluebird; /** * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. @@ -619,7 +619,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(ms: number, value: R | Bluebird.Thenable): Bluebird; + static delay(ms: number, value: R | PromiseLike): Bluebird; static delay(ms: number): Bluebird; /** @@ -671,13 +671,13 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4, Bluebird.Thenable | T5]): Bluebird<[T1, T2, T3, T4, T5]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4]): Bluebird<[T1, T2, T3, T4]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3]): Bluebird<[T1, T2, T3]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2]): Bluebird<[T1, T2]>; - static all(values: [Bluebird.Thenable | T1]): Bluebird<[T1]>; + static all(values: [PromiseLike | T1, PromiseLike | T2, PromiseLike | T3, PromiseLike | T4, PromiseLike | T5]): Bluebird<[T1, T2, T3, T4, T5]>; + static all(values: [PromiseLike | T1, PromiseLike | T2, PromiseLike | T3, PromiseLike | T4]): Bluebird<[T1, T2, T3, T4]>; + static all(values: [PromiseLike | T1, PromiseLike | T2, PromiseLike | T3]): Bluebird<[T1, T2, T3]>; + static all(values: [PromiseLike | T1, PromiseLike | T2]): Bluebird<[T1, T2]>; + static all(values: [PromiseLike | T1]): Bluebird<[T1]>; // array with values - static all(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; + static all(values: PromiseLike<(PromiseLike | R)[]> | (PromiseLike | R)[]): Bluebird; /** * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. @@ -695,14 +695,14 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; + static any(values: PromiseLike<(PromiseLike | R)[]> | (PromiseLike | R)[]): Bluebird; /** * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. * * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. */ - static race(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; + static race(values: PromiseLike<(PromiseLike | R)[]> | (PromiseLike | R)[]): Bluebird; /** * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. @@ -712,11 +712,11 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, count: number): Bluebird; + static some(values: PromiseLike[]>, count: number): Bluebird; // promise of array with values - static some(values: Bluebird.Thenable, count: number): Bluebird; + static some(values: PromiseLike, count: number): Bluebird; // array with promises of value - static some(values: Bluebird.Thenable[], count: number): Bluebird; + static some(values: PromiseLike[], count: number): Bluebird; // array with values static some(values: R[], count: number): Bluebird; @@ -729,15 +729,15 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(arg1: A1 | Bluebird.Thenable, handler: (arg1: A1) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2, arg3: A3) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, arg5: A5 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | Bluebird.Thenable): Bluebird; + static join(arg1: A1 | PromiseLike, handler: (arg1: A1) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, handler: (arg1: A1, arg2: A2) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, arg4: A4 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, arg4: A4 | PromiseLike, arg5: A5 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike): Bluebird; // variadic array /** @deprecated use .all instead */ - static join(...values: (R | Bluebird.Thenable)[]): Bluebird; + static join(...values: (R | PromiseLike)[]): Bluebird; /** * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. @@ -747,16 +747,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: PromiseLike[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; // promise of array with values - static map(values: Bluebird.Thenable, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: PromiseLike, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; // array with promises of value - static map(values: Bluebird.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: PromiseLike[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; // array with values - static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. @@ -766,16 +766,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: PromiseLike[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; // promise of array with values - static reduce(values: Bluebird.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: PromiseLike, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; // array with promises of value - static reduce(values: Bluebird.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: PromiseLike[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; // array with values - static reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; /** * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. @@ -785,16 +785,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: PromiseLike[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; // promise of array with values - static filter(values: Bluebird.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: PromiseLike, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; // array with promises of value - static filter(values: Bluebird.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: PromiseLike[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; // array with values - static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; /** * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. @@ -802,11 +802,11 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static each(values: PromiseLike[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; // array with promises of value - static each(values: Bluebird.Thenable[], iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static each(values: PromiseLike[], iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; // array with values OR promise of array with values - static each(values: R[] | Bluebird.Thenable, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static each(values: R[] | PromiseLike, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order. @@ -815,7 +815,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: (R | Bluebird.Thenable)[] | Bluebird.Thenable<(R | Bluebird.Thenable)[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static mapSeries(values: (R | PromiseLike)[] | PromiseLike<(R | PromiseLike)[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`. @@ -827,16 +827,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection) => void | Bluebird.Thenable): Bluebird.Disposer; + disposer(disposeFn: (arg: R, promise: Bluebird) => void | PromiseLike): Bluebird.Disposer; /** * In conjunction with `.disposer`, using will make sure that no matter what, the specified disposer * will be called when the promise returned by the callback passed to using has settled. The disposer is * necessary because there is no standard interface in node for disposing resources. */ - static using(disposer: Bluebird.Disposer, executor: (transaction: R) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, disposer3: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => Bluebird.Thenable): Bluebird; + static using(disposer: Bluebird.Disposer, executor: (transaction: R) => PromiseLike): Bluebird; + static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2) => PromiseLike): Bluebird; + static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, disposer3: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike): Bluebird; /** * Add handler as the handler to call when there is a possibly unhandled rejection. @@ -891,7 +891,7 @@ declare namespace Bluebird { suffix?: string; filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean; // The promisifier gets a reference to the original method and should return a function which returns a promise - promisifier?: (originalMethod: Function) => () => Thenable; + promisifier?: (originalMethod: Function) => () => PromiseLike; } /** @@ -951,10 +951,8 @@ declare namespace Bluebird { export class Disposer { } - export interface Thenable { - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => void | Thenable): Thenable; - } + /** @deprecated Use PromiseLike directly. */ + export type Thenable = PromiseLike; export interface Resolver { /** diff --git a/types/bookshelf/index.d.ts b/types/bookshelf/index.d.ts index a7c0a90536..55be61ba9e 100644 --- a/types/bookshelf/index.d.ts +++ b/types/bookshelf/index.d.ts @@ -2,7 +2,7 @@ // Project: http://bookshelfjs.org/ // Definitions by: Andrew Schurman , Vesa Poikajärvi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import Knex = require('knex'); import knex = require('knex'); diff --git a/types/browserify/index.d.ts b/types/browserify/index.d.ts index 6d03c76efe..8b51a34dd5 100644 --- a/types/browserify/index.d.ts +++ b/types/browserify/index.d.ts @@ -36,13 +36,22 @@ interface FileOptions { // for each file in a bundle. type InputFile = string | NodeJS.ReadableStream | FileOptions; +/** + * Core options pertaining to a Browserify instance, extended by user options + */ +interface CustomOptions { + /** + * Custom properties can be defined on Options. + * These options are forwarded along to module-deps and browser-pack directly. + */ + [propName: string]: any; + /** the directory that Browserify starts bundling from for filenames that start with .. */ + basedir?: string; +} /** * Options pertaining to a Browserify instance. */ -interface Options { - // Custom properties can be defined on Options. - // These options are forwarded along to module-deps and browser-pack directly. - [propName: string]: any; +interface Options extends CustomOptions { // String, file object, or array of those types (they may be mixed) specifying entry file(s). entries?: InputFile | InputFile[]; // an array which will skip all require() and global parsing for each file in the array. @@ -51,8 +60,6 @@ interface Options { // an array of optional extra extensions for the module lookup machinery to use when the extension has not been specified. // By default Browserify considers only .js and .json files in such cases. extensions?: string[]; - // the directory that Browserify starts bundling from for filenames that start with .. - basedir?: string; // an array of directories that Browserify searches when looking for modules which are not referenced using relative path. // Can be absolute or relative to basedir. Equivalent of setting NODE_PATH environmental variable when calling Browserify command. paths?: string[]; @@ -115,32 +122,32 @@ interface BrowserifyObject extends NodeJS.EventEmitter { * If file is an array, each item in file will be externalized. * If file is another bundle, that bundle's contents will be read and excluded from the current bundle as the bundle in file gets bundled. */ - external(file: string[], opts?: { basedir?: string }): BrowserifyObject; - external(file: string, opts?: { basedir?: string }): BrowserifyObject; + external(file: string[], opts?: CustomOptions): BrowserifyObject; + external(file: string, opts?: CustomOptions): BrowserifyObject; external(file: BrowserifyObject): BrowserifyObject; /** * Prevent the module name or file at file from showing up in the output bundle. * Instead you will get a file with module.exports = {}. */ - ignore(file: string, opts?: { basedir?: string }): BrowserifyObject; + ignore(file: string, opts?: CustomOptions): BrowserifyObject; /** * Prevent the module name or file at file from showing up in the output bundle. * If your code tries to require() that file it will throw unless you've provided another mechanism for loading it. */ - exclude(file: string, opts?: { basedir?: string }): BrowserifyObject; + exclude(file: string, opts?: CustomOptions): BrowserifyObject; /** * Transform source code before parsing it for require() calls with the transform function or module name tr. * If tr is a function, it will be called with tr(file) and it should return a through-stream that takes the raw file contents and produces the transformed source. * If tr is a string, it should be a module name or file path of a transform module */ - transform(tr: string, opts?: T): BrowserifyObject; - transform(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject; + transform(tr: string, opts?: T): BrowserifyObject; + transform(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject; /** * Register a plugin with opts. Plugins can be a string module name or a function the same as transforms. * plugin(b, opts) is called with the Browserify instance b. */ - plugin(plugin: string, opts?: T): BrowserifyObject; - plugin(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject; + plugin(plugin: string, opts?: T): BrowserifyObject; + plugin(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject; /** * Reset the pipeline back to a normal state. This function is called automatically when bundle() is called multiple times. * This function triggers a 'reset' event. diff --git a/types/bunyan-config/index.d.ts b/types/bunyan-config/index.d.ts index 49b642eaa1..0ff84fd9d2 100644 --- a/types/bunyan-config/index.d.ts +++ b/types/bunyan-config/index.d.ts @@ -7,6 +7,23 @@ declare module "bunyan-config" { import * as bunyan from "bunyan"; + interface StreamConfiguration { + name: string, + params?: { + host: string, + port: number + } + } + + interface Stream { + type?: string; + level?: bunyan.LogLevel; + path?: string; + stream?: string | StreamConfiguration + closeOnExit?: boolean; + period?: string; + count?: number; + } /** * Configuration. @@ -14,7 +31,7 @@ declare module "bunyan-config" { */ interface Configuration { name: string; - streams?: bunyan.Stream[]; + streams?: Stream[]; level?: string | number; stream?: NodeJS.WritableStream; serializers?: {}; diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 9a74dc1e53..b42ebabae3 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -1097,7 +1097,7 @@ declare namespace CodeMirror { * Both modes get to parse all of the text, but when both assign a non-null style to a piece of code, the overlay wins, unless * the combine argument was true and not overridden, or state.overlay.combineTokens was true, in which case the styles are combined. */ - function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode + function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode; /** * async specifies that the lint process runs asynchronously. hasGutters specifies that lint errors should be displayed in the CodeMirror @@ -1114,13 +1114,20 @@ declare namespace CodeMirror { * linter. */ interface LintOptions extends LintStateOptions { - getAnnotations: AnnotationsCallback; + getAnnotations: Linter | AsyncLinter; + } + + /** + * A function that return errors found during the linting process. + */ + interface Linter { + (content: string, options: LintStateOptions, codeMirror: Editor): Annotation[] | PromiseLike; } /** * A function that calls the updateLintingCallback with any errors found during the linting process. */ - interface AnnotationsCallback { + interface AsyncLinter { (content: string, updateLintingCallback: UpdateLintingCallback, options: LintStateOptions, codeMirror: Editor): void; } diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index 41b7170fd1..e283abe974 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -28,7 +28,7 @@ var lintStateOptions: CodeMirror.LintStateOptions = { hasGutters: true }; -var lintOptions: CodeMirror.LintOptions = { +var asyncLintOptions: CodeMirror.LintOptions = { async: true, hasGutters: true, getAnnotations: (content: string, @@ -37,6 +37,14 @@ var lintOptions: CodeMirror.LintOptions = { codeMirror: CodeMirror.Editor) => {} }; +var syncLintOptions: CodeMirror.LintOptions = { + async: false, + hasGutters: true, + getAnnotations: (content: string, + options: CodeMirror.LintStateOptions, + codeMirror: CodeMirror.Editor): CodeMirror.Annotation[] => { return []; } +}; + var updateLintingCallback: CodeMirror.UpdateLintingCallback = (codeMirror: CodeMirror.Editor, annotations: CodeMirror.Annotation[]) => {}; diff --git a/types/collections/collections-tests.ts b/types/collections/collections-tests.ts new file mode 100644 index 0000000000..b7feef3c05 --- /dev/null +++ b/types/collections/collections-tests.ts @@ -0,0 +1,32 @@ +import SortedSet = require('collections/sorted-set'); + +interface Person { + name: string; +} + +let set = new SortedSet( + [{name: 'John'}, {name: 'Jack'}, {name: 'Linda'}], + (a: Person, b: Person) => a.name === b.name, + (a: Person, b: Person) => { + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } + return 0; + } +); + +let p1: Person | undefined = set.max(); +let p2: Person | undefined = set.min(); + + +set.push({name: 'Laurie'}, {name: 'Max'}); +set.pop(); + +set.get({name: 'Laurie'}); +set.has({name: 'John'}); + +let a = 1; +set.forEach((p: Person) => a++); \ No newline at end of file diff --git a/types/collections/index.d.ts b/types/collections/index.d.ts new file mode 100644 index 0000000000..8a92df0f2d --- /dev/null +++ b/types/collections/index.d.ts @@ -0,0 +1,133 @@ +// Type definitions for collections v5.0.6 +// Project: http://www.collectionsjs.com/ +// Definitions by: Scarabe Dore +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'collections/sorted-set' { + namespace internal { + // TODO: These methods can be similar in others collection. One's should make some + // class model. + abstract class AbstractSet { + union(...plus: any[]): any; + intersection(...plus: any[]): any; + difference(...plus: any[]): any; + symmetricDifference(...plus: any[]): any; + remove(...plus: any[]): any; + contains(...plus: any[]): any; + toggle(...plus: any[]): any; + addEach(...plus: any[]): any; + deleteEach(...plus: any[]): any; + deleteAll(...plus: any[]): any; + findValue(...plus: any[]): any; + iterator(...plus: any[]): any; + forEach(...plus: any[]): any; + map(...plus: any[]): any; + + filter(...plus: any[]): any; + group(...plus: any[]): any; + some(...plus: any[]): any; + every(...plus: any[]): any; + any(...plus: any[]): any; + all(...plus: any[]): any; + only(...plus: any[]): any; + sorted(...plus: any[]): any; + reversed(...plus: any[]): any; + join(...plus: any[]): any; + sum(...plus: any[]): any; + average(...plus: any[]): any; + zip(...plus: any[]): any; + enumerate(...plus: any[]): any; + concat(...plus: any[]): any; + flatten(...plus: any[]): any; + toArray(...plus: any[]): any; + toObject(...plus: any[]): any; + toJSON(...plus: any[]): any; + equals(...plus: any[]): any; + clone(...plus: any[]): any; + contentCompare(...plus: any[]): any; + contentEquals(...plus: any[]): any; + sortedSetLog(...plus: any[]): any; + addRangeChangeListener(...plus: any[]): any; + removeRangeChangeListener(...plus: any[]): any; + dispatchRangeChange(...plus: any[]): any; + addBeforeRangeChangeListener(...plus: any[]): any; + removeBeforeRangeChangeListener(...plus: any[]): any; + dispatchBeforeRangeChange(...plus: any[]): any; + addOwnPropertyChangeListener(...plus: any[]): any; + addBeforeOwnPropertyChangeListener(...plus: any[]): any; + removeOwnPropertyChangeListener(...plus: any[]): any; + removeBeforeOwnPropertyChangeListener(...plus: any[]): any; + dispatchOwnPropertyChange(...plus: any[]): any; + dispatchBeforeOwnPropertyChange(...plus: any[]): any; + makePropertyObservable(...plus: any[]): any; + } + + class Node { + reduce(cb: (result?: any, val?: any, key?: any, collection?: any) => any, + basis: any, index: number, thisp: any, tree: any, depth: number): any; + touch(...plus: any[]): void; + checkIntegrity(...plus: any[]): number; + getNext(...plus: any[]): Node | undefined; + getPrevious(...plus: any[]): Node | undefined; + summary(...plus: any[]): string; + log(charmap: any, logNode: any, log: any, logAbove: any): any; + } + + class Iterator { + next(): {done: true, value: T | null | undefined}; + } + + export class SortedSet extends AbstractSet { + constructor( + values?: T[], + equals?: (a: T, b: T) => boolean, + compare?: (a: T, b: T) => number, + getDefault?: any + ); + constructClone(values?: T[]): SortedSet; + + add(value: T): boolean; + clear(): void; + ['delete'](value: T): boolean; + + find(value: T): Node | undefined; + findGreatest(n?: Node | undefined): Node | undefined; + findGreatestLessThan(value: T): Node | undefined; + findGreatestLessThanOrEqual(value: T): Node | undefined; + findLeast(n?: Node | undefined): Node | undefined; + findLeastGreaterThan(value: T): Node | undefined; + findLeastGreaterThanOrEqual(value: T): Node | undefined; + max(n?: Node): T | undefined; + min(n?: Node): T | undefined; + one(): T | undefined; + + get(elt: T): T | undefined; + has(elt: T): boolean; + indexOf(value: T): number; + + pop(): T | undefined; + push(...rest: T[]): void; + + shift(): T | undefined; + unshift(...rest: T[]): void; + + slice(start?: number, end?: number): T[]; + splice(start: Node, length: number, ...values: T[]): T[]; + swap(start: number, length: number, values?: T[]): T[]; + + splay(value: T): void; + splayIndex(index: number): boolean; + + reduce(callback: (result?: any, val?: any, key?: any, collection?: any) => any, + basis?: any, thisp?: any): any; + reduceRight( + callback: (result?: any, val?: any, key?: any, collection?: any) => any, + basis?: any, thisp?: any + ): any; + + iterate(start: number, stop: number): Iterator; + } + } + + export = internal.SortedSet; +} diff --git a/types/collections/tsconfig.json b/types/collections/tsconfig.json new file mode 100644 index 0000000000..6b5293a242 --- /dev/null +++ b/types/collections/tsconfig.json @@ -0,0 +1,16 @@ +{ + "files": [ + "collections-tests.ts", + "index.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": ["es6"], + "forceConsistentCasingInFileNames": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "noEmit": true + } +} diff --git a/types/consolidate/index.d.ts b/types/consolidate/index.d.ts index 2a0adb1db9..bfe432214f 100644 --- a/types/consolidate/index.d.ts +++ b/types/consolidate/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/visionmedia/consolidate.js // Definitions by: Carlos Ballesteros Velasco , Theo Sherry , Nicolas Henry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 // Imported from: https://github.com/soywiz/typescript-node-definitions/consolidate.d.ts diff --git a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts index d717e85ea4..1497eec386 100644 --- a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts +++ b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts @@ -1,10 +1,10 @@ // InAppBrowser plugin -//---------------------------------------------------------------------- +// ---------------------------------------------------------------------- // signature of window.open() added by InAppBrowser plugin // is similar to native window.open signature, so the compiler can's // select proper overload, but we cast result to InAppBrowser manually. -var iab = window.open('google.com', '_self'); +const iab = window.open('google.com', '_self'); iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); }); iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); }); @@ -30,5 +30,5 @@ iab.removeEventListener('exit', inAppBrowserCallBack); iab.show(); iab.executeScript( { code: "console.log('Injected script in action')" }, - ()=> { console.log('Script is executed'); } -); \ No newline at end of file + () => { console.log('Script is executed'); } +); diff --git a/types/cordova-plugin-inappbrowser/index.d.ts b/types/cordova-plugin-inappbrowser/index.d.ts index 91dc61314f..b266fbab44 100644 --- a/types/cordova-plugin-inappbrowser/index.d.ts +++ b/types/cordova-plugin-inappbrowser/index.d.ts @@ -1,40 +1,14 @@ -// Type definitions for Apache Cordova InAppBrowser plugin +// Type definitions for Apache Cordova InAppBrowser plugin 1.7 // Project: https://github.com/apache/cordova-plugin-inappbrowser // Definitions by: Microsoft Open Technologies Inc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// +// // Copyright (c) Microsoft Open Technologies Inc // Licensed under the MIT license. // TypeScript Version: 2.3 +type channel = "loadstart" | "loadstop" | "loaderror" | "exit"; interface Window { - /** - * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. - * @param url The URL to load. - * @param target The target in which to load the URL, an optional parameter that defaults to _self. - * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. - * The options string must not contain any blank space, and each feature's - * name/value pairs must be separated by a comma. Feature names are case insensitive. - */ - open(url: string, target?: "_self", options?: string): InAppBrowser; - /** - * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. - * @param url The URL to load. - * @param target The target in which to load the URL, an optional parameter that defaults to _self. - * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. - * The options string must not contain any blank space, and each feature's - * name/value pairs must be separated by a comma. Feature names are case insensitive. - */ - open(url: string, target?: "_blank", options?: string): InAppBrowser; - /** - * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. - * @param url The URL to load. - * @param target The target in which to load the URL, an optional parameter that defaults to _self. - * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. - * The options string must not contain any blank space, and each feature's - * name/value pairs must be separated by a comma. Feature names are case insensitive. - */ - open(url: string, target?: "_system", options?: string): InAppBrowser; /** * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. * @param url The URL to load. @@ -51,10 +25,10 @@ interface Window { * NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs. */ interface InAppBrowser extends Window { - onloadstart: (type: InAppBrowserEvent) => void; - onloadstop: (type: InAppBrowserEvent) => void; - onloaderror: (type: InAppBrowserEvent) => void; - onexit: (type: InAppBrowserEvent) => void; + onloadstart(type: InAppBrowserEvent): void; + onloadstop(type: InAppBrowserEvent): void; + onloaderror(type: InAppBrowserEvent): void; + onexit(type: InAppBrowserEvent): void; // addEventListener overloads /** * Adds a listener for an event from the InAppBrowser. @@ -65,7 +39,7 @@ interface InAppBrowser extends Window { * @param callback the function that executes when the event fires. The function is * passed an InAppBrowserEvent object as a parameter. */ - addEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void; + addEventListener(type: channel, callback: (event: InAppBrowserEvent) => void): void; // removeEventListener overloads /** * Removes a listener for an event from the InAppBrowser. @@ -77,7 +51,7 @@ interface InAppBrowser extends Window { * @param callback the function that executes when the event fires. The function is * passed an InAppBrowserEvent object as a parameter. */ - removeEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void; + removeEventListener(type: channel, callback: (event: InAppBrowserEvent) => void): void; /** Closes the InAppBrowser window. */ close(): void; /** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */ @@ -96,29 +70,13 @@ interface InAppBrowser extends Window { * For multi-line scripts, this is the return value of the last statement, * or the last expression evaluated. */ - executeScript(script: { code: string }, callback: (result: any) => void): void; - /** - * Injects JavaScript code into the InAppBrowser window. - * @param script Details of the script to run, specifying either a file or code key. - * @param callback The function that executes after the JavaScript code is injected. - * If the injected script is of type code, the callback executes with - * a single parameter, which is the return value of the script, wrapped in an Array. - * For multi-line scripts, this is the return value of the last statement, - * or the last expression evaluated. - */ - executeScript(script: { file: string }, callback: (result: any) => void): void; + executeScript(script: { code: string } | { file: string }, callback: (result: any) => void): void; /** * Injects CSS into the InAppBrowser window. * @param css Details of the script to run, specifying either a file or code key. * @param callback The function that executes after the CSS is injected. */ - insertCSS(css: { code: string }, callback: () => void): void; - /** - * Injects CSS into the InAppBrowser window. - * @param css Details of the script to run, specifying either a file or code key. - * @param callback The function that executes after the CSS is injected. - */ - insertCSS(css: { file: string }, callback: () => void): void; + insertCSS(css: { code: string } | { file: string }, callback: () => void): void; } interface InAppBrowserEvent extends Event { @@ -130,4 +88,8 @@ interface InAppBrowserEvent extends Event { code: number; /** the error message, only in the case of loaderror. */ message: string; -} \ No newline at end of file +} + +interface Cordova { + InAppBrowser: InAppBrowser; +} diff --git a/types/cordova-plugin-inappbrowser/tslint.json b/types/cordova-plugin-inappbrowser/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cordova-plugin-inappbrowser/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/core-js/core-js-tests.ts b/types/core-js/core-js-tests.ts index 3f585db33e..325ff56fc1 100644 --- a/types/core-js/core-js-tests.ts +++ b/types/core-js/core-js-tests.ts @@ -243,15 +243,15 @@ promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint); promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => point); promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => point); promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => promiseLikeOfPoint); -promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => { }); -promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => { }); +promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => { throw e; }); +promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => { throw e; }); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => point3d); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => point3d); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => promiseLikeOfPoint3D); -promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => { }); -promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => { }); +promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => { throw e; }); +promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => { throw e; }); promiseOfPoint.then((point: Point) => { }); promiseOfPoint = promiseOfPoint.then(); promiseOfPoint = promiseOfPoint.then(p => point); @@ -262,9 +262,9 @@ promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => point); promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => point); promiseOfPoint = promiseOfPoint.then(p => point, e => promiseOfPoint); promiseOfPoint = promiseOfPoint.then(p => point, e => promiseLikeOfPoint); -promiseOfPoint = promiseOfPoint.then(p => point, e => { }); -promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => { }); -promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => { }); +promiseOfPoint = promiseOfPoint.then(p => point, e => { throw e; }); +promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => { throw e; }); +promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => { throw e; }); promiseOfPoint3D = promiseOfPoint.then(p => point3d); promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D); promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D); @@ -273,16 +273,16 @@ promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => point3d); promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => point3d); promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => promiseOfPoint3D); promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => promiseLikeOfPoint3D); -promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => { }); -promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => { }); -promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => { }); +promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => { throw e; }); +promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => { throw e; }); +promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => { throw e; }); promiseOfPoint = promiseOfPoint.catch(e => point); promiseOfPoint = promiseOfPoint.catch(e => promiseOfPoint); promiseOfPoint = promiseOfPoint.catch(e => promiseLikeOfPoint); -promiseOfPoint = promiseOfPoint.catch(e => { }); -promiseOfPoint3D = promiseOfPoint.catch(e => point3d); -promiseOfPoint3D = promiseOfPoint.catch(e => promiseOfPoint3D); -promiseOfPoint3D = promiseOfPoint.catch(e => promiseLikeOfPoint3D); +promiseOfPoint = promiseOfPoint.catch(e => { throw e; }); +promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => point3d); +promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => promiseOfPoint3D); +promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => promiseLikeOfPoint3D); promiseOfPoint = new Promise((resolve, reject) => resolve(point)); promiseOfPoint = new Promise((resolve, reject) => resolve(promiseOfPoint)); promiseOfPoint = new Promise((resolve, reject) => resolve(promiseLikeOfPoint)); diff --git a/types/datatables.net/datatables.net-tests.ts b/types/datatables.net/datatables.net-tests.ts index ada38d5a21..8ec7ecb084 100644 --- a/types/datatables.net/datatables.net-tests.ts +++ b/types/datatables.net/datatables.net-tests.ts @@ -60,12 +60,35 @@ $(document).ready(function () { sort: "asc" }; - var colRenderFunc: DataTables.FunctionColumnRender = function (data, type, row, meta) { + var colRenderFunc: DataTables.FunctionColumnRender = (data: any, type: 'filter' | 'display' | 'type' | 'sort' | undefined | any, row: any, meta: DataTables.CellMetaSettings): any => { meta.col; meta.row; meta.settings; + switch (type) { + case undefined: + return data.value; + case 'filter': + return data.filterValue; + case 'display': + return data.displayValue; + case 'type': + return data.typeValue; + case 'sort': + return data.sortValue; + default: + // Extensibility: the render type can be a custom value, useful for plugins that require custom rendering. + // Custom values are declared as any. + return data.valueForPlugin; + } }; + colRenderFunc({}, 'filter', {}, null); + colRenderFunc({}, 'display', {}, null); + colRenderFunc({}, 'type', {}, null); + colRenderFunc({}, 'sort', {}, null); + colRenderFunc({}, undefined, {}, null); + colRenderFunc({}, 'custom value', {}, null); + var col: DataTables.ColumnSettings = { cellType: "th", diff --git a/types/datatables.net/index.d.ts b/types/datatables.net/index.d.ts index bb55b54722..37c57198c9 100644 --- a/types/datatables.net/index.d.ts +++ b/types/datatables.net/index.d.ts @@ -1604,7 +1604,7 @@ declare namespace DataTables { } interface FunctionColumnRender { - (data: any, t: string, row: any, meta: CellMetaSettings): void; + (data: any, type: 'filter' | 'display' | 'type' | 'sort' | undefined | any, row: any, meta: CellMetaSettings): any; } interface CellMetaSettings { diff --git a/types/db-migrate-base/index.d.ts b/types/db-migrate-base/index.d.ts index de3a4c0812..a881fa6a06 100644 --- a/types/db-migrate-base/index.d.ts +++ b/types/db-migrate-base/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/db-migrate/db-migrate-base // Definitions by: nickiannone // Definitions: https://github.com/nickiannone/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/db-migrate-pg/index.d.ts b/types/db-migrate-pg/index.d.ts index 7804f4ddad..6a72fd1109 100644 --- a/types/db-migrate-pg/index.d.ts +++ b/types/db-migrate-pg/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/db-migrate/pg // Definitions by: nickiannone // Definitions: https://github.com/nickiannone/DefinitelyTyped +// TypeScript Version: 2.3 import * as pg from "pg"; import * as DbMigrateBase from "db-migrate-base"; diff --git a/types/electron-settings/v2/electron-settings-tests.ts b/types/electron-settings/v2/electron-settings-tests.ts index 38e37e6ba0..25404c90b3 100644 --- a/types/electron-settings/v2/electron-settings-tests.ts +++ b/types/electron-settings/v2/electron-settings-tests.ts @@ -1,4 +1,4 @@ -import * as settings from 'electron-settings'; +import settings = require('electron-settings'); function test_configure() { settings.configure({ @@ -59,6 +59,7 @@ async function test_clear() { function test_clearSync() { settings.clearSync() === undefined; } + async function test_applyDefaults() { await settings.applyDefaults({ overwrite: true }) === undefined; } @@ -100,3 +101,23 @@ function test_on_write() { console.log(); }) === settings; } + +function test_settings_type_annotation(s: typeof settings) { + s.getSettingsFilePath(); +} + +function test_observer_type_annotation(observer: settings.Observer) { + observer.dispose(); +} + +function test_options_type_annotation(options: settings.Options) { + options.atomicSaving; +} + +function test_applyDefaultOptions_type_annotation(options: settings.ApplyDefaultsOptions) { + options.overwrite; +} + +function test_changeEvent_type_annotation(e: settings.ChangeEvent) { + e.oldValue === e.newValue; +} diff --git a/types/electron-settings/v2/index.d.ts b/types/electron-settings/v2/index.d.ts index ead5250015..71677cb0df 100644 --- a/types/electron-settings/v2/index.d.ts +++ b/types/electron-settings/v2/index.d.ts @@ -6,7 +6,10 @@ /// -import * as EventEmitter from 'events'; +import { EventEmitter } from 'events'; + +declare const SettingsInstance: Settings; +export = SettingsInstance; /** * The Settings class. @@ -17,7 +20,7 @@ declare class Settings extends EventEmitter { * * @throws if options is not an object. */ - configure(options: ElectronSettings.Options | object): void; + configure(options: ElectronSettings.Options.Param): void; /** * Globally configures default settings. @@ -76,14 +79,14 @@ declare class Settings extends EventEmitter { * @throws if options is not an object. * @see setSync */ - set(keyPath: string, value: any, options?: ElectronSettings.Options | object): Promise; + set(keyPath: string, value: any, options?: ElectronSettings.Options.Param): Promise; /** * The synchronous version of set(). * * @see set */ - setSync(keyPath: string, value: any, options?: ElectronSettings.Options | object): void; + setSync(keyPath: string, value: any, options?: ElectronSettings.Options.Param): void; /** * Deletes the key and value at the chosen key path. @@ -94,14 +97,14 @@ declare class Settings extends EventEmitter { * @throws if options is not an object. * @see deleteSync */ - delete(keyPath: string, options?: ElectronSettings.Options | object): Promise; + delete(keyPath: string, options?: ElectronSettings.Options.Param): Promise; /** * The synchronous version of delete(). * * @see delete */ - deleteSync(keyPath: string, options?: ElectronSettings.Options | object): void; + deleteSync(keyPath: string, options?: ElectronSettings.Options.Param): void; /** * Clears the entire settings object. @@ -110,14 +113,14 @@ declare class Settings extends EventEmitter { * @throws if options is not an object. * @see clearSync */ - clear(options?: ElectronSettings.Options | object): Promise; + clear(options?: ElectronSettings.Options.Param): Promise; /** * The synchronous version of clear(). * * @see clear */ - clearSync(options?: ElectronSettings.Options | object): void; + clearSync(options?: ElectronSettings.Options.Param): void; /** * Applies defaults to the current settings object (deep). @@ -130,14 +133,14 @@ declare class Settings extends EventEmitter { * @see defaults * @see applyDefaultsSync */ - applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions | object): Promise; + applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions.Param): Promise; /** * The synchronous version of applyDefaults(). * * @see applyDefaults */ - applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions | object): void; + applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions.Param): void; /** * Resets all settings to defaults. @@ -148,14 +151,14 @@ declare class Settings extends EventEmitter { * @see defaults * @see resetToDefaultsSync */ - resetToDefaults(options?: ElectronSettings.Options | object): Promise; + resetToDefaults(options?: ElectronSettings.Options.Param): Promise; /** * The synchronous version of resetToDefaults(). * * @see resetToDefaults */ - resetToDefaultsSync(options?: ElectronSettings.Options | object): void; + resetToDefaultsSync(options?: ElectronSettings.Options.Param): void; /** * Observes the chosen key path for changes and calls the handler if the value changes. @@ -187,8 +190,12 @@ declare class Settings extends EventEmitter { on(event: 'write', listener: () => void): this; } -declare const SettingsInstance: Settings; -export = SettingsInstance; +declare namespace SettingsInstance { + type Observer = ElectronSettings.Observer; + type Options = ElectronSettings.Options; + type ApplyDefaultsOptions = ElectronSettings.ApplyDefaultsOptions; + type ChangeEvent = ElectronSettings.ChangeEvent; +} declare namespace ElectronSettings { /** @@ -205,6 +212,8 @@ declare namespace ElectronSettings { interface Options extends Pick { } namespace Options { + type Param = Options | object; + interface _Impl { /** * Whether electron-settings should create a tmp file during save to ensure data-write consistency. @@ -224,6 +233,8 @@ declare namespace ElectronSettings { interface ApplyDefaultsOptions extends Pick { } namespace ApplyDefaultsOptions { + type Param = ApplyDefaultsOptions | object; + interface _Impl extends Options._Impl { /** * Overwrite pre-existing settings with their respective default values. diff --git a/types/fetch.io/fetch.io-tests.ts b/types/fetch.io/fetch.io-tests.ts index 538da8e74b..67c2612fdc 100644 --- a/types/fetch.io/fetch.io-tests.ts +++ b/types/fetch.io/fetch.io-tests.ts @@ -57,3 +57,8 @@ request .post('') .send({}) .json(); + +request + .post('') + .append('key', 'value') + .append({key: 'value'}); diff --git a/types/fetch.io/index.d.ts b/types/fetch.io/index.d.ts index 8258cbf8da..fabbbc4b52 100644 --- a/types/fetch.io/index.d.ts +++ b/types/fetch.io/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for fetch.io 3.1 +// Type definitions for fetch.io 4.0 // Project: https://github.com/haoxins/fetch.io // Definitions by: newraina // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -95,7 +95,9 @@ export class Request { /** * ppend formData */ - append(key: string, value: string): this; + append(key: string, value: any): this; + + append(object: {[key: string]: any}): this; /** * Get Response directly diff --git a/types/ffmpeg-static/ffmpeg-static-tests.ts b/types/ffmpeg-static/ffmpeg-static-tests.ts new file mode 100644 index 0000000000..319a5e27f8 --- /dev/null +++ b/types/ffmpeg-static/ffmpeg-static-tests.ts @@ -0,0 +1,3 @@ +import * as ffmpegStatic from 'ffmpeg-static'; + +ffmpegStatic.path; diff --git a/types/ffmpeg-static/index.d.ts b/types/ffmpeg-static/index.d.ts new file mode 100644 index 0000000000..dfd9ce0906 --- /dev/null +++ b/types/ffmpeg-static/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ffmpeg-static 2.0 +// Project: https://github.com/eugeneware/ffmpeg-static#readme +// Definitions by: Steve Tran +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ You can declare properties of the module using const, let, or var */ +/** + * Binary location + */ +export const path: string; diff --git a/types/ffmpeg-static/tsconfig.json b/types/ffmpeg-static/tsconfig.json new file mode 100644 index 0000000000..94c7a336b8 --- /dev/null +++ b/types/ffmpeg-static/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", + "ffmpeg-static-tests.ts" + ] +} diff --git a/types/ffmpeg-static/tslint.json b/types/ffmpeg-static/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ffmpeg-static/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ffprobe-static/ffprobe-static-tests.ts b/types/ffprobe-static/ffprobe-static-tests.ts new file mode 100644 index 0000000000..6565fd2ae1 --- /dev/null +++ b/types/ffprobe-static/ffprobe-static-tests.ts @@ -0,0 +1,3 @@ +import * as ffprobeStatic from 'ffmpeg-static'; + +ffprobeStatic.path; diff --git a/types/ffprobe-static/index.d.ts b/types/ffprobe-static/index.d.ts new file mode 100644 index 0000000000..b337d85e38 --- /dev/null +++ b/types/ffprobe-static/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ffprobe-static 2.0 +// Project: https://github.com/joshwnj/ffprobe-static +// Definitions by: Steve Tran +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ You can declare properties of the module using const, let, or var */ +/** + * Binary location + */ +export const path: string; diff --git a/types/ffprobe-static/tsconfig.json b/types/ffprobe-static/tsconfig.json new file mode 100644 index 0000000000..726a8e0feb --- /dev/null +++ b/types/ffprobe-static/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", + "ffprobe-static-tests.ts" + ] +} diff --git a/types/ffprobe-static/tslint.json b/types/ffprobe-static/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ffprobe-static/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts index 46e623207a..b17cb07e32 100644 --- a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts +++ b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts @@ -1,47 +1,48 @@ import fs = require('fs-extra-promise-es6'); import stream = require('stream'); -var stats: fs.Stats; -var str: string; -var strArr: string[]; -var bool: boolean; -var num: number; -var src: string; -var dest: string; -var file: string; -var filename: string; -var dir: string; -var path: string; -var data: any; -var object: Object; -var buffer: NodeBuffer; -var modeNum: number; -var modeStr: string; -var encoding: string; -var type: string; -var flags: string; -var srcpath: string; -var dstpath: string; -var oldPath: string; -var newPath: string; -var cache: string; -var offset: number; -var length: number; -var position: number; -var cacheBool: boolean; -var cacheStr: string; -var fd: number; -var len: number; -var uid: number; -var gid: number; -var atime: number; -var mtime: number; -var statsCallback: (err: Error, stats: fs.Stats) => void; -var errorCallback: (err: Error) => void; -var openOpts: fs.OpenOptions; -var watcher: fs.FSWatcher; -var readStreeam: stream.Readable; -var writeStream: stream.Writable; +let stats: fs.Stats; +let str: string; +let strArr: string[]; +let bool: boolean; +let num: number; +let src: string; +let dest: string; +let file: string; +let filename: string; +let dir: string; +let path: string; +let data: any; +let object: any; +let buffer: NodeBuffer; +let modeNum: number; +let modeStr: string; +let encoding: string; +let type: string; +let flags: string; +let srcpath: string; +let dstpath: string; +let oldPath: string; +let newPath: string; +let cache: string; +let offset: number; +let length: number; +let position: number; +let cacheBool: boolean; +let cacheStr: string; +let fd: number; +let len: number; +let uid: number; +let gid: number; +let atime: number; +let mtime: number; +let statsCallback: (err: Error, stats: fs.Stats) => void; +let errorCallback: (err: Error) => void; +let openOpts: fs.OpenOptions; +let watcher: fs.FSWatcher; +let readStreeam: stream.Readable; +let writeStream: stream.Writable; +let isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -119,13 +120,10 @@ fs.linkSync(srcpath, dstpath); fs.symlink(srcpath, dstpath, type, errorCallback); fs.symlinkSync(srcpath, dstpath, type); fs.readlink(path, (err: Error, linkString: string) => { - }); fs.realpath(path, (err: Error, resolvedPath: string) => { - }); fs.realpath(path, cache, (err: Error, resolvedPath: string) => { - }); str = fs.realpathSync(path, cacheBool); fs.unlink(path, errorCallback); @@ -137,13 +135,11 @@ fs.mkdir(path, modeStr, errorCallback); fs.mkdirSync(path, modeNum); fs.mkdirSync(path, modeStr); fs.readdir(path, (err: Error, files: string[]) => { - }); strArr = fs.readdirSync(path); fs.close(fd, errorCallback); fs.closeSync(fd); fs.open(path, flags, modeStr, (err: Error, fd: number) => { - }); num = fs.openSync(path, flags, modeStr); fs.utimes(path, atime, mtime, errorCallback); @@ -153,24 +149,18 @@ fs.futimesSync(fd, atime, mtime); fs.fsync(fd, errorCallback); fs.fsyncSync(fd); fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { - }); num = fs.writeSync(fd, buffer, offset, length, position); fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { - }); num = fs.readSync(fd, buffer, offset, length, position); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); fs.readFile(filename, encoding, (err: Error, data: string) => { - }); fs.readFile(filename, openOpts, (err: Error, data: string) => { - }); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); buffer = fs.readFileSync(filename); str = fs.readFileSync(filename, encoding); @@ -203,10 +193,8 @@ fs.watchFile(filename, { }); fs.unwatchFile(filename); watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { - }); fs.exists(path, (exists: boolean) => { - }); bool = fs.existsSync(path); @@ -222,3 +210,10 @@ writeStream = fs.createWriteStream(path, { flags: str, encoding: str }); + +let isDirectoryCallback = (err: Error, isDirectory: boolean) => { +}; +fs.isDirectory(path, isDirectoryCallback); +fs.isDirectory(path); +isDirectory = fs.isDirectorySync(path); +fs.isDirectoryAsync(path); diff --git a/types/fs-extra-promise-es6/index.d.ts b/types/fs-extra-promise-es6/index.d.ts index 85055636dc..db262c1460 100644 --- a/types/fs-extra-promise-es6/index.d.ts +++ b/types/fs-extra-promise-es6/index.d.ts @@ -1,158 +1,194 @@ -// Type definitions for fs-extra-promise-es6 +// Type definitions for fs-extra-promise-es6 0.1 // Project: https://github.com/vinsonchuong/fs-extra-promise-es6 -// Definitions by: midknight41 , Jason Swearingen , Joshua DeVinney +// Definitions by: midknight41 +// Jason Swearingen +// Joshua DeVinney +// Hiromi Shikata // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: fs-extra-promise typings (minus Bluebird) -/// - +/// import stream = require("stream"); import fs = require("fs"); -export type Stats = fs.Stats +export type Stats = fs.Stats; export interface FSWatcher { close(): void; } -export declare class ReadStream extends stream.Readable { } -export declare class WriteStream extends stream.Writable { } +export class ReadStream extends stream.Readable { } +export class WriteStream extends stream.Writable { } -//extended methods -export declare function copy(src: string, dest: string, callback?: (err: Error) => void): void; -export declare function copy(src: string, dest: string, filter: (src: string) => boolean, callback?: (err: Error) => void): void; +// extended methods +export function copy(src: string, dest: string, callback?: (err: Error) => void): void; +export function copy(src: string, dest: string, filter: (src: string) => boolean, callback?: (err: Error) => void): void; -export declare function copySync(src: string, dest: string): void; -export declare function copySync(src: string, dest: string, filter: (src: string) => boolean): void; +export function copySync(src: string, dest: string, filter?: (src: string) => boolean): void; -export declare function createFile(file: string, callback?: (err: Error) => void): void; -export declare function createFileSync(file: string): void; +export function createFile(file: string, callback?: (err: Error) => void): void; +export function createFileSync(file: string): void; -export declare function mkdirs(dir: string, callback?: (err: Error) => void): void; -export declare function mkdirp(dir: string, callback?: (err: Error) => void): void; -export declare function mkdirsSync(dir: string): void; -export declare function mkdirpSync(dir: string): void; +export function mkdirs(dir: string, callback?: (err: Error) => void): void; +export function mkdirp(dir: string, callback?: (err: Error) => void): void; +export function mkdirsSync(dir: string): void; +export function mkdirpSync(dir: string): void; -export declare function outputFile(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputFileSync(file: string, data: any): void; +export function outputFile(file: string, data: any, callback?: (err: Error) => void): void; +export function outputFileSync(file: string, data: any): void; -export declare function outputJson(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputJSON(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputJsonSync(file: string, data: any): void; -export declare function outputJSONSync(file: string, data: any): void; +export function outputJson(file: string, data: any, callback?: (err: Error) => void): void; +export function outputJSON(file: string, data: any, callback?: (err: Error) => void): void; +export function outputJsonSync(file: string, data: any): void; +export function outputJSONSync(file: string, data: any): void; -export declare function readJson(file: string, callback?: (err: Error) => void): void; -export declare function readJson(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function readJSON(file: string, callback?: (err: Error) => void): void; -export declare function readJSON(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; +export function readJson(file: string, callback?: (err: Error) => void): void; +export function readJson(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; +export function readJSON(file: string, callback?: (err: Error) => void): void; +export function readJSON(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function readJsonSync(file: string, options?: OpenOptions): void; -export declare function readJSONSync(file: string, options?: OpenOptions): void; +export function readJsonSync(file: string, options?: OpenOptions): void; +export function readJSONSync(file: string, options?: OpenOptions): void; -export declare function remove(dir: string, callback?: (err: Error) => void): void; -export declare function removeSync(dir: string): void; +export function remove(dir: string, callback?: (err: Error) => void): void; +export function removeSync(dir: string): void; // export function delete(dir: string, callback?: (err: Error) => void): void; // export function deleteSync(dir: string): void; -export declare function writeJson(file: string, object: any, callback?: (err: Error) => void): void; -export declare function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeJSON(file: string, object: any, callback?: (err: Error) => void): void; -export declare function writeJSON(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; +export function writeJson(file: string, object: any, callback?: (err: Error) => void): void; +export function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; +export function writeJSON(file: string, object: any, callback?: (err: Error) => void): void; +export function writeJSON(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeJsonSync(file: string, object: any, options?: OpenOptions): void; -export declare function writeJSONSync(file: string, object: any, options?: OpenOptions): void; +export function writeJsonSync(file: string, object: any, options?: OpenOptions): void; +export function writeJSONSync(file: string, object: any, options?: OpenOptions): void; -export declare function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; -export declare function renameSync(oldPath: string, newPath: string): void; -export declare function truncate(fd: number, len: number, callback?: (err: Error) => void): void; -export declare function truncateSync(fd: number, len: number): void; -export declare function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function chownSync(path: string, uid: number, gid: number): void; -export declare function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function fchownSync(fd: number, uid: number, gid: number): void; -export declare function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function lchownSync(path: string, uid: number, gid: number): void; -export declare function chmod(path: string, mode: number, callback?: (err: Error) => void): void; -export declare function chmod(path: string, mode: string, callback?: (err: Error) => void): void; -export declare function chmodSync(path: string, mode: number): void; -export declare function chmodSync(path: string, mode: string): void; -export declare function fchmod(fd: number, mode: number, callback?: (err: Error) => void): void; -export declare function fchmod(fd: number, mode: string, callback?: (err: Error) => void): void; -export declare function fchmodSync(fd: number, mode: number): void; -export declare function fchmodSync(fd: number, mode: string): void; -export declare function lchmod(path: string, mode: string, callback?: (err: Error) => void): void; -export declare function lchmod(path: string, mode: number, callback?: (err: Error) => void): void; -export declare function lchmodSync(path: string, mode: number): void; -export declare function lchmodSync(path: string, mode: string): void; -export declare function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; -export declare function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; -export declare function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): void; -export declare function statSync(path: string): Stats; -export declare function lstatSync(path: string): Stats; -export declare function fstatSync(fd: number): Stats; -export declare function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; -export declare function linkSync(srcpath: string, dstpath: string): void; -export declare function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; -export declare function symlinkSync(srcpath: string, dstpath: string, type?: string): void; -export declare function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; -export declare function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; -export declare function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; -export declare function realpathSync(path: string, cache?: boolean): string; -export declare function unlink(path: string, callback?: (err: Error) => void): void; -export declare function unlinkSync(path: string): void; -export declare function rmdir(path: string, callback?: (err: Error) => void): void; -export declare function rmdirSync(path: string): void; -export declare function mkdir(path: string, mode?: number, callback?: (err: Error) => void): void; -export declare function mkdir(path: string, mode?: string, callback?: (err: Error) => void): void; -export declare function mkdirSync(path: string, mode?: number): void; -export declare function mkdirSync(path: string, mode?: string): void; -export declare function readdir(path: string, callback?: (err: Error, files: string[]) => void): void; -export declare function readdirSync(path: string): string[]; -export declare function close(fd: number, callback?: (err: Error) => void): void; -export declare function closeSync(fd: number): void; -export declare function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; -export declare function openSync(path: string, flags: string, mode?: string): number; -export declare function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; -export declare function utimesSync(path: string, atime: number, mtime: number): void; -export declare function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; -export declare function futimesSync(fd: number, atime: number, mtime: number): void; -export declare function fsync(fd: number, callback?: (err: Error) => void): void; -export declare function fsyncSync(fd: number): void; -export declare function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; -export declare function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; -export declare function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; -export declare function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; -export declare function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void): void; -export declare function readFile(filename: string, options: OpenOptions, callback: (err: Error, data: string) => void): void; -export declare function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void): void; -export declare function readFileSync(filename: string): NodeBuffer; -export declare function readFileSync(filename: string, encoding: string): string; -export declare function readFileSync(filename: string, options: OpenOptions): string; -export declare function writeFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; -export declare function writeFile(filename: string, data: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeFileSync(filename: string, data: any, encoding?: string): void; -export declare function writeFileSync(filename: string, data: any, option?: OpenOptions): void; -export declare function appendFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; -export declare function appendFile(filename: string, data: any, option?: OpenOptions, callback?: (err: Error) => void): void; -export declare function appendFileSync(filename: string, data: any, encoding?: string): void; -export declare function appendFileSync(filename: string, data: any, option?: OpenOptions): void; -export declare function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; -export declare function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; -export declare function unwatchFile(filename: string, listener?: Stats): void; -export declare function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; -export declare function exists(path: string, callback?: (exists: boolean) => void): void; -export declare function existsSync(path: string): boolean; -export declare function ensureDir(path: string, cb: (err: Error) => void): void; -export declare function ensureDirSync(path: string): void; +export function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; +export function renameSync(oldPath: string, newPath: string): void; +export function truncate(fd: number, len: number, callback?: (err: Error) => void): void; +export function truncateSync(fd: number, len: number): void; +export function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; +export function chownSync(path: string, uid: number, gid: number): void; +export function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; +export function fchownSync(fd: number, uid: number, gid: number): void; +export function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; +export function lchownSync(path: string, uid: number, gid: number): void; +export function chmod(path: string, mode: number | string, callback?: (err: Error) => void): void; +export function chmodSync(path: string, mode: number | string): void; +export function fchmod(fd: number, mode: number | string, callback?: (err: Error) => void): void; +export function fchmodSync(fd: number, mode: number | string): void; +export function lchmod(path: string, mode: number | string, callback?: (err: Error) => void): void; +export function lchmodSync(path: string, mode: number | string): void; +export function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; +export function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; +export function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): void; +export function statSync(path: string): Stats; +export function lstatSync(path: string): Stats; +export function fstatSync(fd: number): Stats; +export function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; +export function linkSync(srcpath: string, dstpath: string): void; +export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; +export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; +export function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; +export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; +export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; +export function realpathSync(path: string, cache?: boolean): string; +export function unlink(path: string, callback?: (err: Error) => void): void; +export function unlinkSync(path: string): void; +export function rmdir(path: string, callback?: (err: Error) => void): void; +export function rmdirSync(path: string): void; +export function mkdir(path: string, mode?: number | string, callback?: (err: Error) => void): void; +export function mkdirSync(path: string, mode?: number | string): void; +export function readdir(path: string, callback?: (err: Error, files: string[]) => void): void; +export function readdirSync(path: string): string[]; +export function close(fd: number, callback?: (err: Error) => void): void; +export function closeSync(fd: number): void; +export function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; +export function openSync(path: string, flags: string, mode?: string): number; +export function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; +export function utimesSync(path: string, atime: number, mtime: number): void; +export function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; +export function futimesSync(fd: number, atime: number, mtime: number): void; +export function fsync(fd: number, callback?: (err: Error) => void): void; +export function fsyncSync(fd: number): void; +export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; +export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; +export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; +export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; +/** + * readFile + * @param filename + * @param options + * string: encoding + * OpenOptions: options + * @param callback + */ +export function readFile(filename: string, options: OpenOptions | string, callback: (err: Error, data: string) => void): void; +export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void): void; +export function readFileSync(filename: string): NodeBuffer; +/** + * readFileSync + * @param filename + * @param options + * string: encoding + * OpenOptions: options + */ +export function readFileSync(filename: string, options: OpenOptions | string): string; +/** + * writeFile + * @param filename + * @param data + * @param options + * string: encoding + * OpenOptions: options + * @param callback + */ +export function writeFile(filename: string, data: any, options?: OpenOptions | string, callback?: (err: Error) => void): void; +/** + * writeFileSync + * @param filename + * @param data + * @param option + * string: encoding + * OpenOptions: options + */ +export function writeFileSync(filename: string, data: any, option?: OpenOptions | string): void; +/** + * appendFile + * @param filename + * @param data + * @param option: + * string: encoding + * OpenOptions: options + * @param callback + */ +export function appendFile(filename: string, data: any, option?: OpenOptions | string, callback?: (err: Error) => void): void; +/** + * appendFileSync + * @param filename + * @param data + * @param option + * string: encoding + * OpenOptions: options + */ +export function appendFileSync(filename: string, data: any, option?: OpenOptions | string): void; +export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; +export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; +export function unwatchFile(filename: string, listener?: Stats): void; +export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; +export function exists(path: string, callback?: (exists: boolean) => void): void; +export function existsSync(path: string): boolean; +export function ensureDir(path: string, cb: (err: Error) => void): void; +export function ensureDirSync(path: string): void; export interface OpenOptions { encoding?: string; flag?: string; } -export declare function createReadStream(path: string | Buffer, options?: { +export function createReadStream(path: string | Buffer, options?: { flags?: string; encoding?: string; fd?: number; @@ -161,81 +197,90 @@ export declare function createReadStream(path: string | Buffer, options?: { start?: number; end?: number; }): ReadStream; -export declare function createWriteStream(path: string | Buffer, options?: { +export function createWriteStream(path: string | Buffer, options?: { flags?: string; encoding?: string; fd?: number; mode?: number; }): WriteStream; +// promisified versions +export function copyAsync(src: string, dest: string, filter?: (src: string) => boolean): Promise; +export function createFileAsync(file: string): Promise; -//promisified versions -export declare function copyAsync(src: string, dest: string): Promise; -export declare function copyAsync(src: string, dest: string, filter: (src: string) => boolean): Promise; +export function mkdirsAsync(dir: string): Promise; +export function mkdirpAsync(dir: string): Promise; -export declare function createFileAsync(file: string): Promise; +export function outputFileAsync(file: string, data: any): Promise; -export declare function mkdirsAsync(dir: string): Promise; -export declare function mkdirpAsync(dir: string): Promise; +export function outputJSONAsync(file: string, data: any): Promise; -export declare function outputFileAsync(file: string, data: any): Promise; +export function readJSONAsync(file: string, options?: OpenOptions): Promise; -export declare function outputJsonAsync(file: string, data: any): Promise; -export declare function outputJSONAsync(file: string, data: any): Promise; - -export declare function readJsonAsync(file: string): Promise; -export declare function readJsonAsync(file: string, options?: OpenOptions): Promise; -export declare function readJSONAsync(file: string): Promise; -export declare function readJSONAsync(file: string, options?: OpenOptions): Promise; - - -export declare function removeAsync(dir: string): Promise; +export function removeAsync(dir: string): Promise; // export function deleteAsync(dir: string):Promise; -export declare function writeJsonAsync(file: string, object: any): Promise; -export declare function writeJsonAsync(file: string, object: any, options?: OpenOptions): Promise; -export declare function writeJSONAsync(file: string, object: any): Promise; -export declare function writeJSONAsync(file: string, object: any, options?: OpenOptions): Promise; +export function writeJsonAsync(file: string, object: any, options?: OpenOptions): Promise; +export function writeJSONAsync(file: string, object: any, options?: OpenOptions): Promise; -export declare function renameAsync(oldPath: string, newPath: string): Promise; -export declare function truncateAsync(fd: number, len: number): Promise; -export declare function chownAsync(path: string, uid: number, gid: number): Promise; -export declare function fchownAsync(fd: number, uid: number, gid: number): Promise; -export declare function lchownAsync(path: string, uid: number, gid: number): Promise; -export declare function chmodAsync(path: string, mode: number): Promise; -export declare function chmodAsync(path: string, mode: string): Promise; -export declare function fchmodAsync(fd: number, mode: number): Promise; -export declare function fchmodAsync(fd: number, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: number): Promise; -export declare function statAsync(path: string): Promise; -export declare function lstatAsync(path: string): Promise; -export declare function fstatAsync(fd: number): Promise; -export declare function linkAsync(srcpath: string, dstpath: string): Promise; -export declare function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; -export declare function readlinkAsync(path: string): Promise; -export declare function realpathAsync(path: string): Promise; -export declare function realpathAsync(path: string, cache: string): Promise; -export declare function unlinkAsync(path: string): Promise; -export declare function rmdirAsync(path: string): Promise; -export declare function mkdirAsync(path: string, mode?: number): Promise; -export declare function mkdirAsync(path: string, mode?: string): Promise; -export declare function readdirAsync(path: string): Promise; -export declare function closeAsync(fd: number): Promise; -export declare function openAsync(path: string, flags: string, mode?: string): Promise; -export declare function utimesAsync(path: string, atime: number, mtime: number): Promise; -export declare function futimesAsync(fd: number, atime: number, mtime: number): Promise; -export declare function fsyncAsync(fd: number): Promise; -export declare function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readFileAsync(filename: string, encoding: string): Promise; -export declare function readFileAsync(filename: string, options: OpenOptions): Promise; -export declare function readFileAsync(filename: string): Promise; -export declare function writeFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function writeFileAsync(filename: string, data: any, options?: OpenOptions): Promise; -export declare function appendFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function appendFileAsync(filename: string, data: any, option?: OpenOptions): Promise; +export function renameAsync(oldPath: string, newPath: string): Promise; +export function truncateAsync(fd: number, len: number): Promise; +export function chownAsync(path: string, uid: number, gid: number): Promise; +export function fchownAsync(fd: number, uid: number, gid: number): Promise; +export function lchownAsync(path: string, uid: number, gid: number): Promise; +export function chmodAsync(path: string, mode: number | string): Promise; +export function fchmodAsync(fd: number, mode: number | string): Promise; +export function lchmodAsync(path: string, mode: number | string): Promise; +export function statAsync(path: string): Promise; +export function lstatAsync(path: string): Promise; +export function fstatAsync(fd: number): Promise; +export function linkAsync(srcpath: string, dstpath: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function readlinkAsync(path: string): Promise; +export function realpathAsync(path: string, cache?: string): Promise; +export function unlinkAsync(path: string): Promise; +export function rmdirAsync(path: string): Promise; +export function mkdirAsync(path: string, mode?: number | string): Promise; +export function readdirAsync(path: string): Promise; +export function closeAsync(fd: number): Promise; +export function openAsync(path: string, flags: string, mode?: string): Promise; +export function utimesAsync(path: string, atime: number, mtime: number): Promise; +export function futimesAsync(fd: number, atime: number, mtime: number): Promise; +export function fsyncAsync(fd: number): Promise; +export function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +export function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +/** + * readFileAsync + * @param filename + * @param options: + * string: encoding + * OpenOptions: options + */ +export function readFileAsync(filename: string, options: OpenOptions | string): Promise; +export function readFileAsync(filename: string): Promise; +/** + * writeFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * OpenOptions: options + */ +export function writeFileAsync(filename: string, data: any, options?: OpenOptions | string): Promise; +/** + * appendFileAsync + * @param filename + * @param data + * @param option: + * string: encoding + * OpenOptions: option + */ +export function appendFileAsync(filename: string, data: any, option?: OpenOptions | string): Promise; -export declare function existsAsync(path: string): Promise; -export declare function ensureDirAsync(path: string): Promise; +export function existsAsync(path: string): Promise; +export function ensureDirAsync(path: string): Promise; + +export function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export function isDirectorySync(path: string): boolean; +export function isDirectoryAsync(path: string): Promise; diff --git a/types/fs-extra-promise-es6/tslint.json b/types/fs-extra-promise-es6/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fs-extra-promise-es6/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index ef8de43ad3..9f5a8b32bf 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -1,48 +1,49 @@ import fs = require('fs-extra-promise'); import stream = require('stream'); -var stats: fs.Stats; -var str: string; -var strArr: string[]; -var bool: boolean; -var num: number; -var src: string; -var dest: string; -var file: string; -var filename: string; -var dir: string; -var path: string; -var data: any; -var object: Object; -var buf: Buffer; -var buffer: NodeBuffer; -var modeNum: number; -var modeStr: string; -var encoding: string; -var type: string; -var flags: string; -var srcpath: string; -var dstpath: string; -var oldPath: string; -var newPath: string; -var cache: { [path: string]: string; }; -var offset: number; -var length: number; -var position: number; -var fd: number; -var len: number; -var uid: number; -var gid: number; -var atime: number; -var mtime: number; -var watchListener: (curr: fs.Stats, prev: fs.Stats) => void; -var statsCallback: (err: Error, stats: fs.Stats) => void; -var errorCallback: (err: Error) => void; -var openOpts: fs.ReadOptions; -var writeOpts: fs.WriteOptions; -var watcher: fs.FSWatcher; -var readStream: stream.Readable; -var writeStream: stream.Writable; +let stats: fs.Stats; +let str: string; +let strArr: string[]; +let bool: boolean; +let num: number; +let src: string; +let dest: string; +let file: string; +let filename: string; +let dir: string; +let path: string; +let data: any; +let object: object; +let buf: Buffer; +let buffer: NodeBuffer; +let modeNum: number; +let modeStr: string; +let encoding: string; +let type: string; +let flags: string; +let srcpath: string; +let dstpath: string; +let oldPath: string; +let newPath: string; +let cache: { [path: string]: string; }; +let offset: number; +let length: number; +let position: number; +let fd: number; +let len: number; +let uid: number; +let gid: number; +let atime: number; +let mtime: number; +let watchListener: (curr: fs.Stats, prev: fs.Stats) => void; +let statsCallback: (err: Error, stats: fs.Stats) => void; +let errorCallback: (err: Error) => void; +let openOpts: fs.ReadOptions; +let writeOpts: fs.WriteOptions; +let watcher: fs.FSWatcher; +let readStream: stream.Readable; +let writeStream: stream.Writable; +let isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -122,13 +123,10 @@ fs.linkSync(srcpath, dstpath); fs.symlink(srcpath, dstpath, type, errorCallback); fs.symlinkSync(srcpath, dstpath, type); fs.readlink(path, (err: Error, linkString: string) => { - }); fs.realpath(path, (err: Error, resolvedPath: string) => { - }); fs.realpath(path, cache, (err: Error, resolvedPath: string) => { - }); str = fs.realpathSync(path, cache); fs.unlink(path, errorCallback); @@ -140,13 +138,11 @@ fs.mkdir(path, modeStr, errorCallback); fs.mkdirSync(path, modeNum); fs.mkdirSync(path, modeStr); fs.readdir(path, (err: Error, files: string[]) => { - }); strArr = fs.readdirSync(path); fs.close(fd, errorCallback); fs.closeSync(fd); fs.open(path, flags, modeNum, (err: Error, fd: number) => { - }); num = fs.openSync(path, flags, modeNum); fs.utimes(path, atime, mtime, errorCallback); @@ -156,24 +152,18 @@ fs.futimesSync(fd, atime, mtime); fs.fsync(fd, errorCallback); fs.fsyncSync(fd); fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { - }); num = fs.writeSync(fd, buffer, offset, length, position); fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { - }); num = fs.readSync(fd, buffer, offset, length, position); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); fs.readFile(filename, encoding, (err: Error, data: string) => { - }); fs.readFile(filename, openOpts, (err: NodeJS.ErrnoException, data: Buffer) => { - }); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); buffer = fs.readFileSync(filename); str = fs.readFileSync(filename, encoding); @@ -200,10 +190,8 @@ fs.watchFile(filename, { }, watchListener); fs.unwatchFile(filename); watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { - }); fs.exists(path, (exists: boolean) => { - }); bool = fs.existsSync(path); @@ -219,3 +207,10 @@ writeStream = fs.createWriteStream(path, { flags: str, encoding: str }); + +let isDirectoryCallback = (err: Error, isDirectory: boolean) => { +}; +fs.isDirectory(path, isDirectoryCallback); +fs.isDirectory(path); +isDirectory = fs.isDirectorySync(path); +fs.isDirectoryAsync(path); diff --git a/types/fs-extra-promise/index.d.ts b/types/fs-extra-promise/index.d.ts index b4c9a648ac..9d174f791f 100644 --- a/types/fs-extra-promise/index.d.ts +++ b/types/fs-extra-promise/index.d.ts @@ -1,12 +1,10 @@ // Type definitions for fs-extra-promise 1.0 // Project: https://github.com/overlookmotel/fs-extra-promise -// Definitions by: midknight41 , Jason Swearingen +// Definitions by: midknight41 , Jason Swearingen , Hiromi Shikata // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 /// -/// -/// import * as stream from 'stream'; import { Stats } from 'fs'; @@ -20,73 +18,94 @@ export interface MkdirOptions { mode?: number; } -//promisified versions -export declare function copyAsync(src: string, dest: string): Promise; -export declare function copyAsync(src: string, dest: string, filter: CopyFilter): Promise; -export declare function copyAsync(src: string, dest: string, options: CopyOptions): Promise; +// promisified versions +/** + * copyAsync + * @param src + * @param dest + * @param options + * CopyFilter: filter + * CopyOptions: options + */ +export function copyAsync(src: string, dest: string, options?: CopyFilter | CopyOptions): Promise; -export declare function createFileAsync(file: string): Promise; +export function createFileAsync(file: string): Promise; -export declare function mkdirsAsync(dir: string, options?: MkdirOptions): Promise; -export declare function mkdirpAsync(dir: string, options?: MkdirOptions): Promise; +export function mkdirsAsync(dir: string, options?: MkdirOptions): Promise; +export function mkdirpAsync(dir: string, options?: MkdirOptions): Promise; -export declare function moveAsync(src: string, dest: string, options?: MoveOptions): Promise; +export function moveAsync(src: string, dest: string, options?: MoveOptions): Promise; -export declare function outputFileAsync(file: string, data: any): Promise; +export function outputFileAsync(file: string, data: any): Promise; -export declare function outputJsonAsync(file: string, data: any): Promise; -export declare function outputJSONAsync(file: string, data: any): Promise; +export function outputJsonAsync(file: string, data: any): Promise; +export function outputJSONAsync(file: string, data: any): Promise; -export declare function readJsonAsync(file: string): Promise; -export declare function readJsonAsync(file: string, options?: ReadOptions): Promise; -export declare function readJSONAsync(file: string): Promise; -export declare function readJSONAsync(file: string, options?: ReadOptions): Promise; +export function readJsonAsync(file: string, options?: ReadOptions): Promise; +export function readJSONAsync(file: string, options?: ReadOptions): Promise; -export declare function removeAsync(dir: string): Promise; +export function removeAsync(dir: string): Promise; -export declare function writeJsonAsync(file: string, object: any): Promise; -export declare function writeJsonAsync(file: string, object: any, options?: WriteOptions): Promise; -export declare function writeJSONAsync(file: string, object: any): Promise; -export declare function writeJSONAsync(file: string, object: any, options?: WriteOptions): Promise; +export function writeJsonAsync(file: string, object: any, options?: WriteOptions): Promise; +export function writeJSONAsync(file: string, object: any, options?: WriteOptions): Promise; -export declare function renameAsync(oldPath: string, newPath: string): Promise; -export declare function truncateAsync(fd: number, len: number): Promise; -export declare function chownAsync(path: string, uid: number, gid: number): Promise; -export declare function fchownAsync(fd: number, uid: number, gid: number): Promise; -export declare function lchownAsync(path: string, uid: number, gid: number): Promise; -export declare function chmodAsync(path: string, mode: number): Promise; -export declare function chmodAsync(path: string, mode: string): Promise; -export declare function fchmodAsync(fd: number, mode: number): Promise; -export declare function fchmodAsync(fd: number, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: number): Promise; -export declare function statAsync(path: string): Promise; -export declare function lstatAsync(path: string): Promise; -export declare function fstatAsync(fd: number): Promise; -export declare function linkAsync(srcpath: string, dstpath: string): Promise; -export declare function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; -export declare function readlinkAsync(path: string): Promise; -export declare function realpathAsync(path: string): Promise; -export declare function realpathAsync(path: string, cache: { [path: string]: string }): Promise; -export declare function unlinkAsync(path: string): Promise; -export declare function rmdirAsync(path: string): Promise; -export declare function mkdirAsync(path: string, mode?: number): Promise; -export declare function mkdirAsync(path: string, mode?: string): Promise; -export declare function readdirAsync(path: string): Promise; -export declare function closeAsync(fd: number): Promise; -export declare function openAsync(path: string, flags: string, mode?: string): Promise; -export declare function utimesAsync(path: string, atime: number, mtime: number): Promise; -export declare function futimesAsync(fd: number, atime: number, mtime: number): Promise; -export declare function fsyncAsync(fd: number): Promise; -export declare function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readFileAsync(filename: string, encoding: string): Promise; -export declare function readFileAsync(filename: string, options: ReadOptions): Promise; -export declare function readFileAsync(filename: string): Promise; -export declare function writeFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function writeFileAsync(filename: string, data: any, options?: WriteOptions): Promise; -export declare function appendFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function appendFileAsync(filename: string, data: any, option?: WriteOptions): Promise; +export function renameAsync(oldPath: string, newPath: string): Promise; +export function truncateAsync(fd: number, len: number): Promise; +export function chownAsync(path: string, uid: number, gid: number): Promise; +export function fchownAsync(fd: number, uid: number, gid: number): Promise; +export function lchownAsync(path: string, uid: number, gid: number): Promise; +export function chmodAsync(path: string, mode: number | string): Promise; +export function fchmodAsync(fd: number, mode: number | string): Promise; +export function lchmodAsync(path: string, mode: number | string): Promise; +export function statAsync(path: string): Promise; +export function lstatAsync(path: string): Promise; +export function fstatAsync(fd: number): Promise; +export function linkAsync(srcpath: string, dstpath: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function readlinkAsync(path: string): Promise; +export function realpathAsync(path: string, cache?: { [path: string]: string }): Promise; +export function unlinkAsync(path: string): Promise; +export function rmdirAsync(path: string): Promise; +export function mkdirAsync(path: string, mode?: number | string): Promise; +export function readdirAsync(path: string): Promise; +export function closeAsync(fd: number): Promise; +export function openAsync(path: string, flags: string, mode?: string): Promise; +export function utimesAsync(path: string, atime: number, mtime: number): Promise; +export function futimesAsync(fd: number, atime: number, mtime: number): Promise; +export function fsyncAsync(fd: number): Promise; +export function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +export function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +/** + * readFileAsync + * @param filename + * @param options: + * string: encoding + * ReadOptions: options + */ +export function readFileAsync(filename: string, options: string | ReadOptions): Promise; +export function readFileAsync(filename: string): Promise; +/** + * writeFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * WriteOptions: options + */ +export function writeFileAsync(filename: string, data: any, options?: string | WriteOptions): Promise; +/** + * appendFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * WriteOptions: options + */ +export function appendFileAsync(filename: string, data: any, option?: string | WriteOptions): Promise; -export declare function existsAsync(path: string): Promise; -export declare function ensureDirAsync(path: string): Promise; +export function existsAsync(path: string): Promise; +export function ensureDirAsync(path: string): Promise; + +export function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export function isDirectorySync(path: string): boolean; +export function isDirectoryAsync(path: string): Promise; diff --git a/types/fs-extra-promise/tslint.json b/types/fs-extra-promise/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fs-extra-promise/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/gulp-istanbul/gulp-istanbul-tests.ts b/types/gulp-istanbul/gulp-istanbul-tests.ts index a57932419d..af15f5df54 100644 --- a/types/gulp-istanbul/gulp-istanbul-tests.ts +++ b/types/gulp-istanbul/gulp-istanbul-tests.ts @@ -5,7 +5,7 @@ function testFramework(): NodeJS.ReadWriteStream { return null; } -gulp.task('test', function (cb: Function) { +gulp.task('test', function (cb: () => void) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul()) // Covering files .pipe(gulp.dest('test-tmp/')) @@ -17,7 +17,7 @@ gulp.task('test', function (cb: Function) { }); }); -gulp.task('test', function (cb: Function) { +gulp.task('test', function (cb: () => void) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul({includeUntested: true})) // Covering files .pipe(istanbul.hookRequire()) @@ -29,7 +29,7 @@ gulp.task('test', function (cb: Function) { }); }); -gulp.task('test', function (cb: Function) { +gulp.task('test', function (cb: () => void) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul({includeUntested: true})) // Covering files .pipe(istanbul.hookRequire()) diff --git a/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts b/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts index 9ea2849f1e..f41612c4a5 100644 --- a/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts +++ b/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts @@ -94,4 +94,26 @@ gulp.task('javascript', function() { } })) .pipe(gulp.dest('public/scripts')); +}); + +gulp.task('javascript', function() { + var stream = gulp.src('src/**/*.js') + .pipe(sourcemaps.init()) + .pipe(plugin1()) + .pipe(plugin2()) + .pipe(sourcemaps.write('../maps', { + clone: true + })) + .pipe(gulp.dest('public/scripts')); +}); + +gulp.task('javascript', function() { + var stream = gulp.src('src/**/*.js') + .pipe(sourcemaps.init()) + .pipe(plugin1()) + .pipe(plugin2()) + .pipe(sourcemaps.write('../maps', { + clone: { contents: false } + })) + .pipe(gulp.dest('public/scripts')); }); \ No newline at end of file diff --git a/types/gulp-sourcemaps/index.d.ts b/types/gulp-sourcemaps/index.d.ts index 107c6560c1..8a038af6ec 100644 --- a/types/gulp-sourcemaps/index.d.ts +++ b/types/gulp-sourcemaps/index.d.ts @@ -15,11 +15,17 @@ interface WriteMapper { (file: string): string; } +interface CloneOptions { + contents?: boolean; + deep?: boolean; +} + interface WriteOptions { addComment?: boolean; includeContent?: boolean; sourceRoot?: string | WriteMapper; sourceMappingURLPrefix?: string | WriteMapper; + clone?: boolean | CloneOptions; } export declare function init(opts?: InitOptions): NodeJS.ReadWriteStream; diff --git a/types/gulp-watch/gulp-watch-tests.ts b/types/gulp-watch/gulp-watch-tests.ts index 56a676bc65..de531257a5 100644 --- a/types/gulp-watch/gulp-watch-tests.ts +++ b/types/gulp-watch/gulp-watch-tests.ts @@ -7,7 +7,7 @@ gulp.task('stream', () => .pipe(gulp.dest('build')) ); -gulp.task('callback', (cb: Function) => +gulp.task('callback', (cb: () => void) => watch('css/**/*.css', () => gulp.src('css/**/*.css') .pipe(watch('css/**/*.css')) @@ -25,3 +25,15 @@ gulp.task('build', () => { gulp.src(files, { base: '..' }) .pipe(watch(files, { base: '..' })); }); + +gulp.task('build', () => { + var files = [ + 'app/**/*.ts', + 'lib/**/*.ts', + 'components/**/*.ts', + ]; + + gulp.src(files, { cwd: '..' }) + .pipe(watch(files, { base: '..' })); +}); + diff --git a/types/gulp-watch/index.d.ts b/types/gulp-watch/index.d.ts index de56633491..f9855f09a6 100644 --- a/types/gulp-watch/index.d.ts +++ b/types/gulp-watch/index.d.ts @@ -5,8 +5,9 @@ /// +import {SrcOptions} from "vinyl-fs"; -interface IOptions { +interface IOptions extends SrcOptions { ignoreInitial?: boolean; events?: Array; base?: string; diff --git a/types/hapi/v8/hapi-tests.ts b/types/hapi/v8/hapi-tests.ts index 585e58e100..ee8af0d335 100644 --- a/types/hapi/v8/hapi-tests.ts +++ b/types/hapi/v8/hapi-tests.ts @@ -124,15 +124,5 @@ server.route([{ } }]); -// Implict handler -server.route({ - method: 'GET', - path: '/hello6', - handler: function (request, reply) { - request.log('info', { route: '/hello' }, Date.now()); - reply('hello world'); - } -}); - // Start the server server.start(); diff --git a/types/inline-css/index.d.ts b/types/inline-css/index.d.ts index a6db3ef67b..6d43b7975d 100644 --- a/types/inline-css/index.d.ts +++ b/types/inline-css/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jonkemp/inline-css // Definitions by: Philip Spain // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/java/index.d.ts b/types/java/index.d.ts index 46dc577e35..cf770a8807 100644 --- a/types/java/index.d.ts +++ b/types/java/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/joeferner/node-java // Definitions by: Jim Lloyd , Kentaro Teramoto // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/java/java-tests.ts b/types/java/java-tests.ts index 6d464b36e1..4c79640733 100644 --- a/types/java/java-tests.ts +++ b/types/java/java-tests.ts @@ -1,5 +1,3 @@ -/// - import java = require('java'); import BluePromise = require('bluebird'); @@ -9,7 +7,7 @@ java.asyncOptions = { promiseSuffix: 'P', promisify: BluePromise.promisify }; -// todo: figure out why promise doesn't work here +// todo: figure out why promise doesn't work here /* java.registerClientP((): Promise => { return BluePromise.resolve(); }); */ diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 598d71bc60..cea056ef60 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -25,14 +25,14 @@ // TypeScript Version: 2.3 declare module 'jquery' { - function factory(window: Window): JQueryStatic; + function factory(window: Window): JQueryStatic & JQuery; const factoryOrJQuery: typeof factory & JQueryStatic; export = factoryOrJQuery; } declare module 'jquery/dist/jquery.slim' { - function factory(window: Window): JQueryStatic; + function factory(window: Window): JQueryStatic & JQuery; const factoryOrJQuery: typeof factory & JQueryStatic; export = factoryOrJQuery; @@ -129,7 +129,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxComplete/} * @since 1.0 */ - ajaxComplete(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; + ajaxComplete(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; /** * Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. * @@ -137,7 +137,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxError/} * @since 1.0 */ - ajaxError(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxSettings: JQuery.AjaxSettings, thrownError: string) => void | false): this; + ajaxError(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxSettings: JQuery.AjaxSettings, thrownError: string) => void | false): this; /** * Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. * @@ -145,7 +145,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxSend/} * @since 1.0 */ - ajaxSend(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; + ajaxSend(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; /** * Register a handler to be called when the first Ajax request begins. This is an Ajax Event. * @@ -169,7 +169,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxSuccess/} * @since 1.0 */ - ajaxSuccess(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings, data: JQuery.PlainObject) => void | false): this; + ajaxSuccess(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings, data: JQuery.PlainObject) => void | false): this; /** * Perform a custom animation of a set of CSS properties. * @@ -201,15 +201,22 @@ interface JQuery { * Perform a custom animation of a set of CSS properties. * * @param properties An object of CSS properties and values that the animation will move toward. - * @param duration_easing_complete_options A string or number determining how long the animation will run. - * A string indicating which easing function to use for the transition. - * A function to call once the animation is complete, called once per matched element. - * A map of additional options to pass to the method. + * @param options A map of additional options to pass to the method. * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ animate(properties: JQuery.PlainObject, - duration_easing_complete_options?: JQuery.Duration | string | ((this: TElement) => void) | JQuery.EffectsOptions): this; + options: JQuery.EffectsOptions): this; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param complete A function to call once the animation is complete, called once per matched element. + * @see {@link https://api.jquery.com/animate/} + * @since 1.0 + */ + animate(properties: JQuery.PlainObject, + complete?: (this: TElement) => void): this; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * @@ -516,8 +523,7 @@ interface JQuery { * @see {@link https://api.jquery.com/data/} * @since 1.2.3 */ - // tslint:disable-next-line:unified-signatures - data(key: string, undefined: undefined): any; + data(key: string, undefined: undefined): any; // tslint:disable-line:unified-signatures /** * Store arbitrary data associated with the matched elements. * @@ -693,7 +699,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - fadeIn(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + fadeIn(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display the matched elements by fading them to opaque. * @@ -726,7 +732,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - fadeOut(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + fadeOut(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Hide the matched elements by fading them to transparent. * @@ -780,7 +786,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - fadeToggle(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + fadeToggle(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display or hide the matched elements by animating their opacity. * @@ -933,7 +939,7 @@ interface JQuery { * @see {@link https://api.jquery.com/height/} * @since 1.0 */ - height(): number; + height(): number | undefined; /** * Hide the matched elements. * @@ -1025,7 +1031,7 @@ interface JQuery { * @see {@link https://api.jquery.com/innerHeight/} * @since 1.2.6 */ - innerHeight(): number; + innerHeight(): number | undefined; /** * Set the CSS inner width of each element in the set of matched elements. * @@ -1045,7 +1051,7 @@ interface JQuery { * @see {@link https://api.jquery.com/innerWidth/} * @since 1.2.6 */ - innerWidth(): number; + innerWidth(): number | undefined; /** * Insert every element in the set of matched elements after the target. * @@ -1148,7 +1154,7 @@ interface JQuery { */ load(url: string, data: string | JQuery.PlainObject, - complete: (this: TElement, responseText: string, textStatus: string, jqXHR: JQuery.jqXHR) => void): this; + complete: (this: TElement, responseText: string, textStatus: JQuery.Ajax.TextStatus, jqXHR: JQuery.jqXHR) => void): this; /** * Load data from the server and place the returned HTML into the matched element. * @@ -1159,7 +1165,7 @@ interface JQuery { * @since 1.0 */ load(url: string, - complete_data?: ((this: TElement, responseText: string, textStatus: string, jqXHR: JQuery.jqXHR) => void) | string | JQuery.PlainObject): this; + complete_data?: ((this: TElement, responseText: string, textStatus: JQuery.Ajax.TextStatus, jqXHR: JQuery.jqXHR) => void) | string | JQuery.PlainObject): this; /** * Pass each element in the current matched set through a function, producing a new jQuery object * containing the return values. @@ -1535,7 +1541,7 @@ interface JQuery { * @see {@link https://api.jquery.com/outerHeight/} * @since 1.2.6 */ - outerHeight(includeMargin?: boolean): number; + outerHeight(includeMargin?: boolean): number | undefined; /** * Set the CSS outer width of each element in the set of matched elements. * @@ -1555,7 +1561,7 @@ interface JQuery { * @see {@link https://api.jquery.com/outerWidth/} * @since 1.2.6 */ - outerWidth(includeMargin?: boolean): number; + outerWidth(includeMargin?: boolean): number | undefined; /** * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. * @@ -1610,7 +1616,7 @@ interface JQuery { * @see {@link https://api.jquery.com/prepend/} * @since 1.4 */ - prepend(fn: (this: TElement, elementOfArray: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; + prepend(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; /** * Insert every element in the set of matched elements to the beginning of the target. * @@ -1619,7 +1625,7 @@ interface JQuery { * @see {@link https://api.jquery.com/prependTo/} * @since 1.0 */ - prependTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; + prependTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; /** * Get the immediately preceding sibling of each element in the set of matched elements. If a selector * is provided, it retrieves the previous sibling only if it matches that selector. @@ -1695,8 +1701,7 @@ interface JQuery { * @see {@link https://api.jquery.com/prop/} * @since 1.6 */ - // tslint:disable-next-line:unified-signatures - prop(propertyName: string, value: any): this; + prop(propertyName: string, value: any): this; // tslint:disable-line:unified-signatures /** * Set one or more properties for the set of matched elements. * @@ -1996,7 +2001,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - slideDown(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + slideDown(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display the matched elements with a sliding motion. * @@ -2029,7 +2034,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - slideToggle(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + slideToggle(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display or hide the matched elements with a sliding motion. * @@ -2062,7 +2067,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - slideUp(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + slideUp(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Hide the matched elements with a sliding motion. * @@ -2155,17 +2160,19 @@ interface JQuery { * @see {@link https://api.jquery.com/toggle/} * @since 1.0 */ - toggle(duration: JQuery.Duration, complete?: (this: TElement) => void): this; + toggle(duration: JQuery.Duration, complete: (this: TElement) => void): this; /** * Display or hide the matched elements. * - * @param options A map of additional options to pass to the method. - * Use true to show the element or false to hide it. + * @param duration_complete_options_display A string or number determining how long the animation will run. + * A function to call once the animation is complete, called once per matched element. + * A map of additional options to pass to the method. + * Use true to show the element or false to hide it. * @see {@link https://api.jquery.com/toggle/} * @since 1.0 * @since 1.3 */ - toggle(options?: JQuery.EffectsOptions | boolean): this; + toggle(duration_complete_options_display?: JQuery.Duration | ((this: TElement) => void) | JQuery.EffectsOptions | boolean): this; /** * Add or remove one or more classes from each element in the set of matched elements, depending on * either the class's presence or the value of the state argument. @@ -2179,10 +2186,11 @@ interface JQuery { * @since 1.3 * @since 1.4 */ - toggleClass(className: string | ((this: TElement, index: number, className: string, state: boolean) => string), - state?: boolean): this; + toggleClass(className: string | ((this: TElement, index: number, className: string, state: TState) => string), + state?: TState): this; /** - * + * Add or remove one or more classes from each element in the set of matched elements, depending on + * either the class's presence or the value of the state argument. * * @param state A boolean value to determine whether the class should be added or removed. * @see {@link https://api.jquery.com/toggleClass/} @@ -2316,7 +2324,7 @@ interface JQuery { * @see {@link https://api.jquery.com/width/} * @since 1.0 */ - width(): number; + width(): number | undefined; /** * Wrap an HTML structure around each element in the set of matched elements. * @@ -2356,7 +2364,7 @@ interface JQuery { * @since 1.2 * @since 1.4 */ - wrapInner(wrappingElement: JQuery.htmlString | JQuery.Selector | JQuery | Element | ((this: TElement, index: number) => string)): this; + wrapInner(wrappingElement: JQuery.Selector | JQuery.htmlString | Element | JQuery | ((this: TElement, index: number) => string | Element | JQuery)): this; } interface JQuery extends ArrayLike, Iterable { } @@ -2553,8 +2561,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.data/} * @since 1.2.3 */ - // tslint:disable-next-line:unified-signatures - data(element: Element, key: string, undefined: undefined): any; + data(element: Element, key: string, undefined: undefined): any; // tslint:disable-line:unified-signatures /** * Store arbitrary data associated with the specified element. Returns the value that was set. * @@ -4043,6 +4050,7 @@ declare namespace JQuery { // region Effects type Duration = number | 'fast' | 'slow'; + // TODO: Is the first element always a string or is that specific to the 'fx' queue? type Queue = { 0: string; } & Array>; interface QueueFunction { @@ -4094,7 +4102,7 @@ declare namespace JQuery { * An object containing one or more of the CSS properties defined by the properties argument and their * corresponding easing functions. */ - specialEasing?: PlainObject; + specialEasing?: PlainObject; /** * A function to call when the animation on an element begins. */ diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 09468a1c55..0e2e7ee350 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -9,6 +9,1373 @@ function JQuery() { $('div')[0] === new HTMLElement(); } + function ajax() { + function ajaxComplete() { + // $ExpectType JQuery + $(document).ajaxComplete(function(event, jqXHR, ajaxOptions) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxOptions; + + return false; + }); + } + + function ajaxError() { + // $ExpectType JQuery + $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxSettings; + // $ExpectType string + thrownError; + + return false; + }); + } + + function ajaxSend() { + // $ExpectType JQuery + $(document).ajaxSend(function(event, jqXHR, ajaxOptions) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxOptions; + + return false; + }); + } + + function ajaxStart() { + // $ExpectType JQuery + $(document).ajaxStart(function() { + // $ExpectType Document + this; + + return false; + }); + } + + function ajaxStop() { + // $ExpectType JQuery + $(document).ajaxStop(function() { + // $ExpectType Document + this; + + return false; + }); + } + + function ajaxSuccess() { + // $ExpectType JQuery + $(document).ajaxSuccess(function(event, jqXHR, ajaxOptions, data) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxOptions; + // $ExpectType PlainObject + data; + + return false; + }); + } + + function load() { + // $ExpectType JQuery + $('#result').load('/echo/html/', 'data', function(responseText, textStatus, jqXHR) { + // $ExpectType HTMLElement + this; + // $ExpectType string + responseText; + // $ExpectType TextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType JQuery + $('#result').load('/echo/html/', { data: 'data' }, function(responseText, textStatus, jqXHR) { + // $ExpectType HTMLElement + this; + // $ExpectType string + responseText; + // $ExpectType TextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType JQuery + $('#result').load('/echo/html/', function(responseText, textStatus, jqXHR) { + // $ExpectType HTMLElement + this; + // $ExpectType string + responseText; + // $ExpectType TextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType JQuery + $('#result').load('/echo/html/', 'data'); + + // $ExpectType JQuery + $('#result').load('/echo/html/', { data: 'data' }); + } + } + + function attributes() { + function attr() { + // $ExpectType JQuery + $('#greatphoto').attr('alt', 'Beijing Brush Seller'); + + // $ExpectType JQuery + $('#greatphoto').attr('width', 200); + + // $ExpectType JQuery + $('#greatphoto').attr('title', null); + + // $ExpectType JQuery + $('#greatphoto').attr('alt', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return 'Beijing Brush Seller'; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('width', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return 200; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('title', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('title', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return undefined; + }); + + // $ExpectType JQuery + $('img').attr({ + src: '/resources/hat.gif', + title: 'jQuery', + alt: 'jQuery Logo' + }); + + // $ExpectType string | undefined + $('img').attr('src'); + } + + function removeAttr() { + // $ExpectType JQuery + $('#greatphoto').removeAttr('alt'); + } + } + + function properties() { + function prop() { + // $ExpectType JQuery + $('p').prop('myProp', function(index, oldPropertyValue) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType any + oldPropertyValue; + + return {}; + }); + + // $ExpectType JQuery + $('p').prop('myProp', {}); + + // $ExpectType JQuery + $('input[type=\'checkbox\']').prop({ + myProp: true + }); + + // $ExpectType any + $('input[type=\'checkbox\']').prop('myProp'); + } + + function removeProp() { + // $ExpectType JQuery + $('p').removeProp('luggageCode'); + } + } + + function css() { + // TODO: .css() getters can return 'undefined' for properties that don't exist. Consider changing the return types to reflect this after adding specialized signatures. + function css() { + // $ExpectType JQuery + $('p').css('cssProp', 'value'); + + // $ExpectType JQuery + $('p').css('cssProp', 20); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 'value'; + }); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 20; + }); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + }); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return undefined; + }); + + // $ExpectType JQuery + $('p').css({ + myProp1: 'value', + myProp2: 20, + myProp3(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 'value'; + }, + myProp4(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 20; + }, + myProp5(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + }, + myProp6(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return undefined; + } + }); + + // $ExpectType string + $('p').css('myProp'); + + // $ExpectType PlainObject + $('p').css([ + 'myProp1', + 'myProp2' + ]); + } + + function height() { + // $ExpectType JQuery + $('p').height('200px'); + + // $ExpectType JQuery + $('p').height(400); + + // $ExpectType JQuery + $('p').height(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').height(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return 400; + }); + + // $ExpectType number | undefined + $('p').height(); + } + + function innerHeight() { + // $ExpectType JQuery + $('p').innerHeight('200px'); + + // $ExpectType JQuery + $('p').innerHeight(400); + + // $ExpectType JQuery + $('p').innerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').innerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return 400; + }); + + // $ExpectType number | undefined + $('p').innerHeight(); + } + + function outerHeight() { + // $ExpectType JQuery + $('p').outerHeight('200px'); + + // $ExpectType JQuery + $('p').outerHeight(400); + + // $ExpectType JQuery + $('p').outerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').outerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return 400; + }); + + // $ExpectType number | undefined + $('p').outerHeight(); + + // $ExpectType number | undefined + $('p').outerHeight(true); + } + + function width() { + // $ExpectType JQuery + $('p').width('200px'); + + // $ExpectType JQuery + $('p').width(400); + + // $ExpectType JQuery + $('p').width(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').width(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return 400; + }); + + // $ExpectType number | undefined + $('p').width(); + } + + function innerWidth() { + // $ExpectType JQuery + $('p').innerWidth('200px'); + + // $ExpectType JQuery + $('p').innerWidth(400); + + // $ExpectType JQuery + $('p').innerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').innerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return 400; + }); + + // $ExpectType number | undefined + $('p').innerWidth(); + } + + function outerWidth() { + // $ExpectType JQuery + $('p').outerWidth('200px'); + + // $ExpectType JQuery + $('p').outerWidth(400); + + // $ExpectType JQuery + $('p').outerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').outerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return 400; + }); + + // $ExpectType number | undefined + $('p').outerWidth(); + + // $ExpectType number | undefined + $('p').outerWidth(true); + } + + function offset() { + // $ExpectType JQuery + $('p').offset({ + left: 20, + top: 50 + }); + + // $ExpectType JQuery + $('p').offset(function(index, coords) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType Coordinates + coords; + + return { + left: 20, + top: 50 + }; + }); + + // $ExpectType Coordinates + $('p').offset(); + } + + function position() { + // $ExpectType Coordinates + $('p').position(); + } + + function scrollLeft() { + // $ExpectType JQuery + $('p').scrollLeft(200); + + // $ExpectType number + $('p').scrollLeft(); + } + + function scrollTop() { + // $ExpectType JQuery + $('p').scrollTop(200); + + // $ExpectType number + $('p').scrollTop(); + } + + function addClass() { + // $ExpectType JQuery + $('p').addClass('className'); + + // $ExpectType JQuery + $('p').addClass(function(index, currentClassName) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + currentClassName; + + return 'className'; + }); + } + + function hasClass() { + // $ExpectType boolean + $('p').hasClass('className'); + } + + function removeClass() { + // $ExpectType JQuery + $('p').removeClass('className'); + + // $ExpectType JQuery + $('p').removeClass(function(index, currentClassName) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + currentClassName; + + return 'className'; + }); + + // $ExpectType JQuery + $('p').removeClass(); + } + + function toggleClass() { + // $ExpectType JQuery + $('p').toggleClass('className', true); + + // $ExpectType JQuery + $('p').toggleClass(function(index, className, state) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + className; + // $ExpectType true + state; + + return 'className'; + }, true); + + // $ExpectType JQuery + $('p').toggleClass('className'); + + // $ExpectType JQuery + $('p').toggleClass(function(index, className, state) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + className; + // $ExpectType boolean + state; + + return 'className'; + }); + + // $ExpectType JQuery + $('p').toggleClass(false); + + // $ExpectType JQuery + $('p').toggleClass(); + } + } + + function data() { + function data() { + // $ExpectType any + $('p').data('myData', undefined); + + // $ExpectType JQuery + $('p').data('myData', {}); + + // $ExpectType JQuery + $('p').data({ + myData1: {}, + myData2: false + }); + + // $ExpectType any + $('p').data('myData'); + + // $ExpectType PlainObject + $('p').data(); + } + + function removeData() { + // $ExpectType JQuery + $('p').removeData('myData'); + + // $ExpectType JQuery + $('p').removeData([ + 'myData1', + 'myData2' + ]); + + // $ExpectType JQuery + $('p').removeData(); + } + } + + function effects() { + function animate() { + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000, 'linear', function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000, 'linear'); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000, function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 'linear', function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 'linear'); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: 'toggle', + height: 'toggle' + }, { + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }); + } + + function fadeIn() { + // $ExpectType JQuery + $('p').fadeIn(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn(5000, 'linear'); + + // $ExpectType JQuery + $('p').fadeIn(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn(5000); + + // $ExpectType JQuery + $('p').fadeIn('linear'); + + // $ExpectType JQuery + $('p').fadeIn(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').fadeIn(); + } + + function fadeOut() { + // $ExpectType JQuery + $('p').fadeOut(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut(5000, 'linear'); + + // $ExpectType JQuery + $('p').fadeOut(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut(5000); + + // $ExpectType JQuery + $('p').fadeOut('linear'); + + // $ExpectType JQuery + $('p').fadeOut(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').fadeOut(); + } + + function fadeToggle() { + // $ExpectType JQuery + $('p').fadeToggle(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle(5000, 'linear'); + + // $ExpectType JQuery + $('p').fadeToggle(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle(5000); + + // $ExpectType JQuery + $('p').fadeToggle('linear'); + + // $ExpectType JQuery + $('p').fadeToggle(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').fadeToggle(); + } + + function slideDown() { + // $ExpectType JQuery + $('p').slideDown(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown(5000, 'linear'); + + // $ExpectType JQuery + $('p').slideDown(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown(5000); + + // $ExpectType JQuery + $('p').slideDown('linear'); + + // $ExpectType JQuery + $('p').slideDown(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').slideDown(); + } + + function slideToggle() { + // $ExpectType JQuery + $('p').slideToggle(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle(5000, 'linear'); + + // $ExpectType JQuery + $('p').slideToggle(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle(5000); + + // $ExpectType JQuery + $('p').slideToggle('linear'); + + // $ExpectType JQuery + $('p').slideToggle(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').slideToggle(); + } + + function slideUp() { + // $ExpectType JQuery + $('p').slideUp(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp(5000, 'linear'); + + // $ExpectType JQuery + $('p').slideUp(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp(5000); + + // $ExpectType JQuery + $('p').slideUp('linear'); + + // $ExpectType JQuery + $('p').slideUp(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').slideUp(); + } + + function fadeTo() { + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9, 'linear'); + + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9); + } + + function toggle() { + // $ExpectType JQuery + $('p').toggle(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').toggle(5000, 'linear'); + + // $ExpectType JQuery + $('p').toggle(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').toggle(5000); + + // $ExpectType JQuery + $('p').toggle(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').toggle('linear'); + + // $ExpectType JQuery + $('p').toggle(true); + + // $ExpectType JQuery + $('p').toggle(); + } + + function hide() { + // $ExpectType JQuery + $('p').hide(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').hide(5000, 'linear'); + + // $ExpectType JQuery + $('p').hide(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').hide(5000); + + // $ExpectType JQuery + $('p').hide(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').hide({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').hide(); + } + + function show() { + // $ExpectType JQuery + $('p').show(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').show(5000, 'linear'); + + // $ExpectType JQuery + $('p').show(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').show(5000); + + // $ExpectType JQuery + $('p').show(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').show({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').show(); + } + + function clearQueue() { + // $ExpectType JQuery + $('p').clearQueue('myQueue'); + + // $ExpectType JQuery + $('p').clearQueue(); + } + + function delay() { + // $ExpectType JQuery + $('p').delay('fast', 'myQueue'); + + // $ExpectType JQuery + $('p').delay('slow'); + } + + function dequeue() { + // $ExpectType JQuery + $('p').dequeue('myQueue'); + + // $ExpectType JQuery + $('p').dequeue(); + } + + function finish() { + // $ExpectType JQuery + $('p').finish('myQueue'); + + // $ExpectType JQuery + $('p').finish(); + } + + function queue() { + // $ExpectType JQuery + $('p').queue('myQueue', function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }); + + // $ExpectType JQuery + $('p').queue('myQueue', [ + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }, + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + } + ]); + + // $ExpectType JQuery + $('p').queue(function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }); + + // $ExpectType JQuery + $('p').queue([ + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }, + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + } + ]); + + // $ExpectType Queue + $('p').queue('myQueue'); + + // $ExpectType Queue + $('p').queue(); + } + + function stop() { + // $ExpectType JQuery + $('p').stop('myQueue', true, false); + + // $ExpectType JQuery + $('p').stop('myQueue', true); + + // $ExpectType JQuery + $('p').stop(true, false); + + // $ExpectType JQuery + $('p').stop(true); + } + } + function on() { function false_handler_shorthand() { $().on('events', false); @@ -131,6 +1498,70 @@ function JQueryStatic() { } } +function EffectsOptions() { + $('p').show({ + always(animation, jumpToEnd) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType boolean + jumpToEnd; + }, + complete() { + // $ExpectType HTMLElement + this; + }, + done(animation, jumpToEnd) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType boolean + jumpToEnd; + }, + duration: 5000, + easing: 'linear', + fail(animation, jumpToEnd) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType boolean + jumpToEnd; + }, + progress(animation, progress, remainingMs) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType number + progress; + // $ExpectType number + remainingMs; + }, + queue: true, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + start(animation) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + }, + step(now, tween) { + // $ExpectType HTMLElement + this; + // $ExpectType number + now; + // $ExpectType Tween + tween; + } + }); +} + function JQuery_Event() { function type_guard(e: object) { if (e instanceof JQuery.Event) { @@ -184,7 +1615,9 @@ function jqXHR() { $.ajax('/echo').fail((jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; - // $ExpectType "abort" | "timeout" | "error" | "parsererror" | null + // This test is flaky + // Should be 'ErrorTextStatus | null' and should be able to handle it out of order + // $ExpectType "timeout" | "error" | "abort" | "parsererror" | null textStatus; // $ExpectType string errorThrown; diff --git a/types/jquery/test/example-tests.ts b/types/jquery/test/example-tests.ts index d2c0a8464d..961e239192 100644 --- a/types/jquery/test/example-tests.ts +++ b/types/jquery/test/example-tests.ts @@ -1822,8 +1822,8 @@ function examples() { } function finish_0() { - var horiz = $('#path').width() - 20, - vert = $('#path').height() - 20; + var horiz = $('#path').width()! - 20, + vert = $('#path').height()! - 20; var btns: { [key: string]: () => void; } = { bstt: function() { @@ -1992,13 +1992,13 @@ function examples() { } $('#getp').click(function() { - showHeight('paragraph', $('p').height()); + showHeight('paragraph', $('p').height()!); }); $('#getd').click(function() { - showHeight('document', $(document).height()); + showHeight('document', $(document).height()!); }); $('#getw').click(function() { - showHeight('window', $(window).height()); + showHeight('window', $(window).height()!); }); } @@ -4935,13 +4935,13 @@ function examples() { } $('#getp').click(function() { - showWidth('paragraph', $('p').width()); + showWidth('paragraph', $('p').width()!); }); $('#getd').click(function() { - showWidth('document', $(document).width()); + showWidth('document', $(document).width()!); }); $('#getw').click(function() { - showWidth('window', $(window).width()); + showWidth('window', $(window).width()!); }); } diff --git a/types/jquery/test/jquery-no-window-module-tests.ts b/types/jquery/test/jquery-no-window-module-tests.ts new file mode 100644 index 0000000000..700be9d60c --- /dev/null +++ b/types/jquery/test/jquery-no-window-module-tests.ts @@ -0,0 +1,8 @@ +import jQueryFactory = require('jquery'); + +const jq = jQueryFactory(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQueryStatic' +// // $ExpectType JQueryStatic +// jq; +// jq === jQuery(); +jq === jQuery; diff --git a/types/jquery/test/jquery-slim-no-window-module-tests.ts b/types/jquery/test/jquery-slim-no-window-module-tests.ts new file mode 100644 index 0000000000..fdbd34e06c --- /dev/null +++ b/types/jquery/test/jquery-slim-no-window-module-tests.ts @@ -0,0 +1,8 @@ +import jQueryFactory = require('jquery/dist/jquery.slim'); + +const jq = jQueryFactory(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQueryStatic' +// // $ExpectType JQueryStatic +// jq; +// jq === jQuery(); +jq === jQuery; diff --git a/types/jquery/test/jquery-slim-window-module-tests.ts b/types/jquery/test/jquery-slim-window-module-tests.ts new file mode 100644 index 0000000000..8072811f08 --- /dev/null +++ b/types/jquery/test/jquery-slim-window-module-tests.ts @@ -0,0 +1,8 @@ +import * as jq from 'jquery/dist/jquery.slim'; + +const $window = jq(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQuery' +// // $ExpectType JQuery +// $window; +// $window === jq; +$window === jq(); diff --git a/types/jquery/test/jquery-window-module-tests.ts b/types/jquery/test/jquery-window-module-tests.ts new file mode 100644 index 0000000000..85f2c4c4ea --- /dev/null +++ b/types/jquery/test/jquery-window-module-tests.ts @@ -0,0 +1,8 @@ +import * as jq from 'jquery'; + +const $window = jq(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQuery' +// // $ExpectType JQuery +// $window; +// $window === jq; +$window === jq(); diff --git a/types/jquery/test/module-tests.ts b/types/jquery/test/module-tests.ts deleted file mode 100644 index b55dee0370..0000000000 --- a/types/jquery/test/module-tests.ts +++ /dev/null @@ -1,7 +0,0 @@ -import factory = require('jquery'); -const jq = factory(window); -jq.noop(); - -import slimFactory = require('jquery/dist/jquery.slim'); -const slim = slimFactory(window); -slim.noop(); diff --git a/types/jquery/tsconfig.json b/types/jquery/tsconfig.json index ebfa01c813..21d35a63da 100644 --- a/types/jquery/tsconfig.json +++ b/types/jquery/tsconfig.json @@ -22,6 +22,9 @@ "jquery-tests.ts", "test/example-tests.ts", "test/longdesc-tests.ts", - "test/module-tests.ts" + "test/jquery-no-window-module-tests.ts", + "test/jquery-window-module-tests.ts", + "test/jquery-slim-no-window-module-tests.ts", + "test/jquery-slim-window-module-tests.ts" ] } diff --git a/types/js-data/v1/js-data-tests.ts b/types/js-data/v1/js-data-tests.ts index 0832f066d9..69a056b081 100644 --- a/types/js-data/v1/js-data-tests.ts +++ b/types/js-data/v1/js-data-tests.ts @@ -30,7 +30,7 @@ User.find(1).then(function (user:IUser) { var user:IUser = User.createInstance({name: 'John'}); var store = new JSData.DS(); -var User2 = store.defineResource('user'); +var User2 = store.defineResource('user'); var user:IUser = User2.inject({id: 1, name: 'John'}); var user2:IUser = User2.inject({id: 1, age: 30}); diff --git a/types/jwt-decode/index.d.ts b/types/jwt-decode/index.d.ts index d27cdf91e9..73dacb3c00 100644 --- a/types/jwt-decode/index.d.ts +++ b/types/jwt-decode/index.d.ts @@ -1,15 +1,15 @@ -// Type definitions for jwt-decode v2.2.0 +// Type definitions for jwt-decode 2.2 // Project: https://github.com/auth0/jwt-decode -// Definitions by: Giedrius Grabauskas , Mads Madsen +// Definitions by: Giedrius Grabauskas , Mads Madsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare namespace JwtDecode { - interface JwtDecodeStatic { - (token: string, options?: { header: boolean }): any; + interface Options { + header: boolean; } } -declare var jwtDecode: JwtDecode.JwtDecodeStatic; -export = jwtDecode; -export as namespace jwt_decode; \ No newline at end of file +declare function JwtDecode(token: string, options?: JwtDecode.Options): TTokenDto; + +export = JwtDecode; +export as namespace jwt_decode; diff --git a/types/jwt-decode/jwt-decode-tests.ts b/types/jwt-decode/jwt-decode-tests.ts index 7e65c2a5a4..22bb5cf6cc 100644 --- a/types/jwt-decode/jwt-decode-tests.ts +++ b/types/jwt-decode/jwt-decode-tests.ts @@ -1,7 +1,6 @@ - -import jwtDecode = require('jwt-decode'); - -let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; +import * as jwtDecode from "jwt-decode"; + +const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; interface TokenDto { foo: string; @@ -14,5 +13,7 @@ interface TokenHeaderDto { alg: string; } -let decodedTokenPayload = jwtDecode(token) as TokenDto; -let decodedTokenHeader = jwtDecode(token, { header: true }) as TokenHeaderDto; \ No newline at end of file +const decodedTokenPayloadOld = jwtDecode(token) as TokenDto; +const decodedTokenPayload = jwtDecode(token); +const decodedTokenHeaderOld = jwtDecode(token, { header: true }) as TokenHeaderDto; +const decodedTokenHeader = jwtDecode(token, { header: true }); diff --git a/types/jwt-decode/tsconfig.json b/types/jwt-decode/tsconfig.json index 34ce87d118..8d87ddb618 100644 --- a/types/jwt-decode/tsconfig.json +++ b/types/jwt-decode/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "jwt-decode-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/jwt-decode/tslint.json b/types/jwt-decode/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/jwt-decode/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/jwt-decode/v1/index.d.ts b/types/jwt-decode/v1/index.d.ts new file mode 100644 index 0000000000..10ec01f10f --- /dev/null +++ b/types/jwt-decode/v1/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for jwt-decode 1.4 +// Project: https://github.com/auth0/jwt-decode +// Definitions by: Giedrius Grabauskas +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace JwtDecode { } + +declare function JwtDecode(token: string): TTokenDto; + +export = JwtDecode; +export as namespace jwt_decode; diff --git a/types/jwt-decode/v1/jwt-decode-tests.ts b/types/jwt-decode/v1/jwt-decode-tests.ts new file mode 100644 index 0000000000..f1db120261 --- /dev/null +++ b/types/jwt-decode/v1/jwt-decode-tests.ts @@ -0,0 +1,12 @@ +import jwtDecode = require('jwt-decode'); + +const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; + +interface TokenDto { + foo: string; + exp: number; + iat: number; +} + +const decodedTokenOld = jwtDecode(token) as TokenDto; +const decodedToken = jwtDecode(token); diff --git a/types/jwt-decode/v1/tsconfig.json b/types/jwt-decode/v1/tsconfig.json new file mode 100644 index 0000000000..a0d0dd4f39 --- /dev/null +++ b/types/jwt-decode/v1/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "jwt-decode": [ + "jwt-decode/v1" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jwt-decode-tests.ts" + ] +} diff --git a/types/jwt-decode/v1/tslint.json b/types/jwt-decode/v1/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/jwt-decode/v1/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/kafka-node/index.d.ts b/types/kafka-node/index.d.ts index 46de85286d..89261a3c4d 100644 --- a/types/kafka-node/index.d.ts +++ b/types/kafka-node/index.d.ts @@ -6,11 +6,12 @@ // # Classes export declare class Client { - constructor(connectionString: string, clientId: string, options?: ZKOptions); + constructor(connectionString: string, clientId?: string, options?: ZKOptions); close(callback?: Function): void; topicExists(topics: Array, callback: Function): void; refreshMetadata(topics: Array, cb?: (error: any, data: any) => any): void; close(cb: (error: any) => any): void; + sendOffsetCommitV2Request(group: string, generationId: number, memberId: string, commits: Array, cb: (error: any, data: any) => any): void; } export declare class Producer { @@ -70,6 +71,8 @@ export declare class ConsumerGroup extends HighLevelConsumer { on(eventName: string, cb: (message: string) => any): void; on(eventName: string, cb: (error: any) => any): void; close(force: boolean, cb: (error: any) => any): void; + generationId: number; + memberId: string; } export declare class Offset { diff --git a/types/karma-coverage/index.d.ts b/types/karma-coverage/index.d.ts index 20ee56f43c..03ca857449 100644 --- a/types/karma-coverage/index.d.ts +++ b/types/karma-coverage/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/karma-runner/karma-coverage // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as karma from 'karma'; import * as istanbul from 'istanbul'; diff --git a/types/karma/index.d.ts b/types/karma/index.d.ts index 59590b0a6d..ab4dc9b31f 100644 --- a/types/karma/index.d.ts +++ b/types/karma/index.d.ts @@ -2,8 +2,8 @@ // Project: https://github.com/karma-runner/karma // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -/// /// // See Karma public API https://karma-runner.github.io/0.13/dev/public-api.html @@ -54,7 +54,7 @@ declare namespace karma { }; EXIT_CODE: string; } - + interface LauncherStatic { generateId(): string; //TODO: injector should be of type `di.Injector` diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index fa84243b76..2e301af850 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -2,9 +2,8 @@ // Project: https://github.com/tgriesser/knex // Definitions by: Qubo , Baronfel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 -/// /// import events = require("events"); diff --git a/types/kue/index.d.ts b/types/kue/index.d.ts index afd818c8f2..5a3a08a75a 100644 --- a/types/kue/index.d.ts +++ b/types/kue/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for kue 0.11.x // Project: https://github.com/Automattic/kue // Definitions by: Nicholas Penree +// Amiram Korach // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -29,7 +30,7 @@ export declare class Queue extends events.EventEmitter { checkActiveJobTtl(ttlOptions: Object): void; watchStuckJobs(ms: number): void; setting(name: string, fn: Function): Queue; - process(type: string, n?: number, fn?: Function): void; + process(type: string, n?: number | DoneCallback, fn?: DoneCallback): void; shutdown(timeout: number, type: string, fn: Function): Queue; types(fn: Function): Queue; state(string: string, fn: Function): Queue; @@ -56,17 +57,24 @@ interface Priorities { critical: number; } +export type DoneCallback = (err?: any, result?: any) => void; +export type JobCallback = (err?: any, job?: Job) => void; + export declare class Job extends events.EventEmitter { public id: number; public type: string; public data: any; + public result: any; + // Should always be a number however currently it is a number when creating and a string when loading + // https://github.com/Automattic/kue/issues/1081 + public created_at: string | number; public client: redisClientFactory.RedisClient; private _max_attempts; static priorities: Priorities; static disableSearch: boolean; static jobEvents: boolean; - static get(id: number, fn: Function): void; + static get(id: number, type: string | JobCallback, fn?: JobCallback): void; static remove(id: number, fn?: Function): void; static removeBadJob(id: number): void; static log(id: number, fn: Function): void; @@ -79,6 +87,7 @@ export declare class Job extends events.EventEmitter { log(str: string): Job; set(key: string, val: string, fn?: Function): Job; get(key: string, fn?: Function): Job; + get(key: string, jobType: string, fn?: Function): Job; progress(complete: number, total: number, data?: any): Job; delay(ms: number | Date): Job; removeOnComplete(param: any): Job; diff --git a/types/kue/kue-tests.ts b/types/kue/kue-tests.ts index d69f6eaead..fd929d7aeb 100644 --- a/types/kue/kue-tests.ts +++ b/types/kue/kue-tests.ts @@ -39,6 +39,13 @@ function create() { job.save(); + kue.Job.get(job.id, function (err: any, _job: kue.Job) { + console.log('get job', _job); + }); + kue.Job.get(job.id, 'video conversion', function (err: any, _job: kue.Job) { + console.log('get job', _job); + }); + setTimeout( create, Math.random() * 2000 | 0 ); } @@ -46,25 +53,28 @@ create(); // process video conversion jobs, 1 at a time. -jobs.process('video conversion', 1, function(job: kue.Job, done: Function) { +var processCb = function(job: kue.Job, done: kue.DoneCallback) { var frames: number = job.data.frames; function next(i: number) { // pretend we are doing some work - convertFrame(i, function(err: Error) { + convertFrame(i, function(err: Error, result: any) { if (err) return done(err); // report progress, i/frames complete job.progress(i, frames); - if (i >= frames) done(); + if (i >= frames) done(null, result); else next(i + Math.random() * 10); } ); } next(0); -} ); +} + +jobs.process('video conversion', 1, processCb); +jobs.process('video conversion', processCb); function convertFrame(i: number, fn: Function) { - setTimeout(fn, Math.random() * 50); + setTimeout(() => fn(null, Math.random()), Math.random() * 50); } // one minute @@ -102,4 +112,4 @@ jobs.process('email', 10, function(job: kue.Job, done: Function) { // start the UI kue.app.listen(3000); -console.log('UI started on port 3000'); \ No newline at end of file +console.log('UI started on port 3000'); diff --git a/types/mime/index.d.ts b/types/mime/index.d.ts index 71b4677ac6..7debcca6f3 100644 --- a/types/mime/index.d.ts +++ b/types/mime/index.d.ts @@ -7,7 +7,7 @@ export as namespace mime; -export function lookup(path: string, fallback: string): string; +export function lookup(path: string, fallback?: string): string; export function extension(mime: string): string; export function load(filepath: string): void; export function define(mimes: { [key: string]: any }): void; diff --git a/types/natsort/index.d.ts b/types/natsort/index.d.ts new file mode 100644 index 0000000000..bf448f218d --- /dev/null +++ b/types/natsort/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for natsort 1.0 +// Project: https://github.com/bubkoo/natsort +// Definitions by: Melvin Groenhoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function natsort(options?: natsort.Options): (a: any, b: any) => number; + +declare namespace natsort { + interface Options { + desc?: boolean; + insensitive?: boolean; + } +} + +export = natsort; +export as namespace nasort; diff --git a/types/natsort/natsort-tests.ts b/types/natsort/natsort-tests.ts new file mode 100644 index 0000000000..4e9d0c0fcb --- /dev/null +++ b/types/natsort/natsort-tests.ts @@ -0,0 +1,155 @@ +import * as natsort from "natsort"; + +const someArr = [2, 5, 3, 4, 1, 'a', 'B']; + +someArr.sort(natsort()); +someArr.sort(natsort({ desc: true })); +someArr.sort(natsort({ insensitive: true })); + +// sort with object array +const objArr = [ + { val: 'B' }, + { val: 'a' }, + { val: 'D' }, + { val: 'c' } +]; + +const sorter = natsort(); + +objArr.sort((a, b) => { + return sorter(a.val, b.val); +}); + +// simple numerics +['10', 9, 2, '1', '4'].sort(natsort()); +// ['1',2,'4',9,'10'] + +// floats +[ + '10.0401', + 10.022, + 10.042, + '10.021999' +].sort(natsort()); +// [ +// '10.021999', +// 10.022, +// '10.0401', +// 10.042 +// ] + +// float & decimal notation +[ + '10.04f', + '10.039F', + '10.038d', + '10.037D' +].sort(natsort()); +// [ +// '10.037D', +// '10.038d', +// '10.039F', +// '10.04f' +// ] + +// scientific notation +[ + '1.528535047e5', + '1.528535047e7', + '1.528535047e3' +].sort(natsort()); +// [ +// '1.528535047e3', +// '1.528535047e5', +// '1.528535047e7' +// ] + +// ip addresses +[ + '192.168.0.100', + '192.168.0.1', + '192.168.1.1' +].sort(natsort()); +// [ +// '192.168.0.1', +// '192.168.0.100', +// '192.168.1.1' +// ] + +// Filenames +[ + 'car.mov', + '01alpha.sgi', + '001alpha.sgi', + 'my.string_41299.tif' +].sort(natsort()); +// [ +// '001alpha.sgi', +// '01alpha.sgi', +// 'car.mov', +// 'my.string_41299.tif' +// ] + +// dates +[ + '10/12/2008', + '10/11/2008', + '10/11/2007', + '10/12/2007' +].sort(natsort()); +// [ +// '10/11/2007', +// '10/12/2007', +// '10/11/2008', +// '10/12/2008' +// ] + +// money +[ + '$10002.00', + '$10001.02', + '$10001.01' +].sort(natsort()); +// [ +// '$10001.01', +// '$10001.02', +// '$10002.00' +// ] + +// versions +[ + '1.0.2', + '1.0.1', + '1.0.0', + '1.0.9' +].sort(natsort()); +// [ +// '1.0.0', +// '1.0.1', +// '1.0.2', +// '1.0.9' +// ] + +// movie titles +[ + '1 Title - The Big Lebowski', + '1 Title - Gattaca', + '1 Title - Last Picture Show' +].sort(natsort()); +// [ +// '1 Title - Gattaca', +// '1 Title - Last Picture Show', +// '1 Title - The Big Lebowski' +// ] + +// by default - case-sensitive sorting +['a', 'B'].sort(natsort()); +// ['B', 'a'] + +// enable case-insensitive sorting +['a', 'B'].sort(natsort({ insensitive: true })); +// ['a', 'B'] + +// desc +[4, 2, 3, 5, 1].sort(natsort({ desc: true })); +// [1, 2, 3, 4, 5] diff --git a/types/natsort/tsconfig.json b/types/natsort/tsconfig.json new file mode 100644 index 0000000000..8fd932f326 --- /dev/null +++ b/types/natsort/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", + "natsort-tests.ts" + ] +} diff --git a/types/natsort/tslint.json b/types/natsort/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/natsort/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/node-getopt/index.d.ts b/types/node-getopt/index.d.ts index afd0a89adf..cb08791fc3 100644 --- a/types/node-getopt/index.d.ts +++ b/types/node-getopt/index.d.ts @@ -122,7 +122,7 @@ declare class Getopt { * equals new Getopt(options) * @param options */ - static create(options: string[]): Getopt; + static create(options: string[][]): Getopt; } export = Getopt; diff --git a/types/node-getopt/node-getopt-tests.ts b/types/node-getopt/node-getopt-tests.ts index 7427731ca8..2ba3afd01d 100644 --- a/types/node-getopt/node-getopt-tests.ts +++ b/types/node-getopt/node-getopt-tests.ts @@ -34,7 +34,7 @@ function help() { function onedragon() { // examples/onedragon.js - var opt = require('node-getopt').create([ + var opt = Getopt.create([ ['s' , '' , 'short option.'], ['' , 'long' , 'long option.'], ['S' , 'short-with-arg=ARG' , 'option with argument'], @@ -52,7 +52,7 @@ function onedragon() { function online(){ // node-getopt oneline example. - var opt = require('..').create([ + var opt = Getopt.create([ ['s' , '' , 'short option.'], ['' , 'long' , 'long option.'], ['S' , 'short-with-arg=ARG' , 'option with argument'], diff --git a/types/node-mysql-wrapper/index.d.ts b/types/node-mysql-wrapper/index.d.ts index 7785d8a7b4..c887da3368 100644 --- a/types/node-mysql-wrapper/index.d.ts +++ b/types/node-mysql-wrapper/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/nodets/node-mysql-wrapper // Definitions by: Makis Maropoulos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// @@ -49,20 +50,20 @@ interface IQueryConstructor { declare class Helper { - /** + /** * Callback like forEach * @name valueCallback * @function - * @param {T} the value of the object's key + * @param {T} the value of the object's key * @returnTye {U} * @return {U} */ - + /** * CallbaforEach * @name keyCallback * @function - * @param {string} the name of the object's key + * @param {string} the name of the object's key * @returnTye {U} * @return {U} */ @@ -158,7 +159,7 @@ declare class CriteriaParts implements ICriteriaParts { noDatabaseProperties: string[]; /** - * The converted/exported where clause. + * The converted/exported where clause. */ whereClause: string; @@ -472,7 +473,7 @@ declare class Connection extends EventEmitter { eventTypes: string[]; /** - * Force to fetch ONLY these Database table names {array of string}. + * Force to fetch ONLY these Database table names {array of string}. */ tableNamesToUseOnly: any[]; @@ -495,7 +496,7 @@ declare class Connection extends EventEmitter { * Attach a real connection. * @param {Mysql.IConnection} connection the real connection object. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ attach(connection: Mysql.IConnection): void; @@ -503,13 +504,13 @@ declare class Connection extends EventEmitter { * Close the entire real connection and remove all event's listeners (if exist). * @param {function} callback If error occurs when closing the connection, this callback has the responsibility to catch it. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ end(callback?: (error: any) => void): void; /** * Close the entire real connection and remove all event's listeners (if exist). - * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. + * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. */ destroy(): void; @@ -545,7 +546,7 @@ declare class Connection extends EventEmitter { /** * Escape the query column's value and return it. - * @param {string} val the value which will be escaped. + * @param {string} val the value which will be escaped. * @returnType {string} * @return {string} */ @@ -565,7 +566,7 @@ declare class Connection extends EventEmitter { * Adds an event listener/watcher on a table for a 'database event'. * @param {string} tableName the table name which you want to add the event listener. * @param {string or string[]} evtType the event(s) type you want to watch, one of these(string) or an array of them(string[]): ["INSERT", "UPDATE", "REMOVE", "SAVE"]. - * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawRows (results after query executed and before parsed to object(s)). + * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawRows (results after query executed and before parsed to object(s)). * @returnType {nothing} * @return {nothing} */ @@ -573,7 +574,7 @@ declare class Connection extends EventEmitter { /** * Removes an event listener/watcher from a table for a specific event type. - * @param {string} tableName the table name which you want to remove the event listener. + * @param {string} tableName the table name which you want to remove the event listener. * @param {string} evtType the Event type you want to remove, one of these: "INSERT", "UPDATE", "REMOVE", "SAVE". * @param {function} callbackToRemove the callback that you were used for watch this event type. * @returnType {nothing} @@ -587,13 +588,13 @@ declare class Connection extends EventEmitter { * @param {function} callback the function will be called and fill the one and only parameter when an errors occurs. * @param {any[]} queryArguments (optional) the query arguments you want to pass into query. ['arg1','arg2']... * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ query(queryStr: string, callback: (err: Mysql.IError, results: any) => any, queryArguments?: any[]): void; /** * Returns a MysqlTable object from the database factory. (Note: this method doesn't create anything, just finds and returns the correct table, you don't have to create anything at all. Tables are fetched by the library itself.) - * If you are using typescript you can pass a class (generic) in order to use the auto completion assistance on table's results methods(find,findById,findAll,save,remove,safeRemove). + * If you are using typescript you can pass a class (generic) in order to use the auto completion assistance on table's results methods(find,findById,findAll,save,remove,safeRemove). * @param {string} tableName the table name which you want to get, on the form of: 'anyDatabaseTable' OR 'any_database_table' (possible your real table name into your database). * @returnType {MysqlTable} * @return {MysqlTable} @@ -602,7 +603,7 @@ declare class Connection extends EventEmitter { } declare class Table { - /** Private keywords here are useless but I put them. + /** Private keywords here are useless but I put them. * If the developer wants to see the properties of the Table class, he/she just comes here. */ @@ -630,17 +631,17 @@ declare class Table { primaryKey: string; /** - * The MysqlConnection object which this MysqlTable belongs. + * The MysqlConnection object which this MysqlTable belongs. */ connection: Connection; /** - * The real database name of the table. Autofilled by library. + * The real database name of the table. Autofilled by library. */ name: string; /** - * Set of the query rules that will be applied after the 'where clause' on each select query executed by this table. + * Set of the query rules that will be applied after the 'where clause' on each select query executed by this table. * @return {SelectQueryRules} */ rules: SelectQueryRules; @@ -661,7 +662,7 @@ declare class Table { /** * Adds or turn on an event listener/watcher on a table for a 'database event'. * @param {string} evtType the event type you want to watch, one of these: ["INSERT", "UPDATE", "REMOVE", "SAVE"]. - * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawResults (results after query executed and before exports to object(s)). + * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawResults (results after query executed and before exports to object(s)). * @returnType {nothing} * @return {nothing} */ @@ -689,7 +690,7 @@ declare class Table { * @param {string} functionName the function name you want to use, this is used when you want to call this function later. * @param {function} theFunction the function with any optional parameters you want to pass along. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ extend(functionName: string, theFunction: (...args: any[]) => any): void; @@ -726,9 +727,9 @@ declare class Table { getPrimaryKeyValue(jsObject: any): number | string; /** - * + * */ - find(criteriaRawJsObject: any): Promise; // only criteria + find(criteriaRawJsObject: any): Promise; // only criteria find(criteriaRawJsObject: any, callback: ((_results: T[]) => any)): Promise; // criteria and callback find(criteriaRawJsObject: any, callback?: (_results: T[]) => any): Promise; @@ -792,7 +793,7 @@ declare class Database { /** * Close the entire real connection and remove all event's listeners (if exist). - * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. + * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. */ destroy(): void; @@ -800,7 +801,7 @@ declare class Database { * Close the entire real connection and remove all event's listeners (if exist). * @param {function} maybeAcallbackError If error occurs when closing the connection, this callback has the responsibility to catch it. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ end(maybeAcallbackError: (err: any) => void): void; diff --git a/types/node-static/node-static-tests.ts b/types/node-static/node-static-tests.ts index 4bf2673ab4..471a8fde50 100644 --- a/types/node-static/node-static-tests.ts +++ b/types/node-static/node-static-tests.ts @@ -2,6 +2,6 @@ import {Server, version, mime} from 'node-static'; let server = new Server(__dirname); let pathname = server.resolve('./tsconfig.json'); -let mimetype = mime.lookup(pathname); +let mimetype = mime.lookup(pathname, ''); let versionNum = version.join('.'); console.log(`The node-static server constructed an instance of itself, fetched the mimetype of ${pathname} (${mimetype}), and has a version of ${versionNum}! The package is working.`); diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 022a71313e..815b776e42 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -288,10 +288,10 @@ declare namespace NodeJS { } export class EventEmitter { - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; @@ -299,8 +299,8 @@ declare namespace NodeJS { emit(event: string | symbol, ...args: any[]): boolean; listenerCount(type: string | symbol): number; // Added in Node 6... - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; eventNames(): (string | symbol)[]; } @@ -340,10 +340,10 @@ declare namespace NodeJS { intercept(cb: (data: any) => any): any; dispose(): void; - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + removeListener(event: string, listener: (...args: any[]) => void): this; removeAllListeners(event?: string): this; } @@ -382,7 +382,19 @@ declare namespace NodeJS { "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" | "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" | "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" | - "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ"; + "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO"; + + type BeforeExitListener = (code: number) => void; + type DisconnectListener = () => void; + type ExitListener = (code: number) => void; + type RejectionHandledListender = (promise: Promise) => void; + type UncaughtExceptionListener = (error: Error) => void; + type UnhandledRejectionListener = (reason: any, promise: Promise) => void; + type WarningListener = (warning: Error) => void; + type MessageListener = (message: any, sendHandle: any) => void; + type SignalsListener = () => void; + type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void; + type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void; export interface Socket extends ReadWriteStream { isTTY?: true; @@ -467,63 +479,93 @@ declare namespace NodeJS { * 6. uncaughtException * 7. unhandledRejection * 8. warning - * 9. + * 9. message + * 10. + * 11. newListener/removeListener inherited from EventEmitter */ + addListener(event: "beforeExit", listener: BeforeExitListener): this; + addListener(event: "disconnect", listener: DisconnectListener): this; + addListener(event: "exit", listener: ExitListener): this; + addListener(event: "rejectionHandled", listener: RejectionHandledListender): this; + addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + addListener(event: "warning", listener: WarningListener): this; + addListener(event: "message", listener: MessageListener): this; + addListener(event: Signals, listener: SignalsListener): this; + addListener(event: "newListener", listener: NewListenerListener): this; + addListener(event: "removeListener", listener: RemoveListenerListener): this; - addListener(event: "beforeExit", listener: (code: number) => void): this; - addListener(event: "disconnect", listener: () => void): this; - addListener(event: "exit", listener: (code: number) => void): this; - addListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; - addListener(event: "uncaughtException", listener: (error: Error) => void): this; - addListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - addListener(event: "warning", listener: (warning: Error) => void): this; - addListener(event: Signals, listener: () => void): this; + emit(event: "beforeExit", code: number): boolean; + emit(event: "disconnect"): boolean; + emit(event: "exit", code: number): boolean; + emit(event: "rejectionHandled", promise: Promise): boolean; + emit(event: "uncaughtException", error: Error): boolean; + emit(event: "unhandledRejection", reason: any, promise: Promise): boolean; + emit(event: "warning", warning: Error): boolean; + emit(event: "message", message: any, sendHandle: any): this; + emit(event: Signals): boolean; + emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this; - emit(event: "beforeExit", listener: (code: number) => void): boolean; - emit(event: "disconnect", listener: () => void): boolean; - emit(event: "exit", listener: (code: number) => void): boolean; - emit(event: "rejectionHandled", listener: (promise: Promise) => void): boolean; - emit(event: "uncaughtException", listener: (error: Error) => void): boolean; - emit(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): boolean; - emit(event: "warning", listener: (warning: Error) => void): boolean; - emit(event: Signals, listener: () => void): boolean; + on(event: "beforeExit", listener: BeforeExitListener): this; + on(event: "disconnect", listener: DisconnectListener): this; + on(event: "exit", listener: ExitListener): this; + on(event: "rejectionHandled", listener: RejectionHandledListender): this; + on(event: "uncaughtException", listener: UncaughtExceptionListener): this; + on(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + on(event: "warning", listener: WarningListener): this; + on(event: "message", listener: MessageListener): this; + on(event: Signals, listener: SignalsListener): this; + on(event: "newListener", listener: NewListenerListener): this; + on(event: "removeListener", listener: RemoveListenerListener): this; - on(event: "beforeExit", listener: (code: number) => void): this; - on(event: "disconnect", listener: () => void): this; - on(event: "exit", listener: (code: number) => void): this; - on(event: "rejectionHandled", listener: (promise: Promise) => void): this; - on(event: "uncaughtException", listener: (error: Error) => void): this; - on(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - on(event: "warning", listener: (warning: Error) => void): this; - on(event: "message", listener: (message: any, sendHandle: any) => void): this; - on(event: Signals, listener: () => void): this; + once(event: "beforeExit", listener: BeforeExitListener): this; + once(event: "disconnect", listener: DisconnectListener): this; + once(event: "exit", listener: ExitListener): this; + once(event: "rejectionHandled", listener: RejectionHandledListender): this; + once(event: "uncaughtException", listener: UncaughtExceptionListener): this; + once(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + once(event: "warning", listener: WarningListener): this; + once(event: "message", listener: MessageListener): this; + once(event: Signals, listener: SignalsListener): this; + once(event: "newListener", listener: NewListenerListener): this; + once(event: "removeListener", listener: RemoveListenerListener): this; - once(event: "beforeExit", listener: (code: number) => void): this; - once(event: "disconnect", listener: () => void): this; - once(event: "exit", listener: (code: number) => void): this; - once(event: "rejectionHandled", listener: (promise: Promise) => void): this; - once(event: "uncaughtException", listener: (error: Error) => void): this; - once(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - once(event: "warning", listener: (warning: Error) => void): this; - once(event: Signals, listener: () => void): this; + prependListener(event: "beforeExit", listener: BeforeExitListener): this; + prependListener(event: "disconnect", listener: DisconnectListener): this; + prependListener(event: "exit", listener: ExitListener): this; + prependListener(event: "rejectionHandled", listener: RejectionHandledListender): this; + prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependListener(event: "warning", listener: WarningListener): this; + prependListener(event: "message", listener: MessageListener): this; + prependListener(event: Signals, listener: SignalsListener): this; + prependListener(event: "newListener", listener: NewListenerListener): this; + prependListener(event: "removeListener", listener: RemoveListenerListener): this; - prependListener(event: "beforeExit", listener: (code: number) => void): this; - prependListener(event: "disconnect", listener: () => void): this; - prependListener(event: "exit", listener: (code: number) => void): this; - prependListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; - prependListener(event: "uncaughtException", listener: (error: Error) => void): this; - prependListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - prependListener(event: "warning", listener: (warning: Error) => void): this; - prependListener(event: Signals, listener: () => void): this; + prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this; + prependOnceListener(event: "disconnect", listener: DisconnectListener): this; + prependOnceListener(event: "exit", listener: ExitListener): this; + prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListender): this; + prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependOnceListener(event: "warning", listener: WarningListener): this; + prependOnceListener(event: "message", listener: MessageListener): this; + prependOnceListener(event: Signals, listener: SignalsListener): this; + prependOnceListener(event: "newListener", listener: NewListenerListener): this; + prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this; - prependOnceListener(event: "beforeExit", listener: (code: number) => void): this; - prependOnceListener(event: "disconnect", listener: () => void): this; - prependOnceListener(event: "exit", listener: (code: number) => void): this; - prependOnceListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; - prependOnceListener(event: "uncaughtException", listener: (error: Error) => void): this; - prependOnceListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - prependOnceListener(event: "warning", listener: (warning: Error) => void): this; - prependOnceListener(event: Signals, listener: () => void): this; + listeners(event: "beforeExit"): BeforeExitListener[]; + listeners(event: "disconnect"): DisconnectListener[]; + listeners(event: "exit"): ExitListener[]; + listeners(event: "rejectionHandled"): RejectionHandledListender[]; + listeners(event: "uncaughtException"): UncaughtExceptionListener[]; + listeners(event: "unhandledRejection"): UnhandledRejectionListener[]; + listeners(event: "warning"): WarningListener[]; + listeners(event: "message"): MessageListener[]; + listeners(event: Signals): SignalsListener[]; + listeners(event: "newListener"): NewListenerListener[]; + listeners(event: "removeListener"): RemoveListenerListener[]; } export interface Global { @@ -696,12 +738,12 @@ declare module "events" { static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated static defaultMaxListeners: number; - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; @@ -940,7 +982,7 @@ declare module "cluster" { * 5. message * 6. online */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "disconnect", listener: () => void): this; addListener(event: "error", listener: (code: number, signal: string) => void): this; addListener(event: "exit", listener: (code: number, signal: string) => void): this; @@ -948,15 +990,15 @@ declare module "cluster" { addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. addListener(event: "online", listener: () => void): this; - emit(event: string, listener: Function): boolean - emit(event: "disconnect", listener: () => void): boolean - emit(event: "error", listener: (code: number, signal: string) => void): boolean - emit(event: "exit", listener: (code: number, signal: string) => void): boolean - emit(event: "listening", listener: (address: Address) => void): boolean - emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean - emit(event: "online", listener: () => void): boolean + emit(event: string, listener: (...args: any[]) => void): boolean + emit(event: "disconnect"): boolean + emit(event: "error", code: number, signal: string): boolean + emit(event: "exit", code: number, signal: string): boolean + emit(event: "listening", address: Address): boolean + emit(event: "message", message: any, handle: net.Socket | net.Server): boolean + emit(event: "online"): boolean - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "disconnect", listener: () => void): this; on(event: "error", listener: (code: number, signal: string) => void): this; on(event: "exit", listener: (code: number, signal: string) => void): this; @@ -964,7 +1006,7 @@ declare module "cluster" { on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. on(event: "online", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "disconnect", listener: () => void): this; once(event: "error", listener: (code: number, signal: string) => void): this; once(event: "exit", listener: (code: number, signal: string) => void): this; @@ -972,7 +1014,7 @@ declare module "cluster" { once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. once(event: "online", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "disconnect", listener: () => void): this; prependListener(event: "error", listener: (code: number, signal: string) => void): this; prependListener(event: "exit", listener: (code: number, signal: string) => void): this; @@ -980,7 +1022,7 @@ declare module "cluster" { prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. prependListener(event: "online", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "disconnect", listener: () => void): this; prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; @@ -1013,7 +1055,7 @@ declare module "cluster" { * 6. online * 7. setup */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "disconnect", listener: (worker: Worker) => void): this; addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; addListener(event: "fork", listener: (worker: Worker) => void): this; @@ -1022,16 +1064,16 @@ declare module "cluster" { addListener(event: "online", listener: (worker: Worker) => void): this; addListener(event: "setup", listener: (settings: any) => void): this; - emit(event: string, listener: Function): boolean; - emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - emit(event: "fork", listener: (worker: Worker) => void): boolean; - emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - emit(event: "online", listener: (worker: Worker) => void): boolean; - emit(event: "setup", listener: (settings: any) => void): boolean; + emit(event: string, listener: (...args: any[]) => void): boolean; + emit(event: "disconnect", worker: Worker): boolean; + emit(event: "exit", worker: Worker, code: number, signal: string): boolean; + emit(event: "fork", worker: Worker): boolean; + emit(event: "listening", worker: Worker, address: Address): boolean; + emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean; + emit(event: "online", worker: Worker): boolean; + emit(event: "setup", settings: any): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "disconnect", listener: (worker: Worker) => void): this; on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; on(event: "fork", listener: (worker: Worker) => void): this; @@ -1040,7 +1082,7 @@ declare module "cluster" { on(event: "online", listener: (worker: Worker) => void): this; on(event: "setup", listener: (settings: any) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "disconnect", listener: (worker: Worker) => void): this; once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; once(event: "fork", listener: (worker: Worker) => void): this; @@ -1049,7 +1091,7 @@ declare module "cluster" { once(event: "online", listener: (worker: Worker) => void): this; once(event: "setup", listener: (settings: any) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "disconnect", listener: (worker: Worker) => void): this; prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; prependListener(event: "fork", listener: (worker: Worker) => void): this; @@ -1058,7 +1100,7 @@ declare module "cluster" { prependListener(event: "online", listener: (worker: Worker) => void): this; prependListener(event: "setup", listener: (settings: any) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; @@ -1091,7 +1133,7 @@ declare module "cluster" { * 6. online * 7. setup */ - export function addListener(event: string, listener: Function): Cluster; + export function addListener(event: string, listener: (...args: any[]) => void): Cluster; export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1100,16 +1142,16 @@ declare module "cluster" { export function addListener(event: "online", listener: (worker: Worker) => void): Cluster; export function addListener(event: "setup", listener: (settings: any) => void): Cluster; - export function emit(event: string, listener: Function): boolean; - export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - export function emit(event: "fork", listener: (worker: Worker) => void): boolean; - export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - export function emit(event: "online", listener: (worker: Worker) => void): boolean; - export function emit(event: "setup", listener: (settings: any) => void): boolean; + export function emit(event: string, listener: (...args: any[]) => void): boolean; + export function emit(event: "disconnect", worker: Worker): boolean; + export function emit(event: "exit", worker: Worker, code: number, signal: string): boolean; + export function emit(event: "fork", worker: Worker): boolean; + export function emit(event: "listening", worker: Worker, address: Address): boolean; + export function emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean; + export function emit(event: "online", worker: Worker): boolean; + export function emit(event: "setup", settings: any): boolean; - export function on(event: string, listener: Function): Cluster; + export function on(event: string, listener: (...args: any[]) => void): Cluster; export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function on(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1118,7 +1160,7 @@ declare module "cluster" { export function on(event: "online", listener: (worker: Worker) => void): Cluster; export function on(event: "setup", listener: (settings: any) => void): Cluster; - export function once(event: string, listener: Function): Cluster; + export function once(event: string, listener: (...args: any[]) => void): Cluster; export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function once(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1127,14 +1169,14 @@ declare module "cluster" { export function once(event: "online", listener: (worker: Worker) => void): Cluster; export function once(event: "setup", listener: (settings: any) => void): Cluster; - export function removeListener(event: string, listener: Function): Cluster; + export function removeListener(event: string, listener: (...args: any[]) => void): Cluster; export function removeAllListeners(event?: string): Cluster; export function setMaxListeners(n: number): Cluster; export function getMaxListeners(): number; export function listeners(event: string): Function[]; export function listenerCount(type: string): number; - export function prependListener(event: string, listener: Function): Cluster; + export function prependListener(event: string, listener: (...args: any[]) => void): Cluster; export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1143,7 +1185,7 @@ declare module "cluster" { export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster; export function prependListener(event: "setup", listener: (settings: any) => void): Cluster; - export function prependOnceListener(event: string, listener: Function): Cluster; + export function prependOnceListener(event: string, listener: (...args: any[]) => void): Cluster; export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1541,29 +1583,29 @@ declare module "repl" { * 2. reset **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "exit", listener: () => void): this; - addListener(event: "reset", listener: Function): this; + addListener(event: "reset", listener: (...args: any[]) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: "exit"): boolean; emit(event: "reset", context: any): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "exit", listener: () => void): this; - on(event: "reset", listener: Function): this; + on(event: "reset", listener: (...args: any[]) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "exit", listener: () => void): this; - once(event: "reset", listener: Function): this; + once(event: "reset", listener: (...args: any[]) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "exit", listener: () => void): this; - prependListener(event: "reset", listener: Function): this; + prependListener(event: "reset", listener: (...args: any[]) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "exit", listener: () => void): this; - prependOnceListener(event: "reset", listener: Function): this; + prependOnceListener(event: "reset", listener: (...args: any[]) => void): this; } export function start(options: ReplOptions): REPLServer; @@ -1601,7 +1643,7 @@ declare module "readline" { * 7. SIGTSTP **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "line", listener: (input: any) => void): this; addListener(event: "pause", listener: () => void): this; @@ -1619,7 +1661,7 @@ declare module "readline" { emit(event: "SIGINT"): boolean; emit(event: "SIGTSTP"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "line", listener: (input: any) => void): this; on(event: "pause", listener: () => void): this; @@ -1628,7 +1670,7 @@ declare module "readline" { on(event: "SIGINT", listener: () => void): this; on(event: "SIGTSTP", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "line", listener: (input: any) => void): this; once(event: "pause", listener: () => void): this; @@ -1637,7 +1679,7 @@ declare module "readline" { once(event: "SIGINT", listener: () => void): this; once(event: "SIGTSTP", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "line", listener: (input: any) => void): this; prependListener(event: "pause", listener: () => void): this; @@ -1646,7 +1688,7 @@ declare module "readline" { prependListener(event: "SIGINT", listener: () => void): this; prependListener(event: "SIGTSTP", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "line", listener: (input: any) => void): this; prependOnceListener(event: "pause", listener: () => void): this; @@ -1737,7 +1779,7 @@ declare module "child_process" { * 5. message **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: (code: number, signal: string) => void): this; addListener(event: "disconnect", listener: () => void): this; addListener(event: "error", listener: (err: Error) => void): this; @@ -1751,28 +1793,28 @@ declare module "child_process" { emit(event: "exit", code: number, signal: string): boolean; emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: (code: number, signal: string) => void): this; on(event: "disconnect", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "exit", listener: (code: number, signal: string) => void): this; on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: (code: number, signal: string) => void): this; once(event: "disconnect", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "exit", listener: (code: number, signal: string) => void): this; once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: (code: number, signal: string) => void): this; prependListener(event: "disconnect", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; prependListener(event: "exit", listener: (code: number, signal: string) => void): this; prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this; prependOnceListener(event: "disconnect", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; @@ -2204,7 +2246,7 @@ declare module "net" { * 7. lookup * 8. timeout */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: (had_error: boolean) => void): this; addListener(event: "connect", listener: () => void): this; addListener(event: "data", listener: (data: Buffer) => void): this; @@ -2224,7 +2266,7 @@ declare module "net" { emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; emit(event: "timeout"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: (had_error: boolean) => void): this; on(event: "connect", listener: () => void): this; on(event: "data", listener: (data: Buffer) => void): this; @@ -2234,7 +2276,7 @@ declare module "net" { on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; on(event: "timeout", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: (had_error: boolean) => void): this; once(event: "connect", listener: () => void): this; once(event: "data", listener: (data: Buffer) => void): this; @@ -2244,7 +2286,7 @@ declare module "net" { once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; once(event: "timeout", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: (had_error: boolean) => void): this; prependListener(event: "connect", listener: () => void): this; prependListener(event: "data", listener: (data: Buffer) => void): this; @@ -2254,7 +2296,7 @@ declare module "net" { prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; prependListener(event: "timeout", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; prependOnceListener(event: "connect", listener: () => void): this; prependOnceListener(event: "data", listener: (data: Buffer) => void): this; @@ -2303,7 +2345,7 @@ declare module "net" { * 3. error * 4. listening */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "connection", listener: (socket: Socket) => void): this; addListener(event: "error", listener: (err: Error) => void): this; @@ -2315,25 +2357,25 @@ declare module "net" { emit(event: "error", err: Error): boolean; emit(event: "listening"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "connection", listener: (socket: Socket) => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "listening", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "connection", listener: (socket: Socket) => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "listening", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "connection", listener: (socket: Socket) => void): this; prependListener(event: "error", listener: (err: Error) => void): this; prependListener(event: "listening", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; @@ -2341,7 +2383,7 @@ declare module "net" { } export function createServer(connectionListener?: (socket: Socket) => void): Server; export function createServer(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void): Server; - export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: number, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; export function connect(port: number, host?: string, connectionListener?: Function): Socket; export function connect(path: string, connectionListener?: Function): Socket; export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; @@ -2406,7 +2448,7 @@ declare module "dgram" { * 3. listening * 4. message **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "error", listener: (err: Error) => void): this; addListener(event: "listening", listener: () => void): this; @@ -2418,25 +2460,25 @@ declare module "dgram" { emit(event: "listening"): boolean; emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "listening", listener: () => void): this; on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "listening", listener: () => void): this; once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; prependListener(event: "listening", listener: () => void): this; prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; prependOnceListener(event: "listening", listener: () => void): this; @@ -2480,23 +2522,23 @@ declare module "fs" { * 1. change * 2. error */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; addListener(event: "error", listener: (code: number, signal: string) => void): this; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; on(event: "error", listener: (code: number, signal: string) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; once(event: "error", listener: (code: number, signal: string) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; prependListener(event: "error", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; } @@ -2512,23 +2554,23 @@ declare module "fs" { * 1. open * 2. close */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "open", listener: (fd: number) => void): this; addListener(event: "close", listener: () => void): this; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "open", listener: (fd: number) => void): this; on(event: "close", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "open", listener: (fd: number) => void): this; once(event: "close", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "open", listener: (fd: number) => void): this; prependListener(event: "close", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "open", listener: (fd: number) => void): this; prependOnceListener(event: "close", listener: () => void): this; } @@ -2543,23 +2585,23 @@ declare module "fs" { * 1. open * 2. close */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "open", listener: (fd: number) => void): this; addListener(event: "close", listener: () => void): this; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "open", listener: (fd: number) => void): this; on(event: "close", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "open", listener: (fd: number) => void): this; once(event: "close", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "open", listener: (fd: number) => void): this; prependListener(event: "close", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "open", listener: (fd: number) => void): this; prependOnceListener(event: "close", listener: () => void): this; } @@ -3322,7 +3364,7 @@ declare module "tls" { * 1. OCSPResponse * 2. secureConnect **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; addListener(event: "secureConnect", listener: () => void): this; @@ -3330,19 +3372,19 @@ declare module "tls" { emit(event: "OCSPResponse", response: Buffer): boolean; emit(event: "secureConnect"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "OCSPResponse", listener: (response: Buffer) => void): this; on(event: "secureConnect", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "OCSPResponse", listener: (response: Buffer) => void): this; once(event: "secureConnect", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; prependListener(event: "secureConnect", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; prependOnceListener(event: "secureConnect", listener: () => void): this; } @@ -3412,7 +3454,7 @@ declare module "tls" { * 4. resumeSession * 5. secureConnection **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; @@ -3426,28 +3468,28 @@ declare module "tls" { emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean; emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; @@ -3702,8 +3744,8 @@ declare module "stream" { * 4. readable * 5. error **/ - addListener(event: string, listener: Function): this; - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "data", listener: (chunk: Buffer | string) => void): this; addListener(event: "end", listener: () => void): this; @@ -3717,35 +3759,35 @@ declare module "stream" { emit(event: "readable"): boolean; emit(event: "error", err: Error): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "data", listener: (chunk: Buffer | string) => void): this; on(event: "end", listener: () => void): this; on(event: "readable", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "data", listener: (chunk: Buffer | string) => void): this; once(event: "end", listener: () => void): this; once(event: "readable", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; prependListener(event: "end", listener: () => void): this; prependListener(event: "readable", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; prependOnceListener(event: "end", listener: () => void): this; prependOnceListener(event: "readable", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; - removeListener(event: string, listener: Function): this; + removeListener(event: string, listener: (...args: any[]) => void): this; removeListener(event: "close", listener: () => void): this; removeListener(event: "data", listener: (chunk: Buffer | string) => void): this; removeListener(event: "end", listener: () => void): this; @@ -3782,7 +3824,7 @@ declare module "stream" { * 5. pipe * 6. unpipe **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "drain", listener: () => void): this; addListener(event: "error", listener: (err: Error) => void): this; @@ -3798,7 +3840,7 @@ declare module "stream" { emit(event: "pipe", src: Readable): boolean; emit(event: "unpipe", src: Readable): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "drain", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; @@ -3806,7 +3848,7 @@ declare module "stream" { on(event: "pipe", listener: (src: Readable) => void): this; on(event: "unpipe", listener: (src: Readable) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "drain", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; @@ -3814,7 +3856,7 @@ declare module "stream" { once(event: "pipe", listener: (src: Readable) => void): this; once(event: "unpipe", listener: (src: Readable) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "drain", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; @@ -3822,7 +3864,7 @@ declare module "stream" { prependListener(event: "pipe", listener: (src: Readable) => void): this; prependListener(event: "unpipe", listener: (src: Readable) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "drain", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; @@ -3830,7 +3872,7 @@ declare module "stream" { prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; - removeListener(event: string, listener: Function): this; + removeListener(event: string, listener: (...args: any[]) => void): this; removeListener(event: "close", listener: () => void): this; removeListener(event: "drain", listener: () => void): this; removeListener(event: "error", listener: (err: Error) => void): this; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 1752683835..aeefc2bbdc 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -88,7 +88,7 @@ namespace assert_tests { namespace events_tests { let emitter: events.EventEmitter; let event: string | symbol; - let listener: Function; + let listener: (...args: any[]) => void; let any: any; { @@ -1892,6 +1892,21 @@ namespace process_tests { } { process.on("message", (req: any) => { }); + process.addListener("beforeExit", (code: number) => { }); + process.once("disconnect", () => { }); + process.prependListener("exit", (code: number) => { }); + process.prependOnceListener("rejectionHandled", (promise: Promise) => { }); + process.on("uncaughtException", (error: Error) => { }); + process.addListener("unhandledRejection", (reason: any, promise: Promise) => { }); + process.once("warning", (warning: Error) => { }); + process.prependListener("message", (message: any, sendHandle: any) => { }); + process.prependOnceListener("SIGBREAK", () => { }); + process.on("newListener", (event: string, listener: Function) => { }); + process.once("removeListener", (event: string, listener: Function) => { }); + + const listeners = process.listeners('uncaughtException'); + const oldHandler = listeners[listeners.length - 1]; + process.addListener('uncaughtException', oldHandler); } } diff --git a/types/nodemailer-smtp-transport/index.d.ts b/types/nodemailer-smtp-transport/index.d.ts index 7f0f8d7cca..4e4e11afe0 100644 --- a/types/nodemailer-smtp-transport/index.d.ts +++ b/types/nodemailer-smtp-transport/index.d.ts @@ -24,16 +24,16 @@ declare namespace smtpTransport { /** is the registered client secret of the application */ clientSecret?: string; - + /** is an optional refresh token. If it is provided then Nodemailer tries to generate a new access token if existing one expires or fails */ refreshToken?: string; - + /** is the access token for the user. Required only if refreshToken is not available and there is no token refresh callback specified */ accessToken?: string; - + /** is an optional expiration time for the current accessToken */ expires?: number; - + /** is an optional HTTP endpoint for requesting new access tokens. This value defaults to Gmail */ accessUrl?: string; diff --git a/types/nodemailer/index.d.ts b/types/nodemailer/index.d.ts index 88a82f073a..833873c45e 100644 --- a/types/nodemailer/index.d.ts +++ b/types/nodemailer/index.d.ts @@ -4,11 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import directTransport = require("nodemailer-direct-transport"); import smtpTransport = require("nodemailer-smtp-transport"); -import * as Promise from 'bluebird'; /** * Transporter plugin @@ -36,7 +34,7 @@ export interface Transporter { * Send mail using a template. */ templateSender(template?: any, defaults?: any): (mailData: any, context: any) => Promise; - + /** * Send mail using a template with a callback. */ @@ -50,7 +48,7 @@ export interface Transporter { * @param pluginFunc is a function that takes two arguments: the mail object and a callback function */ use(step: string, plugin: Plugin): void; - + /** * Verifies connection with server */ diff --git a/types/orientjs/index.d.ts b/types/orientjs/index.d.ts index 571aeebe7c..679fc7c70a 100644 --- a/types/orientjs/index.d.ts +++ b/types/orientjs/index.d.ts @@ -2,6 +2,8 @@ // Project: https://github.com/orientechnologies/orientjs // Definitions by: Saeed Tabrizi // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.3 + // Developed with love in www.nowcando.com /// diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 95d173fffe..b4cd725529 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -327,11 +327,12 @@ declare namespace Parse { constructor(attributes?: string[], options?: any); static extend(className: string, protoProps?: any, classProps?: any): any; + static fromJSON(json: any, override: boolean): any; + static fetchAll(list: T[], options: SuccessFailureOptions): Promise; static fetchAllIfNeeded(list: T[], options: SuccessFailureOptions): Promise; static destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; static saveAll(list: T[], options?: Object.SaveAllOptions): Promise; - static registerSubclass(className: string, clazz: new (options?: any) => T): void; initialize(): void; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 282913d17e..ad1a2a2a83 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -56,6 +56,8 @@ function test_object() { gameScore.addUnique("skills", "kungfu"); game.set("gameScore", gameScore); + + var gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); } function test_query() { diff --git a/types/pdf/index.d.ts b/types/pdfjs-dist/index.d.ts similarity index 99% rename from types/pdf/index.d.ts rename to types/pdfjs-dist/index.d.ts index c3d7bc8788..31c9ed7800 100644 --- a/types/pdf/index.d.ts +++ b/types/pdfjs-dist/index.d.ts @@ -474,3 +474,8 @@ interface PDFJSStatic { } declare var PDFJS: PDFJSStatic; + +declare module "pdfjs-dist" { + export = PDFJS; +} + diff --git a/types/pdf/pdf-tests.ts b/types/pdfjs-dist/pdfjs-dist-tests.ts similarity index 100% rename from types/pdf/pdf-tests.ts rename to types/pdfjs-dist/pdfjs-dist-tests.ts diff --git a/types/pdf/tsconfig.json b/types/pdfjs-dist/tsconfig.json similarity index 93% rename from types/pdf/tsconfig.json rename to types/pdfjs-dist/tsconfig.json index ad7d35deb6..110e5b444a 100644 --- a/types/pdf/tsconfig.json +++ b/types/pdfjs-dist/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "pdf-tests.ts" + "pdfjs-dist-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index 2fe301935a..73c18ac1b7 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -1,6 +1,4 @@ - import * as pg from "pg"; -import * as bluebird from "bluebird"; var conString = "postgres://username:password@localhost/database"; @@ -55,7 +53,7 @@ var config = { port: 5432, //env var: PGPORT max: 10, // max number of clients in the pool idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed - Promise: bluebird + Promise, }; var pool = new pg.Pool(config); diff --git a/types/pify/pify-tests.ts b/types/pify/pify-tests.ts index 2252005b85..87e1ba28ae 100644 --- a/types/pify/pify-tests.ts +++ b/types/pify/pify-tests.ts @@ -1,8 +1,4 @@ - -/// - import * as pify from 'pify'; -import * as Bluebird from 'bluebird'; function assert(actual: string, expected: string): void { if (actual !== expected) { @@ -28,4 +24,4 @@ const fsP = pify(fs); fsP.readFile('foo.txt').then((result: string) => assert(result, 'foo')); pify(fs.readFile)('foo.txt').then((result: string) => assert(result, 'foo')); -pify(fs.readFile, Bluebird)('bar.txt').then((result: string) => assert(result, 'bar')); \ No newline at end of file +pify(fs.readFile, Promise)('bar.txt').then((result: string) => assert(result, 'bar')); \ No newline at end of file diff --git a/types/project-oxford/index.d.ts b/types/project-oxford/index.d.ts index db322e3fa8..5a85f26ad6 100644 --- a/types/project-oxford/index.d.ts +++ b/types/project-oxford/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/felixrieseberg/project-oxford // Definitions by: Scott Southwood // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/quill/index.d.ts b/types/quill/index.d.ts index cf7440f428..73a877815f 100644 --- a/types/quill/index.d.ts +++ b/types/quill/index.d.ts @@ -7,7 +7,21 @@ declare namespace Quill { type Key = { key: string, shortKey?: boolean }; type Sources = "api" | "user" | "silent"; - type Formats = { [key: string]: any }; + type StringMap = { [key: string]: any }; + type OptionalAttributes = { attributes?: StringMap }; + /** + * A stricter type definition would be: + * + * type DeltaOperation ({ insert: any } | { delete: number } | { retain: number }) & OptionalAttributes; + * + * But this would break a lot of existing code as it would require manual discrimination of the union types. + */ + type DeltaOperation = { insert?: any, delete?: number, retain?: number } & OptionalAttributes; + + type TextChangeHandler = (delta: DeltaStatic, oldContents: DeltaStatic, source: Sources) => any; + type SelectionChangeHandler = (range: RangeStatic, oldRange: RangeStatic, source: Sources) => any; + type EditorChangeHandler = ((name: "text-change", delta: DeltaStatic, oldContents: DeltaStatic, source: Sources) => any) + | ((name: "selection-change", range: RangeStatic, oldRange: RangeStatic, source: Sources) => any); export interface KeyboardStatic { addBinding(key: Key, callback: (range: RangeStatic, context: any) => void): void; @@ -23,7 +37,7 @@ declare namespace Quill { export interface QuillOptionsStatic { debug?: string, - modules?: Formats, + modules?: StringMap, placeholder?: string, readOnly?: boolean, theme?: string, @@ -38,26 +52,26 @@ declare namespace Quill { } export interface DeltaStatic { - new (ops: Array) : DeltaStatic; - new (ops: any) : DeltaStatic; - ops?: Array; - retain(length: number, attributes: any) : DeltaStatic; + new (ops?: DeltaOperation[] | { ops: DeltaOperation[] }) : DeltaStatic; + ops?: DeltaOperation[]; + retain(length: number, attributes?: StringMap) : DeltaStatic; delete(length: number) : DeltaStatic; - filter(predicate: any) : DeltaStatic; - forEach(predicate: any) : DeltaStatic; - insert(text: any, attributes: any): DeltaStatic; - map(predicate: any) : DeltaStatic; - partition(predicate: any) : DeltaStatic; - reduce(predicate: any, initial: number): DeltaStatic; + filter(predicate: (op: DeltaOperation) => boolean) : DeltaOperation[]; + forEach(predicate: (op: DeltaOperation) => void) : void; + insert(text: any, attributes?: StringMap): DeltaStatic; + map(predicate: (op: DeltaOperation) => T) : T[]; + partition(predicate: (op: DeltaOperation) => boolean) : [DeltaOperation[], DeltaOperation[]]; + reduce(predicate: (acc: T, curr: DeltaOperation, idx: number, arr: DeltaOperation[]) => T, initial: T): T; chop() : DeltaStatic; length(): number; - slice(start: number, end: number): DeltaStatic; - compose(other: any): DeltaStatic; + slice(start?: number, end?: number): DeltaStatic; + compose(other: DeltaStatic): DeltaStatic; concat(other: DeltaStatic): DeltaStatic; - diff(other: DeltaStatic, index: number) : DeltaStatic; - eachLine(predicate: any, newline: any) : DeltaStatic; - transform(other: any, priority: any) : DeltaStatic; - transformPosition(index: number, priority: any) : DeltaStatic; + diff(other: DeltaStatic, index?: number) : DeltaStatic; + eachLine(predicate: (line: DeltaStatic, attributes: StringMap, idx: number) => any, newline?: string) : DeltaStatic; + transform(index: number) : number; + transform(other: DeltaStatic, priority: boolean) : DeltaStatic; + transformPosition(index: number) : number; } export interface RangeStatic { @@ -66,7 +80,19 @@ declare namespace Quill { length: number; } - export interface Quill { + export interface EventEmitter { + on(eventName: "text-change", handler: TextChangeHandler): EventEmitter; + on(eventName: "selection-change", handler: SelectionChangeHandler): EventEmitter; + on(eventName: "editor-change", handler: EditorChangeHandler): EventEmitter; + once(eventName: "text-change", handler: TextChangeHandler): EventEmitter; + once(eventName: "selection-change", handler: SelectionChangeHandler): EventEmitter; + once(eventName: "editor-change", handler: EditorChangeHandler): EventEmitter; + off(eventName: "text-change", handler: TextChangeHandler): EventEmitter; + off(eventName: "selection-change", handler: SelectionChangeHandler): EventEmitter; + off(eventName: "editor-change", handler: EditorChangeHandler): EventEmitter; + } + + export interface Quill extends EventEmitter { new (container: string | Element, options?: QuillOptionsStatic): Quill; deleteText(index: number, length: number, source?: Sources): void; disable(): void; @@ -77,7 +103,7 @@ declare namespace Quill { insertEmbed(index: number, type: string, value: any, source?: Sources): void; insertText(index: number, text: string, source?: Sources): DeltaStatic; insertText(index: number, text: string, format: string, value: any, source?: Sources): DeltaStatic; - insertText(index: number, text: string, formats: Formats, source?: Sources): DeltaStatic; + insertText(index: number, text: string, formats: StringMap, source?: Sources): DeltaStatic; /** * @deprecated Use clipboard.dangerouslyPasteHTML(index: number, html: string, source: Sources) */ @@ -94,12 +120,12 @@ declare namespace Quill { format(name: string, value: any, source?: Sources): DeltaStatic; formatLine(index: number, length: number, source?: Sources): DeltaStatic; formatLine(index: number, length: number, format: string, value: any, source?: Sources): DeltaStatic; - formatLine(index: number, length: number, formats: Formats, source?: Sources): DeltaStatic; + formatLine(index: number, length: number, formats: StringMap, source?: Sources): DeltaStatic; formatText(index: number, length: number, source?: Sources): DeltaStatic; formatText(index: number, length: number, format: string, value: any, source?: Sources): DeltaStatic; - formatText(index: number, length: number, formats: Formats, source?: Sources): DeltaStatic; - getFormat(range?: RangeStatic): Formats; - getFormat(index: number, length?: number): Formats; + formatText(index: number, length: number, formats: StringMap, source?: Sources): DeltaStatic; + getFormat(range?: RangeStatic): StringMap; + getFormat(index: number, length?: number): StringMap; removeFormat(index: number, length: number, source?: Sources): void; blur(): void; @@ -110,15 +136,10 @@ declare namespace Quill { setSelection(index: number, length: number, source?: Sources): void; setSelection(range: RangeStatic, source?: Sources): void; - on(eventName: string, callback: ((delta: T, oldContents: T, source: string) => void) | - ((name: string, ...args: any[]) => void)): Quill; - once(eventName: string, callback: (delta: DeltaStatic, source: string) => void): Quill; - off(eventName: string, callback: (delta: DeltaStatic, source: string) => void): Quill; - debug(level: string): void; import(path: string): any; register(path: string, def: any, suppressWarning?: boolean): void; - register(defs: Formats, suppressWarning?: boolean): void; + register(defs: StringMap, suppressWarning?: boolean): void; addContainer(className: string, refNode?: any): any; addContainer(domNode: any, refNode?: any): any; getModule(name: string): any diff --git a/types/quill/quill-tests.ts b/types/quill/quill-tests.ts index eba77f8b68..f45781a685 100644 --- a/types/quill/quill-tests.ts +++ b/types/quill/quill-tests.ts @@ -168,12 +168,22 @@ function test_addContainer() quillEditor.addContainer('ql-custom'); } -function test_on_EventType1(){ - var quillEditor = new Quill('#editor'); - quillEditor.on('text-change', (newDelta: T, oldDelta: T, source: string)=>{ - // happened - }); +function test_on_Events(){ + var textChangeHandler = function(newDelta: Quill.DeltaStatic, oldDelta: Quill.DeltaStatic, source: string) { }; + var selectionChangeHandler = function(newRange: Quill.RangeStatic, oldRange: Quill.RangeStatic, source: string) { }; + var editorChangeHandler = function(name: string, ...args: any[]) { }; + var quillEditor = new Quill('#editor'); + quillEditor + .on('text-change', textChangeHandler) + .off('text-change', textChangeHandler) + .once('text-change', textChangeHandler) + .on('selection-change', selectionChangeHandler) + .off('selection-change', selectionChangeHandler) + .once('selection-change', selectionChangeHandler) + .on('editor-change', editorChangeHandler) + .off('editor-change', editorChangeHandler) + .once('editor-change', editorChangeHandler); } function test_PasteHTML() @@ -187,3 +197,141 @@ function test_PasteHTML2() var quillEditor = new Quill('#editor'); quillEditor.pasteHTML(5, '

Quill Rocks

'); } + +function test_DeltaChaining() { + var delta = new Delta() + .insert('Hello', { bold: true }) + .insert('World') + .delete(5) + .retain(5) + .retain(5, { color: '#0c6' }); + +} + +function test_DeltaFilter() { + var delta = new Delta().insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var text = delta.filter(function(op) { + return typeof op.insert === 'string'; + }).map(function(op) { + return op.insert; + }).join(''); +} + +function test_DeltaForEach() { + var delta = new Delta(); + delta.forEach(function(op) { + console.log(op); + }); +} + +function test_DeltaMap() { + var delta = new Delta() + .insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var text = delta.map(function(op) { + if (typeof op.insert === 'string') { + return op.insert; + } else { + return ''; + } + }).join(''); +} + +function test_DeltaPartition() { + var delta = new Delta().insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var results = delta.partition(function(op) { + return typeof op.insert === 'string'; + }); + var passed = results[0]; // [{ insert: 'Hello', attributes: { bold: true }}, { insert: 'World'}] + var failed = results[1]; // [{ insert: { image: 'https://octodex.github.com/images/labtocat.png' }}] +} + +function test_DeltaReduce() { + var delta = new Delta().insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var length = delta.reduce(function(length, op) { + return length + (op.insert.length || 1); + }, 0); +} + +function test_DeltaSlice() { + var delta = new Delta().insert('Hello', { bold: true }).insert(' World'); + + // { + // ops: [ + // { insert: 'Hello', attributes: { bold: true } }, + // { insert: ' World' } + // ] + // } + var copy = delta.slice(); + console.log(copy.ops); + + // { ops: [{ insert: 'World' }] } + var world = delta.slice(6); + console.log(world.ops); + + // { ops: [{ insert: ' ' }] } + var space = delta.slice(5, 6); + console.log(space.ops); +} + +function test_DeltaCompose() { + var a = new Delta().insert('abc'); + var b = new Delta().retain(1).delete(1); + + var composed = a.compose(b); // composed == new Delta().insert('ac'); +} + +function test_DeltaDiff() { + var a = new Delta().insert('Hello'); + var b = new Delta().insert('Hello!'); + + var diff = a.diff(b); // { ops: [{ retain: 5 }, { insert: '!' }] } + // a.compose(diff) == b + var diff2 = a.diff(b, 0); // { ops: [{ retain: 5 }, { insert: '!' }] } + // a.compose(diff) == b +} + +function test_DeltaEachLine() { + var delta = new Delta().insert('Hello\n\n') + .insert('World') + .insert({ image: 'octocat.png' }) + .insert('\n', { align: 'right' }) + .insert('!'); + + delta.eachLine(function(line, attributes, i) { + console.log(line, attributes, i); + // Can return false to exit loop early + }); + // Should log: + // { ops: [{ insert: 'Hello' }] }, {}, 0 + // { ops: [] }, {}, 1 + // { ops: [{ insert: 'World' }, { insert: { image: 'octocat.png' } }] }, { align: 'right' }, 2 + // { ops: [{ insert: '!' }] }, {}, 3 +} + +function test_DeltaTransform() { + var a = new Delta().insert('a'); + var b = new Delta().insert('b').retain(5).insert('c'); + + var d1: Quill.DeltaStatic = a.transform(b, true); // new Delta().retain(1).insert('b').retain(5).insert('c'); + var d2: Quill.DeltaStatic = a.transform(b, false); // new Delta().insert('b').retain(6).insert('c'); + var n1: number = a.transform(5); + +} + +function test_DeltatransformPosition() { + var delta = new Delta().retain(5).insert('a'); + var n1: number = delta.transformPosition(4); // 4 + var n2: number = delta.transformPosition(5); // 6 +} diff --git a/types/quill/tsconfig.json b/types/quill/tsconfig.json index 5c353f17a3..cfef2d65ab 100644 --- a/types/quill/tsconfig.json +++ b/types/quill/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/react-input-mask/index.d.ts b/types/react-input-mask/index.d.ts index 74963b8cc3..4396198fde 100644 --- a/types/react-input-mask/index.d.ts +++ b/types/react-input-mask/index.d.ts @@ -41,4 +41,4 @@ declare namespace reactInputMask { } } declare var ReactInputMask: typeof reactInputMask.ReactInputMask; -export = ReactInputMask; +export default ReactInputMask; diff --git a/types/react-input-mask/react-input-mask-tests.tsx b/types/react-input-mask/react-input-mask-tests.tsx index 0a4f2cd74e..d116b2b27a 100644 --- a/types/react-input-mask/react-input-mask-tests.tsx +++ b/types/react-input-mask/react-input-mask-tests.tsx @@ -1,4 +1,4 @@ -import * as ReactInputMask from 'react-input-mask'; +import ReactInputMask from 'react-input-mask'; import * as React from 'react';
diff --git a/types/react-loadable/babel.d.ts b/types/react-loadable/babel.d.ts deleted file mode 100644 index a9f18c2e00..0000000000 --- a/types/react-loadable/babel.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as babel from 'babel-core'; - -export default function(context: Pick): { visitor: any }; diff --git a/types/react-loadable/index.d.ts b/types/react-loadable/index.d.ts index e9330c5c5f..cd10924682 100644 --- a/types/react-loadable/index.d.ts +++ b/types/react-loadable/index.d.ts @@ -1,20 +1,19 @@ -// Type definitions for react-loadable 3.3 +// Type definitions for react-loadable 4.0 // Project: https://github.com/thejameskyle/react-loadable#readme -// Definitions by: Diogo Franco +// Definitions by: Diogo Franco , Oden S. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 import * as React from 'react'; -export type LoadedComponent = React.ComponentClass | React.SFC; - export interface LoadingComponentProps { isLoading: boolean; pastDelay: boolean; + timedOut: boolean; error: any; } -export type Options = OptionsWithoutResolve | OptionsWithResolve; +export type Options = OptionsWithoutRender | OptionsWithRender; export interface CommonOptions { /** @@ -24,64 +23,76 @@ export interface CommonOptions { * (this is considered a valid React component). */ // NOTE: () => null is only needed until React.SFC supports components returning null - LoadingComponent: React.ComponentClass | React.SFC | (() => null); + loading: React.ComponentType | (() => null); /** - * Defaults to 200, in milliseconds + * Defaults to 200, in milliseconds. * - * Only show the LoadingComponent if the loader() has taken this long to succeed or error. + * Only show the loading component if the loader() has taken this long to succeed or error. */ - delay?: number; + delay?: number | false | null; /** - * When rendering server-side, require() this path to load the component instead, this way it happens - * synchronously. If you are rendering server-side you should use this option. + * Disabled by default. * - * If you are using Babel, you might want to use the Babel plugin to add this option automatically. + * After the specified time in milliseconds passes, the component's `timedOut` prop will be set to true. */ - serverSideRequirePath?: string; + timeout?: number | false | null; +} + +export interface OptionsWithoutRender extends CommonOptions { /** - * In order for Loadable to require() a component synchronously (when possible) instead of waiting for - * the promise returned by import() to resolve. If you are using Webpack you should use this option. + * Function returning a promise which returns a React component displayed on success. + * + * Resulting React component receives all the props passed to the generated component. + */ + loader(): Promise | { [key: string]: React.ComponentType }>; +} + +export interface OptionsWithRender extends CommonOptions { + /** + * Function returning a promise which returns an object to be passed to `render` on success. + */ + loader(): Promise; + /** + * If you want to customize what gets rendered from your loader you can also pass `render`. + * + * Note: If you want to load multiple resources at once, you can also use `Loadable.Map`. * * ```ts * Loadable({ * // ... - * webpackRequireWeakId: () => require.resolveWeak('./MyComponent') + * render(loaded, props) { + * const Component = loaded.default; + * return + * } * }); * ``` - * - * If you are using Babel, you might want to use the Babel plugin to add this option automatically. */ - webpackRequireWeakId?(): number|string; + render(loaded: Exports, props: Props): React.ReactNode; } -export interface OptionsWithoutResolve extends CommonOptions { +export interface OptionsWithMap extends CommonOptions { /** - * Function returning promise returning a React component displayed on success. - * - * Resulting React component receives all the props passed to the generated component. + * An object containing functions which return promises, which resolve to an object to be passed to `render` on success. */ - loader(): Promise | { default: LoadedComponent }>; -} - -export interface OptionsWithResolve extends CommonOptions { + loader: { + [P in keyof Exports]: () => Promise + }; /** - * Function returning promise returning a React component displayed on success. + * If you want to customize what gets rendered from your loader you can also pass `render`. * - * Resulting React component receives all the props passed to the generated component. - */ - loader(): Promise; - /** - * If the component that you want to load is not the default exported from a module you can use this - * function to resolve it. + * Note: If you want to load multiple resources at once, you can also use `Loadable.Map`. * * ```ts * Loadable({ * // ... - * resolveModule: module => module.MyComponent + * render(loaded, props) { + * const Component = loaded.default; + * return + * } * }); * ``` */ - resolveModule(obj: T): LoadedComponent; + render(loaded: Exports, props: Props): React.ReactNode; } export interface LoadableComponent { @@ -96,22 +107,10 @@ export interface LoadableComponent { preload(): void; } -export default function Loadable(options: Options): LoadedComponent & LoadableComponent; +export interface Loadable { + (options: Options): React.ComponentType & LoadableComponent; + Map(options: OptionsWithMap): React.ComponentType & LoadableComponent; +} -/** - * In case you are rendering server-side and want to find out after a render cycle which - * serverSideRequirePath's and webpackRequireWeakId's were actually rendered, you can use - * flushServerSideRequirePaths or flushWebpackRequireWeakIds to get an array of them. - * - * Note: These are flushed individually, one does not affect the other. - */ -export function flushServerSideRequirePaths(): string[]; - -/** - * In case you are rendering server-side and want to find out after a render cycle which - * serverSideRequirePath's and webpackRequireWeakId's were actually rendered, you can use - * flushServerSideRequirePaths or flushWebpackRequireWeakIds to get an array of them. - * - * Note: These are flushed individually, one does not affect the other. - */ -export function flushWebpackRequireWeakIds(): string[]|number[]; +declare const LoadableExport: Loadable; +export default LoadableExport; diff --git a/types/react-loadable/react-loadable-tests.tsx b/types/react-loadable/react-loadable-tests.tsx index 630849fbeb..d1b031f040 100644 --- a/types/react-loadable/react-loadable-tests.tsx +++ b/types/react-loadable/react-loadable-tests.tsx @@ -3,7 +3,14 @@ import Loadable, { LoadingComponentProps } from 'react-loadable'; class LoadingComponent extends React.Component { render() { - return
{this.props.isLoading}
; + return ( +
+ {this.props.error} + {this.props.isLoading} + {this.props.pastDelay} + {this.props.timedOut} +
+ ); } } @@ -16,36 +23,62 @@ const Component: React.SFC = ({ text }) =>
{text}
; const Loadable100 = Loadable({ // a module shape with 'export = Component' / 'module.exports = Component' loader: () => Promise.resolve(Component), - LoadingComponent, - delay: 100 + loading: LoadingComponent, + delay: 100, + timeout: 10000 }); const Loadable200 = Loadable({ // a module shape with 'export default Component' loader: () => Promise.resolve({ default: Component }), - LoadingComponent, - delay: 200 + loading: LoadingComponent, + delay: null, + timeout: null }); const Loadable300 = Loadable({ // a module shape with 'export { Component }' loader: () => Promise.resolve({ Component }), - LoadingComponent, - delay: 300, - resolveModule: shape => shape.Component + loading: LoadingComponent, + delay: false, + timeout: false, + render(loaded, props) { + const { Component } = loaded; + return ; + } }); const Loadable400 = Loadable({ // a module shape with both 'export default Component' and 'export { Component }' loader: () => Promise.resolve({ default: Component, Component }), - LoadingComponent: () => null, + loading: () => null, delay: 300, - resolveModule: shape => shape.Component + render(loaded, props) { + const Component = loaded.default; + const NamedComponent = loaded.Component; + return ( + + + + ); + } }); -const used100 = ; -const used200 = ; -const used300 = ; -const used400 = ; +const LoadableMap = Loadable.Map({ + loading: () => null, + loader: { + Component: () => Promise.resolve({ default: Component }), + text: () => Promise.resolve("test text") + }, + render(loaded, props: ComponentProps) { + let Component = loaded.Component.default; + return ; + } +}); + +const used100 = ; +const used200 = ; +const used300 = ; +const used400 = ; Loadable100.preload(); diff --git a/types/react-loadable/tsconfig.json b/types/react-loadable/tsconfig.json index bf26cfdbc5..4f1cf2c0f0 100644 --- a/types/react-loadable/tsconfig.json +++ b/types/react-loadable/tsconfig.json @@ -18,7 +18,6 @@ }, "files": [ "index.d.ts", - "babel.d.ts", "react-loadable-tests.tsx" ] } diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 9599fbde9a..7c1b0cec8b 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -361,7 +361,7 @@ export interface NavigationProp { } export type NavigationScreenProp = NavigationProp & { - goBack: (routeKey?: string) => boolean, + goBack: (routeKey?: string | null) => boolean, navigate: (routeName: string, params?: NavigationParams, action?: NavigationAction) => boolean, setParams: (newParams: NavigationParams) => boolean, } diff --git a/types/react-paginate/index.d.ts b/types/react-paginate/index.d.ts index ff3985a9f1..a6c1c41d1b 100644 --- a/types/react-paginate/index.d.ts +++ b/types/react-paginate/index.d.ts @@ -1,6 +1,9 @@ -// Type definitions for react-paginate 4.2 +// Type definitions for react-paginate 4.3 // Project: https://github.com/AdeleD/react-paginate -// Definitions by: Simon Hartcher , Wouter Hardeman , pegel03 +// Definitions by: Simon Hartcher +// Wouter Hardeman +// pegel03 +// Simon Archer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -111,6 +114,11 @@ interface ReactPaginateProps { * The method is called to generate the href attribute value on tag a of each page element. */ hrefBuilder?(pageIndex: number): void; + + /** + * Extra context to add to the aria-label HTML attribute. + */ + extraAriaContext?: string; } declare const ReactPaginate: React.ComponentClass; diff --git a/types/react-paginate/react-paginate-tests.tsx b/types/react-paginate/react-paginate-tests.tsx index d1e893fddf..56e0890221 100644 --- a/types/react-paginate/react-paginate-tests.tsx +++ b/types/react-paginate/react-paginate-tests.tsx @@ -26,6 +26,7 @@ class Test extends React.Component<{}> { nextLinkClassName={'next-a'} disabledClassName={'disabled'} hrefBuilder={(pageIndex: number) => null} + extraAriaContext={'aria'} /> ); } diff --git a/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx b/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx index 204a8a5d53..0f23939771 100644 --- a/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx +++ b/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx @@ -5,10 +5,12 @@ import * as SmoothScrollbar from "react-smooth-scrollbar"; ; class Test extends React.Component { - ref: SmoothScrollbar; + ref: SmoothScrollbar | null; componentDidMount() { - this.ref.scrollbar.scrollTo(0, 500); + if (this.ref) { + this.ref.scrollbar.scrollTo(0, 500); + } } render() { diff --git a/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx b/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx index 44da1e55d6..9820a51c6a 100644 --- a/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx +++ b/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx @@ -8,21 +8,30 @@ import { } from 'react-svg-pan-zoom'; class Example1 extends React.Component<{}> { - Viewer: ReactSVGPanZoom; + Viewer: ReactSVGPanZoom | null; + constructor(props: Props) { super(props); } componentDidMount() { - this.Viewer.fitToViewer(); + if (this.Viewer) { + this.Viewer.fitToViewer(); + } } render() { return (
- - - + + +
diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 887256c6ca..1572fb9dec 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1,13 +1,14 @@ // Type definitions for React v15.0 // Project: http://facebook.github.io/react/ -// Definitions by: Asana -// AssureSign -// Microsoft -// John Reilly -// Benoit Benezech -// Patricio Zavolinsky -// Digiguru -// Eric Anderson +// Definitions by: Asana , +// AssureSign , +// Microsoft , +// John Reilly , +// Benoit Benezech , +// Patricio Zavolinsky , +// Digiguru , +// Eric Anderson , +// Albert Kurniawan , // Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -37,7 +38,7 @@ declare namespace React { type ComponentType

= ComponentClass

| StatelessComponent

; type Key = string | number; - type Ref = string | ((instance: T) => any); + type Ref = string | ((instance: T | null) => any); type ComponentState = {}; interface Attributes { @@ -455,7 +456,7 @@ declare namespace React { * `createElement` or a factory, use `ClassAttributes`: * * ```ts - * var b: Button; + * var b: Button | null; * var props: ButtonProps & ClassAttributes