diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4217471f9d..79793c16c1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,6 +2,7 @@ Please fill in this template. - [ ] Use a meaningful title for the pull request. Include the name of the package modified. - [ ] Test the change in your own code. (Compile and run.) +- [ ] Add or edit tests to reflect the change. (Run with `npm test`.) - [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [ ] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). diff --git a/notNeededPackages.json b/notNeededPackages.json index a3423d479c..8c587f7c43 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -173,6 +173,12 @@ "typingsPackageName": "bignumber.js", "sourceRepoURL": "https://github.com/MikeMcl/bignumber.js/", "asOfVersion": "5.0.0" + }, + { + "libraryName": "bingmaps", + "typingsPackageName": "bingmaps", + "sourceRepoURL": "https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions", + "asOfVersion": "2.0.15" }, { "libraryName": "botvs", diff --git a/types/ace/index.d.ts b/types/ace/index.d.ts index 822c394a32..1f7dd9752b 100644 --- a/types/ace/index.d.ts +++ b/types/ace/index.d.ts @@ -52,6 +52,10 @@ declare namespace AceAjax { export interface TokenInfo { value: string; + + index?: number; + + start?: number; } export interface Position { @@ -575,7 +579,7 @@ declare namespace AceAjax { * @param row The row number to retrieve from * @param column The column number to retrieve from **/ - getTokenAt(row: number, column: number): TokenInfo; + getTokenAt(row: number, column: number): TokenInfo|null; /** * Sets the undo manager. diff --git a/types/aframe/index.d.ts b/types/aframe/index.d.ts index 803318a754..0da1ed0ef5 100644 --- a/types/aframe/index.d.ts +++ b/types/aframe/index.d.ts @@ -16,16 +16,13 @@ declare var AFRAME: AFrame.AFrameGlobal; declare var hasNativeWebVRImplementation: boolean; -interface NodeSelector { - querySelector(selectors: 'a-scene'): AFrame.Scene; +interface Document { + createElement(tagName: string): AFrame.Entity; + querySelector(selectors: 'a-scene'): AFrame.Scene; querySelector>(selectors: string): T; querySelectorAll(selectors: string): NodeListOf | Element>; } -interface Document { - createElement(tagName: string): AFrame.Entity; -} - // Interfaces declare namespace AFrame { interface ObjectMap { diff --git a/types/amqplib/index.d.ts b/types/amqplib/index.d.ts index 25b0ef04e9..269ed0112e 100644 --- a/types/amqplib/index.d.ts +++ b/types/amqplib/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for amqplib 0.5 // Project: https://github.com/squaremo/amqp.node -// Definitions by: Michael Nahkies , Ab Reitsma , Nicolás Fantone +// Definitions by: Michael Nahkies , Ab Reitsma , Nicolás Fantone , Nick Zelei // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/amqplib/properties.d.ts b/types/amqplib/properties.d.ts index af90909d8c..9f96b14f5c 100644 --- a/types/amqplib/properties.d.ts +++ b/types/amqplib/properties.d.ts @@ -141,6 +141,52 @@ export namespace Options { export interface Message { content: Buffer; - fields: any; - properties: any; + fields: MessageFields; + properties: MessageProperties; +} + +export interface MessageFields { + deliveryTag: number; + redelivered: boolean; + exchange: string; + routingKey: string; + messageCount: string; +} + +export interface MessageProperties { + contentType: any | undefined; + contentEncoding: any | undefined; + headers: MessagePropertyHeaders; + deliveryMode: any | undefined; + priority: any | undefined; + correlationId: any | undefined; + replyTo: any | undefined; + expiration: any | undefined; + messageId: any | undefined; + timestamp: any | undefined; + type: any | undefined; + userId: any | undefined; + appId: any | undefined; + clusterId: any | undefined; +} + +export interface MessagePropertyHeaders { + "x-first-death-exchange"?: string; + "x-first-death-queue"?: string; + "x-first-death-reason"?: string; + "x-death"?: XDeath[]; + [key: string]: any; +} + +export interface XDeath { + count: number; + reason: "rejected" | "expired" | "maxlen"; + queue: string; + time: { + "!": "timestamp"; + value: number; + }; + exchange: string; + "original-expiration"?: any; + "routing-keys": string[]; } diff --git a/types/angular-route/angular-route-tests.ts b/types/angular-route/angular-route-tests.ts index 4d596cdfdf..677c1589ed 100644 --- a/types/angular-route/angular-route-tests.ts +++ b/types/angular-route/angular-route-tests.ts @@ -40,7 +40,8 @@ $routeProvider } }) .otherwise({ redirectTo: '/' }) - .otherwise({ redirectTo: ($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) => "" }); + .otherwise({ redirectTo: ($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) => "" }) + .otherwise("/"); var current: ng.route.ICurrentRoute; diff --git a/types/angular-route/index.d.ts b/types/angular-route/index.d.ts index 29c59f955c..56bd3f2263 100644 --- a/types/angular-route/index.d.ts +++ b/types/angular-route/index.d.ts @@ -138,7 +138,7 @@ declare module 'angular' { * * @params Mapping information to be assigned to $route.current. */ - otherwise(params: IRoute): IRouteProvider; + otherwise(params: IRoute | string): IRouteProvider; /** * Adds a new route definition to the $route service. * diff --git a/types/array-unique/array-unique-tests.ts b/types/array-unique/array-unique-tests.ts new file mode 100644 index 0000000000..a854cab3bf --- /dev/null +++ b/types/array-unique/array-unique-tests.ts @@ -0,0 +1,9 @@ +import arrayUnique = require("array-unique"); + +arrayUnique([1, 1, 2, 3, 3]); + +arrayUnique(["foo", "foo", "bar", "foo"]); + +arrayUnique.immutable([1, 1, 2, 3, 3]); + +arrayUnique.immutable(["foo", "foo", "bar", "foo"]); diff --git a/types/array-unique/index.d.ts b/types/array-unique/index.d.ts new file mode 100644 index 0000000000..40d73a53de --- /dev/null +++ b/types/array-unique/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for array-unique 0.3 +// Project: https://github.com/jonschlinkert/array-unique +// Definitions by: Michaël St-Georges +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function arrayUnique(arr: T[]): T[]; + +declare namespace arrayUnique { + function immutable(arr: ReadonlyArray): T[]; +} + +export = arrayUnique; diff --git a/types/array-unique/tsconfig.json b/types/array-unique/tsconfig.json new file mode 100644 index 0000000000..9829c01906 --- /dev/null +++ b/types/array-unique/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "array-unique-tests.ts" + ] +} \ No newline at end of file diff --git a/types/array-unique/tslint.json b/types/array-unique/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/array-unique/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/assets-webpack-plugin/index.d.ts b/types/assets-webpack-plugin/index.d.ts index 660fbc6052..7644d8f9ad 100644 --- a/types/assets-webpack-plugin/index.d.ts +++ b/types/assets-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/sporto/assets-webpack-plugin // Definitions by: Michael Strobel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import * as webpack from 'webpack'; diff --git a/types/async/index.d.ts b/types/async/index.d.ts index 17fecb467b..e2ecb522bc 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -7,6 +7,7 @@ export as namespace async; export interface Dictionary { [key: string]: T; } +export type IterableCollection = T[] | IterableIterator | Dictionary export interface ErrorCallback { (err?: T): void; } export interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } @@ -36,11 +37,9 @@ export interface AsyncQueue { running(): number; idle(): boolean; concurrency: number; - push(task: T, callback?: ErrorCallback): void; + push(task: T | T[], callback?: ErrorCallback): void; push(task: T, callback?: AsyncResultCallback): void; - push(task: T[], callback?: ErrorCallback): void; - unshift(task: T, callback?: ErrorCallback): void; - unshift(task: T[], callback?: ErrorCallback): void; + unshift(task: T | T[], callback?: ErrorCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -62,8 +61,7 @@ export interface AsyncPriorityQueue { concurrency: number; started: boolean; paused: boolean; - push(task: T, priority: number, callback?: AsyncResultArrayCallback): void; - push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T | T[], priority: number, callback?: AsyncResultArrayCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -86,7 +84,6 @@ export interface AsyncCargo { length(): number; payload?: number; push(task: any, callback? : Function): void; - push(task: any[], callback? : Function): void; saturated(): void; empty(): void; drain(): void; @@ -97,39 +94,28 @@ export interface AsyncCargo { } // Collections -export function each(arr: T[] | IterableIterator, iterator: AsyncIterator, callback?: ErrorCallback): void; -export function each(arr: Dictionary, iterator: AsyncIterator, callback?: ErrorCallback): void; +export function each(arr: IterableCollection, iterator: AsyncIterator, callback?: ErrorCallback): void; export const eachSeries: typeof each; -export function eachLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; -export function eachLimit(arr: Dictionary, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; +export function eachLimit(arr: IterableCollection, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; export const forEach: typeof each; export const forEachSeries: typeof each; export const forEachLimit: typeof eachLimit; -export function forEachOf(obj: T[] | IterableIterator, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; -export function forEachOf(obj: Dictionary, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export function forEachOf(obj: IterableCollection, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; export const forEachOfSeries: typeof forEachOf; -export function forEachOfLimit(obj: T[] | IterableIterator, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; -export function forEachOfLimit(obj: Dictionary, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export function forEachOfLimit(obj: IterableCollection, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; export const eachOf: typeof forEachOf; export const eachOfSeries: typeof forEachOf; export const eachOfLimit: typeof forEachOfLimit; export function map(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export function map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export const mapSeries: typeof map; -export function mapLimit( - arr: T[] | Dictionary | IterableIterator, - limit: number, - iterator: AsyncResultIterator, - callback?: AsyncResultArrayCallback -): void; +export function mapLimit(arr: IterableCollection, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export function mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; export function mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; export const mapValuesSeries: typeof mapValues; -export function filter(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; -export function filter(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; +export function filter(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; export const filterSeries: typeof filter; -export function filterLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; -export function filterLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; +export function filterLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; export const select: typeof filter; export const selectSeries: typeof filter; export const selectLimit: typeof filterLimit; @@ -141,36 +127,28 @@ export const inject: typeof reduce; export const foldl: typeof reduce; export const reduceRight: typeof reduce; export const foldr: typeof reduce; -export function detect(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; -export function detect(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export function detect(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; export const detectSeries: typeof detect; -export function detectLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; -export function detectLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export function detectLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; export const find: typeof detect; export const findSeries: typeof detect; export const findLimit: typeof detectLimit; export function sortBy(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function some(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; -export function some(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function some(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const someSeries: typeof some; -export function someLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; -export function someLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function someLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const any: typeof some; export const anySeries: typeof someSeries; export const anyLimit: typeof someLimit; -export function every(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; -export function every(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function every(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const everySeries: typeof every; -export function everyLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; -export function everyLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function everyLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const all: typeof every; export const allSeries: typeof every; export const allLimit: typeof everyLimit; -export function concat(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function concat(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function concatLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function concatLimit(arr: Dictionary, limit: number,iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function concat(arr: IterableCollection, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function concatLimit(arr: IterableCollection, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export const concatSeries: typeof concat; // Control Flow diff --git a/types/atom/atom-tests.ts b/types/atom/atom-tests.ts index b295259d79..cefa92ef5c 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -719,6 +719,9 @@ function testDisplayMarker() { // DisplayMarkerLayer ========================================================= function testDisplayMarkerLayer() { + // Properties + str = displayMarkerLayer.id; + // Lifecycle displayMarkerLayer.destroy(); displayMarkerLayer.clear(); @@ -1275,6 +1278,9 @@ function testMarker() { // MarkerLayer ================================================================ function testMarkerLayer() { + // Properties + str = markerLayer.id; + // Lifecycle markerLayer = markerLayer.copy(); bool = markerLayer.destroy(); diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index 5cc136f7a6..5db8f55ce5 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -9,7 +9,6 @@ // NOTE: only those classes exported within this file should be retain that status below. // https://github.com/atom/atom/blob/v1.24.0/exports/atom.js -/// /// import { ReadStream, WriteStream } from "fs"; @@ -40,58 +39,58 @@ export function watchPath(rootPath: string, options: {}, eventCallback: (events: export interface AtomEnvironment { // Properties /** A CommandRegistry instance. */ - commands: CommandRegistry; + readonly commands: CommandRegistry; /** A Config instance. */ - config: Config; + readonly config: Config; /** A Clipboard instance. */ - clipboard: Clipboard; + readonly clipboard: Clipboard; /** A ContextMenuManager instance. */ - contextMenu: ContextMenuManager; + readonly contextMenu: ContextMenuManager; /** A MenuManager instance. */ - menu: MenuManager; + readonly menu: MenuManager; /** A KeymapManager instance. */ - keymaps: KeymapManager; + readonly keymaps: KeymapManager; /** A TooltipManager instance. */ - tooltips: TooltipManager; + readonly tooltips: TooltipManager; /** A NotificationManager instance. */ - notifications: NotificationManager; + readonly notifications: NotificationManager; /** A Project instance. */ - project: Project; + readonly project: Project; /** A GrammarRegistry instance. */ - grammars: GrammarRegistry; + readonly grammars: GrammarRegistry; /** A HistoryManager instance. */ - history: HistoryManager; + readonly history: HistoryManager; /** A PackageManager instance. */ - packages: PackageManager; + readonly packages: PackageManager; /** A ThemeManager instance. */ - themes: ThemeManager; + readonly themes: ThemeManager; /** A StyleManager instance. */ - styles: StyleManager; + readonly styles: StyleManager; /** A DeserializerManager instance. */ - deserializers: DeserializerManager; + readonly deserializers: DeserializerManager; /** A ViewRegistry instance. */ - views: ViewRegistry; + readonly views: ViewRegistry; /** A Workspace instance. */ - workspace: Workspace; + readonly workspace: Workspace; /** A TextEditorRegistry instance. */ - textEditors: TextEditorRegistry; + readonly textEditors: TextEditorRegistry; // Event Subscription /** Invoke the given callback whenever ::beep is called. */ @@ -447,7 +446,7 @@ export interface Config { */ export interface Decoration { /** The identifier for this Decoration. */ - id: number; + readonly id: number; // Construction and Destruction /** @@ -654,6 +653,9 @@ export interface DisplayMarker { * This API is experimental and subject to change on any release. */ export interface DisplayMarkerLayer { + /** The identifier for the underlying MarkerLayer. */ + readonly id: string; + // Lifecycle /** Destroy this layer. */ destroy(): void; @@ -837,7 +839,7 @@ export interface LayerDecoration { */ export interface Marker { /** The identifier for this Marker. */ - id: number; + readonly id: number; // Lifecycle /** @@ -949,6 +951,9 @@ export interface Marker { /** Experimental: A container for a related set of markers. */ export interface MarkerLayer { + /** The identifier for this MarkerLayer. */ + readonly id: string; + // Lifecycle /** Create a copy of this layer with markers in the same state and locations. */ copy(): MarkerLayer; @@ -1031,7 +1036,7 @@ export class Notification { /** A notification manager used to create Notifications to be shown to the user. */ export interface NotificationManager { // Properties - notifications: Notification[]; + readonly notifications: Notification[]; // Events /** Invoke the given callback after a notification has been added. */ @@ -1267,8 +1272,8 @@ export class Range { * including cursor and selection positions, folds, and soft wraps. */ export class TextEditor { - id: number; - buffer: TextBuffer; + readonly id: number; + readonly buffer: TextBuffer; // NOTE: undocumented within the public API. Don't go down the rabbit hole. constructor(options?: object); @@ -2519,6 +2524,10 @@ export interface TextEditorRegistry { observe(callback: (editor: TextEditor) => void): Disposable; } +export interface JQueryCompatible extends Iterable { + jquery: string; +} + export type TooltipPlacement = |"top"|"bottom"|"left"|"right" |"auto"|"auto top"|"auto bottom"|"auto left"|"auto right"; @@ -2526,7 +2535,7 @@ export type TooltipPlacement = /** Associates tooltips with HTML elements or selectors. */ export interface TooltipManager { /** Add a tooltip to the given element. */ - add(target: HTMLElement, options: { + add(target: HTMLElement | JQueryCompatible, options: { item?: object, } | { title?: string|(() => string), @@ -2975,7 +2984,7 @@ export interface WorkspaceCenter { * Node's ChildProcess. */ export class BufferedProcess { - process?: ChildProcess; + readonly process?: ChildProcess; constructor(options: ProcessOptions); @@ -4043,10 +4052,10 @@ export interface MenuManager { */ export interface Package { /** The name of the Package. */ - name: string; + readonly name: string; /** The path to the Package on disk. */ - path: string; + readonly path: string; // Event Subscription /** Invoke the given callback when all packages have been activated. */ @@ -4368,7 +4377,7 @@ export interface Pane { */ export interface Panel { /** Whether or not the Panel is visible. */ - visible: boolean; + readonly visible: boolean; // Construction and Destruction /** Destroy and remove this panel from the UI. */ @@ -4489,7 +4498,7 @@ export interface Project { * syntax tree to a token including all scope names for the entire path. */ export interface ScopeDescriptor { - scopes: string[]; + readonly scopes: string[]; /** Returns all scopes for this descriptor. */ getScopesArray(): string[]; @@ -4885,13 +4894,13 @@ export class Task { */ export class TextBuffer { /** The unique identifier for this buffer. */ - id: string; + readonly id: string; /** The number of retainers for the buffer. */ - refcount: number; + readonly refcount: number; /** Whether or not the bufffer has been destroyed. */ - destroyed: boolean; + readonly destroyed: boolean; /** Create a new buffer backed by the given file path. */ static load(filePath: string, params?: BufferLoadOptions): Promise; @@ -6744,11 +6753,11 @@ export interface TokenizeLineResult { * jQuery, which is an expensive dependency we want to eliminate. */ export interface Tooltip { - options: TooltipOptions; - enabled: boolean; - timeout: number; - hoverState: "in"|"out"|null; - element: JQuery|HTMLElement; + readonly options: TooltipOptions; + readonly enabled: boolean; + readonly timeout: number; + readonly hoverState: "in"|"out"|null; + readonly element: HTMLElement; getTitle(): string; getTooltipElement(): HTMLElement; @@ -6765,11 +6774,11 @@ export interface ViewModel { } export interface WindowLoadSettings { - appVersion: string; - atomHome: string; - devMode: boolean; - resourcePath: string; - safeMode: boolean; - env?: { [key: string]: string|undefined }; - profileStartup?: boolean; + readonly appVersion: string; + readonly atomHome: string; + readonly devMode: boolean; + readonly resourcePath: string; + readonly safeMode: boolean; + readonly env?: { [key: string]: string|undefined }; + readonly profileStartup?: boolean; } diff --git a/types/bingmaps/Autosuggest.d.ts b/types/bingmaps/Autosuggest.d.ts deleted file mode 100644 index 7d83ca6e4b..0000000000 --- a/types/bingmaps/Autosuggest.d.ts +++ /dev/null @@ -1,112 +0,0 @@ -declare module Microsoft.Maps { - /** Options used to customize the autosuggest functionality. */ - export interface IAutosuggestOptions { - /** Specifies if street address suggestions should be returned. Default: true */ - addressSuggestions?: boolean; - - /** - * Specifies if the user’s location should be auto detected using their IP address, if no location information is provided - * in the userLocation property. Default: true - */ - autoDetectLocation?: boolean; - - /** - * A bounding box that is used to help influence the results such that locations that are in or near this bounding box - * are given more weight than they would normally. - */ - bounds?: LocationRect; - - /** - * A reference to a map instance. If the useMapView property is set to true, the bounding box of the map view will be used - * to influence the weight of suggestions. - */ - map?: Map; - - /** The maximum number of results to return. Can be any value between 1 and 10. Default: 5 */ - maxResults?: number; - - /** Specifies if place suggestions (city, landmark, etc.) should be returned. Default: true */ - placeSuggestions?: boolean; - - /** - * Indicates if the maps bounding box should be used to influence the suggested results. Ignored if the bounds property is - * set. Default: true - */ - useMapView?: boolean; - - /** A coordinate indicating where the user is located. This will influence the results to be more relevant to the user. */ - userLocation?: Location; - } - - /** Represents the suggestion result from the Autosuggest manager. */ - export interface ISuggestionResult { - /** A structured address object for the result. */ - address: IAddress; - - /** A LocationRect that can be used to set the map view over the result. */ - bestView: LocationRect; - - /** Unique entity id to be used for searching the entity. */ - entityId: string; - - /** The type of the result; Address, Place */ - entityType: string; - - /** The sub type of result; Address, RoadBlock, PopulatedPlace, CountryRegion, etc. */ - entitySubType: string; - - /** A nicely formatted suggestion string for the result based on market. */ - formattedSuggestion: string; - - /** - * The coordinate of the result. This value is only returned for place (city, landmarks) results and not for addresses. - * Street addresses will need to be geocoded to get their location. - */ - location: Location; - - /** A secondary title that provides additional context to the title value of the suggestion. **/ - subtitle: string; - - /** The display title for the result (i.e. “Redmond”). */ - title: string; - } - - /** - * The AutosuggestManager is the primary class in the Autosuggest module that powers the autosuggest functionality. - * @requires The Microsoft.Maps.Autosuggest module. - */ - export class AutosuggestManager { - /** - * @constructor - * @requires The Microsoft.Maps.Autosuggest module. - * @param options The options to use with the autosuggest manager. - */ - constructor(options?: IAutosuggestOptions); - - /** - * Attaches the Autosuggest functionality to an input box. - * @param suggestionBoxId The HTML element identifier of the input box. - * @param suggestionContainerId The Id of container where suggestions will be displayed. - * @param selectedSuggestionCallback A reference to a callback function that will be called when a user selects a suggestion from the Autosuggest UI. - */ - public attachAutosuggest(suggestionBoxId: string, suggestionContainerId: string, selectedSuggestionCallback: (result: ISuggestionResult) => void) : void; - - /** Detaches the autosuggest functionality from the input box, freeing any resources it has or events it has tied to. */ - public detachAutosuggest(): void; - - /** Disposes the Autosuggest object, freeing any resources it has or events it has tied to. */ - public dispose(): void; - - /** - * Gets the options currently used by the autosuggest manager. - * @returns The options currently used by the autosuggest manager. - */ - public getOptions(): IAutosuggestOptions; - - /** - * Sets the options currently used by the autosuggest manager. - * @param options The options to use with the autosuggest manager. - */ - public setOptions(options?: IAutosuggestOptions): void; - } -} \ No newline at end of file diff --git a/types/bingmaps/Clustering.d.ts b/types/bingmaps/Clustering.d.ts deleted file mode 100644 index 17c9425933..0000000000 --- a/types/bingmaps/Clustering.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -declare module Microsoft.Maps { - /** The options used to customize how the ClusterLayer functions. */ - export interface IClusterLayerOptions { - /** - * A callback function that is fired after the clustering for a map view has completed. This is useful if you want to generate a list of locations based on what is in the current view. - */ - callback?: () => void; - - /** - * A callback function that allows you to process a clustered pushpin before it is added to a layer. This is useful if you want to add events or set style options on the clustered pushpin. - */ - clusteredPinCallback?: (pin: ClusterPushpin) => void; - - /** - * Indicates if the layer should cluster the locations or not. Default: true - */ - clusteringEnabled?: boolean; - - /** - * Defines how clusters are positioned on the map. Default: MeanAverage - */ - clusterPlacementType?: ClusterPlacementType; - - /** - * The width and height of the gird cells used for clustering in pixels. Default: 45 - */ - gridSize?: number; - - /** - * Offsets the placement of clustered pushpins by a set number of pixels. This option is only available when the placement type is set to GridCenter. - * This is useful if you have multiple cluster layers on the map and you want to offset the clustered pushpins between the layers so that they are visible, - * otherwise the clusters from the different layers would overlap completely. - */ - layerOffset?: Point; - - /** - * A boolean indicating if the layer is visible or not. - */ - visible?: boolean; - - /** - * The z-index of the layer. - */ - zIndex?: number; - } - - /** - * Used to specify how a clustered pushpin should be positioned relative to the pushpins it contains. - * @requires The Microsoft.Maps.Clustering module. - */ - export enum ClusterPlacementType { - /** - * Mean Average placement calculates the average position of a group of coordinates. This method creates a more realistic representation of the data, - * however requires more processing power and increases the chances of pushpins overlapping. - */ - MeanAverage, - - /** - * This method is the simplest way to represent a cluster. It places the cluster at the first location in the cluster. This method may not accurately - * represent the data but requires little processing power. - */ - FirstLocation - } - - /** - * This class extends the Pushpin class and has all the same methods and properties plus the following properties. - * @requires The Microsoft.Maps.Clustering module. - */ - export class ClusterPushpin extends Pushpin { - /** An array of all the pushpins that are in the cluster. */ - containedPushpins: Pushpin[]; - - /** - * The grid cell key that can be used retrieve the clustered pushpin(s) from the clustering layer. This is useful when creating a clickable list that - * link items in the list to clusters or pushpins on the map. Your list just needs to store the gridKey value. - */ - gridKey: number; - } - - /** - * This class allows you to easily add in client side clustering to your application. Client Side Clustering is a method where pushpins that are close - * together are grouped and represented as a single pushpin, often using a different icon to indicate the cluster. This is a great way to improve both - * the user experience and performance of the map. - * @requires The Microsoft.Maps.Clustering module. - */ - export class ClusterLayer implements IDataLayer { - /** - * @constructor - * @requires The Microsoft.Maps.Clustering module. - * @param pushpins An array of pushpins to cluster in the layer. - * @param options The options used to customize how the ClusterLayer functions. - */ - constructor(pushpins: Pushpin[], options?: IClusterLayerOptions); - - /** Clears all the data in the cluster layer. */ - public clear(): void; - - /** - * Gets all the pushpins that are in the current map view. If clustering is disabled, all pushpins in the clustering layer are returned. - * @returns All the pushpins that are in the current map view. If clustering is disabled, all pushpins in the clustering layer are returned. - */ - public getDisplayedPushpins(): Pushpin[]; - - /** - * Gets the current options used by the cluster layer. - * @returns The current options used by the cluster layer. - */ - public getOptions(): IClusterLayerOptions; - - /** - * Gets all pushpins that are in the layers. - * @returns An array of all the pushpins that are in the layers. - */ - public getPushpins(): Pushpin[]; - - /** - * Gets the original pushpins that are in the specified grid cell. - * @param The gridKey index to retrieve the pushpins for. - * @returns The original pushpins that are in the specified grid cell. - */ - public getPushpinsByGridKey(gridKey: number): Pushpin[]; - - /** - * Gets the pushpin in the specified cluster grid cell which can be either a ClusterPushpin if there are multiple pushpins in a cell or a single Pushpin. - * @param The gridKey index to retrieve the pushpins for. - * @returns The pushpin in the specified cluster grid cell which can be either a ClusterPushpin if there are multiple pushpins in a cell or a single Pushpin. - */ - public getClusterPushpinByGridKey(gridKey: number): ClusterPushpin | Pushpin; - - /** - * Sets the clustering options to use in the layer. - * @params options The clustering options to use in the layer. - */ - public setOptions(options: IClusterLayerOptions): void; - - /** - * Sets the array of pushpins that are used in the clustering layer. - * @param pushpins An array of pushpins that are to be used by the clustering layer. - */ - public setPushpins(pushpins: Pushpin[]): void; - } -} \ No newline at end of file diff --git a/types/bingmaps/Contour.d.ts b/types/bingmaps/Contour.d.ts deleted file mode 100644 index cd2d9767c7..0000000000 --- a/types/bingmaps/Contour.d.ts +++ /dev/null @@ -1,87 +0,0 @@ -declare module Microsoft.Maps { - - /** - * The contour layer options - */ - interface IContourLayerOptions { - /** The z-index of this layer */ - zIndex?: number; - - /** Whether the layer is visible */ - visible?: boolean; - - /** A callback function which defines the color of the contour line fill. */ - colorCallback?: (contourValue: number | string) => string | Color; - - /** The polygon options that apply to all contour lines of this layer */ - polygonOptions?: IPolygonOptions; - } - - /** - * The contour line of a contour layer - */ - export class ContourLine extends Polygon { - /** The contour lines that are directly nested inside this contour line */ - public innerContourLines: ContourLine[]; - - /** The outer/parent contour line of this contour */ - public outerContourLine: ContourLine; - - /** The data value associated with this contour line */ - public contourValue: number | string; - - /** - * @constructor - * @param boundary The boundary of this contour line - * @param contourValue The value associated with this contour line - */ - constructor(boundary: Location[], contourValue?: number | string); - } - - /** - * The contour layer class. - */ - export class ContourLayer extends Layer { - /** - * @constructor - * @param contourLines The contour lines that compose this layer. - * @param options The contour layer options. - */ - constructor(contourLines: ContourLine[], options?: IContourLayerOptions); - - /** - * Clears all data on the contour layer. - */ - public clear(): void; - - /** - * Gets the contour lines of this layer. - * @returns The contour lines of this layer. - */ - public getContourLines(): ContourLine[]; - - /** - * Gets the polygons that were generated from the contour lines in this layer. - * @returns The polygons that were generated from the contour lines in this layer. - */ - public getContourPolygons(): Polygon[]; - - /** - * Retrieves the options of this contour layer. - * @returns The options of this contour layer. - */ - public getOptions(): IContourLayerOptions; - - /** - * Sets the contour lines used to calculate the polygon areas of this layer. - * @param contourLines The contour lines used to calculate the polygon areas of this layer. - */ - public setContourLines(contourLines: ContourLine[]): void; - - /** - * Sets the options of the contour layer. - * @param options The new options to update the layer. - */ - public setOptions(options: IContourLayerOptions): void; - } -} \ No newline at end of file diff --git a/types/bingmaps/DataBinning.d.ts b/types/bingmaps/DataBinning.d.ts deleted file mode 100644 index e33b2d5113..0000000000 --- a/types/bingmaps/DataBinning.d.ts +++ /dev/null @@ -1,148 +0,0 @@ -/// - -declare module Microsoft.Maps { - - /** - * Specifies the shape of data bin rendered in the layer. - */ - export enum DataBinType { - /* Renders data bins as circles in a square grid. */ - circle, - - /* Renders data bins as hexagons with a flat top edge. */ - hexagon, - - /* Renders data bins as circles in a hexagonal grid. */ - hexCircle, - - /* Renders data bins as hexagons with a pointy top corner. */ - pointyHexagon, - - /* Renders data bins as a square grid. */ - square - } - - /** - * A set options the define how a data binning layer is rendered. - */ - export interface IDataBinningOptions { - /* The name of a property in the Pushpin.metadata object on which to perform calculations (average, count, sum) against the pushpins in each data bin. */ - aggregationProperty?: string; - - /* - * A callback function which defines the color a data bin polygon should be. This callback recieves data bin information - * along with the min and max calculated metrics for the data set. If set, this callback function must return a color value. - */ - colorCallback?: (binInfo: IDataBinInfo, min: IDataBinMetrics, max: IDataBinMetrics) => string | Color; - - /* The shape of the data bin to generate. Default: hexagon */ - dataBinType?: DataBinType; - - /* The distance units of the radius option. Default: meters */ - distanceUnits?: SpatialMath.DistanceUnits; - - /* The default options used for rendering the data bin polygons. */ - polygonOptions?: IPolygonOptions; - - /* - * A spatial distance which will be converted into a pixel distance at the equater and used to generate symetrically sized data bins - * that have the apprimate spatial distance radius. Default: 1000 - */ - radius?: number; - - /* - * A callback function which defines how much to scale a data bins size. This callback recieves data bin information - * along with the min and max calculated metrics for the data set. If set, this callback function must return a number between 0 and 1. - */ - scaleCallback?: (binInfo: IDataBinInfo, min: IDataBinMetrics, max: IDataBinMetrics) => number; - } - - /** - * A set of values calculated from the pushpins in a data bin. - */ - export interface IDataBinMetrics { - - /* The average value of the aggregation property of the pushpins in a data bin. */ - average?: number; - - /* The number of pushpins in a data bin. */ - count?: number; - - /* The number of pushpins in the data bin who's aggregation property has a value. */ - countNotBlank?: number; - - /* The number of pushpins in the data bin who's aggregation property is a valid number. */ - countNumbers?: number; - - /* The sum of the aggregation property of the pushpins in a data bin. */ - sum?: number; - } - - /** - * The result of a calculated data bin. - */ - export interface IDataBinInfo { - /* An array of all the pushpins that are in the data bin. */ - containedPushpins: Microsoft.Maps.Pushpin[]; - - /* A set of calculated metric values determined using the aggregationProperty value of all the pushpins contained in the data bin. */ - metrics: IDataBinMetrics; - } - - /** - * A polygon which represents a data bin on the map and contains the data bin information. - */ - - export class DataBinPolygon extends Polygon { - /* Information about the data bin; the contained pushpins and calculated metrics. */ - public dataBinInfo: IDataBinInfo; - } - - /** - * This class provides a data binning visualization for the map. It takes in an array of pushpins, groups them into - * symmetrical shapes that fit together in a grid such as hexagons. Aggregation of data values are done and can be - * used to customize how the data bins are rendered on the map (i.e. scale / color) . - */ - export class DataBinningLayer extends Layer { - /** - * Initializes the data binning layer. - * @param pushpins The array of pushpins that are used to generate the data bins. - * @param options The options used for calculating and rendering the data bins. - */ - constructor(pushpins?: Pushpin[], options?: IDataBinningOptions); - - /** - * Gets the options used for calculating and rendering the data bins. - * @returns The options used for calculating and rendering the data bins. - */ - public getOptions(): IDataBinningOptions; - - /** - * Gets all pushpins that are in the layers. - * @returns All pushpins that are in the layers. - */ - public getPushpins(): Pushpin[]; - - /** - * Sets the array of pushpins that are used to generate the data bins. - * @param pushpins The array of pushpins that are used to generate the data bins. - */ - public setPushpins(pushpins: Pushpin[]): void; - - /** - * Clears all the data in the data binning layer. - */ - public clear(): void; - - /** - * Cleans up any resources this object is consuming. - */ - public dispose(): void; - - /** - * Sets the options used for calculating and rendering the data bins. - * @param options The options used for calculating and rendering the data bins. - */ - public setOptions(options: IDataBinningOptions): void; - } -} \ No newline at end of file diff --git a/types/bingmaps/Directions.d.ts b/types/bingmaps/Directions.d.ts deleted file mode 100644 index 3663fc8c21..0000000000 --- a/types/bingmaps/Directions.d.ts +++ /dev/null @@ -1,611 +0,0 @@ -declare module Microsoft.Maps.Directions { - ///////////////////////////////////// - /// Enumerations - //////////////////////////////////// - - /** Distance units for calculating the directions in. */ - export enum DistanceUnit { - - /** A distance in Kilometers. */ - km, - - /** A distance in Miles. */ - miles - } - - /** Defines the type of route to calculate. */ - export enum RouteMode { - /** Driving directions are calculated. */ - driving, - - /** Transit directions are calculated. */ - transit, - - /** Walking directions are calculated. */ - walking - } - - /** Defines features to avoid when calculating the route. */ - export enum RouteAvoidance { - /** Calculate the best route using any travel option available. */ - none = 0, - - /** Reduce the use of limited access highways when calculating the route. */ - minimizeHighways = 1, - - /** Reduce the use of roads with tolls when calculating the route. */ - minimizeToll = 2, - - /** Avoid using limited access highways when calculating the route. */ - avoidHighways = 4, - - /** Avoid using roads with tolls when calculating the route. */ - avoidToll = 8, - - /** Avoid using express trains when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */ - avoidExpressTrain = 16, - - /** Avoid using airlines when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */ - avoidAirline = 32, - - /** Avoid using bullet trains when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */ - avoidBulletTrain = 64 - } - - /** Response codes for a route calculation request. */ - export enum RouteResponseCode { - /** The route was successfully calculated. */ - success = 0, - - /** An unknown error has occurred. */ - unknownError = 1, - - /** A nearby road cannot be found for one or more of the route waypoints. */ - cannotFindNearbyRoad = 2, - - /** - * The distance between two route waypoints, or the total length of the route exceeds the limit of the route mode. - * Modify the waypoint locations so that they are closer together. - */ - tooFar = 3, - - /** - * A route cannot be calculated for the specified waypoints. For example, this code is returned when a route between - * “Seattle, WA” and “Honolulu, HI” is requested. - */ - noSolution = 4, - - /** There is no route data for the specified waypoints. */ - dataSourceNotFound = 5, - - /** There are no transit options available for the specified time. */ - noAvailableTransitTrip = 7, - - /** The transit stops are so close that walking is always a better option. */ - transitStopsTooClose = 8, - - /** The transit stops are so close that walking is a better option. */ - walkingBestAlternative = 9, - - /** - * There is no transit data available for the route or for one or more of the specified waypoints, - * or the waypoints are in different transit areas that do not overlap. - */ - outOfTransitBounds = 10, - - /** The directions calculation request has timed out. */ - timeOut = 11, - - /** - * One or more waypoints need to be disambiguated. This error does not occur if the - * autoDisplayDisambiguation directions render option is set to true. - */ - waypointDisambiguation = 12, - - /** One or more waypoints do not have an address or location specified. */ - hasEmptyWaypoint = 13, - - /** The maximum number of waypoints, which is 25, has been exceeded. */ - exceedMaxWaypointLimit = 14, - - /** At least two waypoints are required to calculate a route. */ - atleastTwoWaypointRequired = 15, - - /** The first or last waypoint is a via point, which is not allowed. */ - firstOrLastStoppointIsVia = 16, - - /** The search service failed to return results. */ - searchServiceFailed = 17, - - /** The credentials passed to the Directions module are invalid. */ - invalidCredentials = 18 - } - - /** Defines optimization options for calculating directions. */ - export enum RouteOptimization { - /** Calculate a route the shortest time. */ - shortestTime = 0, - - /** Calculate a route with the shortest distance. */ - shortestDistance = 1, - - /** The route is calculated to minimize the time and uses current traffic information. */ - timeWithTraffic = 2, - - /** The route is calculated to minimize the time and avoid road closures. Traffic information is not used in the calculation. */ - timeAvoidClosure = 3, - - /** Minimize the cost when calculating directions. This option only affects routes with a transitRouteMode that have the culture set to ja-jp.*/ - minimizeMoney = 4, - - /** Minimize transit transfers when calculating directions. This option only affects routes with a transitRouteMode that have the culture set to ja-jp.*/ - minimizeTransfers = 5, - - /** Minimize the amount of walking when calculating directions. This option only affects routes with a transitRouteMode that have the culture set to ja-jp.*/ - minimizeWalking = 6 - } - - /** An enumeration that specifies the releance of a dateTime when calculating a route. */ - export enum TimeType { - /** The dateTime parameter contains the desired arrival time for a transit request. */ - arrival, - - /** The dateTime parameter contains the desired departure time for a transit request. */ - departure, - - /** The dateTime parameter should be ignored and the first available transit taken. */ - firstAvailable, - - /** The dateTime parameter contains the latest departure time available for a transit request. */ - lastAvailable - } - - ///////////////////////////////////// - /// Interfaces - //////////////////////////////////// - - /** Contains the arguments for directions events. */ - export interface IDirectionsEventArgs { - /** The calculated route (or routes, if the route mode is transit). */ - route: IRoute[]; - - /** The route summary (or summaries) of the route(s) defined in the route property. */ - routeSummary: IRouteSummary[]; - } - - /** Contains arguments for directions error events. */ - export interface IDirectionsErrorEventArgs { - /** The code which identifies the error that occurred. */ - responseCode: RouteResponseCode; - - /** The error message. */ - message: string; - } - - /** Represents one direction in a set of route directions. */ - export interface IDirectionsStep { - /** The child direction items for this directions step. */ - childItineraryItems: IDirectionsStep[]; - - /** The location of the start of the direction. */ - coordinate: Location; - - /** The total distance of the step in the unit specified in the distanceUnit property of the DirectionsRequestOptions. */ - distance: string; - - /** The total time, in seconds, of the direction step. */ - durationInSeconds: number; - - /** The HTML formatted route instruction associated with the step. */ - formattedText: string; - - /** A boolean indicating whether the maneuver image is a road shield image. */ - isImageRoadShield: boolean; - - /** The name of the maneuver image. */ - maneuverImageName: string; - - /** An array of strings, where each string is a hint to help determine when to move to the next direction step. Not all direction steps have hints. */ - postIntersectionHints: string[]; - - /** An array of strings, where each string is a hint to help determine when you have arrived at this direction step. Not all direction steps have hints. */ - preIntersectionHints: string[]; - - /** The name of the transit stop where this step originates. */ - startStopName: string; - - /** The transit line associated with this step. */ - transitLine: ITransitLine; - - /** The URL of the image to use for transit direction steps. */ - transitStepIcon: string; - - /** The ID of the transit stop. */ - transitStopId: string; - - /** The name of the transit line end. */ - transitTerminus: string; - } - - /** Represents a route. */ - export interface IRoute { - /** The legs of the route. Each route leg represents the route between two waypoints. */ - routeLegs: IRouteLeg[]; - - /** An array of locations that makes up the path of the route. */ - routePath: Location[]; - } - - /** Represents a leg of a route. A route leg is the part of the route between two stop waypoints. */ - export interface IRouteLeg { - /** The end time of the route leg. This property only applies when the routeMode of the DirectionsRequestOptions is set to transit. */ - endTime: Date; - - /** The location of the last waypoint of this leg. */ - endWaypointLocation: Location; - - /** The directions steps associated with this route leg. */ - itineraryItems: IDirectionsStep[]; - - /** The index of the route to which this route leg belongs. */ - originalRouteIndex: number; - - /** The start time of the route leg. This property only applies when the routeMode of the DirectionsRequestOptions is set to transit. */ - startTime: Date; - - /** The location of the first waypoint of this route leg. */ - startWaypointLocation: Location; - - /** The sub legs of this route leg. A sub leg of a route is the part of the route between a stop point and a via point or between two via points.*/ - subLegs: IRouteSubLeg[]; - - /** The summary which describes this route leg. */ - summary: IRouteSummary; - } - - /** Represents a route sub leg. A route sub leg is the part of the route between a stop point and a via point or between two via points. */ - export interface IRouteSubLeg { - /** The location of the last waypoint of the sub leg. */ - actualEnd: Location; - - /** The location of the first waypoint of the sub leg. */ - actualStart: Location; - - /** The description of the last waypoint of the sub leg. */ - endDescription: string; - - /** The description of the first waypoint of the sub leg. */ - startDescription: string; - } - - /** Represents a route summary. */ - export interface IRouteSummary { - /** The total travel distance of the route */ - distance: number; - - /** The cost of the route. This property is only returned if the routeMode of the IDirectionsRequestOptions is set to transit and the map culture is set to ja-jp. */ - monetaryCost: number; - - /** The location of the northeast corner of bounding box that defines the best map view of the route. */ - northEast: Location; - - /** The location of the southwest corner of bounding box that defines the best map view of the route. */ - southWest: Location; - - /** The total travel time, in seconds, for the route. */ - time: number; - - /** - * The total travel time, in seconds, taking into account traffic delays, for the route. - * This property is 0 if the avoidTraffic property of the IDirectionsRequestOptions is set to false. - */ - timeWithTraffic: number; - } - - /** Contains information about a transit line. */ - export interface ITransitLine { - /** The short name for the transit line. */ - abbreviatedName: string; - - /** The ID of the agency that owns the transit line. */ - agencyId: number; - - /** The name of the agency that owns the transit line. */ - agencyName: string; - - /** The URL of the website of the agency that owns the transit line. */ - agencyUrl: string; - - /** Phone number for the transit agency. */ - phoneNumber: string; - - /** Information about the provider of this transit line data. */ - providerInfo: string; - - /** The uri for the transit agencies website. */ - uri: string; - - /** The full name of this transit line. */ - verboseName: string; - } - - /** Options that can be used to define a waypoint. */ - export interface IWaypointOptions { - /** - * The address string of the waypoint. For example, the following strings are valid for this parameter: "Seattle", "1 Microsoft Way, Redmond, WA". Either the address or location property must be specified. - */ - address?: string; - - /** - * A boolean indicating whether the waypoint is a via point. A via point is a point along the route that is not a stop point. Set this property to - * true if you just want the route to pass through this location. Default: false - */ - isViaPoint?: boolean; - - /** The location of the waypoint. Either the address or location property must be specified. */ - location?: Location; - } - - /** Contains options for the directions to calculate. */ - export interface IDirectionsRequestOptions { - /** The unit to use when displaying direction distances. */ - distanceUnit?: DistanceUnit; - - /** The number of routes to calculate. */ - maxRoutes?: number; - - /** The features to avoid when calculating the route. */ - routeAvoidance?: RouteAvoidance[]; - - /** A boolean indicating whether the route line on the map can be dragged with the mouse cursor. */ - routeDraggable?: boolean; - - /** If multiple routes are returned, the index of the route and directions to display. */ - routeIndex?: number; - - /** The type of directions to calculate. */ - routeMode?: RouteMode; - - /** The optimization setting for the route calculation. */ - routeOptimization?: RouteOptimization; - - /** The type of the time specified. The default value is departure. */ - timeType?: TimeType; - - /** The time to use when calculating the route. If this property is set to null, the current time is used */ - time?: Date; - } - - /** Represents render options for a route. */ - export interface IDirectionsRenderOptions { - /** A boolean indicating whether to automatically set the map view to the best map view of the calculated route. Default: true */ - autoUpdateMapView?: boolean; - - /** A boolean indicating whether to display the disclaimer about the accuracy of the directions. Default: true */ - displayDisclaimer?: boolean; - - /** A boolean indicating whether to display the icons for each direction maneuver. Default: true */ - displayManeuverIcons?: boolean; - - /** A boolean indicating whether to display direction hints that describe when a direction step was missed. Default: true */ - displayPostItineraryItemHints?: boolean; - - /** - * A boolean indicating whether to display direction hints that describe what to look for before you come to the next - * direction step. The default value is true. - */ - displayPreItineraryItemHints?: boolean; - - /** A boolean indicating whether to display the route selector control. Default: true */ - displayRouteSelector?: boolean; - - /** A boolean indicating whether to display direction warnings. Default: true */ - displayStepWarnings?: boolean; - - /** A boolean indicating whether to display a warning about walking directions. Default: true */ - displayWalkingWarning?: boolean; - - /** The polyline options that define how to draw the route line on the map, if the RouteMode is driving. */ - drivingPolylineOptions?: IPolylineOptions; - - /** The pushpin options that define how the first waypoint should be rendered. */ - firstWaypointPushpinOptions?: IPushpinOptions; - - /** The DOM element inside which the directions itinerary will be rendered. */ - itineraryContainer?: HTMLElement; - - /** The pushpin options that define how the last waypoint should be rendered. */ - lastWaypointPushpinOptions?: IPushpinOptions; - - /** A boolean indicating whether to show the input panel. Default: false */ - showInputPanel?: boolean; - - /** The options that define how to draw the route line on the map, if the RouteMode is transit. */ - transitPolylineOptions?: IPolylineOptions; - - /** The options that define how to draw the route line on the map, if the RouteMode is walking. */ - walkingPolylineOptions?: IPolylineOptions; - - /** The options that define the pushpin to use for all route waypoints by default. The first and last waypoints in the route will be overriden by firstWaypointPushpinOptions and lastWaypointPushpinOptions if set. */ - waypointPushpinOptions?: IPushpinOptions; - } - - ///////////////////////////////////// - /// Classes - //////////////////////////////////// - - /** An object used to define a start, end or stop location along a route. */ - export class Waypoint { - /** - * @constructor - * @param options: Options used to define the Waypoint. - */ - constructor(options: IWaypointOptions); - - /** Releases any resources associated with the waypoint. */ - public dispose(): void; - - /** - * Gets the address associated with the waypoint. - * @returns The address associated with the waypoint. - */ - public getAddress(): string; - - /** - * Gets the location of the waypoint. - * @returns The location of the waypoint. - */ - public getLocation(): Location; - - /** - * Gets a boolean value indicating whether the waypoint is a via point. - * @returns A boolean value indicating whether the waypoint is a via point. - */ - public isViapoint(): boolean; - - /** - * Sets options for the waypoint. For these options to take effect, you must recalculate the route. - * @param options Options used to define the Waypoint. - */ - public setOptions(options: IWaypointOptions): void; - } - - /** The main class in the Directions module that process direction calculations and rendering. */ - export class DirectionsManager { - - /** - * @constructor - * @param map A map to calculate directions for. - * @param waypoints An array of waypoints to be added to the route. - */ - constructor(map: Map, waypoints?: Waypoint[]); - - /** - * Adds a waypoint to the route at the given index, if specified. If an index is not specified, the waypoint is added as the last waypoint in the route. The maximum number of walking or driving waypoints is 25. The maximum number of transit waypoints is 2. Up to 10 via points are allowed between two stop waypoints. To recalculate the route, use calculateDirections. - * @param waypoint The waypoint to be added to the directions manager. - * @param index An index at which the waypoint is to be added. - */ - public addWaypoint(waypoint: Waypoint, index?: number): void; - - /** - * Calculates directions based on request and render options set - */ - public calculateDirections(): void; - - /** Clears the directions request and render options and removes all waypoints */ - public clearAll(): void; - - /** - * Clears the directions displayed and removes the route line from the map. - * This method does not remove waypoints from the route and retains all calculated direction information and option settings. - */ - public clearDisplay(): void; - - /** Deletes the DirectionsManager object and releases any associated resources. */ - public dispose(): void; - - /** - * Gets all the waypoints in the directions manager. - * @returns All the waypoints in the directions manager. - */ - public getAllWaypoints(): Waypoint[]; - - /** - * Gets the currently displayed route information. - * @returns The currently displayed route information. - */ - public getCurrentRoute(): IRoute; - - /** - * Gets the route render options. - * @returns The route render options - */ - public getRenderOptions(): IDirectionsRenderOptions; - - /** - * Gets the directions request options. - * @returns The directions request options. - */ - public getRequestOptions(): IDirectionsRequestOptions; - - /** - * Gets the current calculated route(s) - * @returns The current calculated route(s). If the route was not successfully calculated, null is returned. - */ - public getRouteResult(): IRoute[]; - - /** - * Removes the given waypoint or the waypoint identified by the given index from the route. - * @param waypointOrIndex A Waypoint object to be removed or the index of the waypoint to be removed - */ - public removeWaypoint(waypointOrIndex: Waypoint | number): void; - - /** - * Sets the specified render options for the route. - * @param options The options that customize the rendering of the calculated route. - */ - public setRenderOptions(options: IDirectionsRenderOptions): void; - - /** - * Sets the specified route calculation options. - * @param options The route calculation options. - */ - public setRequestOptions(options: IDirectionsRequestOptions): void; - - /** - * Displays an input panel for calculating directions in the specified container. Provides autosuggest for location inputs. - * @param inputContainerId The id name of the HTML container in which to render the directions input panel. - */ - public showInputPanel(inputContainerId: string): void; - } -} - -declare module Microsoft.Maps { - /** A static class that manages events within the map SDK. */ - module Events { - ///////////////////////////////////// - /// addHandler Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * • directionsError - * • directionsUpdated - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: Directions.DirectionsManager, eventName: string, handler: (eventArg?: Directions.IDirectionsEventArgs | Directions.IDirectionsErrorEventArgs) => void): IHandlerId; - - ///////////////////////////////////// - /// addOne Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * • directionsError - * • directionsUpdated - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: Directions.DirectionsManager, eventName: string, handler: (eventArg?: Directions.IDirectionsEventArgs | Directions.IDirectionsErrorEventArgs) => void): void; - - ///////////////////////////////////// - /// addThrottledHandler Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * • directionsError - * • directionsUpdated - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: Directions.DirectionsManager, eventName: string, handler: (eventArg?: Directions.IDirectionsEventArgs | Directions.IDirectionsErrorEventArgs) => void, throttleInterval: number): IHandlerId; - } -} diff --git a/types/bingmaps/DrawingTools.d.ts b/types/bingmaps/DrawingTools.d.ts deleted file mode 100644 index bd5c938e4e..0000000000 --- a/types/bingmaps/DrawingTools.d.ts +++ /dev/null @@ -1,234 +0,0 @@ -declare module Microsoft.Maps { - /** An object that contains the event arguments for when the drawing mode changes in the drawing tools. **/ - export interface IDrawingModeChangedData { - - /** The shape being modified by the drawing tools. **/ - shape: IPrimitive; - - /** The new drawing mode. **/ - mode: DrawingTools.DrawingMode; - } - - /** - * The DrawingManager class manages the ability to draw and edit multiple shapes on the map. Shapes managed by this class are rendered on a separate drawing layer. - * User can use a mouse or a touch screen to draw on the map. When they are done, pressing the escape button or any button on the toolbar will exit the current drawing mode. - * This class does not have a publicly accessible constructor and can only be accessed using the showDrawingManager of the DrawingTools class. - */ - export interface DrawingManager { - /** - * Adds a shapes to the layer, at the specified index if specified. - • @param data The shape(s) to be added to the layer. - • @param index The index at which to insert the shape into the layer. - */ - add(data: IPrimitive | IPrimitive[], index?: number): void; - - /** - * Disposes the drawing manager instance. - */ - dispose(): void; - - /** - * Resets the drawing manager and clears all shapes in the drawing layer. - */ - clear(): void; - - /** - * Gets the current drawing mode of the drawing manager. - * @returns The current drawing mode of the drawing manager. - */ - getDrawingMode(): DrawingTools.DrawingMode; - - /** - * Gets an array of shapes that are in the layer. This can be used to iterate over the individual shapes. - * @returns An array of shapes that are in the layer. This can be used to iterate over the individual shapes. - */ - getPrimitives(): IPrimitive[]; - - /** - * Returns the index of the shape in the drawing layer. - * @param primitive The shape to find the index of. - * @param fromIndex The index to start the search from. - * @returns The index of the shape in the drawing layer. Returns -1 if shape is not found. - */ - indexOf(primitive: IPrimitive, fromIndex?: number): number; - - /** - * Removes a shape from the layer and returns it. - * @param primitive The shape to remove from the layer. - * @returns The shape that was removed from the layer. - */ - remove(primitive: IPrimitive): IPrimitive; - - /** - * Removes a shape from the layer at the specified index. - * @param index The index of the shape to remove from the layer. - * @returns The shape that was removed from the layer. - */ - removeAt(index: number): IPrimitive; - - /** - * Sets the drawing mode of the drawing manager. - * @param mode The drawing mode to set the DrawingManager to. - */ - setDrawingMode(mode: DrawingTools.DrawingMode): void; - - /** - * Replaces all shapes in the layer with the new array of shapes that have been provided. - * @param primitives An array of shapes to add to the drawing layer. - */ - setPrimitives(primitives: IPrimitive[]): void; - } - - /** - * Provides a set of tools for drawing and editing shapes on top of the map. - * @requires The Microsoft.Maps.DrawingTools module. - */ - export class DrawingTools { - /** - * @constructor - * @requires The Microsoft.Maps.DrawingTools module. - * @param map A map instanct to attach the drawing tools to. - */ - constructor(map: Map); - - /** - * Initializes the drawing layer and instructs it to create a new shape of a given type. - * @param shapeType The type of new shape to create. - * @param created A callback function that is fired after the initial shape is created. - */ - public create(shapeType: DrawingTools.ShapeType, created?: (shape: IPrimitive) => void): void; - - /** Disposes the instance of the DrawingTools class. */ - public dispose(): void; - - /** - * Adds a shape to the drawing layer and puts it into edit mode. - * @param shape A shape to put into editting mode. - */ - public edit(shape: IPrimitive): void; - - /** - * Finishes any shape create / edit operation currently in progress, and returns the shape that was created or editted through a specified callback function. - * @param finished A callback function to return the completed shape with. - */ - public finish(finished?: (shape: IPrimitive) => void): void; - - /** - * Creates a drawing manager which allows multi-shape editing and displays the toolbar. - * @param callback A callback function that is triggered after the DrawingTools have loaded. - */ - public showDrawingManager(callback?: (manager: DrawingManager) => void): void; - } - - export module Events { - ///////////////////////////////////// - /// addHandler Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * drawingChanged, drawingChanging, drawingEnded, drawingModeChanged, drawingStarted - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: DrawingTools, eventName: string, handler: (eventArg?: IPrimitive | IDrawingModeChangedData) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * disposed, drawingChanged, drawingChanging, drawingEnded, drawingErased, drawingModeChanged, drawingStarted - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: DrawingManager, eventName: string, handler: (eventArg?: IPrimitive | DrawingTools.DrawingMode) => void): IHandlerId; - - ///////////////////////////////////// - /// addOne Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * drawingChanged, drawingChanging, drawingEnded, drawingModeChanged, drawingStarted - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: DrawingTools, eventName: string, handler: (eventArg?: IPrimitive | IDrawingModeChangedData) => void): void; - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * disposed, drawingChanged, drawingChanging, drawingEnded, drawingErased, drawingModeChanged, drawingStarted - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: DrawingManager, eventName: string, handler: (eventArg?: IPrimitive | DrawingTools.DrawingMode) => void): void; - - ///////////////////////////////////// - /// addThrottledHandler Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * drawingChanged, drawingChanging, drawingEnded, drawingModeChanged, drawingStarted - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addThrottledHandler(target: DrawingTools, eventName: string, handler: (eventArg?: IPrimitive | IDrawingModeChangedData) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * disposed, drawingChanged, drawingChanging, drawingEnded, drawingErased, drawingModeChanged, drawingStarted - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: DrawingManager, eventName: string, handler: (eventArg?: IPrimitive | DrawingTools.DrawingMode) => void, throttleInterval: number): IHandlerId; - } - -} - -declare module Microsoft.Maps.DrawingTools { - /** - * The different drawing modes that the drawing manager can be set to. - * @requires The Microsoft.Maps.DrawingTools module. - */ - export enum DrawingMode { - /** Edit an existing shape. Click on a shape to edit it. */ - edit, - - /** Erase and existing shape. Click on the shapes to erase them. */ - erase, - - /** Sets the drawing manager into an idle mode. */ - none, - - /** Allow the user to draw a polygon. */ - polygon, - - /** Allow the user to draw a polyline. */ - polyline, - - /** Allow the user to draw a pushpin. */ - pushpin - } - - /** - * The different types of shapes that are created or edited by the drawing tools. - * @requires The Microsoft.Maps.DrawingTools module. - */ - export enum ShapeType { - /** A polygon shape type. */ - polygon, - - /** A polyline shape type. */ - polyline - } -} \ No newline at end of file diff --git a/types/bingmaps/GeoJson.d.ts b/types/bingmaps/GeoJson.d.ts deleted file mode 100644 index 94726ab542..0000000000 --- a/types/bingmaps/GeoJson.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -declare module Microsoft.Maps { - - /** GeoJSON object definition */ - export interface IGeoJsonObject { - /** - * Type of the object - * could be one of the following: - * Point - * LineString - * Polygon - * MultiPoint - * MultiLineString - * MultiPolygon - * GeometryCollection - * Feature - * FeatureCollection - */ - type: string; - - /** Geometric coordinates of the object */ - coordinates?: number[] | number[][] | number[][][] | number[][][][]; - - /** Additional properties of the object as a key,value pair */ - properties?: any; - - /** Set of features (only applicable if the type is 'featurecollection') */ - features?: IGeoJsonObject[]; - - /** Set of geometries (only applicable if the type is 'geometrycollection') */ - geometries?: IGeoJsonObject[]; - - /** Geometry (only applicable if the type is 'feature') */ - geometry?: IGeoJsonObject; - - /** identifier of a feature (only applicable if the type is 'feature') */ - id?: any; - } - - /** - * Class responsible for reading/writing geo data in GeoJson format - * @requires The Microsoft.Maps.GeoJson module. - */ - export module GeoJson { - /** - * Reads the data from a given url and returns the shapes. - * @param url GeoJson download url. - * @param callback Callback function that needs to be called once the data is downloaded and parsed. - * @param jsonpQueryParam The name of the url query param to make a jsonp request. - * @param styles Styles that needs to be applied. - */ - export function readFromUrl(url: string, callback: (data: IPrimitive | IPrimitive[]) => void, jsonpQueryParam?: string, styles?: IStylesOptions): void; - - /** - * Reads the data in geoJson format and returns the shapes. - * @param geoJson GeoJson data object that needs to be parsed into shapes. - * @param styles Styles that needs to be applied. - * @returns An array of shapes. - */ - export function read(geoJson: IGeoJsonObject | string, styles?: IStylesOptions): IPrimitive | IPrimitive[]; - - /** - * Writes the data into geoJson format. - * @param data Data that needs to be serialized. - * @returns A geoJson formatted string. - */ - export function write(data: IPrimitive | IPrimitive[]): IGeoJsonObject; - } -} \ No newline at end of file diff --git a/types/bingmaps/HeatMapLayer.d.ts b/types/bingmaps/HeatMapLayer.d.ts deleted file mode 100644 index c90813b00d..0000000000 --- a/types/bingmaps/HeatMapLayer.d.ts +++ /dev/null @@ -1,106 +0,0 @@ -declare module Microsoft.Maps { - /** A standard dictionary object (associative array). */ - export interface IDictionary { - [K: string]: T; - } - - /** Options for customizing how the heat map is rendered. */ - export interface IHeatMapLayerOptions { - /** - * The temperature gradient that is used to colorize the map. Default gradient: - * { - * '0.00': 'rgb(255,0,255)', // Magenta - * '0.25': 'rgb(0,0,255)', // Blue - * '0.50': 'rgb(0,255,0)', // Green - * '0.75': 'rgb(255,255,0)', // Yellow - * '1.00': 'rgb(255,0,0)' // Red - * } - */ - colorGradient?: IDictionary; - - /** - * The intensity of each heat point. This is a decimal value between 0 and 1. This is used to specify how "hot" a single data point should be. Default: 0.5 - */ - intensity?: number; - - /** - * The opacity of the HeatMapLayer canvas. Value should be a decimal between 0 and 1. Default: 1 - */ - opacity?: number; - - /** - * The radius to draw each data point on the map. Default: 10 - */ - radius?: number; - - /** - * The distance units of the radius. Possible values are: - * - * • 'pixels' (defualt) - * • 'meters' - * - * When set to pixels the size of each data point will always be the same radius, regardless of zoom level. When set to meters, the size of the data points - * will scale based on zoom level so as to ensure that the radius is spatially accurate. - */ - unit?: 'meters' | 'pixel'; - - /** A boolean indicating if the heat map layer is visible or not. **/ - visible?: boolean; - } - - /** - * Class for rendering data as a heat map layer. - * @requires The Microsoft.Maps.Heatmap module. - */ - export class HeatMapLayer implements IDataLayer { - /** - * @constructor - * @requires The Microsoft.Maps.Heatmap module. - * @param locations Set of locations to visualize as a heat map. - * @param options Options for customizing how the heat map is rendered. - */ - constructor(locations: (Location | Pushpin)[], options?: IHeatMapLayerOptions); - - /** Clears all data in the heat map layer. */ - public clear(): void; - - /** Disposes the heat map layer. */ - public dispose(): void; - - /** - * Gets a boolean indicating if the heat map layer is visible or not. - * @returns A boolean indicating if the heat map layer is visible or not. - */ - public getVisible(): boolean; - - /** - * @deprecated - * Hides the heat map layer. - */ - public hide(): void; - - /** - * Specifies the locations to use when generating the heat map. - * @param locations Set of locations. - */ - public setLocations(locations: (Location | Pushpin)[]): void; - - /** - * Sets the options to use with the heat map layer. - * @param options Set of heat map layer options. - */ - public setOptions(options: IHeatMapLayerOptions): void; - - /** - * Sets the visibility of the heat map layer. - * @param visible A boolean indicating if the heat map layer is visible or not. - */ - public setVisible(visible: boolean): void; - - /** - * @deprecated - * Shows the heat map layer. - */ - public show(): void; - } -} \ No newline at end of file diff --git a/types/bingmaps/Search.d.ts b/types/bingmaps/Search.d.ts deleted file mode 100644 index 0d799c7078..0000000000 --- a/types/bingmaps/Search.d.ts +++ /dev/null @@ -1,228 +0,0 @@ -/** - * Provides an easy method for geocoding address and searching for points of interest from JavaScript. - * @requires The Microsoft.Maps.Search module. - */ -declare module Microsoft.Maps.Search { - /** - * Defines the match precision of a geocdoed result. - * @requires The Microsoft.Maps.Search module. - */ - export enum LocationPrecision { - /** The geocode result was matched to a point on a road using interpolation. */ - interpolated, - - /** - * The geocode result was matched to a point on a road using interpolation with an additional offset to shift the - * Location to the side of the street. - */ - InterpolatedOffset, - - /** The geocode result was matched to the center of a parcel (property boundary). */ - parcel, - - /** The geocode result was matched to the rooftop of a building. */ - rooftop - } - - /** - * Defines the geocoding level of the location match found by the geocoder. - * @requires The Microsoft.Maps.Search module. - */ - export enum MatchCode { - /** No match was found. */ - none, - - /** The match was good. */ - good, - - /** The match was ambiguous. Multiple results were returned. */ - ambiguous, - - /** The match was found by a broader search. */ - upHierarchy, - - /** The match was found, but possibly using a modified query. */ - modified - } - - /** - * Defines the confidence of the location match found by the geocoding service. - * @requires The Microsoft.Maps.Search module. - */ - export enum MatchConfidence { - /** The confidence of the match is high. */ - high, - - /** The confidence of the match is medium. */ - medium, - - /** The confidence of the match is low. */ - low, - - /** The confidence of the match is unknown. */ - unknown - } - - /** A object that represents a geocoded location. */ - export interface IGeocodeLocation { - /** The map location of this geocode location match. */ - location: Location; - - /** The name of this geocode location match. */ - name: string; - - /** The precision of this geocode location match. */ - precision: string | LocationPrecision; - } - - /** An object that represents an place result. */ - export interface IPlaceResult { - /** The geocoded address of the place result. */ - address: IAddress; - - /** The location rectangle that defines the boundaries of the best map view of the place result. */ - bestView: LocationRect; - - /** The classification of the geographic entity returned, such as PopulatedPlace. */ - entityType: string; - - /** The geocoded location of the best result. */ - location: Location; - - /** The geocoded locations. */ - locations: IGeocodeLocation[]; - - /** The match code of the best result. */ - matchCode: string | MatchCode; - - /** The match confidence of the best result. */ - matchConfidence: string | MatchConfidence; - - /** The name of the place result, if one exists. */ - name: string; - } - - /** An object that represents a geocode result returned by REST service. */ - export interface IGeocodeResult { - /** An array of geocode results. */ - results: IPlaceResult[]; - } - - /** The options for a geocode request. */ - export interface IGeocodeRequestOptions { - /** - * A location rectangle that defines the boundaries of the area in which to search for - * location results. The default is the bounds of the map view associated with this - * instance of the SearchManager, which is usually the current map view. - */ - bounds?: LocationRect; - - /** - * The name of the function to call when a successful result is returned from the - * geocode request. The callback function must accept two parameters: result, which is - * a GeocodeResult type, and a userData object. - */ - callback: (geocodeResult: IGeocodeResult, userData: any) => void; - - /** The maximum number of results to return. Required. The maximum number than can be returned is 20. */ - count?: number; - - /** - * The name of the function to call when the request is returned with an error. The - * error callback function must accept an IGeocodeRequestOptions object. - */ - errorCallback?: (geocodeRequestOptions: IGeocodeRequestOptions) => void; - - /** Specifies to include the two-letter ISO country code. */ - includeCountryIso2?: boolean; - - /** Specifies to include the neighborhood in the response when it is available. */ - includeNeighborhood?: boolean; - - /** A number indicating how long to wait, in seconds, for the geocode request to return. The default value is 5 seconds. */ - timeout?: number; - - /** An object containing any data that needs to be passed to the callback when the request is completed. */ - userData?: any; - - /** A string containing the address or place to be matched to a location on the map. */ - where: string; - } - - /** The options for a reverse geocode request. */ - export interface ReverseGeocodeRequestOptions { - /** - * A reference to a function to call when a successful result is returned from the geocode request. The callback function - * will receive a PlaceResult object as an argument. - */ - callback: (placeResult: IPlaceResult, userData: any) => void; - - /** - * A reference to a function to call when the request is returned with an error. The error callback function will receive - * an object containing the geocode request options used in the request. - */ - errorCallback?: (reverseGeocodeRequestOptions: ReverseGeocodeRequestOptions) => void; - - /** Specifies to include the two-letter ISO country code. Default: false */ - includeCountryIso2?: boolean; - - /** - * An array of entity types selected from the following options. - * • Address - * • Neighborhood - * • PopulatedPlace - * • Postcode1 - * • AdminDivision1 - * • AdminDivision2 - * • CountryRegion - * These entity types are ordered from the most specific entity to the least specific entity. When entities of more than one entity type are found, only the most specific - * entity is returned. For example, if you specify Address and AdminDistrict1 as entity types and entities were found for both types, only the Address entity information is - * returned in the response. One exception to this rule is when both PopulatedPlace and Neighborhood entity types are specified and information is found for both. In this case, - * the information for both entity types is returned. Also, more than one Neighborhood may be returned because the area covered by two different neighborhoods can overlap. - */ - includeEntityTypes?: string[]; - - /** - * Specifies to include the neighborhood in the response when it is available. Note: This feature isn’t - * available in all locations. - */ - includeNeighborhood?: boolean; - - /** The location to use to match to geographic entities and addresses. */ - location: Location; - - /** A number indicating how long to wait, in seconds, for the reverse geocode request to return. The default value is 5 seconds. */ - timeout?: number; - - /** An object containing any data that needs to be passed to the callback when the request is completed. */ - userData?: any; - } - - /** - * A class that contains methods for returning search and location results. - * @requires The Microsoft.Maps.Search module. - */ - export class SearchManager { - /** - * @constructor - * @requires The Microsoft.Maps.Search module. - * @param map A Map object - */ - constructor(map: Map); - - /** - * Matches the address or place query in the specified request - * options to a location and returns the results to the request - * options callback function. - * @param request Options for sending geocode request - */ - public geocode(request: IGeocodeRequestOptions): void; - - /** - * Matches the specified location to an address and returns the - * address results to the specified request options callback function. - * @param request Options for sending reverse geocode request - */ - public reverseGeocode(request: ReverseGeocodeRequestOptions): void; - } -} \ No newline at end of file diff --git a/types/bingmaps/SpatialDataService.d.ts b/types/bingmaps/SpatialDataService.d.ts deleted file mode 100644 index 627ab7cbad..0000000000 --- a/types/bingmaps/SpatialDataService.d.ts +++ /dev/null @@ -1,440 +0,0 @@ -/** - * This module wraps the Query and GeoData REST API’s in the Bing Spatial Dara Services and expose them as an easy to use JavaScript library. - * @requires The Microsoft.Maps.SpatialDataService module. - */ -declare module Microsoft.Maps.SpatialDataService { - - ////////////////////////////////////////////// - /// GeoData API - ////////////////////////////////////////////// - - /** Represents the options for requests boundary data from the GeoData API in the Bing Spatial Data Services. */ - export interface IGetBoundaryRequestOptions { - /** - * The level of detail for the boundary polygons returned. An integer between 0 and 3, where 0 specifies the coarsest level of boundary detail and 3 - * specifies the best. Default: 0 - */ - lod?: number; - - /** - * The entity type to return. Default: CountryRegion - * Supported entity types: - * AdminDivision1, AdminDivision2, CountryRegion, eighborhood, PopulatedPlace, Postcode1, Postcode2, Postcode3, Postcode4 - * Note: Not all entity types are available in all areas. - */ - entityType?: string; - - /** - * Specifies the preferred language to use for any metadata text about the entity or polygons. Defaults to the culture used by the map control, which - * usually automatically detected based on user's browser settings. Setting this property will override the default value. - */ - culture?: string; - - /** - * Specifies whether the response should include all of the boundary polygons for the requested entity or just return a single polygon that represents - * the main outline of the entity. Default: false - */ - getAllPolygons?: boolean; - - /** - * Specifies whether the response should include metadata about the entity, such as AreaSqKm and others. Default: false - */ - getEntityMetadata?: boolean; - - /** - * Specifies the user’s home country or region.Defaults to the region setting of the user who loads the map. - * Warning: Setting this property will override the default value, which is the region the user is actually in, and will allow the user to see boundaries - * which may not align with the views of their region.This could result in geopolitically sensitive borders being returned. - */ - userRegion?: string; - } - - /** Represents the primitive object for a boundary returned by the GeoData API. */ - export interface IGeoDataPrimitive { - /** A unique ID associated with this polygon primitive. */ - PrimitiveID: string; - - /** - * A comma-delimited sequence starting with the version number of the polygon set followed by a list of compressed polygon - * "rings" (closed paths represented by sequences of latitude and-longitude points). - */ - Shape: string; - - /** The number of vertex points used to define the polygon. */ - NumPoints: string; - - /** - * An ID identifying the data provider that supplied the data. This ID number will reference one of the sources listed in the - * array of CopyrightSources in the Copyright property of the GeoDataResultSet object. - */ - SourceID: string; - } - - /** Represents the copyright source object for a boundary returned by the GeoData API. */ - export interface ICopyrightSource { - /** The copyright string from the source. */ - Copyright: string; - - /** An ID identifying the data provider that supplied the data. */ - SourceID: string; - - /** The name of the data provider represented by this Source element. */ - SourceName: string; - } - - /** Represents the copyright object for a boundary returned by the GeoData API. */ - export interface ICopyright { - /** The copyright URL for the GeoData service. */ - CopyrightURL: string; - - /** A collection of CopyrightSource objects that give information about the sources of the polygon data that is returned. */ - Sources: ICopyrightSource[]; - } - - /** Represents the name object for a boundary returned by the GeoData API. */ - export interface IName { - /** The name of boundary. Example: "United States" */ - EntityName: string; - - /** The culture of the region. */ - Culture: string; - - /** An ID identifying the data provider that supplied the data. */ - SourceID: string; - } - - /** Represents the metadata object for a boundary returned by the GeoData API. Not all properties will be returned for all results. */ - export interface IMetadata { - /** The approximate total surface area (in square kilometers) covered by all the polygons that comprise this entity. */ - AreaSqKm: string; - - /** - * An area on the Earth that provides the best map view for this entity. This area is defined as a bounding box in the format of a - * “MULTIPOINT ((WestLongitude SouthLatitude), (EastLongitude NorthLatitude))”. - */ - BestMapViewBox: string; - - /** The culture associated with this entity. Example: en */ - OfficialCulture: string; - - /** The approximate population within this entity. Example: PopClass20000to99999 */ - PopulationClass: string; - - /** The regional culture associated with this entity. */ - RegionalCulture: string; - } - - /** Represents a single result object returned by the GeoData API. */ - export interface IGeoDataResult { - /** Copyright information for the returned boundary data. */ - Copyright: ICopyright; - - /** A unique ID number associated with this entity. */ - EntityID: string; - - /** - * A collection of metadata information associated with the entity. The getEntityMetadata option of the request must be set - * to true. Note, not all boundaries will return this metadata. - */ - EntityMetadata: IMetadata; - - /** Information about the name of the boundary location. */ - Name: IName; - - /** A Polygon object that has been generated from the data in the Primitives property. */ - Polygons: Polygon[]; - - /** An array of objects that contain the polygon information for the boundary. */ - Primitives: IGeoDataPrimitive[]; - } - - /** Represents the set of results returned by the GeoData API. */ - export interface IGeoDataResultSet { - /** Copyright information for the GeoData API. */ - Copyright: string; - - /** The location provided in the query that generated this result. */ - location: string |  Location; - - /** Results of the boundary data. */ - results: IGeoDataResult[]; - } - - /** - * This is a static class that provides the ability to request polygons that describe the boundaries of a geographic entities, such as an AdminDivision1 - * (such as a state or province) or a Postcode1 (such as a zip code) that contain a given point (latitude and longitude) or address. This uses the GeoData - * API in the Bing Spatial Data Services. - * @requires The Microsoft.Maps.SpatialDataService module. - */ - export module GeoDataAPIManager { - /** - * Gets a boundary for the specified request. If the specified location value is a string, it will be geocoded and the coordinates of the result will - * be used to find a boundary of the specified entityType that intersects with this coordinate. - * @requires The Microsoft.Maps.SpatialDataService module. - * @param locations The locations to retrieve boundaries for. If the specified location value is a string, it will be geocoded and the coordinates of - * the result will be used to find a boundary of the specified entityType that intersects with this coordinate. - * @param request The request options for retrieving a boundary. - * @param credentials A bing maps key or a map instance which can be used to provide credentials to access the data source. Note that the map will need - * to be loaded with a bing maps key that has access to the data source. - * @param callback A callback function to return the results to. If an array of locations are specified the callback function will be triggered for each location in the array. - */ - export function getBoundary(locations: string | Location | (string | Location)[], request: IGetBoundaryRequestOptions, credentials: string | Map, callback: (results: IGeoDataResultSet) => void): void; - } - - ////////////////////////////////////////////// - /// Query API - ////////////////////////////////////////////// - - /** - * An enumeration that defines how to compare the filters value against the corresponding property value. - * @requires The Microsoft.Maps.SpatialDataService module. - */ - export enum FilterCompareOperator { - /** Determines if a string value ends with a specified string value. */ - endsWith, - - /** Determines if two values are equal. */ - equals, - - /** Determines if a first value is greater than a second value. */ - greaterThan, - - /** Determines if a first value is greater than or equal to a second value. */ - greaterThanOrEqual, - - /** Determines if a value is within an array. */ - isIn, - - /** Determines if a first value is less than a second value. */ - lessThan, - - /** Determines if a first value is less than or equal a second value. */ - lessThanOrEqual, - - /** Determines if a string value does not end with a specified string value. */ - notEndsWith, - - /** Determines if two values are not equal. */ - notEquals, - - /** Determines if a string value does not start with a specified string value. */ - notStartsWith, - - /** Determines if a string value starts with a specified string value. */ - startsWith - } - - /** - * An enumeration that defines how two or more filters are linked together. - * @requires The Microsoft.Maps.SpatialDataService module. - */ - export enum FilterLogicalOperator { - /** Connects two or more filters that both must be true. */ - and, - - /** Connects two or more filters where one of them must be true. */ - or - } - - /** - * A Fitler object that defines the logic behind a filter expression that can be executed against a JSON object or generate - * a filter string that can be used with the Bing Spatial Data Services. - */ - export interface IFilter { - /** - * Executes the filter logic against a JSON object and returns a boolean indicating if the object meets the requirements of the Filter. - * @returns A boolean indicating if the specified object meets the requirements of the Filter. - */ - execute(object: any): boolean; - - /** - * Converts the filter logic into a string format that is compatible with the Bing Spatial Data Services. - * @returns A filter string that is formatted such that it is compatible with the Bing Spatial Data Services. - */ - toString(): string; - } - - /** - * The Fitler class defines the logic behind a filter expression that can be executed against a JSON object or generate - * a filter string that can be used with the Bing Spatial Data Services. - * @requires The Microsoft.Maps.SpatialDataService module. - */ - export class Filter implements IFilter { - /** - * @constructor - * @requires The Microsoft.Maps.SpatialDataService module. - * @param propertyName The name of the property in the object to test against. Can also provide child properties i.e. 'root.child'. - * @param operator The operator to use when comparing the specified property to value to the provided value. - * @param value A value to compare against. - */ - constructor(propertyName: string, operator: string | FilterCompareOperator, value: any); - - /** - * Executes the filter logic against a JSON object and returns a boolean indicating if the object meets the requirements of the Filter. - * @returns A boolean indicating if the specified object meets the requirements of the Filter. - */ - public execute(object: any): boolean; - - /** - * Converts the filter logic into a string format that is compatible with the Bing Spatial Data Services. - * @returns A filter string that is formatted such that it is compatible with the Bing Spatial Data Services. - */ - public toString(): string; - } - - /** - * A class that groups two or more logical filters or filter groups together. It can be executed against a JSON or generate - * a filter string that can be used with the Bing Spatial Data Services. - * @requires The Microsoft.Maps.SpatialDataService module. - */ - export class FilterGroup implements IFilter { - /** - * @constructor - * @requires The Microsoft.Maps.SpatialDataService module. - * @param filters An array consisting of Filter or FilterGroup objects to combine. - * @param operator The logical operator for combining the filters together. - * @param not A boolean is the logical inverse should of the filter should be used. - */ - constructor(filters: IFilter[], operator: FilterLogicalOperator, not?: boolean) - - /** - * Executes the filter logic against a JSON object and returns a boolean indicating if the object meets the requirements of the Filter. - * @returns A boolean indicating if the specified object meets the requirements of the Filter. - */ - public execute(object: any): boolean; - - /** - * Converts the filter logic into a string format that is compatible with the Bing Spatial Data Services. - * @returns A filter string that is formatted such that it is compatible with the Bing Spatial Data Services. - */ - public toString(): string; - } - - /** Options for find near route query API. */ - export interface ISpatialFilterOptions { - /** - * One of the following values: - * • nearby – Searches in a radius around a location. - * • nearRoute – Searches for results that are within 1 mile of a route. - * • intersects – Searches for results that intersect with the specified geometry. - * Note: Note that the NavteqNA and NavteqEU data sources only support nearby queries. - */ - spatialFilterType: string; - - /** Location at which the filter should be applied (only for nearby filter). */ - location?: string | Location; - - /** - * Radius to use when performing a nearby search. The distance in kilometers and must be between 0.16 and 1000 kilometers - * (only for nearby filter). - */ - radius?: number; - - /** Start location of the route (only for nearroute filter). */ - start?: string | Location; - - /** End location of the route (only for nearroute filter). */ - end?: string | Location; - - /** Intersection object. Can be a well known text string or a LocationRect object (only for intersects filter). */ - intersects?: string | LocationRect | IPrimitive; - } - - /** Options for find near route query API. */ - export interface IFindNearRouteOptions extends ISpatialFilterOptions { - /** - * One of the following values: - * • Driving [default] - * • Walking - */ - travelMode?: string; - - /** - * An integer value between 0 and 359 that represents degrees from north - * where north is 0 degrees and the heading is specified clockwise from north. - * For example, setting the heading of 270 degrees creates a route that initially heads west - */ - heading?: number; - - /** - * An integer distance specified in meters. - * Use this parameter to make sure that the moving vehicle has enough distance - * to make the first turn - */ - distanceBeforeFirstTurn?: number; - - /** - * A list of values that limit the use of highways and toll roads in the route. - * Use one of the following values: - * • highways - Avoids the use of highways in the route. - * • tolls - Avoids the use of toll roads in the route. - * • minimizeHighways - Minimizes (tries to avoid) the use of highways in the route. - * • minimizeTolls - Minimizes (tries to avoid) the use of toll roads in the route. - */ - avoid?: string[]; - - /** - * One of the following values: - * • distance - The route is calculated to minimize the distance.Traffic information is not used. - * • time[default] - The route is calculated to minimize the time.Traffic information is not used. - * • timeWithTraffic - The route is calculated to minimize the time and uses current traffic information. - */ - optimize?: string; - } - - /** Set of options that can be specified for query APIs. */ - export interface IQueryAPIOptions { - /** A queryurl containing the access id, data source name and the entity type name. */ - queryUrl: string; - - /** Specifies a conditional expression for a list of properties and values. */ - filter?: IFilter; - - /** Specifies whether or not to return a count of the results in the response. Default: false */ - inlineCount?: boolean; - - /** Specifies to query the staged version of the data source instead of the published version. Default: false */ - isStaging?: boolean; - - /** - * Specifies one or more properties to use to sort the results of a query. - * You can specify up to three (3) properties. Results are sorted in ascending order. - * Note: You cannot use the latitude and longitude properties to sort results. You can use the elevation property. - */ - orderBy?: string[]; - - /** - * Specifies the data source properties to return in the response. If the $select query option is not specified or - * if it is set to "" ($select=), all data source properties are returned. Default: "*,_distance" - */ - select?: string[]; - - /** Specifies to not return a specified number of query results. */ - skip?: number; - - /** Spatial filter options to apply. */ - spatialFilter?: ISpatialFilterOptions | IFindNearRouteOptions; - - /** Specifies the maximum number of results to return in the query response. Default: 25 */ - top?: number; - } - - /** - * This is a static class that provides that ability to query data sources that are hosted by the Bing Spatial Data Services using the Query API. - * @requires The Microsoft.Maps.SpatialDataService module. - */ - export module QueryAPIManager { - /** - * Perform a search - * @requires The Microsoft.Maps.SpatialDataService module. - * @param queryOptions - Options for the query - * @param credentials - Credentials for the query - * @param callback - The function to call once the results are retrieved - * @param styles - (Optional) Styles of the data that needs to be rendered on map - */ - export function search(queryOptions: IQueryAPIOptions, - credentials: string | Map, - callback: (data: IPrimitive[], inlineCount?: number) => void, - styles?: IStylesOptions): void; - } -} \ No newline at end of file diff --git a/types/bingmaps/SpatialMath.d.ts b/types/bingmaps/SpatialMath.d.ts deleted file mode 100644 index 4fe3b4ea12..0000000000 --- a/types/bingmaps/SpatialMath.d.ts +++ /dev/null @@ -1,530 +0,0 @@ -////////////////////////////////////////////// -/// Core Library -////////////////////////////////////////////// - -/** - * This module provides a bunch of useful spatial math calculations. - * @requires The Microsoft.Maps.SpatialMath module. - */ -declare module Microsoft.Maps.SpatialMath { - - /** - * Distance Unit enumerator - * @requires The Microsoft.Maps.SpatialMath module. - **/ - export enum DistanceUnits { - /** A distance in meters */ - Meters, - - /** A distance in kilometers */ - Kilometers, - - /** A distance in miles */ - Miles, - - /** A distance in Feet */ - Feet, - - /** A distance in Yards */ - Yards, - - /** A distance in Nautical Miles */ - NauticalMiles - } - - /** - * Area units enumerator - * @requires The Microsoft.Maps.SpatialMath module. - **/ - export enum AreaUnits { - /** Area in square meters */ - SquareMeters, - - /** Area in square kilometers */ - SquareKilometers, - - /** Area in square miles */ - SquareMiles, - - /** Area in square Feet */ - SquareFeet, - - /** Area in square Yards */ - SquareYards, - - /** Area in Acres */ - Acres, - - /** Area in Hectares */ - Hectares - } - - ////////////////////////////////////////////// - /// Core Calculations - ////////////////////////////////////////////// - - /** - * Converts an area from one area units to another. - * @param area A number that represents an area to convert. - * @param fromUnits The area units the original area is in. - * @param toUnits The area units to convert to. - * @returns An area in the new units. - **/ - export function convertArea(area: number, fromUnits: AreaUnits, toUnits: AreaUnits): number; - - /** - * Converts a distance from one distance units to another. - * @param distance A number that represents a distance to convert. - * @param fromUnits The distance units the original distance is in. - * @param toUnits The disired distance units to convert to. - * @returns A distance in the new units. - **/ - export function convertDistance(distance: number, fromUnits: DistanceUnits, toUnits: DistanceUnits): number; - - /** - * Calculates an array of locations that form a cardinal spline between the specified array of locations. - * @param locations The array of locations to calculate the spline through. - * @param tension A number that indicates the tightness of the curve. Can be any number, although a value between 0 and 1 is usually used. Default: 0.5 - * @param nodeSize Number of nodes to insert between each Location. Default: 15 - * @param close A boolean indicating if the spline should be a closed ring or not. Default: false - * @returns An array of locations that form a cardinal spline between the specified array of locations. - */ - export function getCardinalSpline(locations: Location[], tension ?: number, nodeSize ?: number, close ?: boolean): Location[]; - - /** - * Calculates a destination Location based on a starting Location, a heading, a distance, and a distance unit type. - * @param origin Location that the destination is relative to. - * @param bearing A heading angle between 0 - 360 degrees. 0 - North, 90 - East, 180 - South, 270 - West. - * @param distance Distance that destination is away. - * @param units Unit of distance measurement. Default is Meters. - * @returns A Location that is the specified distance away from the origin. - **/ - export function getDestination(origin: Location, bearing: number, distance: number, units?: DistanceUnits): Location; - - /** - * Calculate the distance between two Location objects on the surface of the earth using the Haversine formula. - * @param origin First Location to calculate distance between. - * @param destination Second Location to calculate distance between. - * @param units Unit of distance measurement. Default is Meters. - * @param highAccuracy When set enabled, will use the slower but more accurate Vincenty formula for calculating distances, rather than the Haversine formula. - * @returns The shortest distance between two Locations in the specifed units. - **/ - export function getDistanceTo(origin: Location, destination: Location, units?: DistanceUnits, highAccuracy?: boolean): number; - - /** - * Retrieves the radius of the earth in a specific distance unit for WGS84. - * @param units Unit of distance measurement. Default: Meters - * @returns A number that represents the radius of the earth in a specific distance unit. - **/ - export function getEarthRadius(units?: DistanceUnits): number; - - /** - * Takes an array of Locations objects and fills in the space between them with accurately positioned Locations to form an approximated Geodesic path. - * @param path Array of Location objects that form a path to fill in. - * @param nodeSize Number of nodes to insert between each Location. Default: 15 - * @returns An array of Location objects that form a geodesic paths. - **/ - export function getGeodesicPath(path: Location[], nodeSize?: number): Location[]; - - /** - * Calculates the heading from one Location object to another. - * @param origin Point of origin. - * @param destination Destination to calculate relative heading to. - * @returns A heading in degrees between 0 and 360. 0 degrees points due North. - **/ - export function getHeading(origin: Location, destination: Location): number; - - /** - * Calculates the distance between all Location objects in an array. - * @param path The array of Location objects that make up the path to calculate the length of. - * @param units Unit of distance measurement. Default: Meters - * @param highAccuracy If set to true, uses the more accurate Vincenty algorithm for calcuating distances. Otherwise the faster Haversine formula is used. - * @returns The distance between all Locations in between all Location objects in an array on the surface of a earth in the specifed units. - **/ - export function getLengthOfPath(path: Location[], units?: DistanceUnits, highAccuracy?: boolean): number; - - /** - * Calculates the Location object on a path that is a specified distance away from the start of the path. If the specified distance is longer - * than the length of the path, the last Location of the path will be returned. - * @param path A polyline or array of Location coordinates that form a path. - * @param distance The distance along the path (from the start) to calculate the location for. - * @param units Unit of distance measurement. Default is Meters. - * @returns A Location object that is the specified distance away from the start of the path when following the path. - **/ - export function getLocationAlongPath(path: Polyline | Location[], distance: number, units?: DistanceUnits): Location; - - /** - * Calculates an array of Location objects that are an equal distance away from a central point to create a regular polygon. - * @param origin Center of the regular polygon. - * @param radius Radius of the regular polygon. - * @param numberOfPoints Number of points the polygon should have. - * @param units Unit of distance measurement for radius. Default is Meters. - * @param offset An offset to rotate the polygon clockwise in degrees. When 0 the first Location will align with North. - * @returns An array of Location objects that form a regular polygon. - **/ - export function getRegularPolygon(origin: Location, radius: number, numberOfPoints: number, units?: DistanceUnits, offset?: number): Location[]; - - /** - * Calculates a Location object that is a fractional distance between two Location objects. - * @param origin First Location to calculate mid-point between. - * @param destination Second Location to calculate mid-point between. - * @param fraction The fractional parameter to calculate a mid-point for. Default 0.5. - * @returns A Location that lies a fraction of the distance between two Location objects, relative to the first Location object. - **/ - export function interpolate(origin: Location, destination: Location, fraction?: number): Location; - - /** - * Takes a LocationRect and converts it to a polygon. - * @param bounds The LocationRect to convert to a Polygon. - * @returns A polygon representation of the LocationRect. - **/ - export function locationRectToPolygon(bounds: LocationRect): Polygon; - - /** - * Takes a Location object and converts it into a Degree Minute Seconds string in the format. For example: 40° 26′ 46″ N 79° 58′ 56″ W - * @param loc The Location object to convert into a Degree Minute Seconds string. - * @returns A string in Degree Minute Seconds format or null if invalid Location object is provided. - */ - export function toDegMinSec(loc: Location): string; - - /** - * Tries to parse the given string that is in Degree Minute Seconds format. For Example: 35° 26′ 31″ E or 40° 26′ 46″ N 79° 58′ 56″ W - * @param input A string in Degree Minute Seconds format to parse. - * @returns Returns a decimal degree value if only a single angle is provided. If two angles provided in the string, then a - * Location object is returned. If string is in an invalid format, null is returned. - */ - export function tryParseDegMinSec(input: string): number | Location; -} - - -////////////////////////////////////////////// -/// Tile Calculations -////////////////////////////////////////////// - -/** -* A colleciton of mathematical algorithms based on the tile pyramid used by Bign Maps. -* @requires The Microsoft.Maps.SpatialMath module. -*/ -declare module Microsoft.Maps.SpatialMath.Tiles { - //Based on https://msdn.microsoft.com/en-us/library/bb259689.aspx - - /** - * Calculates the full width of the map in pixels at a specific zoom level from -180 degrees to 180 degrees. - * @param zoom Zoom level to calculate width at. - * @param tileWidth Width of tile. - * @returns Width of map in pixels. - **/ - export function mapSize(zoom: number): number; - - /** - * Calculates the Ground resolution at a specific degree of latitude in the specified units per pixel. - * @param latitude Degree of latitude to calculate resolution at. - * @param zoom Zoom level to calculate resolution at. - * @param units Distance unit type to calculate resolution in. - * @returns Ground resolution in distance unit per pixels. - **/ - export function groundResolution(latitude: number, zoom: number, units?: SpatialMath.DistanceUnits): number; - - /** - * Converts a Pixel coordinate into a Geospatial Location at a specified zoom level. - * Global Pixel coordinates are relative to the top left corner of the map (90, -180) - * @param point Pixel coordinate. - * @param zoom Zoom level. - * @returns A Location that is at the specified pixel location at a specified zoom level. - **/ - export function globalPixelToLocation(point: Point, zoom: number): Location; - - /** - * Converts a point from latitude/longitude WGS-84 Location (in degrees) - * into pixel XY coordinates at a specified level of detail. - * @param loc Location to convert to a global pixel. - * @param zoom Level of detail, from 1 (lowest detail) to 23 (highest detail). - * @returns Point object containing the the global pixel location of a Location. - **/ - export function locationToGlobalPixel(loc: Location, zoom: number): Point; - - /** - * Calculates the PyramidTileId that a global pixel intersects with at a specific zoom level. - * @param pixel The pixel coordinate to calculate the tile for. - * @param zoom The zoom level to calculate the tile for. - * @returns A PyramidTileId that a global pixel intersects with at a specific zoom level. - **/ - export function globalPixelToTile(pixel: Point, zoom: number): PyramidTileId; - - /** - * Converts a PyramidTileId into a global pixel coordinates of the upper-left pixel of the specified tile. - * @param tile A PyramidTileId to calculate the upper-left pixel for. - * @returns Global pixel coordinate of the top left corner of a tile. - **/ - export function tileToGlobalPixel(tile: PyramidTileId): Point; - - /** - * Calculates the PyramidTileId that a Location object intersects with at a specific zoom level. - * @param loc The location to calulate the tile for. - * @param zoom The zoom level to use to calculate the tile. - * @returns A PyramidTileId that a Location object intersects with at a specific zoom level. - **/ - export function locationToTile(loc: Location, zoom: number): PyramidTileId; - - /** - * Calculates all the PyramidTileId's that are within a LocationRect at a specific zoom level. - * @param bounds A LocationRect to search for tiles in. - * @param zoom The zoom level to calculate tiles for. - * @returns A list of PyramidTileId's that are within the specified LocationRect and zoom level. - **/ - export function getTilesInBounds(bounds: LocationRect, zoom: number): PyramidTileId[]; - - /** - * Calculates the LocationRect (bounding box) of a PyramidTileId. - * @param tile A PyramidTileId to calculate the LocationRect of. - * @returns The bounding box of a tile. - **/ - export function tileToLocationRect(tile: PyramidTileId): LocationRect; -} - - -////////////////////////////////////////////// -/// Geometry Calculations -////////////////////////////////////////////// - -/** -* A colleciton of geometry calculations that can be performed against Bing Maps shapes. -* @requires The Microsoft.Maps.SpatialMath module. -*/ -declare module Microsoft.Maps.SpatialMath.Geometry { - - /** Defines how the end of a line should be buffered. */ - export enum BufferEndCap { - /** Adds a rounded end to a buffered line. */ - Round, - - /** Adds a flat end to a buffered line that touches the end of the line. */ - Flat, - - /** Adds a square end to a buffered line that has a buffer area at the end of the line. */ - Square - } - - /** - * Calculates the area of a shape. - * @param shape The shape to calculate the area of. - * @param areaUnits The unit of measurement to calculate the area in. - * @returns The area of a shape in the specified unit of measurement. - */ - export function area(shape: IPrimitive | IPrimitive[], areaUnits?: AreaUnits): number; - - /** - * Calculates a bounding box that encloses a set of shapes and/or locations. - * @param shapes The shape(s) to calculate the bounding box for. - * @returns A location rect that encloses the shapes and/or locations. - */ - export function bounds(shapes: Location | IPrimitive | (Location | IPrimitive)[]): LocationRect; - - /** - * Calcuates a shape with an updated boundary that has been inflated/deflated by a speicifed distance. - * @param shape The shape to buffer. - * @param distance The distance to buffer the shape by. - * @param units The distance units to buffer the shape by. - * @param endCapType The type of end cap to use for the joints of the buffer, default value is round. - * @param options A set of polygon options to apply to the generated shape. - * @returns A buffered version of the shape. - */ - export function buffer(shape: Location | IPrimitive | (Location | IPrimitive)[], distance: number, units?: DistanceUnits, endCapType?: BufferEndCap, options?: IPolygonOptions): IPrimitive | IPrimitive[]; - - /** - * Calculates the center of a shape. - * @param shape The shape to calculate the center of. - * @returns The center of the specified shape. - */ - export function centroid(shape: IPrimitive | IPrimitive[]): Location; - - /** - * Calculates an approximate concave hull that best fits the data. - * A concave hull is a shape that represents that a possible concave geometry that encloses all shapes in the specified data set. - * If a single unique Location is in the data set, a Pushpin is returned. If only two unique Locations are provided, or if all Locations form a line, a Polyline is returned. - * If 3 or more unique Locations are in the data set a Polygon, or array of Polygons will be returned. - * @param shapes Shape(s) whose Location(s) or Location(s) are to be used to generate a concave hull. - * @param allowMultiPolygons A boolean indicating if the resulting concave hull can be a MultiPolygon. Default: false - * @param allowHoles A boolean indicating if the polygons in the resulting concave hull can have holes in them. Default: false - * @param options A set of polygon options to apply to the generated shape. - * @returns An approximate concave hull that best fits the data. - * If a single unique Location is in the data set, a Pushpin is returned. If only two unique Locations are provided, or if all Locations form a line, a Polyline is returned. - * If 3 or more unique Locations are in the data set a Polygon, or array of Polygons will be returned. - */ - export function concaveHull(shapes: Location | IPrimitive | (Location | IPrimitive)[], allowMultiPolygons?: boolean, allowHoles?: boolean, options?: IPolygonOptions): IPrimitive | IPrimitive[]; - - /** - * Given two shapes, determines if the first one contains the second one - * (or, the second shape is a subset of the first shape) or not. - * @param shapeA The first shape to test against the second. - * @param shapeB The second shape to test against the first. - * @returns A boolean indicating if the first shape contains the second shape. - */ - export function contains(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[]): boolean; - - /** - * Calculates a convex hull. A convex hull is a shape that represents that minimum convex geometry that encloses all shapes in the specified data set. - * @param shapes Shape(s) whose Location(s) or Location(s) are to be used to generate a convex hull. - * @param options A set of polygon options to apply to the generated shape. - * @returns An array of locations that form a convex hull that encloses all locations of the shapes provided in an array. - */ - export function convexHull(shapes: Location | IPrimitive | (Location | IPrimitive)[], options?: IPolygonOptions): IPrimitive | IPrimitive[]; - - /** - * Creates Delaunay Triangles from the Location objects of the provided shapes. - * @param shapes Location(s) of shape(s) or Location(s) to generate a Delaunay Triangles from. - * @param options A set of polyline or polygon options to apply to the generated shape. - * @returns An array of shapes that form the polygon triangles of the delaunay triangles. - */ - export function delaunayTriangles(shapes: Location | IPrimitive | (Location | IPrimitive)[], options?: IPolygonOptions): Polygon[]; - - /** - * Returns an object that represents area of an initial shape subtracted by the overlapping area of a second shape. - * @param shapeA The first shape. - * @param shapeB The second shape to subtract from the first. - * @returns A set of shapes that represent the area of the first shape that is not overlapped by the second shape. - */ - export function difference(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; - - /** - * Calculates the approximate shortest distance between any two shapes. - * @param shapeA The first shape to calculate the distance from. - * @param shapeB The second shape to calculate the distance to. - * @param units Unit of distance measurement. Default: Meters - * @param highAccuracy If set to true, uses the more accurate Vincenty algorithm for calcuating distances. Otherwise the faster Haversine formula is used. - * @returns The shorested distance between the shapes in the specified units. - */ - export function distance(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[], units?: DistanceUnits, highAccuracy?: boolean): number; - - /** - * Returns an object that represents the area where two shapes intersect. - * @param shapeA The first shape. - * @param shapeB The second shape. - * @returns A set of shapes that represents the area where two shapes intersect. - */ - export function intersection(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; - - /** - * Determines if two shapes intersect or not. - * @param shapeA The first shape to test against the second. - * @param shapeB The second shape to test against the first. - * @returns A boolean indicating if the two shapes intersect. - */ - export function intersects(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[]): boolean; - - /** - * Tests to see if the shape is valid and meets the requirements of an SQL Geography type and other OGC compliant systems. Polylines & Polygons can't be self intersecting. For Polygons, - * coordinates in an exterior rings have a counter-clockwise orientation, while holes have a clockwise orientation. - * @param shape The shape to test for validity. - * @returns Returns a boolean indicting if the specified shape(s) is valid or not. - */ - export function isValid(shape: IPrimitive | IPrimitive[]): boolean; - - /** - * Calculates the distance between all Locations in a shape. If the shape is a polygon, the length of the perimeter of all rings is calculated. - * @param shape The shape to calculate the length of. - * @param units Unit of distance measurement. Default: Meters - * @param highAccuracy If set to true, uses the more accurate Vincenty algorithm for calcuating distances. Otherwise the faster Haversine formula is used. - * @returns The distance between all Locations in a polyline or the perimeter of a ploygon on the surface of a earth in the specifed units. - */ - export function calculateLength(shape: IPrimitive | IPrimitive[], units ?: DistanceUnits, highAccuracy ?: boolean): number; - - /** - * Takes a shape and returns a copy of it that meets the requirements of an SQL Geography type and other OGC compliant systems. Polylines & Polygons can't be self intersecting. For Polygons, - * coordinates in an exterior rings have a counter-clockwise orientation, while holes have a clockwise orientation. - * @param shape The shape to make valid. - * @returns Valiated version of the provided shape. May be a different shape type than what was provided. i.e. A polygon may be broken up into an array of polygons (MultiPolygon). - */ - export function makeValid(shape: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; - - /** - * Calculates the nearest Location objects between to shapes that lie on the shapes. - * If the shapes do not overlap, this calculates a location on each shape that is closest to the other shape. - * If the shapes overlap, a location that is within the intersection area of the shapes will be added twice to an array, once for each shape, and returned. - * @param shapeA The first shape. - * @param shapeB The second shape. - * @returns An array of two Location objects that represent the nearest points between two shapes. - * The Location objects are in the same order as the input shapes. - * Returns null if nearest points were unable to be computed. - */ - export function nearestLocations(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[]): Location[]; - - /** - * Reduces the resolution of a shape using the Douglas-Peucker algorithm. - * @param shape The shape to reduce the resolution of. - * @param tolerance A tolerance distance in meters used by the reduction algorithms. - * @returns A version of the specified shape that has been reduced. - */ - export function reduce(shape: IPrimitive | IPrimitive[], tolerance: number): IPrimitive | IPrimitive[]; - - /** - * Rotates a shape around a given Location for the specified angle of rotation. If an origin is not provided, the centroid of the shape is used. - * @param shape The shape to be rotated. - * @param angle The amount to rotate the shape in degrees. - * @param origin The location to rotate the shape around. Defaults to the centroid of the shape. - */ - export function rotate(shape: IPrimitive | IPrimitive[], angle: number, origin?: Location): void; - - /** - * Calculates the shortest path that between two shapes and returns a Polyline. - * @param shapeA The first shape. - * @param shapeB The second shape. - * @param options A set of polyline options to apply to the generated polyline. - * @returns A polyline that represents the shortest path between two shapes. - */ - export function shortestLineTo(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[], options?: IPolylineOptions): Polyline; - - /** - * Snaps the locations of one shape that are within the specified tolerance distance away from another shape. - * @param locs The locations to snap to the shape. - * @param shape The shape to snap the locations to. - * @param tolerance A maximum distance (in the specified units) that the snapped location can be from the input location. Default: Infinity - * @param toleranceUnits The distance units of the tolerance value. Default: Meters - * @returns A snapped location if only one location is provided, otherwise returns an array of snapped locations. - */ - export function snapLocationsToShape(locs: Location | Location[], shape: IPrimitive | IPrimitive[], tolerance?: number, toleranceUnits?: DistanceUnits): Location | Location[]; - - /** - * Snaps the locations of one shape that are within the specified tolerance distance away from another shape. - * @param shapeToSnap The shape to snap the locations of. - * @param shape The shape to snap the locations to. - * @param tolerance A maximum distance (in the specified units) that the snapped location can be from the input location. Default: Infinity - * @param toleranceUnits The distance units of the tolerance value. Default: Meters - */ - export function snapShapeToShape(shapeToSnap: IPrimitive | IPrimitive[], shape: IPrimitive | IPrimitive[], tolerance?: number, toleranceUnits?: DistanceUnits): void; - - /** - * Returns an object that represents all points that are either in one shape instance or another, but not those points that lie in both instances. - * "Sym" stands for Symmetric. symDifference is an OGC standard name for this calculation used in most spatial math libraries, including SQL. - * @param shapeA The first shape. - * @param shapeB The second shape. - * @returns A shape that represents the symetric difference between two shapes. - */ - export function symDifference(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; - - /** - * Returns an object that represents the union of two shapes. If shapes don't overlap, an array of each individual shapes will be returned. - * @param shapeA The first shape. - * @param shapeB The second shape. - * @returns A shape that represents the union of two shapes. - */ - export function union(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; - - /** - * Performs a union operation on a set of shapes. - * If a shape doesn't overlap with the rest, the returned result will be an array of shapes containing this shape and the union of the rest. - * @param shapes An array of shapes to union together. - * @returns A shape that represents the union of all specified shapes. - */ - export function unionAggregate(shapes: IPrimitive[]): IPrimitive | IPrimitive[]; - - /** - * Creates a Voronoi diagram from the Location objects of the provided shapes. The diagram is returned as an array of Polygons. - * If a clip region is specified, the diagram will be clipped accordingly. - * @param shapes Location(s) of shape(s) or Location(s) to generate a Voronoi diagram. - * @param clipRegion A region to clip the voronoi diagram to. - * @param options A set of polygon options to apply to the generated shape. - * @returns An array of polygons that form a Voronoi diagram. - */ - export function voronoiDiagram(shapes: Location | IPrimitive | (Location | IPrimitive)[], clipRegion?: LocationRect | Polygon, options?: IPolygonOptions): Polygon[]; -} \ No newline at end of file diff --git a/types/bingmaps/Traffic.d.ts b/types/bingmaps/Traffic.d.ts deleted file mode 100644 index 1c78256053..0000000000 --- a/types/bingmaps/Traffic.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Adds a traffic incident and flow data to the map. - * @requires The Microsoft.Maps.Traffic module. - */ -declare module Microsoft.Maps.Traffic { - /** Options that can be customized in the Traffic manager. */ - export interface ITrafficOptions { - /** Displays the traffic flow layer. */ - flowVisible?: boolean; - - /** Displays all traffic incidents. */ - incidentsVisible?: boolean; - - /** Displays the traffic legend. */ - legendVisible?: boolean; - - /** - * Sets the opacity of the traffic flow tile layer. Must be a number between 0 and 1. The default is 1 unless the map - * mode is set to lite, in which case the default is set to 0.7. - */ - opacity?: number; - } - - /** - * The TrafficManager class provides the ability to show traffic flow and incident data on top of the map. When creating an - * instance of the TrafficManager class the map must be passed as an argument to the constructor. - * @requires The Microsoft.Maps.Traffic module. - */ - export class TrafficManager { - /** - * @constructor - * @requires The Microsoft.Maps.Traffic module. - * @param map A map instnce to attach the traffic manager to. - */ - constructor(map: Map); - - /** Hides all traffic data. */ - public hide(): void; - - /** Hides the traffic flow layer. */ - public hideFlow(): void; - - /** Hides all traffic incidents. */ - public hideIncidents(): void; - - /** Hides the traffic legend. */ - public hideLegend(): void; - - /** - * Sets the options for the traffic manager. - * @param options The options for the traffic manager. - */ - public setOptions(options: ITrafficOptions): void; - - /** Displays all traffic data. */ - public show(): void; - - /** Displays the traffic flow layer. */ - public showFlow(): void; - - /** Displays all traffic incidents. */ - public showIncidents(): void; - - /** Displays the traffic legend. */ - public showLegend(): void; - - } -} \ No newline at end of file diff --git a/types/bingmaps/WellKnownText.d.ts b/types/bingmaps/WellKnownText.d.ts deleted file mode 100644 index 51c42203ce..0000000000 --- a/types/bingmaps/WellKnownText.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -declare module Microsoft.Maps { - /** - * Class responsible for readon/writing geo data in well known text format - * @requires The Microsoft.Maps.WellKnownText module. - */ - export module WellKnownText { - /** - * Reads the data in wellknowntext format and returns the shapes. Multi-Geometry type shapes are returned as an array of shapes. - * @param wkt The well known text string that needs to be parsed into shapes. - * @param styles Styles to apply to the shapes. - * @returns One of more shapes. - */ - export function read(wkt: string, styles?: IStylesOptions): IPrimitive | IPrimitive[]; - - /** - * Writes the data into wellknowntext format. - * @param data The data that needs to be serialized. - * @returns Well known text formatted string. - */ - export function write(data: IPrimitive | IPrimitive[]): string; - } -} \ No newline at end of file diff --git a/types/bingmaps/bingmaps-tests.ts b/types/bingmaps/bingmaps-tests.ts deleted file mode 100644 index 962c3047fa..0000000000 --- a/types/bingmaps/bingmaps-tests.ts +++ /dev/null @@ -1,83 +0,0 @@ -namespace BingMapsTests { - - // An interactive set of Bing Maps AJAX control usages can be found at http://www.bingmapsportal.com/isdk/ajaxv7 - // A full API description can be found at http://msdn.microsoft.com/en-us/library/gg427610.aspx - export class TestFixture { - - public createMap( - // This key can be acquired at http://www.microsoft.com/maps/create-a-bing-maps-key.aspx - bingMapsApiKey: string, - // This is the HTML container that the map will be drawn inside of - target: HTMLElement, - // These positions will be placed as pushpins onto the map - mapPositions: Array, - // This will fire if the geolocation fails and will pass the original target (parameter 2) - onFailure: (element: HTMLElement) => any) { - - var self = this; - var map: Microsoft.Maps.Map; - - navigator.geolocation.getCurrentPosition((position: Position) => { - - var locations: Array = new Array(); - var options: Microsoft.Maps.IMapLoadOptions; - - function loadMap() { - options = { - credentials: bingMapsApiKey, - enableClickableLogo: false, - showDashboard: false, - showScalebar: false, - center: self.toLocation(position), - zoom: 16, - mapTypeId: Microsoft.Maps.MapTypeId.road - }; - - target.innerHTML = ""; - - map = new Microsoft.Maps.Map(target, options); - - for (var i = 0; i < mapPositions.length; ++i) { - - var mapPosition: Position = mapPositions[i]; - var location: Microsoft.Maps.Location = self.createPushpin(map, mapPosition); - - locations.push(location); - } - - // Sets the view of the map to the smallest size that contains all of the - // specified locations (in this case the pusphin locations) - map.setView({ bounds: Microsoft.Maps.LocationRect.fromLocations(locations) }); - } - - if ((window).Windows != undefined) { - // Running in Win8 app - Microsoft.Maps.loadModule("Microsoft.Maps.Map", { callback: loadMap }); - } else { - // Running anywhere else - loadMap(); - } - }, () => onFailure(target), { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); - - } - - // Converts a standard HTML geolocation Position to a Location - private toLocation(position: Position): Microsoft.Maps.Location { - return new Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude); - } - - // Creates a pushpin on a specified map and returns the Location for potentially setting the map view - private createPushpin(map: Microsoft.Maps.Map, position: Position): Microsoft.Maps.Location { - - var location: Microsoft.Maps.Location; - var pushpin: Microsoft.Maps.Pushpin; - - location = this.toLocation(position); - pushpin = new Microsoft.Maps.Pushpin(location, null); - - map.entities.push(pushpin); - - return location; - } - } -} diff --git a/types/bingmaps/index.d.ts b/types/bingmaps/index.d.ts deleted file mode 100644 index b629e3b903..0000000000 --- a/types/bingmaps/index.d.ts +++ /dev/null @@ -1,2850 +0,0 @@ -// Type definitions for Microsoft.Maps 8.0 (Change set e6d7cc4) -// Project: https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions -// Definitions by: Ricky Brundritt -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// - -/** - * The Bing Maps V8 developer API. - */ -declare module Microsoft.Maps { - - ////////////////////////////////////////////// - /// Custom Map Styles - ////////////////////////////////////////////// - - /** The styles options that can be applied to map elements. */ - export interface IMapElementStyle { - /** - * Hex color used for filling polygons, the background of point icons, and for the center of lines if they have split. - */ - fillColor?: string; - - /** - * The hex color of a map label. - */ - labelColor?: string; - - /** - * The outline hex color of a map label. - */ - labelOutlineColor?: string; - - /** - * Species if a map label type is visible or not. - */ - labelVisible?: boolean; - - /** - * Hex color used for the outline around polygons, the outline around point icons, and the color of lines. - */ - strokeColor?: string; - - /** - * Specifies if the map element is visible or not. - */ - visible?: boolean; - } - - /** The style options that can be appliction to bordered map elements. */ - export interface IBorderedMapElementStyle extends IMapElementStyle { - /** - * Secondary/casing line hex color of the border of a filled polygon. - */ - borderOutlineColor?: string; - - /** - * Primary line hex color of the border of a filled polygon. - */ - borderStrokeColor?: string; - - /** - * Specifies if a border is visible or not. - */ - borderVisible?: boolean; - } - - /** Global style settings */ - export interface ISettingsStyle { - /** A hex color value that all land is first flushed to before things are drawn on it. */ - landColor?: string; - - /** Specifies whether or not to draw elevation shading on the map. */ - shadedReliefVisible?: boolean; - } - - /** Map Elements which can be styled. */ - export interface IMapElements { - - /** Admin1, state, province, etc. */ - adminDistrict?: IBorderedMapElementStyle; - - /** Icon representing the capital of a state/province. */ - adminDistrictCapital?: IMapElementStyle; - - /** Area of land encompassing an airport. */ - airport?: IMapElementStyle; - - /** Area of land use, not to be confused with Structure */ - area?: IMapElementStyle; - - /** An arterial road is a high-capacity urban road. Its primary function is to deliver traffic from collector roads to freeways or expressways, and between urban centers efficiently. */ - arterialRoad?: IMapElementStyle; - - /** A structure such as a house, store, factory. */ - building?: IMapElementStyle; - - /** Restaurant, hospital, school, etc. */ - business?: IMapElementStyle; - - /** Icon representing the capital populated place. */ - capital?: IMapElementStyle; - - /** Area of a cemetery */ - cemetery?: IMapElementStyle; - - /** Area of a whole continent */ - continent?: IMapElementStyle; - - /** A controlled-access highway is a type of road which has been designed for high-speed vehicular traffic, with all traffic flow and ingress/egress regulated. Also known as a highway, freeway, motorway, expressway, interstate, parkway. */ - controlledAccessHighway?: IMapElementStyle; - - /** A country or independent sovereign state. */ - countryRegion?: IBorderedMapElementStyle; - - /** Icon representing the capital of a country/region. */ - countryRegionCapital?: IMapElementStyle; - - /** Admin2, county, etc. */ - district?: IBorderedMapElementStyle; - - /** An area of land used for educational purposes such as a school campus. */ - education?: IMapElementStyle; - - /** A school or other educational building. */ - educationBuilding?: IMapElementStyle; - - /** Restaurant, caf�, etc. */ - foodPoint?: IMapElementStyle; - - /** Area of forest land. */ - forest?: IMapElementStyle; - - /** An area of land where the game of golf is played. */ - golfCourse?: IMapElementStyle; - - /** Lines representing ramps typically alongside ControlledAccessHighways */ - highSpeedRamp?: IMapElementStyle; - - /** A highway. */ - highway?: IMapElementStyle; - - /** An area of land reserved for Indigenous people. */ - indigenousPeoplesReserve?: IMapElementStyle; - - /** Labeling of area of an island. */ - island?: IMapElementStyle; - - /** Major roads. */ - majorRoad?: IMapElementStyle; - - /** The base map element in which all other map elements inherit from. */ - mapElement?: IMapElementStyle; - - /** Area of land used for medical purposes. Generally, hospital campuses. */ - medical?: IMapElementStyle; - - /** A building which provides medical services. */ - medicalBuilding?: IMapElementStyle; - - /** A military area. */ - military?: IMapElementStyle; - - /** A natural point of interest. */ - naturalPoint?: IMapElementStyle; - - /** Area of land used for nautical purposes. */ - nautical?: IMapElementStyle; - - /** Area defined as a neighborhood. Labels only. */ - neighborhood?: IMapElementStyle; - - /** Area of any kind of park. */ - park?: IMapElementStyle; - - /** Icon representing the peak of a mountain. */ - peak?: IMapElementStyle; - - /** All point features that are rendered with an icon of some sort */ - point?: IMapElementStyle; - - /** Restaurant, hospital, school, marina, ski area, etc. */ - pointOfInterest?: IMapElementStyle; - - /** A political border. */ - political?: IBorderedMapElementStyle; - - /** Icon representing size of populated place (city, town, etc). */ - populatedPlace?: IMapElementStyle; - - /** Railway lines */ - railway?: IMapElementStyle; - - /** Line representing the connecting entrance/exit to a highway. */ - ramp?: IMapElementStyle; - - /** Area of nature reserve. */ - reserve?: IMapElementStyle; - - /** River, stream, or other passage. Note that this may be a line or polygon and may connect to non-river water bodies. */ - river?: IMapElementStyle; - - /** Lines that represent all roads */ - road?: IMapElementStyle; - - /** Icon representing the exit, typically from a controlled access highway. */ - roadExit?: IMapElementStyle; - - /** Sign representing a compact name for a road. For example, I-5. */ - //roadShield?: IMapElementStyle; - - /** Land area covered by a runway. See also Airport for the land area of the whole airport. */ - runway?: IMapElementStyle; - - /** Area generally used for beaches, but could be used for sandy areas/golf bunkers in the future. */ - sand?: IMapElementStyle; - - /** A shopping center or mall. */ - shoppingCenter?: IMapElementStyle; - - /** Area of a stadium. */ - stadium?: IMapElementStyle; - - /** A street. */ - street?: IMapElementStyle; - - /** Buildings and other building-like structures */ - structure?: IMapElementStyle; - - /** A toll road. */ - tollRoad?: IMapElementStyle; - - /** Walking trail, either through park or hiking trail */ - trail?: IMapElementStyle; - - /** Icon representing a bus stop, train stop, airport, etc. */ - transit?: IMapElementStyle; - - /** A transit building. */ - transitBuilding?: IMapElementStyle; - - /** Lines that are part of the transportation network (roads, trains, ferries, etc) */ - transportation?: IMapElementStyle; - - /** An unpaved street. */ - unpavedStreet?: IMapElementStyle; - - /** Forests, grassy areas, etc. */ - vegetation?: IMapElementStyle; - - /** Icon representing the peak of a volcano. */ - volcanicPeak?: IMapElementStyle; - - /** Anything that looks like water */ - water?: IMapElementStyle; - - /** Icon representing a water feature location such as a waterfall. */ - waterPoint?: IMapElementStyle; - - /** Ferry route lines */ - waterRoute?: IMapElementStyle; - } - - /** Defines a custom map style. */ - export interface ICustomMapStyle { - /** A list of map elements to be styled. */ - elements?: IMapElements; - - /** Global Settings. */ - settings?: ISettingsStyle; - - /** The version of the style syntax used. */ - version: string; - } - - ////////////////////////////////////////////// - /// Enumerations - ////////////////////////////////////////////// - - /** This enumeration defines how the map labels are displayed. */ - export enum LabelOverlay { - /** - * Map labels are hidden. Note that this will have no effect on road maps unless the allowHidingLabelsOfRoad map option - * is set to true. - */ - hidden, - - /** Map labels are visible. */ - visible - } - - /** This enumeration is used to specify the type of map style that should be displayed by the map. */ - export enum MapTypeId { - /** The aerial map type which uses top-down satellite & airplane imagery. */ - aerial, - - /** High resolution aerial imagery taken at 45 degrees to the ground, from 4 different directions. */ - birdseye, - - /** A darker version of the road maps. */ - canvasDark, - - /** A lighter version of the road maps which also has some of the details such as hill shading disabled. */ - canvasLight, - - /** A grayscale version of the road maps. */ - grayscale, - - /** Displays a blank canvas that uses the mercator map project. It basically removed the base maps layer. */ - mercator, - - /** Ordnance survey map type (en-gb only). */ - ordnanceSurvey, - - /** Road map type. */ - road, - - /** Provides streetside panoramas from the street level. */ - streetside - } - - /** The NavigationBarMode can be used to customize the layout and style of the navigation bar. */ - export enum NavigationBarMode { - /** - * A compact navigation bar that includes a smaller drop down for the map type and zoom buttons. Recommended for small - * maps or screen such as a mobile device. - */ - compact, - - /** - * The default navigation bar that has a drop down for the map type, a locate me button, and zoom buttons. Recommended for - * medium to large maps in desktop browsers. - */ - default, - - /** - * A minified navigation bar that has a button to toggle between road and aerial maps, zoom buttons, and a button to turn - * traffic information on and off. Recommended for small maps or screen such as a mobile device. - */ - minified - } - - /** The NavigationBarOrientation enumeration is used to define how the navigation bar controls are laid out. */ - export enum NavigationBarOrientation { - /** Repositions the buttons in the navigation bar such that they are aligned horizontally. */ - horizontal, - - /** Repositions the buttons in the navigation bar such that they are aligned vertically. */ - vertical - } - - /** This enumeration is used to specify how the overview map for the streetside map mode should be displayed. */ - export enum OverviewMapMode { - /** Shows the overview map in an expanded state. */ - expanded, - - /** Hides the overview map. */ - hidden, - - /** Shows the overview map in a minimized state. */ - minimized - } - - /** Contains enum to show how pixels are defined. */ - export enum PixelReference { - /** The pixel is defined relative to the map control�s root element, where the top left corner of the map control is (0, 0). */ - control, - - /** The pixel is defined relative to the page, where the top left corner of the HTML page is (0, 0). */ - page, - - /** The pixel is defined in viewport coordinates, relative to the center of the map, where the center of the map is (0, 0). */ - viewport - } - - ////////////////////////////////////////////// - /// Interfaces - ////////////////////////////////////////////// - - /** Represents a structured address object. */ - export interface IAddress { - /** - * The street line of an address. The addressLine property is the most precise, official line for an address relative to the postal agency - * servicing the area specified by the locality or postalCode properties. - */ - addressLine: string; - - /** - * The subdivision name within the country or region for an address. This element is also commonly treated as the first order administrative - * subdivision. An example is a US state, such as �Oregon�. - */ - adminDistrict: string; - - /** The country or region name of the address. */ - countryRegion: string; - - /** A string specifying the two-letter ISO country code. */ - countryRegionISO2: string; - - /** The second, third, or fourth order subdivision within a country, dependency, or region. An example is a US county, such as �King�. */ - district: string; - - /** A nicely formatted address string for the result. */ - formattedAddress: string; - - /** The locality, such as the primary city, that corresponds to an address. An example is �Seattle�. */ - locality: string; - - /** The post code, postal code, or ZIP code of an address. An example is a US ZIP code, such as �98152�. */ - postalCode: string; - } - - /** The event args for when a layer frame is being loaded in an AnimtedTileLayer. **/ - export interface IAnimatedFrameEventArgs { - /** The animated tile layer that the frame belongs to. **/ - animatedTileLayer: AnimatedTileLayer; - - /** The index of the frame being loaded. **/ - index: number; - } - - /** An object that defines the options for an AnimatedTileLayer. **/ - export interface IAnimatedTileLayerOptions { - /** A boolean that specifies whether the animation should auto-start when it is added to the map or not. Default: true **/ - autoPlay?: boolean; - - /** The number of miliseconds between two layer frames. Default: 1000 **/ - frameRate?: number; - - /** A custom loading screen to show on the map when the map tiles are being fetched. **/ - loadingScreen?: CustomOverlay; - - /** The max amount of total loading time of all tiles in a viewport in milliseconds. Default: 15000 **/ - maxTotalLoadTime?: number; - - /** The array of tile layer sources to animate through. **/ - mercator: TileSource[]; - - /** A boolean specifying if the animated tile layer is visible or not. **/ - visible?: boolean; - } - - /** Represents the options that can be used when initializing a custom overlay. **/ - export interface ICustomOverlayOptions { - /** - * Specifies if the custom overlay should eb rendered above or below the label layer of the map. When above, - * elements in the overlay can be clickable. Default: True - */ - beneathLabels?: boolean; - } - - /** Base data layer interface. */ - export interface IDataLayer extends ILayer { - /** Clears all data in the layer. */ - clear(): void; - } - - /** Event args included in entity collection events. */ - export interface IEntityCollectionChangedEventArgs { - /** The entity collection the event was triggered from. */ - collection: EntityCollection; - - /** The IPrimitive object that the event occurred for. */ - data: IPrimitive; - } - - /** An object the identifies an event that has been attached to an object. */ - export interface IHandlerId { - } - - /** Base layer interface. */ - export interface ILayer { - } - - /** - * @deprecated use IMouseEventArgs - * A LayerMouseEventArgs object is returned by many the mouse event handlers attached to a Layer. - */ - export interface ILayerMouseEventArgs { - /** - * @deprecated use target - * The IPrimitive shape (pushpin, polyline, polygon) that the event occurred on. - */ - primitive: IPrimitive; - } - - /** The options that can be used to customize an infobox. */ - export interface IInfoboxOptions { - /** - * @deprecated Use HTML buttons and links in description instead. - */ - actions?: IInfoboxActions[]; - - /** The string displayed inside the infobox. */ - description?: string; - - /** - * The HTML that represents the infobox. Note that infobox options are ignored if custom HTML is set. Also, if custom HTML is used to represent the - * infobox, the infobox is anchored at the top-left corner. - */ - htmlContent?: string; - - /** The location on the map where the infobox�s anchor is attached. */ - location?: Location; - - /** The maximium size that the infobox height can expand to based on it�s content. Default: 126 **/ - maxHeight?: number; - - /** The maximium size that the infobox width can expand to based on it�s content. Default: 256 **/ - maxWidth?: number; - - /** - * The amount the infobox pointer is shifted from the location of the infobox, or if showPointer is false, then it is the amount the info box bottom - * left edge is shifted from the location of the infobox. If custom HTML is set, it is the amount the top-left corner of the infobox is shifted from - * its location. The default offset value is (0,0), which means there is no offset. - */ - offset?: Point; - - /** - * A boolean indicating whether to show the close dialog button on the infobox. The default value is true. By default, the close button is displayed - * as an X in the top right corner of the infobox. This property is ignored if custom HTML is used to represent the infobox. - */ - showCloseButton?: boolean; - - /** - * A boolean indicating whether to display the infobox with a pointer. The default value is true. In this case the infobox is anchored at the bottom - * point of the pointer. If this property is set to false, the infobox is anchored at the bottom left corner. This property is ignored if custom HTML - * is used to represent the infobox. - */ - showPointer?: boolean; - - /** The title of the infobox. */ - title?: string; - - /** - * A boolean indicating whether to show or hide the infobox. The default value is true. A value of false indicates that the infobox is hidden, - * although it is still an entity on the map. - */ - visible?: boolean; - - /** The z-index of the infobox with respect to other items on the map. */ - zIndex?: number; - } - - /** - * @deprecated Use HTML buttons and links in description instead. - */ - export interface IInfoboxActions { - /** The text to display for the action. */ - label: string; - - /** The function to call when the label is clicked. */ - eventHandler: (eventArg?: MouseEvent) => void; - } - - /** An object that contains information about an infobox event. **/ - export interface IInfoboxEventArgs { - /** The event that occurred. **/ - eventName: string; - - /** The x-value of the pixel coordinate on the page of the mouse cursor. **/ - pageX: number; - - /** The y-value of the pixel coordinate on the page of the mouse cursor. **/ - pageY: number; - - /** The infobox object that fired the event. **/ - target: Infobox; - - /** The type of the object that fired the event.This will always be 'infobox'. **/ - targetType: string; - - /** Original mouse event from the browser. */ - originalEvent?: MouseEvent; - } - - /** Map or View options */ - export interface IMapLoadOptions extends IMapOptions, IViewOptions { - /** The Bing Maps Key used to authenticate the application. This property can only be set when using the Map constructor. */ - credentials: string; - } - - /** - * An object that can be used to customize the map. Some of the map options can be changed after the map has loaded by using - * the setOptions function on the map. - */ - export interface IMapOptions { - - /** - * A boolean that, when set to true, allows the road labels to be hidden. Default: false - * This property can only be set when using the Map constructor. This property can only be set when using the Map constructor. - */ - allowHidingLabelsOfRoad?: boolean; - - /** A boolean indicating if the infobox is allowed to overflow outside the bounds of the map. Default: false. */ - allowInfoboxOverflow?: boolean; - - /** The color to use for the map control background. The default color is #EAE8E1. This property can only be set when using the Map constructor. */ - backgroundColor?: string | Color; - - /** Custom map styles used to modify the look and feel of the base map. */ - customMapStyle?: ICustomMapStyle; - - /** A boolean value indicating whether to disable the user�s ability to control the using the keyboard. Default: false */ - disableKeyboardInput?: boolean; - - /** A boolean value indicating if mousing over the map type selector should open it or not. Default: true */ - disableMapTypeSelectorMouseOver?: boolean; - - /** A boolean value indicating whether to disable the user's ability to pan the map. Default: false */ - disablePanning?: boolean; - - /** - * Scrolling the mouse wheel over the map will zoom it in or out, but will not scroll the page. - * Setting this property to true disables the zooming of the map and instead reverts back to scrolling the page instea. - * Default: false - */ - disableScrollWheelZoom?: boolean; - - /** - * A boolean indicating whether to disable streetside mode.If this property is set to true, streetside will be removed from - * the navigation bar, and the automatic coverage overlay will be disabled when zoomed in at lower zoom levels. Default false - * This property can only be set when using the Map constructor. - */ - disableStreetside?: boolean; - - /** - * A boolean indicating whether to disable the automatic streetside coverage layer that appears when zoomed in at lower zoom - * levels. Default false - * This property can only be set when using the Map constructor. - **/ - disableStreetsideAutoCoverage?: boolean; - - /** A boolean value indicating whether to disable the user's ability to zoom in or out. Default: false */ - disableZooming?: boolean; - - /** - * A boolean value indicating whether the Bing(TM) logo on the map is clickable. Default: true. - * This property can only be set when using the Map constructor. - */ - enableClickableLogo?: boolean; - - /** - * A boolean value indicating whether to use the inertia animation effect during map navigation. Default: true - * This property can only be set when using the Map constructor. - */ - enableInertia?: boolean; - - /** - * A boolean that indicates if the map should be rendered using lite mode. When set to true vector map labels are - * disabled and map labels are rendered directly into the map tiles. This offers improved performance, but will result - * in the labels being rendered behind data on the map and the labels will also not use collision dection with pushpins. - * If this property is not set, the map set this value based on the target device and browser as vector labels perform - * better in some scenrarios than others. - * This property can only be set when using the Map constructor. - */ - liteMode?: boolean; - - /** A bounding area that restricts the map view. */ - maxBounds?: LocationRect; - - /** The maximum zoom level that the map can be zoomed into. */ - maxZoom?: number; - - /** The minimum zoom level that the map cab be zoomed out to. */ - minZoom?: number; - - /** Specifies how the navigation bar should be rendered on the map. */ - navigationBarMode?: NavigationBarMode; - - /** A boolean whether what orientation should be used when laying out the navigation controls. */ - navigationBarOrientation?: NavigationBarOrientation; - - /** - * A boolean value indicating whether to display the �breadcrumb control�. The breadcrumb control shows the current center location�s geography hierarchy. - * The default value is false. Requires the showLocateMeButton map option to be set to true. The breadcrumb control displays best when the width of the map - * is at least 400 pixels. - */ - showBreadcrumb?: boolean; - - /** - * A boolean value indicating whether to show the map navigation control. Default: true�This property can only be set when using the Map constructor. - */ - showDashboard?: boolean; - - /** - * A boolean value indicating whether to show a button that centers the map over the user's location in the map navigation control. Default: true - * This property can only be set when using the Map constructor. - */ - showLocateMeButton?: boolean; - - /** - * A boolean value indicating whether or not to show the map Bing logo. The default value is true. - * This property can only be set when using the Map constructor. - */ - showLogo?: boolean; - - /** - * A boolean value indicating whether to show the map type selector in the map navigation control. Default: true - * This property can only be set when using the Map constructor. - */ - showMapTypeSelector?: boolean; - - /** - * A boolean value indicating whether to show the scale bar. Default: true - * This property can only be set when using the Map constructor. - */ - showScalebar?: boolean; - - /** When using the minified navigation bar, a traffic button is displayed. Setting this option to false will hide this button. */ - showTrafficButton?: boolean; - - /** - * A boolean value indicating whether to show a link to the End User Terms of Use, which appears to the right of the copyrights, or not. Default: true - * This property can only be set when using the Map constructor. - */ - showTermsLink?: boolean; - - /** - * A boolean value indicating whether to show the zoom buttons in the map navigation control. Default: true - * This property can only be set when using the Map constructor. - */ - showZoomButtons?: boolean; - - /** A set of properties for the streetside mode of the map. */ - streetsideOptions?: IStreetsideOptions; - - /** Additional support map types that should be added to the navigaiton bar such as canvasDark, canvasLight, and grayscale.*/ - supportedMapTypes?: MapTypeId[]; - } - - /** A MapTypeChangeEventArgs object is returned by the map when using the mapTypeChanged event. */ - export interface IMapTypeChangeEventArgs { - /** The map type that map has changed to. */ - newMapTypeId: MapTypeId; - - /** The map type that the map has changed from. */ - oldMapTypeId: MapTypeId; - - /** The map instance the event occured on */ - target: Map; - - /** The type of object the event was attached to. Should always be "map" */ - targetType: string; - } - - /** Interface for module options. */ - export interface IModuleOptions { - /** A callback function that is fired after the module has loaded. */ - callback?: () => void; - - /** A function that is called if there is an error loading the module. */ - errorCallback?: () => void; - - /** A Bing Maps key that is used with the module when the module is loaded without a map. */ - credentials?: string; - } - - /** A MouseEventArgs object is returned by many the mouse event handlers. */ - export interface IMouseEventArgs extends ILayerMouseEventArgs { - /** The event that occurred. */ - eventName: string; - - /** A boolean indicating if the primary button, such as the left mouse button or a tap on a touch screen, was used during a mouse down or up event. */ - isPrimary: boolean; - - /** A boolean indicating if the secondary mouse button, such as the right mouse button, was used during a mouse down or up event. */ - isSecondary: boolean; - - /** If the target is a shape, this will be the layer that the shape is in. */ - layer: Layer; - - /** The map location of where the event occurred. */ - location: Location; - - /** The x-value of the pixel coordinate on the page of the mouse cursor. */ - pageX: number; - - /** The y-value of the pixel coordinate on the page of the mouse cursor. */ - pageY: number; - - /** The pixel coordinate of the mouse cusrsor relative to the top left corner of the map div. */ - point: Point; - - /** The object that triggered the event. */ - target: Map | IPrimitive; - - /** The type of the object that the event is attached to. Valid values include the following: �map�, 'layer', �polygon�, �polyline�, or �pushpin� */ - targetType: string; - - /** - * Returns the x-value of the pixel coordinate, relative to the map, of the mouse. - * @returns The x-value of the pixel coordinate, relative to the map, of the mouse. - */ - getX(): number; - - /** - * Returns the y-value of the pixel coordinate, relative to the map, of the mouse. - * @returns The y-value of the pixel coordinate, relative to the map, of the mouse. - */ - getY(): number; - } - - /** - * An object tthat contains information about a streetside scene. - */ - export interface IPanoramaInfo { - /** The capture date of the streetside scene. */ - cd?: string; - } - - /** - * All shapes; Pushpins, Polylines and Polygons, derive from the IPrimitive interface. This means that they can be - * passed into any function that takes in an IPrimitive object. Also, any function that returns an IPrimitive is capable - * of returning any of these shapes. - */ - export interface IPrimitive { - /** Optional property to store any additional metadata for this primitive. */ - metadata?: any; - - /** - * Gets the css cursor value when the primitive has events on it. - * @returns css cursor string when primitive has events on it. - */ - getCursor(): string; - - /** - * Gets whether the primitive is visible. - * @returns A boolean indicating whether the primitive is visible or not. - */ - getVisible(): boolean; - - /** - * Sets the options for customizing the IPrimitive. - * @param options The options for customizing the IPrimitive. - */ - setOptions(options: IPrimitiveOptions): void; - } - - /** A IPrimitiveChangedEventArgs object is returned by the changed event on IPrimitive shapes. */ - export interface IPrimitiveChangedEventArgs { - /** The IPrimitive shape the event occured on. */ - sender: IPrimitive; - - /** The name of the change that occured; 'locations' or 'options'. */ - name: string; - } - - /** Options used for customizing IPrimitive objects. */ - export interface IPrimitiveOptions { - /** The css cursor to show when the IPrimitive has mouse events on it. Default value is pointer (hand). */ - cursor?: string; - - /** Boolean indicating whether the IPrimitive is visible. */ - visible?: boolean; - } - - /** Options used for customizing Polylines. */ - export interface IPolylineOptions extends IPrimitiveOptions { - /** Indicates if drawn shape should be generalized based on the zoom level to improve rendering performance. Default true **/ - generalizable?: boolean; - - /** CSS string or Color object as the poly's color. */ - strokeColor?: string | Color; - - /** An array of numbers separated by spaces, or a string separated by spaces/commas specifying the repetitive stroke pattern. */ - strokeDashArray?: number[] | string; - - /** The thickness of the poly stroke. */ - strokeThickness?: number; - } - - /** Options used for customizing Polygons. */ - export interface IPolygonOptions extends IPolylineOptions { - /** CSS string or Color object as the polygon's filling color. */ - fillColor?: string | Color; - } - - /** Options used for customizing Pushpins. */ - export interface IPushpinOptions extends IPrimitiveOptions { - /** The point on the pushpin icon, in pixels, which is anchored to the pushpin location. An anchor of (0,0) is the top left corner of the icon. */ - anchor?: Point; - - /** Specifies what color to make the default pushpin. */ - color?: string | Color; - - /** A boolean indicating whether the pushpin can be dragged to a new position with the mouse or by touch. */ - draggable?: boolean; - - /** Specifies whether to enable the clicked style on the pushpin. */ - enableClickedStyle?: boolean; - - /** Specifies whether to enable the hover style on the pushpin. */ - enableHoverStyle?: boolean; - - /** - * Defines the the icon to use for the pushpin.This can be a URL to an Image or SVG file, an image data URI, or an inline SVG string. - * Tip: When using inline SVG, you can pass in placeholders `{color}` and `{text}` in your SVG string. This placeholder will be replaced by the pushpins color or text property value when rendered. - */ - icon?: string; - - /** Whether the clickable area of pushpin should be an ellipse instead of a rectangle. */ - roundClickableArea?: boolean; - - /** - * A secondary title label value to display under the pushpin. Uses label collision detection. This label automatically changes color between white - * and dark grey depending on which map style is selected. Requires the title label to be set. - */ - subTitle?: string; - - /** - * The title label value to display under the pushpin. This label automatically changes color between white and dark grey depending on which map - * style is selected. Pushpin Titles support label collision detection, as described below. - */ - title?: string; - - /** A short string of text that is overlaid on top of the pushpin. */ - text?: string; - - /** The amount the text is shifted from the pushpin icon. The default value is (0,5). */ - textOffset?: Point; - } - - /** An object that represents a min and max value range. */ - export interface IRange { - /** The minimum value. */ - min: number; - - /** The maximum value. */ - max: number; - } - - /** The options that can be used to customize how the streetside map mode is displayed to the user. */ - export interface IStreetsideOptions { - /** A boolean indicating if the ability to navigate between image bubbles should be disabled in streetside map mode. Default: false */ - disablePanoramaNavigation?: boolean; - - /** The location that the streetside panorama should be looking towards. This can be used instead of a heading. */ - locationToLookAt?: Location; - - /** A callback function that is triggered after the streetside view has not loaded successfully. */ - onErrorLoading?: () => void; - - /** A callback function that is triggered after the streetside view has loaded successfully. */ - onSuccessLoading?: () => void; - - /** - * Specifies how to render the overview map when in streetside mode. - * Default: Microsoft.Maps.OverviewMapMode.expanded - */ - overviewMapMode?: OverviewMapMode; - - /** - * Information for a streetside panorama scene to load. - */ - panoramaInfo?: IPanoramaInfo; - - /** The radius to search in for available streetside panoramas. */ - panoramaLookupRadius?: number; - - /** A boolean indicating if the current address being viewed should be hidden when in streetside map mode. Default: true */ - showCurrentAddress?: boolean; - - /** A boolean indicating if the exit button should be hidden when in streetside map mode. Default: true */ - showExitButton?: boolean; - - /** A boolean indicating if the heading compass button is hidden when in streetside map mode. Default: true */ - showHeadingCompass?: boolean; - - /** A boolean indicating if the link to report a problem with a streetside image is hidden when in streetside map mode. Default: true */ - showProblemReporting?: boolean; - - /** A boolean indicating if the zoom buttons should be displayed when in streetside map mode. Default: true */ - showZoomButtons?: boolean; - } - - /** Defines a set of styles for pushpins, polylines, and polygons. */ - export interface IStylesOptions { - /** Sets the options for all pushpins. */ - pushpinOptions?: IPushpinOptions; - - /** Sets the options for all polylines. */ - polylineOptions?: IPolylineOptions; - - /** Sets the options for all polygons. */ - polygonOptions?: IPolygonOptions; - } - - /** Interface to specify style css while registering a module */ - export interface IStyleUrl { - /** List of style css urls o be downloaded */ - styleURLs: string[]; - } - - /** Represents options that can be used to customize a tile layer. */ - export interface ITileLayerOptions { - - /** - * The number of milliseconds allowed for the tile layer image download. If the timeout occurs before the image is fully - * downloaded, the map control considers the download a failure. The default value is 10000. - */ - downloadTimeout?: number; - - /** The tile source for the tile layer. */ - mercator: TileSource; - - /** The opacity of the tile layer, defined by a number between 0 (not visible) and 1. */ - opacity?: number; - - /** - * A boolean indicating whether to show or hide the tile layer. The default value is true. A value of false indicates that - * the tile layer is hidden, although it is still an entity on the map. - */ - visible?: boolean; - - /** The z-index of the tile layer. */ - zIndex?: number; - } - - /** Represents options that can be used to define a tile source. */ - export interface ITileSourceOptions { - /** - * A bounding box that specifies where tiles are available. - * Note: This will not crop tiles to the specific bounding box, it limits the tiles it loads to those that intersect this bounding box. - */ - bounds?: LocationRect; - - /** The maximum zoom level tiles that tiles should be rendered at. */ - maxZoom?: number; - - /** The minimum zoom level tiles that tiles should be rendered at. */ - minZoom?: number; - - /** - * Required. This can be a string or a callback function that constructs the URLs used to retrieve tiles from the tile source. - * When using a string, the uriConstructor will allow you to specify placeholders that will be replaced with the tiles value (i.e. {quadkey}). - * See the Tile URL Parameters section for a list of supported parameters. - * Besides using formatted tile URLs, you can also specify a callback function as the uriConstructor. This is useful if you need to be able to - * build custom tile URL�s that may require some additional calculations for a tile. - */ - uriConstructor: string | ((tile: PyramidTileId) => string); - } - - /** Represents options that can be used to set the view of the map. */ - export interface IViewOptions { - /** The bounding rectangle of the map view. If both bounds and center are specified, bounds takes precedence over center. */ - bounds?: LocationRect; - - /** The location of the center of the map view. If both bounds and center are specified, bounds takes precedence over center. */ - center?: Location; - - /** - * The directional heading of the map. The heading is represented in geometric degrees with 0 or 360 = North, 90 = East, - * 180 = South, and 270 = West. - */ - heading?: number; - - /** Indicates how the map labels are displayed. */ - labelOverlay?: LabelOverlay; - - /** The map type of the view. */ - mapTypeId?: MapTypeId; - - /** The amount of padding in pixels to be added to each side of the bounds of the map view. */ - padding?: number; - - /** The angle relative to the horizon to tilt a streetside panorama image. */ - pitch?: number; - - /** The zoom level of the map view. */ - zoom?: number; - } - - ////////////////////////////////////////////// - /// Modular Framework - ////////////////////////////////////////////// - - /** - * Loads the specified registered module, making its functionality available. You can provide the name of a single module or an array of names in. - * Options or a callback function that is called when the module is loaded can be specified. - * @param moduleName Name of the module to load. Can be the name of a custom module or a built in module name. Built in modules: - * Microsoft.Maps.Autosuggest, Microsoft.Maps.Clustering, Microsoft.Maps.Directions, Microsoft.Maps.DrawingTools, Microsoft.Maps.GeoJSON, - * Microsoft.Maps.HeatMap, Microsoft.Maps.Search, Microsoft.Maps.SpatialDataService, Microsoft.Maps.SpatialMath, Microsoft.Maps.Traffic, - * Microsoft.Maps.WellKnownText - * @param options A callback function or options containing additional information and a callback to call once a module is loaded - */ - export function loadModule(moduleName: string | string[], options?: (() => void) | IModuleOptions): void; - - /** - * Registers a module with the map control. The name of the module is specified in moduleKey, the module script is defined in scriptURL, and the - * options provides the location of a *.css file to load with the module. - * @param moduleName Name of the module to load. - * @param url Url to where the module code is located. - * @param styles List of css files to download. - */ - export function registerModule(moduleName: string, url: string, styles?: IStyleUrl): void; - - /** - * Signals that the specified module has been loaded and if specified, calls the callback function in loadModule. Call this method at the end of your custom module script. - * @param moduleName Name of the module that is loaded. - */ - export function moduleLoaded(moduleName: string): void; - - ////////////////////////////////////////////// - /// Classes - ////////////////////////////////////////////// - - /** - * Provides a layer which can smoothly animate through an array of tile layer sources. - */ - export class AnimatedTileLayer { - /** - * @contstructor - * @param options Options that define how to animate between the specified tile layers. - */ - constructor(options?: IAnimatedTileLayerOptions); - - /** - * Gets the frame rate of this animated tile layer. - * @returns The frame rate of this animated tile layer. - **/ - public getFrameRate(): number; - - /** - * Gets the loading screen overlay when tiles are being fetched. - * @returns The loading screen overlay when tiles are being fetched. - **/ - public getLoadingScreen(): CustomOverlay; - - /** - * Gets the maximum total tile fetching time of this animated tile layer. - * @returns The maximum total tile fetching time of this animated tile layer - **/ - public getMaxTotalLoadTime(): number; - - /** - * Gets the tile sources associated with this layer. - * @returns The tile sources associated with this layer. - **/ - public getTileSources(): TileSource[]; - - /** - * Gets the visibility of this animated tile layer. - * @returns The visibility of this animated tile layer. - **/ - public getVisible(): boolean; - - /** Pause the tile layer animation. **/ - public pause(): void; - - /** Play the animation either from start or where it was paused. **/ - public play(): void; - - /** - * Sets the options for the animated tile layer. - * @params Options that define how to animate between the specified tile layers. - **/ - public setOptions(options: IAnimatedTileLayerOptions): void; - - /** Stop the layer animation, hide layer, and reset frame to the beginning. **/ - public stop(): void; - } - - /** Class that represents a color */ - export class Color { - /** The opacity of the color. The range of valid values are an interger between 0 and 255, or a decimal between 0 and 1. */ - public a: number; - - /** The red value of the color. The range of valid values is 0 to 255 */ - public r: number; - - /** The green value of the color. The range of valid values is 0 to 255 */ - public g: number; - - /** The blue value of the color. The range of valid values is 0 to 255 */ - public b: number; - - /** - * @constructor - * @param a The alpha value in argb format - * @param r The r value in argb format - * @param g The g value in argb format - * @param b The b value in argb format - */ - constructor(a: number, r: number, g: number, b: number); - - /** - * Clones the color. - * @param color The color class that needs to be clones. - * @returns The colne of the color. - */ - public static clone(color: Color): Color; - - /** - * Creates the color from a hex string. - * @param hex The color represented as '#rrggbb' format. - * @returns The color object. - */ - public static fromHex(hex: string): Color; - - /** - * Clones the color. - * @returns The clone of the color. - */ - public clone(): Color; - - /** - * Gets the opacity of this color. - * @returns The opacity between 0 and 1 of this color. - */ - public getOpacity(): number; - - /** - * Converts the color to hex notation. - * @returns The hex notation as '#rrggbb' (ignores a). - */ - public toHex(): string; - - /** - * Converts the color to rgba notation. - * @returns The rgba notation as rgba(rr, gg, bb, aa) - */ - public toRgba(): string; - } - - /** - * You can use this class to create custom overlays on top of the map. These can be static overlays such as custom - * navigation bars, or dynamic overlays such as custom visualization layers. CustomOverlays can be added to the map - * just like any other layer using the map.layers property. - */ - export class CustomOverlay implements ILayer { - /** A reference the the map instance that the overlay was added to. This will be null until the onLoad function has fired. **/ - _map: Map; - - /** - * @constructor - * @param options The options to use when initializing the custom overlay. - */ - constructor(options?: ICustomOverlayOptions); - - /** - * Gets the html element of this custom overlay. - * @returns The htmlElement of this overlay. - */ - public getHtmlElement(): HTMLElement; - - /** - * Gets the map that this overlay is attached to. - * @returns The map that this overlay is attached to. - */ - public getMap(): Map; - - /** - * Updates the html element of this custom overlay. - * @param htmlElement The new htmlElement to set for the overlay. - */ - public setHtmlElement(htmlElement: HTMLElement): void; - - /** - * Implement this method to perform any task that should be done when the overlay is added to the map. - */ - public onAdd(): void; - - /** - * Implement this methof to perform any task that should be done after the overlay has been added to the map. - */ - public onRemove(): void; - - /** - * Implement this method to perform any tasks that should be done when the overlay is removed from the map. - */ - public onLoad(): void; - } - - /** - * Use the Layer class. - * @deprecated in V8 - */ - export class EntityCollection extends Layer { - /** - * @constructor Deprecated. Use the Layer class. - * @deprecated in V8 - */ - constructor(); - - /** - * Removes all shapes from the collection. - */ - public clear(): void; - - /** - * Gets the item at a specified index. - * @param index Index of the item to get. - * @returns The item at a specified index. - */ - public get(index: number): IPrimitive; - - /** - * Gets the number of items in this collection. - * @returns The count of the items. - */ - public getLength(): number; - - /** - * Gets the index of the item in the list. - * @param primitive The item to get the index of. - * @returns The index of the item in the list. - */ - public indexOf(primitive: IPrimitive): number; - - /** - * Inserts the item into the list at a specific index. - * @param primitive The item to insert. - * @param index Index of the item to be inserted. - */ - public insert(primitive: IPrimitive, index: number): void; - - /** - * Returns the last element in the list after removing it. - * @returns The last element in the list after removing it. - */ - public pop(): IPrimitive; - - /** - * Adds the item to the end of the list. - * @param primitive Item to be added. - */ - public push(primitive: IPrimitive | IPrimitive[]): void; - - /** - * Removes the item from the list. - * @param primitive Item to be removed. - * @returns The item to be removed. - */ - public remove(primitive: IPrimitive): IPrimitive; - - /** - * Removes the item from the list at a specified index. - * @param index Index of the item that needs to be removed. - * @returns The item to be removed at a specified index. - */ - public removeAt(index: number): IPrimitive; - } - - /** A static class that manages events within the map SDK. */ - export module Events { - ///////////////////////////////////// - /// addHandler Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported events: - * click, dblclick, maptypechanged, mousedown, mousemove, mouseout, mouseover, mouseup, mousewheel, rightclick, viewchange, viewchangeend, viewchangestart - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: Map, eventName: string, handler: (eventArg?: IMouseEventArgs | IMapTypeChangeEventArgs) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * changed, click, dblclick, drag, dragend, dragstart, mousedown, mouseout, mouseover, mouseup - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: Pushpin, eventName: string, handler: (eventArg?: IMouseEventArgs | IPrimitiveChangedEventArgs) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * changed, click, dblclick, mousedown, mouseout, mouseover, mouseup - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: Polyline | Polygon, eventName: string, handler: (eventArg?: IMouseEventArgs | IPrimitiveChangedEventArgs) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * click, infoboxChanged, mouseenter, mouseleave - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: Infobox, eventName: string, handler: (eventArg?: IInfoboxEventArgs) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * click, dblclick, mousedown, mouseout, mouseover, mouseup, rightclick - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: Layer, eventName: string, handler: (eventArg?: IMouseEventArgs) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * � entityadded - * � entityremoved - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: EntityCollection, eventName: string, handler: (eventArg?: IEntityCollectionChangedEventArgs) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addHandler(target: any, eventName: string, handler: (eventArg?: any) => void): IHandlerId; - - ///////////////////////////////////// - /// addOne Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported events: - * click, dblclick, maptypechanged, mousedown, mousemove, mouseout, mouseover, mouseup, mousewheel, rightclick, viewchange, viewchangeend, viewchangestart - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: Map, eventName: string, handler: (eventArg?: IMouseEventArgs | IMapTypeChangeEventArgs) => void): void; - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * changed, click, dblclick, drag, dragend, dragstart, mousedown, mouseout, mouseover, mouseup - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: Pushpin, eventName: string, handler: (eventArg?: IMouseEventArgs | IPrimitiveChangedEventArgs) => void): void; - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * changed, click, dblclick, mousedown, mouseout, mouseover, mouseup - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: Polyline | Polygon, eventName: string, handler: (eventArg?: IMouseEventArgs | IPrimitiveChangedEventArgs) => void): void; - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * click, infoboxChanged, mouseenter, mouseleave - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: Infobox, eventName: string, handler: (eventArg?: IInfoboxEventArgs) => void): void; - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * click, dblclick, mousedown, mouseout, mouseover, mouseup, rightclick - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: Layer, eventName: string, handler: (eventArg?: IMouseEventArgs) => void): void; - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * � entityadded - * � entityremoved - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: EntityCollection, eventName: string, handler: (eventArg?: IEntityCollectionChangedEventArgs) => void): void; - - /** - * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. - * @param handler The callback function to handle the event when triggered. - */ - export function addOne(target: any, eventName: string, handler: (eventArg?: any) => void): void; - - ///////////////////////////////////// - /// addThrottledHandler Definitions - //////////////////////////////////// - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported events: - * click, dblclick, maptypechanged, mousedown, mousemove, mouseout, mouseover, mouseup, mousewheel, rightclick, viewchange, viewchangeend, viewchangestart - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: Map, eventName: string, handler: (eventArg?: IMouseEventArgs | IMapTypeChangeEventArgs) => void, throttleInterval: number): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * changed, click, dblclick, drag, dragend, dragstart, mousedown, mouseout, mouseover, mouseup - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: Pushpin, eventName: string, handler: (eventArg?: IMouseEventArgs | IPrimitiveChangedEventArgs) => void, throttleInterval: number): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * changed, click, dblclick, mousedown, mouseout, mouseover, mouseup - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: Polyline | Polygon, eventName: string, handler: (eventArg?: IMouseEventArgs | IPrimitiveChangedEventArgs) => void, throttleInterval: number): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * click, infoboxChanged, mouseenter, mouseleave - * @param handler The callback function to handle the event when triggered. - * @returns The handler id. - */ - export function addThrottledHandler(target: Infobox, eventName: string, handler: (eventArg?: IInfoboxEventArgs) => void): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * click, dblclick, mousedown, mouseout, mouseover, mouseup, rightclick - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: Layer, eventName: string, handler: (eventArg?: IMouseEventArgs) => void, throttleInterval: number): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. Supported Events: - * � entityadded - * � entityremoved - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: EntityCollection, eventName: string, handler: (eventArg?: IEntityCollectionChangedEventArgs) => void, throttleInterval: number): IHandlerId; - - /** - * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. - * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. - * @param eventName The type of event to attach. - * @param handler The callback function to handle the event when triggered. - * @param throttleInterval throttle interval (in ms) - * @returns The handler id. - */ - export function addThrottledHandler(target: any, eventName: string, handler: (eventArg?: any) => void, throttleInterval: number): IHandlerId; - - ///////////////////////////////////// - /// All other definitions - //////////////////////////////////// - - /** - * Checks if the target has any attached event handler. - * @param target The object to check if an event is attached to it. - * @param eventName The name of the event to check to see is attached. - * @returns A boolean indicating if the specified event type is attached to the object. - */ - export function hasHandler(target: any, eventName: string): boolean; - - /** - * Invokes an event on the target. This causes all handlers for the specified event name to be called. - * @param target The object to invoke the event on. - * @param eventName The name of the event to invoke. - * @param args Arguments for the event handler. - */ - export function invoke(target: any, evenName: string, args: any): void; - - /** - * Detaches the specified handler from the event. The handlerId is returned by the addHandler and addThrottledHandler methods. - * @param handlerId The handler id of the event to remove. - */ - export function removeHandler(handlerId: IHandlerId): void; - } - - /** - * Standard compass headings; north, south, east, west. - */ - export class Heading { - /** A heading pointing north, 0 degrees. */ - static North: number; - - /** A heading pointing south, 180 degrees. */ - static South: number; - - /** A heading pointing east, 90 degrees. */ - static East: number; - - /** A heading pointing west, 270 degrees. */ - static West: number; - } - - /** - * An infobox, also sometimes refer to as an info window or popup, is a simple panel that displays information over top the map. This is - * often used to display information linked to a location after clicking on a pushpin. - */ - export class Infobox { - - /** - * @constructor - * @param location The location to display the infobox at. - * @param options Options for rendering the infobox. - */ - constructor(location: Location, options?: IInfoboxOptions); - - /** - * @deprecated Use HTML buttons and links in description instead. - */ - public getActions(): IInfoboxActions[]; - - /** - * Gets the point on the infobox which is anchored to the map. An anchor of (0,0) is the top left corner of the infobox. - * @returns The anchor point of the infobox. - */ - public getAnchor(): Point; - - /** - * Gets the string that is printed inside the infobox. - * @returns The description value of the infobox options. - */ - public getDescription(): string; - - /** - * Gets the height of the infobox. - * @returns The height of the infobox. - */ - public getHeight(): number; - - /** - * Gets the infobox as HTML. - * @returns The HTML string used to create a custom infobox. - */ - public getHtmlContent(): string; - - /** - * Gets the location on the map where the infobox�s anchor is attached. - * @returns The location of the infobox. - */ - public getLocation(): Location; - - /** - * Gets the maximium height setting for the infobox. - * @returns the maximium height setting for the infobox. - */ - public getMaxHeight(): number; - - /** - * Gets the maximium width setting for the infobox. - * @returns the maximium width setting for the infobox. - */ - public getMaxWidth(): number; - - /** - * Gets the amount the infobox pointer is shifted from the location of the infobox, or if showPointer is false, then it is the amount the infobox - * bottom left edge is shifted from the location of the infobox. The default value is (0,0), which means there is no offset. - * @returns The offset of the infobox. - */ - public getOffset(): Point; - - /** - * Gets the infobox options. - * @returns The infobox options currently used by the infobox. - */ - public getOptions(): IInfoboxOptions; - - /** - * Gets a boolean indicating whether the infobox close button is shown. - * @returns A boolean indicating if the close button is shown or not. - */ - public getShowCloseButton(): boolean; - - /** - * Gets a boolean indicating whether the infobox is drawn with a pointer. - * @returns A boolean indicating if the pointer of the infobox is shown or not. - */ - public getShowPointer(): boolean; - - /** - * Gets a string that is the title of the infobox. - * @returns The title property of the infobox. - */ - public getTitle(): string; - - /** - * Gets whether the infobox is visible. A value of false indicates that the infobox is hidden, although it is still an entity on the map. - * @returns A boolean indicating if the infobox is visible or not. - */ - public getVisible(): boolean; - - /** - * Gets the width of the infobox. - * @returns The width of the infobox. - */ - public getWidth(): number; - - /** - * Gets the z-index of the infobox. - * @returns The z-index of the infobox. - */ - public getZIndex(): number; - - /** - * Sets the HTML content of the infobox. You can use this method to change the look of the infobox. Note that infobox options are ignored if - * custom HTML is set. Also, when custom HTML is used to represent the infobox, the infobox is anchored at the bottom-left corner. - * @param content The HTML string to use to generate the infobox. - */ - public setHtmlContent(content: string): void; - - /** - * Sets the location on the map where the anchor of the infobox is attached. - * @param loc The location to display the infobox at. - */ - public setLocation(loc: Location): void; - - /** - * Adds the infobox to the map. To remove an Infobox from the map, simply pass null into this function. - * @param map A map instance to display the infoboox on, or null if removing infobox from map. - */ - public setMap(map: Map): void; - - /** - * Sets options for the infobox. - * @param options The options to assign to the infobox. - */ - public setOptions(options: IInfoboxOptions): void; - } - - /** - * The Layer class makes it easy to organize groups of data by storing them in separate layers on the map. Grouping your data into layers - * provides a number of benefits such as the ability to hide or attach events to all IPrimitive shapes in a layer with a single line of code, - * while also providing providing a performance benefit over manually looping through each shape and performing these tasks. - */ - export class Layer implements IDataLayer { - - /** Optional property to store any additional metadata for this layer. */ - public metadata: any; - - /** - * @constructor - * @param id Unique string identifier for the layer. - */ - constructor(id?: string); - - /** - * Adds a shapes to the layer, at the specified index if specified. - * @param primitive The shape(s) to be added to the layer. - * @param index The index at which to insert the shape into the layer. - */ - public add(primitive: IPrimitive | IPrimitive[], index?: number): void; - - /** - * Clears all the data - */ - public clear(): void; - - /** - * Cleans up any resources this object is consuming - */ - public dispose(): void; - - /** - * Gets the id of the layer. - * @returns The id assigned to the layer. - */ - public getId(): string; - - /** - * Gets an array of shapes that are in the layer. This can be used to iterate over the individual shapes. - * @returns An array of shapes that are in the layer. - */ - public getPrimitives(): IPrimitive[]; - - /** - * Gets a value indicating whether the layer is visible or not. - * @returns A boolean indicating if the layer is visible or not. - */ - public getVisible(): boolean; - - /** - * Gets the zIndex of the layer. - * @returns The zIndex of the layer. - */ - public getZIndex(): number; - - /** - * Removes a primitive - * @param primitive primitive that needs to be removed - * @returns The primitive that needs to be removed - */ - public remove(primitive: IPrimitive): IPrimitive; - - /** - * Removes a primitive at a specified index - * @param index index of the primitive that needs to be removed - * @returns The primitive that needs to be removed at this index - */ - public removeAt(index: number): IPrimitive; - - /** - * Replaces all shapes in the layer with the new array of shapes that have been provided. - * @param primitives The array of shapes to add to the layer. - */ - public setPrimitives(primitives: IPrimitive[]): void; - - /** - * Sets whether the layer is visible or not. - * @param value A value indicating if the layer should be displayed or not. - */ - public setVisible(value: boolean): void; - - /** - * Sets the zIndex of the layer. - * @param zIndex The zIndex value to assign to the layer. - */ - public setZIndex(zIndex: number): void; - } - - /** - * The layers property of the map is a LayerCollection object and contains all the layers that have been added to the map. - * Note: This class is only exposed in the map.layers property. No other instance of this class can be created. - */ - export class LayerCollection extends Array { - /** The number of layers in the collection. */ - public length: number; - - /** - * Removes all layers from the map. - */ - public clear(): void; - - /** - * Gets the index of a layer in the collection. - * @param layer The layer to get the index of. - * @returns The index of the specified layer. - */ - public indexOf(layer: ILayer): number; - - /** - * Adds a layer to the map. - * @param layer The layer to insert into the collection. - */ - public insert(layer: ILayer): void; - - /** - * Adds an array of layers to the map. - * @param layers The layers to insert into the collection. - */ - public insertAll(layers: ILayer[]): void; - - /** - * Removes a layer from the map. - * @param layer The layer to remove from the collection. - */ - public remove(layer: ILayer): void; - - /** - * Removes a layer from the map at the specified index in the collection. - * @param idx The index of the layer to remove. - */ - public removeAt(idx: number): void; - } - - /** - * This class stores the coordinate information needed to mark locations on a map. The Location class consists of two properties: - * latitude and longitude. - */ - export class Location { - /** The location north or south of the equator from +90 to -90 */ - public latitude: number; - - /** The location east or west of the prime meridian +180 to -180 */ - public longitude: number; - - /** - * @constructor - * @param latitude The location north or south of the equator from +90 to -90 - * @param longitude The location east or west of the prime meridian +180 to -180 - */ - constructor(latitude: any, longitude: any); - - /** - * Determines if two locations are equal. - * @param location1 The first location to test. - * @param location2 The second location to test. - * @returns True if both locations are equivalent. - */ - static areEqual(location1: Location, location2: Location): boolean; - - /** - * Creates a deep copy of the map location. - * @returns A deep copy of the map location. - */ - public clone(): Location; - - /** - * Creates a proper Location from an object that has the same signature. - * @param source A Location or Location-like object that contains the same properties. - * @returns A copy of the map location. - */ - static cloneFrom(source: Location): Location; - - /** - * Normalizes the longitude by wrapping it around the earth. - * @param longitude The input longitude. - * @returns The longitude normalized to within -180 and +180. - */ - static normalizeLongitude(longitude: number): number; - - /** - * Parses a location string of the form "lat,long". - * @param str The location string. - * @returns The parsed location or null otherwise. - */ - static parseLatLong(str: string): Location; - - /** - * Converts the Location to a string representation. - * @returns A string representation of the location. - */ - public toString(): string; - } - - /** - * The LocationRect class, also known as a bounding box, consists of a set of coordinates that are used to represent rectangular area on the map. - */ - export class LocationRect { - /** The location that defines the center of the rectangle. */ - public center: Location; - - /** The height, in degrees, of the rectangle. */ - public height: number; - - /** The width, in degrees, of the rectangle. */ - public width: number; - - /** - * @constructor - * @param center The center of the LocationRect. - * @param width The width of the LocationRect in degrees. - * @param height The height of the LocationRect in degrees. - */ - constructor(center: Location, width: number, height: number); - - /** - * Gets a LocationRect using the specified locations for the northwest and southeast corners. - * @param northwest The north west corner of the LocationRect. - * @param southeast The south east corner of the LocationRect. - * @returns A LocationRect using the specified locations for the northwest and southeast corners. - */ - static fromCorners(northwest: Location, southeast: Location): LocationRect; - - /** - * Gets a LocationRect using the specified northern and southern latitudes and western and eastern longitudes for the rectangle boundaries. - * @param north The northern latitude of the LocationRect. - * @param west The western longitude of the LocationRect. - * @param south The southern latitude of the LocationRect. - * @param east The eastern longitude of the LocationRect. - * @returns A LocationRect defined by the specified northern and southern latitudes and western and eastern longitudes for the rectangle boundaries. - */ - static fromEdges(north: number, west: number, south: number, east: number): LocationRect; - - /** - * Gets a LocationRect using a list of locations. - * @param locations A list of locations. - * @returns A LocationRect that encloses all the specified locations. - */ - static fromLocations(...locations: Location[]): LocationRect; - - /** - * Gets a LocationRect using an array of locations. - * @param locations An array of locations. - * @returns A LocationRect that encloses all the specified locations. - */ - static fromLocations(locations: Location[]): LocationRect; - - /** - * Creates a LocationRect from a string with the following format: "north,west,south,east". North, west, south and east specify the coordinate number values. - * @param str A string that repsents a LocationRect with the format "north,west,south,east". - * @returns A LocationRect defined by the specified northern and southern latitudes and western and eastern longitudes for the rectangle boundaries that have been parsed by the string. - */ - static fromString(str: string): LocationRect; - - /** - * Gets a copy of the LocationRect object. - * @retruns A copy of the LocationRect object. - */ - public clone(): LocationRect; - - /** - * Gets whether the specified Location is within the LocationRect. - * @returns A boolean indicating if a location is within a LocationRect. - */ - public contains(location: Location): boolean; - - /** - * Determines if the LocationRect crosses the 180th meridian. - * @returns A boolean indicating if the LocationRect crosses the international date line (-180/180 degrees longitude). - */ - public crossesInternationalDateLine(): boolean; - - /** - * Gets the longitude that defines the eastern edge of the LocationRect. - * @returns The eastern longitude value of the LocationRect. - */ - public getEast(): number; - - /** - * Gets the latitude that defines the northern edge of the LocationRect. - * @returns The northern latitude value of the LocationRect. - */ - public getNorth(): number; - - /** - * Gets the Location that defines the northwest corner of the LocationRect. - * @returns The northwest corner location of the LocationRect. - */ - public getNorthwest(): Location; - - /** - * Gets the latitude that defines the southern edge of the LocationRect. - * @returns The southern latitude value of the LocationRect. - */ - public getSouth(): number; - - /** - * Gets the Location that defines the southeast corner of the LocationRect. - * @returns The southeast corner location of the LocationRect. - */ - public getSoutheast(): Location; - - /** - * Gets the latitude that defines the western edge of the LocationRect. - * @returns The western longitude value of the LocationRect. - */ - public getWest(): number; - - /** - * Gets whether the specified LocationRect intersects with this LocationRect. - * @param rect A second LocationRect to test for intersection with. - * @returns A boolean indicating if a second LocationRect interests with this LocationRect. - */ - public intersects(rect: LocationRect): boolean; - - /** - * Scales the size of a LocationRect by multiplying the width and height properties by a percentage. - * @param percentage A percentage value to increase the size of the LocationRect by. - */ - public inflate(percentage: number): void; - - /** - * If a LocationRect crosses the international date line, this method splits it into two LocationRect objects and returns them as an array. - * @returns An array of LocationRects, that are split by the international date line (-180/180 degrees longitude) - */ - public splitByInternationalDateLine(): LocationRect[]; - - /** - * Converts the LocationRect object to a string. - * @returns A string version of the LocationRect. - */ - public toString(): string; - } - - /** The map object generates an interactive map within a specified DOM element. */ - export class Map { - /** Entities of the map */ - public entities: EntityCollection; - - /** Set of map layers */ - public layers: LayerCollection; - - /** - * @constructor - * @param parentElement The parent element of the map as a CSS selector string or HTMLElement. - * @param options Options used when creating the map. - */ - constructor(parentElement: string | HTMLElement, options: IMapLoadOptions); - - /** - * Gets the streetside panorama information closest to the specified bounding box and returns using a success callback function. - * This information can then be used to set the map view to that streetside panorama. - */ - public static getClosestPanorama(bounds: LocationRect, success: (panoramaInfo: IPanoramaInfo) => void, missingCoverage: () => void): void; - - /** Returns the branch name; release, experimental, frozen. */ - public static getVersion(): string; - - - /** Deletes the Map object and releases any associated resources. */ - public dispose(): void; - - /** - * Gets the location rectangle that defines the boundaries of the current map view. - * @returns The location rectangle that defines the boundaries of the current map view. - */ - public getBounds(): LocationRect; - - /** - * Gets the location of the center of the current map view. - * @returns The location of the center of the current map view. - */ - public getCenter(): Location; - - /** - * Gets to the specified callback an array of strings representing the attributions of the imagery currently displayed on the map. - * @param callback The callback function that needs to be called after retrieving the copyright information. - */ - public getCopyrights(callback: (copyrights: string[]) => void): void; - - /** - * Gets the session ID. This method calls the callback function with the session ID as the first parameter - * @param callback The callback function that needs to be called with the session id. - */ - public getCredentials(callback: (creds: string) => void): void; - - /** - * Gets the current culture. - * @returns The current culture. - */ - public getCulture(): string; - - /** - * Gets the height of the map control. - * @returns The height of the map control. - */ - public getHeight(): number; - - /** - * Returns the heading of the current map view. - * @returns Returns the heading of the current map view. - */ - public getHeading(): number; - - /** - * Gets the string that represents the imagery currently displayed on the map. - * @returns The string that represents the imagery currently displayed on the map. - */ - public getImageryId(): string; - - /** - * Gets a string that represents the current map type displayed on the map. - * @returns A string that represents the current map type displayed on the map. - */ - public getMapTypeId(): MapTypeId; - - /** - * Gets the current scale in meters per pixel of the center of the map. - * @returns The current scale in meters per pixel of the center of the map. - */ - public getMetersPerPixel(): number; - - /** - * Gets the map options that have been set. - * @returns the map options that have been set. - */ - public getOptions(): IMapOptions; - - /** - * Gets the x coordinate of the top left corner of the map control, relative to the page. - * @returns The x coordinate of the top left corner of the map control, relative to the page. - */ - public getPageX(): number; - - /** - * Gets the y coordinate of the top left corner of the map control, relative to the page. - * @returns The y coordinate of the top left corner of the map control, relative to the page. - */ - public getPageY(): number; - - /** - * Returns the pitch of the current streetside map view. - * @returns Returns the pitch of the current streetside map view. - */ - public getPitch(): number; - - /** - * Gets the map root node. - * @returns the map root node. - */ - public getRootElement(): HTMLElement; - - /** - * Gets the user region. - * @returns The user region. - */ - public getUserRegion(): string; - - /** - * Gets the width of the map control. - * @returns the width of the map control. - */ - public getWidth(): number; - - /** - * Gets the zoom level of the current map view. - * @returns Returns the zoom level of the current map view. - */ - public getZoom(): number; - - /** - * Gets the range of valid zoom levels for the current map view. - * @returns The range of valid zoom levels for the current map view. - */ - public getZoomRange(): IRange; - - /** - * Gets a boolean indicating whether the map is in a regular Mercator nadir mode. - * @returns A boolean indicating whether the map is in a regular Mercator nadir mode. - */ - public isMercator(): boolean; - - /** - * Gets a boolean indicating if the current map type allows the heading to change; false if the display heading is fixed. - * @returns true if the current map type allows the heading to change; false if the display heading is fixed. - */ - public isRotationEnabled(): boolean; - - /** - * Sets the current map type. - * @param mapTypeId The map imagery type of the map to set. - */ - public setMapType(mapTypeId: MapTypeId): void; - - /** - * Sets the map options. - * @param options The map options to be set. - */ - public setOptions(options: IMapOptions): void; - - /** - * Sets the view of the map. - * @param viewOptions The view options to be set. - */ - public setView(viewOptions: IViewOptions): void; - - /** - * Converts a specified Location or a Location array to a Point or Point array on the map - * relative to the specified PixelReference. If no reference is specified, PixelReference.viewport - * is taken. - * @param location The given Location or Location[] to convert. - * @param reference The PixelReference to specify the reference point. - * @returns The converted Point or Point[], or null if the conversion fails. - */ - public tryLocationToPixel(location: Location | Location[], reference?: any): Point | Point[]; - - /** - * Converts a specified Point or a Point array to a Location or Location array on the map - * relative to the specified PixelReference. If no reference is specified, PixelReference.viewport - * is taken. - * @param point The given Point or Point[] to convert. - * @param reference The PixelReference to specify the reference point. - * @returns The converted Location or Location[], or null if the conversion fails. - */ - public tryPixelToLocation(point: Point | Point[], reference?: any): Location | Location[]; - } - - /** - * This class is used to represent a pixel coordinate or offset. This is often used by pushpin anchors, and map location to pixel conversion calculations. - */ - export class Point { - /** The x coordinate */ - public x: number; - - /** The y coordinate */ - public y: number; - - /** - * @constructor - * @param x The x coordinate. - * @param y The y coordinate. - */ - constructor(x: number, y: number); - - /** - * Adds the x and y values of two points and returns a new Point. - * @param point The point to add. - * @returns A new point created by the sum of two points. - */ - public add(point: Point): Point; - - /** - * Creates a copy of the current point. - * @returns A new instance of the current point. - */ - public clone(): Point; - - /** - * Compares the x and y values of two points to see if they are equal. If a tolerance value is specified, it checks to see if the linear distance between the points is less than or equal to the tolerance value. - * @param point The point to compare to. - * @param tolerance Optional, tolerance (>= 0) to avoid false result because of floating point errors. - * @returns true if this point equals point, false otherwise - */ - public equals(point: Point, tolerance?: number): boolean; - - /** - * Subtracts the x and y values of a points and returns a new Point. - * @param point The point to subtract. - * @returns A new point created by the subtraction of two points. - */ - public subtract(point: Point): Point; - - /** - * Converts the Point to a string representation. - * @returns A string representation of the point. - */ - public toString(): string; - } - - /** - * This compression algorithm encodes/decodes an array of locations into a string. - * This algorithm is used for generating a compressed collection of locations for use - * with the Bing Maps REST Elevation Service. This algorithm is also used for decoding - * the compressed coordinates returned by the GeoData API. - * - * These algorithms come from the following documentation: - * http://msdn.microsoft.com/en-us/library/jj158958.aspx - * http://msdn.microsoft.com/en-us/library/dn306801.aspx - */ - export class PointCompression { - /** - * Decodes a collection of locations from a compressed string. - * @param value Compressed string to decode. - * @returns An array of locations that have been decoded from the compressed string. - */ - public static decode(value: string): Location[]; - - /** - * Compresses an array of locations into a string. - * @param locations Collection of coordinates to compress. - * @returns A compressed string representing an array of locations. - */ - public static encode(locations: Location[]): string; - } - - /** - * A polygon is an area defined by a closed ring of locations. A simple polygon consists of an array of Location objects that form a boundary. - * A complex polygon consists of several arrays of Locations, where the first array is the outline of the polygon, and the subsequent arrays are holes in the polygon. - * The Polygon class derives from the IPrimitive interface. - */ - export class Polygon implements IPrimitive { - /** - * Information that is linked to the polygon. - * Some modules such as the GeoJSON, and Spatial Data Service modules will also often add information to this property. - */ - public metadata: any; - - /** - * @constructor - * @param rings A Location array for basic polygon with single outer perimeter, - * or an array of Location arrays for advanced polygon (multi-polygon, polygon with holes, or combination of polygons). - * @param options Options used to customize polygon. - */ - constructor(rings: Location[] | Location[][], options?: IPolygonOptions); - - /** - * Gets the css cursor value when polygon has events on it. - * @returns CSS cursor string when polygon has events on it. - */ - public getCursor(): string; - - /** - * Gets the fill color of the inside of the polygon. Will be string or Color object depending on the the what method was used in the pushpin options. - * @returns The fill color of the inside of the polygon. - */ - public getFillColor(): string | Color; - - /** - * Returns whether the polygon is generalizable based on zoom level or not. - * @returns whether the polygon is generalizable based on zoom level or not. - */ - public getGeneralizable(): boolean; - - /** - * Gets the first ring of the polygon (for V7 compatability). - * @returns An array of Locations that is the first ring of the polygon; or an empty array if the polygon has no ring at all. - */ - public getLocations(): Location[]; - - /** - * Gets an array of location arrays, where each location array defines a ring of the polygon. - * @returns An array of location arrays, where each location array defines a ring of the polygon. - */ - public getRings(): Location[][]; - - /** - * Gets the color of the border stroke of the polygon. Will be string or Color object depending on the the what method was used in the pushpin options. - * @returns The color of the border stroke of the polygon. - */ - public getStrokeColor(): string | Color; - - /** - * Gets the stroke dash array of the polygon, in format of either array or string, whichever user provides. - * @returns The stroke dash array of the polygon. - */ - public getStrokeDashArray(): number[] | string; - - /** - * Gets the thickness of the border stroke of the polygon. - * @returns The thickness of the border stroke of the polygon as a number. - */ - public getStrokeThickness(): number; - - /** - * Gets whether the polygon is visible. - * @returns A boolean indicating whether the polygon is visible or not. - */ - public getVisible(): boolean; - - /** - * Sets locations (single ring) of the polygon. (for V7 compatability) - * @param locations A Location[] that defines the only ring of the polygon - */ - public setLocations(locations: Location[]): void; - - /** - * Sets the properties for the polygon. - * @param options The IPolygonOptions object containing the options to customize the polygon. - */ - public setOptions(options: IPolygonOptions): void; - - /** - * Sets rings of the polygon. - * @param rings A Location[][] where each Location[] defines a ring of the polygon. - */ - public setRings(rings: Location[] | Location[][]): void; - } - - /** - * Polylines allow you to draw connected lines on a map. In many spatial database systems, this is also known as a LineString. - * The Polyline class derives from the IPrimitive interface. - */ - export class Polyline implements IPrimitive { - /** - * Information that is linked to the polyline. - * Some modules such as the GeoJSON, and Spatial Data Service modules will also often add information to this property. - */ - public metadata: any; - - /** - * @constructor - * @param locations An array of locations that make up the path of the polyine. - * @param options Options used to customize polyline. - */ - constructor(locations: Location[], options?: IPolylineOptions); - - /** - * Gets the css cursor value when polyline has events on it. - * @returns CSS cursor string when polyline has events on it. - */ - public getCursor(): string; - - /** - * Returns whether the polyline is generalizable based on zoom level or not. - * @returns whether the polyline is generalizable based on zoom level or not. - */ - public getGeneralizable(): boolean; - - /** - * Gets the locations that make up the polyline. - * @returns An array that defines the path of the polyline. - */ - public getLocations(): Location[]; - - /** - * Gets the color of the border stroke of the polyline. Will be string or Color object depending on the the what method was used in the polyline options. - * @returns The stroke color of the polyline. - */ - public getStrokeColor(): string | Color; - - /** - * Gets the stroke dash array of the polyline, in format of either array or string, whichever user provides. - * @returns The stroke dash array of the polyline. - */ - public getStrokeDashArray(): number[] | string; - - /** - * Gets the thickness of the border stroke of the polyline. - * @returns The thickness of the border stroke of the polyline as a number. - */ - public getStrokeThickness(): number; - - /** - * Gets whether the polyline is visible. - * @returns A boolean indicating whether the polyline is visible or not. - */ - public getVisible(): boolean; - - /** - * Sets locations of the polyline. - * @param locations A Location[] that defines path of the polyline - */ - public setLocations(locations: Location[]): void; - - /** - * Sets the properties for the polyline. - * @param options The IPolylineOptions object containing the options to customize the polyline. - */ - public setOptions(options: IPolylineOptions): void; - } - - /** - * Pushpins, sometimes also referred to as markers or MapIcons on other mapping platforms, are one of the primary ways of marking a location on a map. - * The Pushpin class derives from the IPrimitive interface. - */ - export class Pushpin implements IPrimitive { - - /** - * Information that is linked to the pushpin. - * Some modules such as the GeoJSON, and Spatial Data Service modules will also often add information to this property. - */ - public metadata: any; - - /** - * @constructor - * @param location A Location object that specifies where to display the pushpin. - * @param options Options used when creating the Pushpin. - */ - constructor(location: Location, options?: IPushpinOptions); - - /** - * Gets the point on the Pushpin icon which is anchored to the pushpin location. - * An anchor of (0,0) is the top left corner of the icon. - * @returns The point on the Pushpin icon which is anchored to the pushpin location. - */ - public getAnchor(): Point; - - /** - * Gets whether the pushpin clicked style is enabled - * @returns Whether the pushpin clicked style is enabled. - */ - public getClickedStyleEnabled(): boolean; - - /** - * Gets the color option of the pushpin. - * @returns The color option of the pushpin. - */ - public getColor(): string | Color; - - /** - * Gets the css cursor value when pushpin has events on it. - * @returns CSS cursor string when pushpin has events on it. - */ - public getCursor(): string; - - /** - * Gets a boolean indicating if the pushpin is draggable or not. - * @returns A boolean indicating if the pushpin is draggable or not. - */ - public getDraggable(): boolean; - - /** - * Gets whether the pushpin hover style is enabled - * @returns Whether the pushpin hover style is enabled. - */ - public getHoverStyleEnabled(): boolean; - - /** - * Gets the custom Pushpin source icon string which can be a url to an image or SVG, inline SVG string, or data URI. - * @returns the custom Pushpin icon source string, which can be a url to an image or SVG, inline SVG string, or data URI. - */ - public getIcon(): string; - - /** - * Returns the location of the pushpin. - * @returns The location of the pushpin. - */ - public getLocation(): Location; - - /** - * Returns whether the clickable area of the pushpin is an ellipse. - * @returns A boolean indicating whether the clickable area of the pushpin is an ellipse. - */ - public getRoundClickableArea(): boolean; - - /** - * Gets the subtitle label of the Pushpin. - * @returns The subtitle label of the Pushpin. - */ - public getSubTitle(): string; - - /** - * Gets the text within the Pushpin icon. - * @returns The text within the Pushpin icon. - */ - public getText(): string; - - /** - * Gets the amount the text is shifted from the Pushpin icon. - * @returns the amount the text is shifted from the Pushpin icon. - */ - public getTextOffset(): Point; - - /** - * Gets the title label of the Pushpin. - * @returns the title label of the Pushpin. - */ - public getTitle(): string; - - /** - * Gets whether the pushpin is visible. - * @returns A boolean indicating whether the pushpin is visible or not. - */ - public getVisible(): boolean; - - /** - * Sets the location of the Pushpin. - * @param location The location of the Pushpin. - */ - public setLocation(location: Location): void; - - /** - * Sets the properties for the pushpin. - * @param options The IPushpinOptions object containing the options to customize the pushpin. - */ - public setOptions(options: IPushpinOptions): void; - } - - /** - * Used to represent the location of a map tile in the quadkey tile pyramid system used by the map. - * If using a tile source where the uriConstructor property is set to a callback function, that callback function will recieve - * an instance of the PyramidTileId class. - */ - export class PyramidTileId { - /** The height of the tile. */ - public pixelHeight: number; - - /** The width of the tile. */ - public pixelWidth: number; - - /** The quadkey ID of the tile. */ - public quadKey: string; - - /** The x tile coordinate. */ - public x: number; - - /** The y tile coordinate. */ - public y: number; - - /** The zoom level of the tile. */ - public zoom: number; - - /** - * @constructor - * @param x The integer x position of the tile within the tile layer at the specified zoom level. - * @param y The integer y position of the tile within the tile layer at the specified zoom level. - * @param zoom The zoom level of the tile. - * @param width The tile's width in pixels. Default value: 256 - * @param height The tile's height in pixels. Default value: 256 - */ - constructor(x: number, y: number, zoom: number, width?: number, height?: number) - - /** - * Compares two PyramidTileId objects and returns a boolean indicating if the two PyramidTileId are equal. - * @param tileId1 The first PyramidTileId to compare to the second. - * @param tileId2 The second PyramidTileId to compare to the first. - * @returns A boolean indicating if the two PyramidTileId are equal. - */ - public static areEqual(tileId1: PyramidTileId, tileId2: PyramidTileId): boolean; - - /** - * Generates a PyramidTileId from a quadkey tile id string. - * @param quadkey The quadkey tile id string to convert into a PyramidTileId object. - * @param width The tile's width in pixels. Default value: 256 - * @param height The tile's height in pixels. Default value: 256 - */ - public static fromQuadKey(quadkey: string, width?: number, height?: number): PyramidTileId; - } - - /** Provides static functions for generating random test data. */ - export class TestDataGenerator { - /** - * Generates a random hex or rgba color string. - * @param withAlpha A boolean indicating if the color should have an alpha value or not. if set to true, a rgba value will be returned with an alpha value of 0.5. - * @returns A css color string, hex or rgba. - */ - public static getColor(withAlpha?: boolean): string; - - /** - * Generates random Location objects. - * @param num The number of locations to generate. If set to one a single Location will be returned. If greater than one and array will be returned. - * @param bounds The bounding box in which all the locations should fall within. - * @returns One or more random Locations. - */ - public static getLocations(num?: number, bounds?: LocationRect): Location | Location[]; - - /** - * Generates random pushpins. - * @param num The number of pushpins to generate. If set to one a single Pushpin will be returned. If greater than one and array will be returned. - * @param bounds The bounding box in which all the pushpins should fall within. - * @param options The options to use for rendering the pushpins. Default is random. - * @returns One or more random Pushpins. - */ - public static getPushpins(num?: number, bounds?: LocationRect, options?: IPushpinOptions): Pushpin | Pushpin[]; - - /** - * Generates random polylines. - * @param num The number of polylines to generate. If set to one a single Polyline will be returned. If greater than one and array will be returned. - * @param bounds The bounding box in which all the locations of the polylines should fall within. - * @param size The number of locations each polylines should have. Default: random between 3 and 10. - * @param scaleFactor A number that scales the size of the polylines based on size of the bounding box. A value of 0.1 would generate polylines that are no larger than 10% of the width/height of the map. Default: 0.1 - * @param options The options to use for rendering the polylines. Default is random. - * @returns One or more random Polylines. - */ - public static getPolylines(num?: number, bounds?: LocationRect, size?: number, scaleFactor?: number, options?: IPolylineOptions): Polyline | Polyline[]; - - /** - * Generates random polygons. - * @param num The number of polygons to generate. If set to one a single Polygon will be returned. If greater than one and array will be returned. - * @param bounds The bounding box in which all the locations of the polygon should fall within. - * @param size The number of locations each polygon should have. Default: random between 3 and 10. - * @param scaleFactor A number that scales the size of the polygons based on the size of the bounding box. A value of 0.1 would generate polygons that are no larger than 10% of the width/height of the map. Default: 0.1 - * @param options The options to use for rendering the polygons. Default is random. - * @param addHole A boolean indicating if the generated polygon should have a hole or not. Note that this will double the number of Location objects that are in the Polygon. Default: false - * @returns One or more random polygons. - */ - public static getPolygons(num?: number, bounds?: LocationRect, size?: number, scaleFactor?: number, options?: IPolygonOptions, addHole?: boolean): Polygon | Polygon[]; - } - - /** Represents a tile layer that can be overlaid on top of the map. */ - export class TileLayer implements ILayer { - /** - * @constructor - * @param options The options to use to define the tile layer. - */ - constructor(options: ITileLayerOptions); - - /** - * Gets the opacity of the tile layer, defined as a double between 0 (not visible) and 1. - * @returns The opacity of the tile layer, defined as a double between 0 (not visible) and 1. - */ - public getOpacity(): number; - - /** - * Gets the tile source of the tile layer. - * @returns The tile source of the tile layer. - */ - public getTileSource(): TileSource; - - /** - * Gets a boolean that indicates if the tile layer is visible or not. - * @returns A boolean that indicates if the tile layer is visible or not. - */ - public getVisible(): boolean; - - /** - * Gets the zIndex of the tile layer. - * @returns The zIndex of the tile layer. - */ - public getZIndex(): number; - - /** - * Sets the opacity of the tile layer. Value must be a number between 0 and 1. - * @param opacity The opacity of the tile layer. Value must be a number between 0 and 1. - */ - public setOpacity(opacity: number): void; - - /** - * Sets options for the tile layer. - * @param options The options for the tile layer. - */ - public setOptions(options: ITileLayerOptions): void; - - /** - * Sets the visibility of the tile layer. - * @param show A boolean indicating if the tile layer should be visible or not. - */ - public setVisible(show: boolean): void; - - /** - * Sets the zIndex of the tile layer. - * @param idx The zIndex of the tile layer. - */ - public setZIndex(idx: number): void; - } - - /** Defines the data source for a tile layer. */ - export class TileSource { - /** - * @constructor - * @param options The options to use to define the tile source. - */ - constructor(options: ITileSourceOptions); - - /** - * Gets the specified bounding box of the of the tile source. - * @returns The specified bounding box of the of the tile source. - */ - public getBounds(): LocationRect; - - /** - * Gets the pixel height of each tile in the tile source. - * @returns The pixel height of each tile in the tile source. - */ - public getHeight(): number; - - /** - * Gets the maximum zoom level specified for the tile source. - * @returns The maximum zoom level specified for the tile source. - */ - public getMaxZoom(): number; - - /** - * Gets the minimum zoom level specified for the tile source. - * @returns The minimum zoom level specified for the tile source. - */ - public getMinZoom(): number; - - /** - * Gets a string that constructs tile URLs used to retrieve tiles for the tile layer. - * @returns A string that constructs tile URLs used to retrieve tiles for the tile layer. - */ - public getUriConstructor(): string | ((tile: PyramidTileId) => string); - - /** - * Gets the pixel width of each tile in the tile source. - * @returns The pixel width of each tile in the tile source. - */ - public getWidth(): number; - } -} diff --git a/types/bitcoinjs-lib/index.d.ts b/types/bitcoinjs-lib/index.d.ts index c7d1acc899..11d311a276 100644 --- a/types/bitcoinjs-lib/index.d.ts +++ b/types/bitcoinjs-lib/index.d.ts @@ -85,7 +85,7 @@ export class ECPair { static fromPublicKeyBuffer(buffer: Buffer, network: Network): ECPair; - static fromWIF(string: string, network: Network): ECPair; + static fromWIF(string: string, network?: Network): ECPair; static makeRandom(options?: { compressed?: boolean, network?: Network, rng?: Rng }): ECPair; } diff --git a/types/boom/boom-tests.ts b/types/boom/boom-tests.ts index 4d133b2545..5ffd808de4 100644 --- a/types/boom/boom-tests.ts +++ b/types/boom/boom-tests.ts @@ -1,10 +1,10 @@ -import Boom = require('boom'); +import * as Boom from 'boom'; // 4xx and data type const badRequestError = Boom.badRequest('message', {some: 'data'}); badRequestError.data.some; -const badRequestError2: Boom.Boom = Boom.badImplementation('message'); +const badRequestError2: Boom = Boom.badImplementation('message'); const unauthorizedError1 = Boom.unauthorized('message', 'scheme', {some: 'attribute'}); unauthorizedError1.output.payload.attributes === { some: 'attribute', error: 'message' }; @@ -24,127 +24,131 @@ unauthorizedError4.output.headers === { 'WWW-Authenticate': 'scheme some="attrib const paymentRequiredError = Boom.paymentRequired('message', {some: 'data'}); paymentRequiredError.data.some; -const paymentRequiredError2: Boom.Boom = Boom.paymentRequired('message'); +const paymentRequiredError2: Boom = Boom.paymentRequired('message'); const forbiddenError = Boom.forbidden('message', {some: 'data'}); forbiddenError.data.some; -const forbiddenError2: Boom.Boom = Boom.forbidden('message'); +const forbiddenError2: Boom = Boom.forbidden('message'); const notFoundError = Boom.notFound('message', {some: 'data'}); notFoundError.data.some; -const notFoundError2: Boom.Boom = Boom.notFound('message'); +const notFoundError2: Boom = Boom.notFound('message'); const methodNotAllowedError = Boom.methodNotAllowed('message', {some: 'data'}); methodNotAllowedError.data.some; -const methodNotAllowedError2: Boom.Boom = Boom.methodNotAllowed('message'); +const methodNotAllowedError2: Boom = Boom.methodNotAllowed('message'); const notAcceptableError = Boom.notAcceptable('message', {some: 'data'}); notAcceptableError.data.some; -const notAcceptableError2: Boom.Boom = Boom.notAcceptable('message'); +const notAcceptableError2: Boom = Boom.notAcceptable('message'); const proxyAuthRequiredError = Boom.proxyAuthRequired('message', {some: 'data'}); proxyAuthRequiredError.data.some; -const proxyAuthRequiredError2: Boom.Boom = Boom.proxyAuthRequired('message'); +const proxyAuthRequiredError2: Boom = Boom.proxyAuthRequired('message'); const clientTimeoutError = Boom.clientTimeout('message', {some: 'data'}); clientTimeoutError.data.some; -const clientTimeoutError2: Boom.Boom = Boom.clientTimeout('message'); +const clientTimeoutError2: Boom = Boom.clientTimeout('message'); const conflictError = Boom.conflict('message', {some: 'data'}); conflictError.data.some; const resourceGoneError = Boom.resourceGone('message', {some: 'data'}); resourceGoneError.data.some; -const resourceGoneError2: Boom.Boom = Boom.resourceGone('message'); +const resourceGoneError2: Boom = Boom.resourceGone('message'); const lengthRequiredError = Boom.lengthRequired('message', {some: 'data'}); lengthRequiredError.data.some; -const lengthRequiredError2: Boom.Boom = Boom.lengthRequired('message'); +const lengthRequiredError2: Boom = Boom.lengthRequired('message'); const preconditionFailedError = Boom.preconditionFailed('message', {some: 'data'}); preconditionFailedError.data.some; -const preconditionFailedError2: Boom.Boom = Boom.preconditionFailed('message'); +const preconditionFailedError2: Boom = Boom.preconditionFailed('message'); const entityTooLargeError = Boom.entityTooLarge('message', {some: 'data'}); entityTooLargeError.data.some; -const entityTooLargeError2: Boom.Boom = Boom.lengthRequired('message'); +const entityTooLargeError2: Boom = Boom.lengthRequired('message'); const uriTooLongError = Boom.uriTooLong('message', {some: 'data'}); uriTooLongError.data.some; -const uriTooLongError2: Boom.Boom = Boom.uriTooLong('message'); +const uriTooLongError2: Boom = Boom.uriTooLong('message'); const unsupportedMediaTypeError = Boom.unsupportedMediaType('message', {some: 'data'}); unsupportedMediaTypeError.data.some; -const unsupportedMediaTypeError2: Boom.Boom = Boom.unsupportedMediaType('message'); +const unsupportedMediaTypeError2: Boom = Boom.unsupportedMediaType('message'); const rangeNotSatisfiableError = Boom.rangeNotSatisfiable('message', {some: 'data'}); rangeNotSatisfiableError.data.some; -const rangeNotSatisfiableError2: Boom.Boom = Boom.rangeNotSatisfiable('message'); +const rangeNotSatisfiableError2: Boom = Boom.rangeNotSatisfiable('message'); const expectationFailedError = Boom.expectationFailed('message', {some: 'data'}); expectationFailedError.data.some; -const expectationFailedError2: Boom.Boom = Boom.expectationFailed('message'); +const expectationFailedError2: Boom = Boom.expectationFailed('message'); const teapotError = Boom.teapot('message', {some: 'data'}); teapotError.data.some; -const teapotError2: Boom.Boom = Boom.teapot('message'); +const teapotError2: Boom = Boom.teapot('message'); const badDataError = Boom.badData('message', {some: 'data'}); badDataError.data.some; -const badDataError2: Boom.Boom = Boom.badData('message'); +const badDataError2: Boom = Boom.badData('message'); const lockedError = Boom.locked('message', {some: 'data'}); lockedError.data.some; -const lockedError2: Boom.Boom = Boom.locked('message'); +const lockedError2: Boom = Boom.locked('message'); + +const failedDependencyError = Boom.failedDependency('message', {some: 'data'}); +failedDependencyError.data.some; +const failedDependencyError2: Boom = Boom.failedDependency('message'); const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'}); preconditionRequiredError.data.some; -const preconditionRequiredError2: Boom.Boom = Boom.preconditionRequired('message'); +const preconditionRequiredError2: Boom = Boom.preconditionRequired('message'); const tooManyRequestsError = Boom.tooManyRequests('message', {some: 'data'}); tooManyRequestsError.data.some; -const tooManyRequestsError2: Boom.Boom = Boom.tooManyRequests('message'); +const tooManyRequestsError2: Boom = Boom.tooManyRequests('message'); const illegalError = Boom.illegal('message', {some: 'data'}); illegalError.data.some; -const illegalError2: Boom.Boom = Boom.illegal('message'); +const illegalError2: Boom = Boom.illegal('message'); // 5xx and data type const badImplementationError = Boom.badImplementation('message', {some: 'data'}); badImplementationError.data.some; -const badImplementationError2: Boom.Boom = Boom.badImplementation('message'); +const badImplementationError2: Boom = Boom.badImplementation('message'); const internalError = Boom.internal('message', {some: 'data'}); internalError.data.some; -const internalError2: Boom.Boom = Boom.internal('message'); +const internalError2: Boom = Boom.internal('message'); const notImplementedError = Boom.notImplemented('message', {some: 'data'}); notImplementedError.data.some; -const notImplementedError2: Boom.Boom = Boom.notImplemented('message'); +const notImplementedError2: Boom = Boom.notImplemented('message'); const badGatewayError = Boom.badGateway('message', {some: 'data'}); badGatewayError.data.some; -const badGatewayError2: Boom.Boom = Boom.badGateway('message'); +const badGatewayError2: Boom = Boom.badGateway('message'); const serverUnavailableError = Boom.serverUnavailable('message', {some: 'data'}); serverUnavailableError.data.some; -const serverUnavailableError2: Boom.Boom = Boom.serverUnavailable('message'); +const serverUnavailableError2: Boom = Boom.serverUnavailable('message'); const gatewayTimeoutError = Boom.gatewayTimeout('message', {some: 'data'}); gatewayTimeoutError.data.some; -const gatewayTimeoutError2: Boom.Boom = Boom.gatewayTimeout('message'); +const gatewayTimeoutError2: Boom = Boom.gatewayTimeout('message'); // boomify const boomifiedError = Boom.boomify(new Error('test'), { statusCode: 400, message: 'some message' }); // isBoom -const isBoomError = new Boom.Boom('test') +const isBoomError = new Boom('test') Boom.isBoom(isBoomError); -const maybeBoom = new Boom.Boom('test'); +const maybeBoom = new Boom('test'); if(Boom.isBoom(maybeBoom)) { // isBoom is a type guard that allows accessing these properties: maybeBoom.output.headers; @@ -152,7 +156,7 @@ if(Boom.isBoom(maybeBoom)) { // constructor -const constructorError: Boom.Boom = new Boom.Boom('test'); +const constructorError: Boom = new Boom('test'); constructorError.message; @@ -180,11 +184,11 @@ interface CustomPayload extends Boom.Payload { * Test assignment of custom error data: */ const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1', isCustom: true } as CustomData1); -const errorWithNoExplicitDataType: Boom.Boom = errorWithData; // can assign to error without explicit data type -const errorWithExplicitType: Boom.Boom = errorWithData; // can assign to union data type -const errorWithConcreteCustomData: Boom.Boom = errorWithData; // can assign to concrete data type +const errorWithNoExplicitDataType: Boom = errorWithData; // can assign to error without explicit data type +const errorWithExplicitType: Boom = errorWithData; // can assign to union data type +const errorWithConcreteCustomData: Boom = errorWithData; // can assign to concrete data type // assignment to CustomData2 would not be possible -// const errorWithConcreteCustomData2: Boom.Boom = errorWithData; +// const errorWithConcreteCustomData2: Boom = errorWithData; // Some complex error data types for testing purposes: interface CustomDataBase { diff --git a/types/boom/index.d.ts b/types/boom/index.d.ts index ed48f181cf..b38dafe038 100644 --- a/types/boom/index.d.ts +++ b/types/boom/index.d.ts @@ -1,23 +1,22 @@ -// Type definitions for boom 7.1.1 +// Type definitions for boom 7.2.0 // Project: https://github.com/hapijs/boom // Definitions by: Igor Rogatty // AJP // Jinesh Shah // Timon van Spronsen +// Daniel Machado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -export = Boom; - -declare namespace Boom { - - /** + export = Boom; +/** * boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: * @see {@link https://github.com/hapijs/boom#boom} */ - export class Boom extends Error { +declare class Boom extends Error { + /** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */ - constructor(message?: string | Error, options?: Options); + constructor(message?: string | Error, options?: Boom.Options); /** isBoom - if true, indicates this is a Boom object instance. */ isBoom: boolean; /** isServer - convenience bool indicating status code >= 500. */ @@ -25,7 +24,7 @@ declare namespace Boom { /** message - the error message. */ message: string; /** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */ - output: Output; + output: Boom.Output; /** reformat() - rebuilds error.output using the other object properties. */ reformat: () => string; /** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */ @@ -33,7 +32,7 @@ declare namespace Boom { /** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */ data: Data; } - +declare namespace Boom { interface Options { /** statusCode - the HTTP status code. Defaults to 500 if no status code is already set. */ statusCode?: number; @@ -49,7 +48,7 @@ declare namespace Boom { override?: boolean; } - export interface Output { + interface Output { /** statusCode - the HTTP status code (typically 4xx or 5xx). */ statusCode: number; /** headers - an object containing any HTTP headers where each key is a header name and value is the header content. (Limited value type to string https://github.com/hapijs/boom/issues/151 ) */ @@ -58,7 +57,7 @@ declare namespace Boom { payload: Payload; } - export interface Payload { + interface Payload { /** statusCode - the HTTP status code, derived from error.output.statusCode. */ statusCode: number; /** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */ @@ -80,13 +79,13 @@ declare namespace Boom { * @param options optional additional options * @see {@link https://github.com/hapijs/boom#boomifyerror-options} */ - export function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom; + function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom; /** * Identifies whether an error is a Boom object. Same as calling instanceof Boom. * @param error the error object to identify. */ - export function isBoom(error: Error): error is Boom + function isBoom(error: Error): error is Boom // 4xx /** @@ -95,7 +94,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data} */ - export function badRequest(message?: string, data?: Data): Boom; + function badRequest(message?: string, data?: Data): Boom; /** * Returns a 401 Unauthorized error @@ -106,10 +105,10 @@ declare namespace Boom { * @param attributes an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the attributes key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. null and undefined will be replaced with an empty string. If attributes is set, message will be used as the 'error' segment of the 'WWW-Authenticate' header. If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object. * @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */ - export function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom; - export function unauthorized(message?: string, scheme?: string[]): Boom; - export function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom; - export function unauthorized(message?: null, scheme?: string[]): Boom; + function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom; + function unauthorized(message?: string, scheme?: string[]): Boom; + function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom; + function unauthorized(message?: null, scheme?: string[]): Boom; /** * Returns a 402 Payment Required error @@ -117,7 +116,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data} */ - export function paymentRequired(message?: string, data?: Data): Boom; + function paymentRequired(message?: string, data?: Data): Boom; /** * Returns a 403 Forbidden error @@ -125,7 +124,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data} */ - export function forbidden(message?: string, data?: Data): Boom; + function forbidden(message?: string, data?: Data): Boom; /** * Returns a 404 Not Found error @@ -133,7 +132,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data} */ - export function notFound(message?: string, data?: Data): Boom; + function notFound(message?: string, data?: Data): Boom; /** * Returns a 405 Method Not Allowed error @@ -142,7 +141,7 @@ declare namespace Boom { * @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header. * @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow} */ - export function methodNotAllowed(message?: string, data?: Data, allow?: string | string[]): Boom; + function methodNotAllowed(message?: string, data?: Data, allow?: string | string[]): Boom; /** * Returns a 406 Not Acceptable error @@ -150,7 +149,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data} */ - export function notAcceptable(message?: string, data?: Data): Boom; + function notAcceptable(message?: string, data?: Data): Boom; /** * Returns a 407 Proxy Authentication Required error @@ -158,7 +157,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data} */ - export function proxyAuthRequired(message?: string, data?: Data): Boom; + function proxyAuthRequired(message?: string, data?: Data): Boom; /** * Returns a 408 Request Time-out error @@ -166,7 +165,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data} */ - export function clientTimeout(message?: string, data?: Data): Boom; + function clientTimeout(message?: string, data?: Data): Boom; /** * Returns a 409 Conflict error @@ -174,7 +173,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomconflictmessage-data} */ - export function conflict(message?: string, data?: Data): Boom; + function conflict(message?: string, data?: Data): Boom; /** * Returns a 410 Gone error @@ -182,7 +181,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data} */ - export function resourceGone(message?: string, data?: Data): Boom; + function resourceGone(message?: string, data?: Data): Boom; /** * Returns a 411 Length Required error @@ -190,7 +189,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data} */ - export function lengthRequired(message?: string, data?: Data): Boom; + function lengthRequired(message?: string, data?: Data): Boom; /** * Returns a 412 Precondition Failed error @@ -198,7 +197,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data} */ - export function preconditionFailed(message?: string, data?: Data): Boom; + function preconditionFailed(message?: string, data?: Data): Boom; /** * Returns a 413 Request Entity Too Large error @@ -206,7 +205,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data} */ - export function entityTooLarge(message?: string, data?: Data): Boom; + function entityTooLarge(message?: string, data?: Data): Boom; /** * Returns a 414 Request-URI Too Large error @@ -214,7 +213,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data} */ - export function uriTooLong(message?: string, data?: Data): Boom; + function uriTooLong(message?: string, data?: Data): Boom; /** * Returns a 415 Unsupported Media Type error @@ -222,7 +221,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data} */ - export function unsupportedMediaType(message?: string, data?: Data): Boom; + function unsupportedMediaType(message?: string, data?: Data): Boom; /** * Returns a 416 Requested Range Not Satisfiable error @@ -230,7 +229,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data} */ - export function rangeNotSatisfiable(message?: string, data?: Data): Boom; + function rangeNotSatisfiable(message?: string, data?: Data): Boom; /** * Returns a 417 Expectation Failed error @@ -238,7 +237,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data} */ - export function expectationFailed(message?: string, data?: Data): Boom; + function expectationFailed(message?: string, data?: Data): Boom; /** * Returns a 418 I'm a Teapot error @@ -246,7 +245,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomteapotmessage-data} */ - export function teapot(message?: string, data?: Data): Boom; + function teapot(message?: string, data?: Data): Boom; /** * Returns a 422 Unprocessable Entity error @@ -254,7 +253,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombaddatamessage-data} */ - export function badData(message?: string, data?: Data): Boom; + function badData(message?: string, data?: Data): Boom; /** * Returns a 423 Locked error @@ -262,7 +261,15 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomlockedmessage-data} */ - export function locked(message?: string, data?: Data): Boom; + function locked(message?: string, data?: Data): Boom; + + /** + * Returns a 424 Failed Dependency error + * @param message optional message. + * @param data optional additional error data. + * @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data} + */ + function failedDependency(message?: string, data?: Data): Boom; /** * Returns a 428 Precondition Required error @@ -270,7 +277,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data} */ - export function preconditionRequired(message?: string, data?: Data): Boom; + function preconditionRequired(message?: string, data?: Data): Boom; /** * Returns a 429 Too Many Requests error @@ -278,7 +285,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data} */ - export function tooManyRequests(message?: string, data?: Data): Boom; + function tooManyRequests(message?: string, data?: Data): Boom; /** * Returns a 451 Unavailable For Legal Reasons error @@ -286,7 +293,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomillegalmessage-data} */ - export function illegal(message?: string, data?: Data): Boom; + function illegal(message?: string, data?: Data): Boom; // 5xx /** @@ -296,7 +303,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal} */ - export function badImplementation(message?: string, data?: Data): Boom; + function badImplementation(message?: string, data?: Data): Boom; /** * Returns a 500 Internal Server Error error @@ -305,7 +312,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal} */ - export function internal(message?: string, data?: Data): Boom; + function internal(message?: string, data?: Data): Boom; /** * Returns a 501 Not Implemented error with your error message to the user @@ -313,7 +320,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data} */ - export function notImplemented(message?: string, data?: Data): Boom; + function notImplemented(message?: string, data?: Data): Boom; /** * Returns a 502 Bad Gateway error with your error message to the user @@ -321,7 +328,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data} */ - export function badGateway(message?: string, data?: Data): Boom; + function badGateway(message?: string, data?: Data): Boom; /** * Returns a 503 Service Unavailable error with your error message to the user @@ -329,7 +336,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data} */ - export function serverUnavailable(message?: string, data?: Data): Boom; + function serverUnavailable(message?: string, data?: Data): Boom; /** * Returns a 504 Gateway Time-out error with your error message to the user @@ -337,5 +344,5 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data} */ - export function gatewayTimeout(message?: string, data?: Data): Boom; + function gatewayTimeout(message?: string, data?: Data): Boom; } diff --git a/types/boom/v3/index.d.ts b/types/boom/v3/index.d.ts index adf433c9f4..d9c34be4fb 100644 --- a/types/boom/v3/index.d.ts +++ b/types/boom/v3/index.d.ts @@ -48,6 +48,7 @@ declare namespace Boom { export function expectationFailed(message?: string, data?: any): BoomError; export function badData(message?: string, data?: any): BoomError; export function locked(message?: string, data?: any): BoomError; + export function failedDependency(message?: string, data?: any): BoomError; export function preconditionRequired(message?: string, data?: any): BoomError; export function tooManyRequests(message?: string, data?: any): BoomError; export function illegal(message?: string, data?: any): BoomError; diff --git a/types/boom/v4/boom-tests.ts b/types/boom/v4/boom-tests.ts index 1819be25cb..33e86699e8 100644 --- a/types/boom/v4/boom-tests.ts +++ b/types/boom/v4/boom-tests.ts @@ -98,6 +98,10 @@ const lockedError = Boom.locked('message', {some: 'data'}); lockedError.data.some; const lockedError2: Boom.BoomError = Boom.locked('message'); +const failedDependencyError = Boom.failedDependency('message', {some: 'data'}); +failedDependencyError.data.some; +const failedDependencyError2: Boom.BoomError = Boom.failedDependency('message'); + const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'}); preconditionRequiredError.data.some; const preconditionRequiredError2: Boom.BoomError = Boom.preconditionRequired('message'); diff --git a/types/boom/v4/index.d.ts b/types/boom/v4/index.d.ts index 76cd2d6b46..50d7a7d59a 100644 --- a/types/boom/v4/index.d.ts +++ b/types/boom/v4/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Igor Rogatty // AJP // Jinesh Shah +// Daniel Machado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -258,6 +259,14 @@ declare namespace Boom { */ export function locked(message?: string, data?: Data): BoomError; + /** + * Returns a 424 Failed Dependency error + * @param message optional message. + * @param data optional additional error data. + * @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data} + */ + export function failedDependency(message?: string, data?: Data): BoomError; + /** * Returns a 428 Precondition Required error * @param message optional message. diff --git a/types/bootstrap3-dialog/bootstrap3-dialog-tests.ts b/types/bootstrap3-dialog/bootstrap3-dialog-tests.ts new file mode 100644 index 0000000000..5434971f41 --- /dev/null +++ b/types/bootstrap3-dialog/bootstrap3-dialog-tests.ts @@ -0,0 +1,123 @@ +function BootstrapDialogOptionsTests() { + const options1: BootstrapDialog.DialogOptions = { }; + const options2: BootstrapDialog.DialogOptions = { + animate: false, + buttons: [{id: "btn-1"}], + callback: (result: boolean) => { }, + closable: false, + closeByBackdrop: false, + closeByKeyboard: false, + data: {name: "value"}, + draggable: false, + description: "", + buttonLabel: "", + message: "", + onhide: (dialog: BootstrapDialog.DialogContext) => { }, + onhidden: (dialog: BootstrapDialog.DialogContext) => { }, + onshow: (dialog: BootstrapDialog.DialogContext) => { }, + onshown: (dialog: BootstrapDialog.DialogContext) => { }, + size: BootstrapDialog.SIZE_LARGE, + title: "", + type: BootstrapDialog.TYPE_DEFAULT, + btnCancelLabel: "", + btnOKClass: "", + btnOKLabel: "", + cssClass: "", + spinicon: "", + autodestroy: false, + nl2br: false, + }; + options2.onhide = (dialog: BootstrapDialog.DialogContext): void => { }; + options2.onhide = (dialog: BootstrapDialog.DialogContext): boolean => false; + options2.message = ""; + options2.message = $("#element"); + options2.message = (dialog?: BootstrapDialog.DialogContext): string => { + return ""; + }; + options2.message = (dialog?: BootstrapDialog.DialogContext): JQuery => { + return $("#element"); + }; + // BootstrapDialog.SIZE_xxx constants. + options2.size = BootstrapDialog.SIZE_LARGE; + options2.size = BootstrapDialog.SIZE_NORMAL; + options2.size = BootstrapDialog.SIZE_SMALL; + options2.size = BootstrapDialog.SIZE_WIDE; + options2.title = ""; + options2.title = $("#element"); + // BootstrapDialog.TYPE_xxx constants. + options2.type = BootstrapDialog.TYPE_DANGER; + options2.type = BootstrapDialog.TYPE_DEFAULT; + options2.type = BootstrapDialog.TYPE_INFO; + options2.type = BootstrapDialog.TYPE_PRIMARY; + options2.type = BootstrapDialog.TYPE_SUCCESS; + options2.type = BootstrapDialog.TYPE_WARNING; +} + +function BootstrapDialogStaticTests() { + BootstrapDialog.alert(""); + BootstrapDialog.alert("", () => { }); + BootstrapDialog.confirm(""); + BootstrapDialog.confirm("", (result: boolean) => { }); + const instance1: BootstrapDialog.DialogInstance = BootstrapDialog.show({}); + // BUTTON_SIZES + BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = ''; + const buttonSize: string = BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL]; + // Buttons order + BootstrapDialog.BUTTONS_ORDER_CANCEL_OK = ""; + BootstrapDialog.BUTTONS_ORDER_OK_CANCEL = ""; + // DEFAULT_TEXTS + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = 'Information'; + const defaultText: string = BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT]; + // Miscellaneous + BootstrapDialog.ICON_SPINNER = ""; + BootstrapDialog.NAMESPACE = ""; +} + +function BootstrapDialogContextTests() { + const dialog1: BootstrapDialog.DialogContext = BootstrapDialog({}); + dialog1.close(); + dialog1.enableButtons(false); + const button: JQuery = dialog1.getButton(""); + const value: any = dialog1.getData("name"); + const modal: JQuery = dialog1.getModal(); + const content: JQuery = dialog1.getModalContent(); + const dialog: JQuery = dialog1.getModalDialog(); + const header: JQuery = dialog1.getModalHeader(); + const footer: JQuery = dialog1.getModalFooter(); + const body: JQuery = dialog1.getModalBody(); + const title: string = dialog1.getTitle(); + dialog1.open(); + dialog1.realize(); + dialog1.setClosable(false); + dialog1.setData("name", "value"); + dialog1.setData("", null); + dialog1.setMessage(""); + dialog1.setTitle(""); + dialog1.setType(BootstrapDialog.TYPE_DEFAULT); +} + +function BootstrapDialogInstanceTests() { + const instance1: BootstrapDialog.DialogInstance = BootstrapDialog.show({}); + const modal: JQuery = instance1.$modal; + const modalBody: JQuery = instance1.$modalBody; + const modalContent: JQuery = instance1.$modalContent; + const modalDialog: JQuery = instance1.$modalDialog; + const modalHeader: JQuery = instance1.$modalHeader; + const modalFooter: JQuery = instance1.$modalFooter; + const options: BootstrapDialog.DialogOptions = instance1.options; + const opened: boolean = instance1.opened; +} + +function BootstrapDialogButtonTests() { + const button1: BootstrapDialog.DialogButton = { }; + const button2: BootstrapDialog.DialogButton = { + id: "", + label: "", + hotkey: 0, + icon: "", + cssClass: "", + data: {name: "value"}, + autospin: false, + action: (dialog: BootstrapDialog.DialogContext) => { }, + }; +} diff --git a/types/bootstrap3-dialog/index.d.ts b/types/bootstrap3-dialog/index.d.ts new file mode 100644 index 0000000000..d9612167f8 --- /dev/null +++ b/types/bootstrap3-dialog/index.d.ts @@ -0,0 +1,197 @@ +// Type definitions for bootstrap3-dialog 1.35 +// Project: http://nakupanda.github.io/bootstrap3-dialog +// Definitions by: Dante +// Craig Boland +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +declare namespace BootstrapDialog { + interface DialogStatic { + BUTTON_SIZES: any; + BUTTONS_ORDER_CANCEL_OK: string; + BUTTONS_ORDER_OK_CANCEL: string; + DEFAULT_TEXTS: any; /** For text localization. */ + ICON_SPINNER: string; + NAMESPACE: string; + + SIZE_NORMAL: string; + SIZE_SMALL: string; + SIZE_WIDE: string; + SIZE_LARGE: string; + + TYPE_DEFAULT: string; + TYPE_INFO: string; + TYPE_PRIMARY: string; + TYPE_SUCCESS: string; + TYPE_WARNING: string; + TYPE_DANGER: string; + + (options: DialogOptions): DialogContext; + alert(message: string, closeCallback?: () => void): void; + confirm(message: string, closeCallback?: (result: boolean) => void): void; + show(options: DialogOptions): DialogInstance; + } + + interface DialogOptions { + /** Dialog header type. See BootstrapDialog.TYPE_xxx constants. */ + type?: string; + /** Text size. See BootstrapDialog.SIZE_xxx constants. By default - SIZE_NORMAL */ + size?: string; + /** Dialog title. Either string or JQuery element. */ + title?: string | JQuery; + /** Dialog message. Either string, JQuery element, or function that returns either string or JQuery element. */ + message?: string | JQuery | ((dialog?: DialogContext) => string | JQuery); + /** + * When set to true, you can close the dialog by: + * - Clicking the close icon in dialog header. + * - Clicking outside the dialog. + * - ESC key. + * + * FALSE by default. + */ + closable?: boolean; + /** Whether dialog will close by clicking outside of it. */ + closeByBackdrop?: boolean; + /** Whether dialog will close by ESC. */ + closeByKeyboard?: boolean; + /** Whether fade-out background while showing the dialog. TRUE by default. */ + animate?: boolean; + /** Data to be bound to the dialog. */ + data?: any; + /** Whether dialog could be dragged by its header. Cursor could be changed (see doc)! FALSE by default. */ + draggable?: boolean; + /** + * If provided, 'aria-describedby' attribute will be added to the dialog with the description string as its value. This can improve accessibility, as the description can be read by screen + * readers. + */ + description?: string; + /** Default button title. OK by default. */ + buttonLabel?: string; + buttons?: DialogButton[]; + /** Result will be true if button was click, while it will be false if users close the dialog directly. */ + callback?: (result: boolean) => void; + /** If provided, it will be invoked when the dialog is popping up. */ + onshow?(dialog?: DialogContext): void; + /** If provided, it will be invoked when the dialog is popped up. */ + onshown?(dialog?: DialogContext): void; + /** + * If provided, it will be invoked when the dialog is popping down. + * Return FALSE to don`t close the dialog. Don`t return anything by default. + */ + onhide?(dialog?: DialogContext): any; + /** If provided, it will be invoked when the dialog is popped down. */ + onhidden?(dialog?: DialogContext): void; + + /** 'Cancel' by default. */ + btnCancelLabel?: string; + /** 'OK' by default. */ + btnOKLabel?: string; + /** If you didn't specify it, dialog type will be used. */ + btnOKClass?: string; + /** Additional css classes that will be added to your dialog. */ + cssClass?: string; + /** Icon class name, for example 'glyphicon glyphicon-check'. */ + spinicon?: string; + /** + * When it's true, all modal stuff will be removed from the DOM tree after the dialog is popped down, + * set it to false if you need your dialog (same instance) pups up and down again and again. + * Default is true. + */ + autodestroy?: boolean; + /** + * Automatically convert line breaking character to
if it's set to true, + * everything keeps original if it's false. + */ + nl2br?: boolean; + } + + interface DialogInstance { + $modal: JQuery; + $modalBody: JQuery; + $modalContent: JQuery; + $modalDialog: JQuery; + $modalHeader: JQuery; + $modalFooter: JQuery; + options: DialogOptions; + opened: boolean; + } + + interface DialogButton { + /** If id is set, you can use dialogInstance.getButton(id) to get the button later. */ + id?: string; + label?: string; + /** Hotkey char code */ + hotkey?: number; + /** If set, the specified icon will be added to the button. */ + icon?: string; + /** Additional css class to be added to the button. */ + cssClass?: string; + /** Object containing data attributes to be added to the button. */ + data?: any; + /** If it's true, after clicked the button a spinning icon appears. */ + autospin?: boolean; + /** + * If provided, the callback will be invoked after the button is clicked, and the dialog instance + * will be passed to the callback function. + */ + action?: (dialog: DialogContext) => void; + } + + interface DialogButtonInstance { + toggleEnable(enabled: boolean): void; + /** Equals to $button.toggleEnable(true); */ + enable(): void; + /** Equals to $button.toggleEnable(false); */ + disable(): void; + toggleSpin(spin: boolean): void; + /** Equals to $button.toggleSpin(true); */ + spin(): void; + /** Equals to $button.toggleSpin(false); */ + stopSpin(): void; + } + + interface DialogContext { + /** Open the dialog. Usage: dialogInstance.open() */ + open(): void; + /** Close the dialog. Usage: dialogInstance.close() */ + close(): void; + /** + * Calling dialog.open() will automatically get this method called first, but if you want to do something on your dialog + * before it's shown, you can manually call dialog.realize() before calling dialog.open(). + */ + realize(): void; + getTitle(): string; + setTitle(title: string): void; + setMessage(message: string): void; + /** Bind data entry to dialog instance, value can be any types that javascript supports. */ + setData(dataName: string, value: any): void; + /** Get data entry according to the given key, returns null if no data entry found. */ + getData(dataName: string): any; + getButton(buttonId: string): JQuery; + /** + * When set to true (default), dialog can be closed by clicking close icon in dialog header, + * or by clicking outside the dialog, or, ESC key is pressed. + */ + setClosable(closable: boolean): void; + /** See BootstrapDialog.TYPE_xxx constants. */ + setType(dialogType: string): void; + /** Disable all buttons in dialog footer when it's false, enable all when it's true. */ + enableButtons(enable: boolean): void; + /** Return the raw modal, equivalent to $('') */ + getModal(): JQuery; + /** Return the raw modal content. */ + getModalContent(): JQuery; + /** Return the raw modal dialog. */ + getModalDialog(): JQuery; + /** Return the raw modal header. */ + getModalHeader(): JQuery; + /** Return the raw modal footer. */ + getModalFooter(): JQuery; + /** Return the raw modal body. */ + getModalBody(): JQuery; + } +} + +declare const BootstrapDialog: BootstrapDialog.DialogStatic; diff --git a/types/bootstrap3-dialog/tsconfig.json b/types/bootstrap3-dialog/tsconfig.json new file mode 100644 index 0000000000..cdf93479b7 --- /dev/null +++ b/types/bootstrap3-dialog/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bootstrap3-dialog-tests.ts" + ] +} diff --git a/types/bootstrap3-dialog/tslint.json b/types/bootstrap3-dialog/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/bootstrap3-dialog/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/braft-editor/braft-editor-tests.tsx b/types/braft-editor/braft-editor-tests.tsx index 999850acaa..48513f6de4 100644 --- a/types/braft-editor/braft-editor-tests.tsx +++ b/types/braft-editor/braft-editor-tests.tsx @@ -12,7 +12,7 @@ class BraftEditorTest extends React.Component { height: 500, initialContent: this.state.content, onChange: this.handleChange, - onHTMLChange: this.handleHTMLChange + onHTMLChange: this.handleHTMLChange, }; return (
diff --git a/types/braft-editor/index.d.ts b/types/braft-editor/index.d.ts index 505403d2f3..1ad5f728ad 100644 --- a/types/braft-editor/index.d.ts +++ b/types/braft-editor/index.d.ts @@ -15,8 +15,8 @@ declare namespace BraftEditor { } interface editorProps { editorState?: any; - contentFormat?: RawDraftContentState; - initialContent?: RawDraftContentState | null; + contentFormat?: 'raw' | 'html'; + initialContent?: string | null; onChange?: (content: RawDraftContentState) => void; onRawChange?: (content: RawDraftContentState) => void; onHTMLChange?: (content: string) => void; diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index a7a9ea350b..97844cfbbb 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -5,6 +5,7 @@ // Marshall Cottrell // Weeco // Gabriel Terwesten +// Oleg Repin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -51,6 +52,8 @@ declare namespace Bull { settings?: AdvancedSettings; limiter?: RateLimiter; + + defaultJobOptions?: JobOptions; } interface AdvancedSettings { diff --git a/types/case-sensitive-paths-webpack-plugin/index.d.ts b/types/case-sensitive-paths-webpack-plugin/index.d.ts index 38fdd9c032..58cdccf25f 100644 --- a/types/case-sensitive-paths-webpack-plugin/index.d.ts +++ b/types/case-sensitive-paths-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/Urthen/case-sensitive-paths-webpack-plugin#readme // Definitions by: Andrew Makarov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin } from 'webpack'; diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 338e38e223..c637164d30 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -198,6 +198,8 @@ declare namespace Chart { cutoutPercentage?: number; circumference?: number; rotation?: number; + // Plugins can require any options + plugins?: { [plugin: string]: any }; } interface ChartFontOptions { diff --git a/types/chroma-js/chroma-js-tests.ts b/types/chroma-js/chroma-js-tests.ts index 82cfb7274d..fdd1b5946b 100644 --- a/types/chroma-js/chroma-js-tests.ts +++ b/types/chroma-js/chroma-js-tests.ts @@ -1,3 +1,6 @@ +import { Color } from "chroma-js"; +import chroma = require("chroma-js"); + function test_chroma() { chroma('hotpink'); chroma('#ff3399'); @@ -187,3 +190,9 @@ function test_types() { const color: chroma.Color = chroma('orange'); const scale: chroma.Scale = chroma.scale('RdYlBu'); } + +// the following should actually, pass, but TS can't disambiguate between a parameter +// which is passed as undefined/null or not passed at all +// const scaleColors1: Color[] = chroma.scale(['black', 'white']).colors(12); +const scaleColors2: Color[] = chroma.scale(['black', 'white']).colors(12, null); +const scaleColors3: Color[] = chroma.scale(['black', 'white']).colors(12, undefined); diff --git a/types/chroma-js/index.d.ts b/types/chroma-js/index.d.ts index c18484dc1f..797752c8ad 100644 --- a/types/chroma-js/index.d.ts +++ b/types/chroma-js/index.d.ts @@ -303,10 +303,10 @@ declare namespace chroma { * You can call scale.colors(n) to quickly grab `c` equi-distant colors from a color scale. If called with no * arguments, scale.colors returns the original array of colors used to create the scale. */ - colors(c?: number, format?: 'hex' | 'name'): string[]; - colors(c?: number, format?: null | 'alpha' | 'darken' | 'brighten' | 'saturate' | 'desaturate'): Color[]; - colors(c?: number, format?: 'luminance' | 'temperature'): number[]; - colors(c?: number, format?: K): Array; + colors(c: number | undefined, format: undefined | null | 'alpha' | 'darken' | 'brighten' | 'saturate' | 'desaturate'): Color[]; + colors(c: number | undefined, format: 'luminance' | 'temperature'): number[]; + colors(c: number | undefined, format: K): Array; + colors(c: number | undefined, format?: 'hex' | 'name'): string[]; /** * If you want the scale function to return a distinct set of colors instead of a continuous gradient, you can diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index cde1de9092..d12bf94302 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -5041,7 +5041,7 @@ declare namespace chrome.runtime { export interface PortDisconnectEvent extends chrome.events.Event<(port: Port) => void> {} - export interface PortMessageEvent extends chrome.events.Event<(message: Object, port: Port) => void> {} + export interface PortMessageEvent extends chrome.events.Event<(message: any, port: Port) => void> {} export interface ExtensionMessageEvent extends chrome.events.Event<(message: any, sender: MessageSender, sendResponse: (response: any) => void) => void> {} diff --git a/types/clean-webpack-plugin/index.d.ts b/types/clean-webpack-plugin/index.d.ts index afe8a65b69..7c23e51df5 100644 --- a/types/clean-webpack-plugin/index.d.ts +++ b/types/clean-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/johnagan/clean-webpack-plugin // Definitions by: Jed Fox // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin } from 'webpack'; diff --git a/types/coinbase/coinbase-tests.ts b/types/coinbase/coinbase-tests.ts index 793833355e..fb804ac566 100644 --- a/types/coinbase/coinbase-tests.ts +++ b/types/coinbase/coinbase-tests.ts @@ -85,7 +85,7 @@ client.getAccount("abcdef", (error: Error, account: coinbase.Account): void => { }); }); -client.getBuyPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.MoneyHash): void => undefined); +client.getBuyPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.Price): void => undefined); client.getCurrencies((error: Error, result: coinbase.Currency[]): void => undefined); @@ -95,10 +95,10 @@ client.getPaymentMethod("foo", (error: Error, result: coinbase.PaymentMethod): v client.getPaymentMethods((error: Error, result: coinbase.PaymentMethod[]): void => undefined); -client.getSellPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.MoneyHash): void => undefined); +client.getSellPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.Price): void => undefined); -client.getSpotPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.MoneyHash): void => undefined); -client.getSpotPrice({ currencyPair: "USD-BTC", date: "2017-22-01" }, (error: Error, result: coinbase.MoneyHash): void => undefined); +client.getSpotPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.Price): void => undefined); +client.getSpotPrice({ currencyPair: "USD-BTC", date: "2017-22-01" }, (error: Error, result: coinbase.Price): void => undefined); client.getTime((error: Error, result: coinbase.Time): void => undefined); diff --git a/types/coinbase/index.d.ts b/types/coinbase/index.d.ts index ae1e041203..6057f58142 100644 --- a/types/coinbase/index.d.ts +++ b/types/coinbase/index.d.ts @@ -294,6 +294,33 @@ export interface MoneyHash { currency: string; } +/** + * Price response + */ +export interface Price { + data: { + /** + * Currency e.g. "BTC" (see Client#getCurrencies() for available strings) + */ + base: string; + /** + * Amount as floating-point in a string + */ + amount: string; + /** + * Currency e.g. "EUR" (see Client#getCurrencies() for available strings) + */ + currency: string; + }; + warnings?: [ + { + id: string + message: string + url: string + } + ]; +} + export type ResourceType = "account" | "transaction" | "address" | "user" | "buy" | "sell" | "deposit" | "withdrawal" | "payment_method"; /** @@ -1308,7 +1335,7 @@ export class Client { * If you need more accurate price estimate for a specific payment method or amount, @see Account#buy() and `quote: true` option. * Scope: none */ - getBuyPrice(opts: GetBuyPriceOpts, cb: (error: Error, result: MoneyHash) => void): void; + getBuyPrice(opts: GetBuyPriceOpts, cb: (error: Error, result: Price) => void): void; /** * Get the total price to sell one bitcoin or ether. Note that exchange rates fluctuates so the price is only correct for seconds at the time. @@ -1316,7 +1343,7 @@ export class Client { * estimate for a specific payment method or amount, see sell bitcoin endpoint and quote: true option. * Scope: none */ - getSellPrice(opts: GetSellPriceOpts, cb: (error: Error, result: MoneyHash) => void): void; + getSellPrice(opts: GetSellPriceOpts, cb: (error: Error, result: Price) => void): void; /** * Get the current market price for bitcoin. This is usually somewhere in between the buy and sell price. @@ -1324,7 +1351,7 @@ export class Client { * You can also get historic prices with date parameter. * Scope: none */ - getSpotPrice(opts: GetSpotPriceOpts, cb: (error: Error, result: MoneyHash) => void): void; + getSpotPrice(opts: GetSpotPriceOpts, cb: (error: Error, result: Price) => void): void; /** * Get the API server time. diff --git a/types/compression-webpack-plugin/index.d.ts b/types/compression-webpack-plugin/index.d.ts index bfb769ed2f..a7b38383ef 100644 --- a/types/compression-webpack-plugin/index.d.ts +++ b/types/compression-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/webpack-contrib/compression-webpack-plugin // Definitions by: Anton Kandybo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin } from 'webpack'; diff --git a/types/compression/compression-tests.ts b/types/compression/compression-tests.ts index dc284ce2df..192ec309e8 100644 --- a/types/compression/compression-tests.ts +++ b/types/compression/compression-tests.ts @@ -1,4 +1,3 @@ - import express = require('express'); import compress = require('compression'); @@ -7,3 +6,15 @@ app.use(compress()); app.use(compress({ threshold: 512 })); +app.use(compress({ + threshold: 512, + filter: (req, res) => { + if (req.headers['x-no-compression']) { + // don't compress responses with this request header + return false; + } + + // fallback to standard filter function + return compress.filter(req, res); + } +})); \ No newline at end of file diff --git a/types/compression/index.d.ts b/types/compression/index.d.ts index 68d687a9c4..813a823a96 100644 --- a/types/compression/index.d.ts +++ b/types/compression/index.d.ts @@ -1,13 +1,26 @@ // Type definitions for compression // Project: https://github.com/expressjs/compression // Definitions by: Santi Albo +// Rob van der Burgt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 import * as express from 'express'; +declare function e(options?: e.CompressionOptions): express.RequestHandler; + declare namespace e { - interface CompressionOptions { + /** + * Default filter, used for extending filter given in CompressionOptions + * See https://github.com/expressjs/compression#filter-1 regarding the usage + */ + export function filter(req: express.Request, res: express.Response): boolean; + + interface CompressionFilter { + (req: express.Request, res: express.Response): boolean; + } + + interface CompressionOptions { /** * See https://github.com/expressjs/compression#chunksize regarding the usage. */ @@ -31,7 +44,7 @@ declare namespace e { /** * See https://github.com/expressjs/compression#threshold regarding the usage. */ - threshold?: number|string; + threshold?: number | string; /** * See https://github.com/expressjs/compression#windowbits regarding the usage. @@ -41,8 +54,8 @@ declare namespace e { /** * See https://github.com/expressjs/compression#filter regarding the usage. */ - filter?: Function; - + filter?: CompressionFilter; + /** * See https://nodejs.org/api/zlib.html#zlib_class_options regarding the usage. */ @@ -55,5 +68,4 @@ declare namespace e { } } -declare function e(options?: e.CompressionOptions): express.RequestHandler; export = e; diff --git a/types/copy-webpack-plugin/index.d.ts b/types/copy-webpack-plugin/index.d.ts index 72331b4c6d..eedf42f450 100644 --- a/types/copy-webpack-plugin/index.d.ts +++ b/types/copy-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/kevlened/copy-webpack-plugin // Definitions by: flying-sheep // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin } from 'webpack' import { IOptions } from 'minimatch' diff --git a/types/csv2json/csv2json-tests.ts b/types/csv2json/csv2json-tests.ts new file mode 100644 index 0000000000..b211fd9aee --- /dev/null +++ b/types/csv2json/csv2json-tests.ts @@ -0,0 +1,8 @@ +import csv2json = require("csv2json"); +import fs = require("fs"); + +fs.createReadStream('data.csv') + .pipe(csv2json({ + separator: ';' + })) + .pipe(fs.createWriteStream('data.json')); diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts new file mode 100644 index 0000000000..6906d3e925 --- /dev/null +++ b/types/csv2json/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for csv2json 1.4 +// Project: https://github.com/julien-f/csv2json +// Definitions by: Piotr Roszatycki +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Writable } from "stream"; + +declare namespace csv2json { + interface Options { + dynamicTyping?: boolean; + separator?: string; + } +} + +declare function csv2json(options?: csv2json.Options): Writable; + +export = csv2json; diff --git a/types/csv2json/tsconfig.json b/types/csv2json/tsconfig.json new file mode 100644 index 0000000000..79a635ca7d --- /dev/null +++ b/types/csv2json/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "csv2json-tests.ts" + ] +} diff --git a/types/csv2json/tslint.json b/types/csv2json/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/csv2json/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/d3-contour/d3-contour-tests.ts b/types/d3-contour/d3-contour-tests.ts index 2879e71e79..4563521751 100644 --- a/types/d3-contour/d3-contour-tests.ts +++ b/types/d3-contour/d3-contour-tests.ts @@ -63,6 +63,8 @@ let contGen: d3Contour.Contours = d3Contour.contours(); // size(...) ------------------------------------------------------------------- +const multiPolygon: d3Contour.ContourMultiPolygon = contGen.contour(values, 5); + // set with chainability contGen = contGen.size([n, m]); @@ -111,7 +113,11 @@ interface CustomDatum { // Get contour generator ------------------------------------------------------- -const contDensDefault: d3Contour.ContourDensity<[number, number]> = d3Contour.contourDensity(); +// test generic parameter defaults for ContourDensity and contourDensity +const contDensDefault: d3Contour.ContourDensity = d3Contour.contourDensity(); +// tslint:disable-next-line: use-default-type-parameter +const contDensDefaultCopy: d3Contour.ContourDensity<[number, number]> = contDensDefault; +// test with explicit generic parameter let contDensCustom: d3Contour.ContourDensity = d3Contour.contourDensity(); // Configure contour generator ================================================= diff --git a/types/d3-contour/index.d.ts b/types/d3-contour/index.d.ts index 1d82faae40..c0b3d70b5e 100644 --- a/types/d3-contour/index.d.ts +++ b/types/d3-contour/index.d.ts @@ -1,10 +1,10 @@ -// Type definitions for d3-contour 1.1 +// Type definitions for d3-contour 1.2 // Project: https://d3js.org/d3-contour/ // Definitions by: Tom Wanzek , Hugues Stefanski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// Last module patch version validated against: 1.1.0 +// Last module patch version validated against: 1.2.0 import { MultiPolygon } from 'geojson'; import { ThresholdArrayGenerator, ThresholdCountGenerator } from 'd3-array'; @@ -41,6 +41,17 @@ export interface Contours { */ (values: number[]): ContourMultiPolygon[]; + /** + * Computes a single contour, returning a GeoJSON MultiPolygon geometry object. + * This geometry object represents the area where the input values are greater than or equal to the given threshold value; + * the threshold value for the geometry object is exposed as geometry.value. + * + * @param values Array of input values. The input values must be an array of length n×m where [n, m] is the contour generator’s size; + * furthermore, each values[i + jn] must represent the value at the position ⟨i, j⟩. + * @param threshold Threshold value. + */ + contour(values: number[], threshold: number): ContourMultiPolygon; + /** * Return the expected size of the input values grid, which defaults to [1,1]. */ @@ -109,8 +120,13 @@ export function contours(): Contours; /** * A contour generator for density estimates. + * + * The generic refers to the data type of an element in the data array + * used with the density contour generator. If omitted, the default setting assumes that, + * the elements of the data array used with the density contour generator are two-element arrays. + * The first element corresponds to the x-dimension, the second to the y-dimension. */ -export interface ContourDensity { +export interface ContourDensity { /** * Estimates the density contours for the given array of data, returning an array of GeoJSON MultiPolygon geometry objects. * Each geometry object represents the area where the estimated number of points per square pixel is greater than or equal to @@ -227,21 +243,15 @@ export interface ContourDensity { bandwidth(bandwidth: number): this; } -/** - * Construct a new contour generator for density estimates with the default settings. - * - * The default settings assume that, the elements of the data array used - * with the density contour generator are two-element arrays. The first element - * corresponds to the x-dimension, the second to the y-dimension. - */ -export function contourDensity(): ContourDensity<[number, number]>; /** * Construct a new contour generator for density estimates. * * The generic refers to the data type of an element in the data array - * used with the density contour generator. + * used with the density contour generator. If omitted, the default setting assumes that, + * the elements of the data array used with the density contour generator are two-element arrays. + * The first element corresponds to the x-dimension, the second to the y-dimension. * * Important: ensure that the x- and y-accessor functions are configured to * match the data type used for the generic Datum. */ -export function contourDensity(): ContourDensity; +export function contourDensity(): ContourDensity; diff --git a/types/d3-drag/d3-drag-tests.ts b/types/d3-drag/d3-drag-tests.ts index 848e3d1256..3bc7e6f851 100644 --- a/types/d3-drag/d3-drag-tests.ts +++ b/types/d3-drag/d3-drag-tests.ts @@ -67,7 +67,8 @@ let containerAccessor: (this: SVGCircleElement, d: CircleDatum, i: number, group containerAccessor = function(d, i, group) { console.log('Node Id of circle: ', d.nodeId); // console.log(this.a); // fails, a is not a property of SVGCircleElement - return this.ownerSVGElement; // this-type is SVGCircleElement + /* tslint:disable-next-line:no-unnecessary-type-assertion */ + return this.ownerSVGElement!; // this-type is SVGCircleElement }; // Test chainability @@ -75,7 +76,8 @@ circleDrag = circleDrag .container(function(d, i, group) { // container accessor function setter console.log('Node Id of circle: ', d.nodeId); // CircleDatum type // console.log(this.a); // fails, a is not a property of SVGCircleElement - return this.ownerSVGElement; // this-type is SVGCircleElement + /* tslint:disable-next-line:no-unnecessary-type-assertion */ + return this.ownerSVGElement!; // this-type is SVGCircleElement }); // Test chainability diff --git a/types/datadog-tracer/datadog-tracer-tests.ts b/types/datadog-tracer/datadog-tracer-tests.ts new file mode 100644 index 0000000000..b0fa4744b1 --- /dev/null +++ b/types/datadog-tracer/datadog-tracer-tests.ts @@ -0,0 +1,9 @@ +import Tracer = require('datadog-tracer'); + +const tracer = new Tracer({ + service: 'test' +}); + +tracer.on('error', (e: any) => { + void(0); +}); diff --git a/types/datadog-tracer/index.d.ts b/types/datadog-tracer/index.d.ts new file mode 100644 index 0000000000..e7a11245fe --- /dev/null +++ b/types/datadog-tracer/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for datadog-tracer 0.4 +// Project: https://github.com/rochdev/datadog-tracer-js#readme +// Definitions by: Dinesh Saravanan Kumaraswamy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import * as opentracing from "opentracing"; +import { EventEmitter } from "events"; + +export as namespace Tracer; +export = Tracer; + +interface TracerOptions { + service: string; + hostname?: string; + port?: number; + protocol?: string; + endpoint?: string; +} + +declare class Tracer extends opentracing.Tracer { + constructor(tracerOptions: TracerOptions); + + on(method: "error", cb?: (e: any) => void): void; + addEventListener(method: "error", cb?: (e: any) => void): void; +} diff --git a/types/datadog-tracer/package.json b/types/datadog-tracer/package.json new file mode 100644 index 0000000000..ce14cc9e91 --- /dev/null +++ b/types/datadog-tracer/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "opentracing": "^0.14.1" + } +} diff --git a/types/datadog-tracer/tsconfig.json b/types/datadog-tracer/tsconfig.json new file mode 100644 index 0000000000..f117daa17e --- /dev/null +++ b/types/datadog-tracer/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "datadog-tracer-tests.ts" + ] +} diff --git a/types/datadog-tracer/tslint.json b/types/datadog-tracer/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/datadog-tracer/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/dc/index.d.ts b/types/dc/index.d.ts index 69ee20a93e..4ba0e5e4ab 100644 --- a/types/dc/index.d.ts +++ b/types/dc/index.d.ts @@ -176,6 +176,7 @@ declare namespace dc { legend: IGetSet; options(optionsObject: any): T; renderlet(fn: (chart: T) => any): T; + useViewBoxResizing: IGetSet; on(event: "renderlet", fn: (chart: T, filter: any) => any): T; on(event: "pretransition", fn: (chart: T, filter: any) => any): T; @@ -484,4 +485,4 @@ declare namespace dc { boxPlot(parent: string, chartGroup?: string): BoxPlot; selectMenu(parent: string, chartGroup?: string): SelectMenu; } -} \ No newline at end of file +} diff --git a/types/dispatchr/addons/BaseStore.d.ts b/types/dispatchr/addons/BaseStore.d.ts new file mode 100644 index 0000000000..6507a7fcf4 --- /dev/null +++ b/types/dispatchr/addons/BaseStore.d.ts @@ -0,0 +1,16 @@ +/// + +import { Dispatcher, DispatcherInterface, DispatcherContext, Store } from '../index'; +import { EventEmitter } from 'events'; + +declare class BaseStore extends EventEmitter implements Store { + constructor(dispatcher: DispatcherInterface); + initialize?(): void; + getContext(): DispatcherContext; + addChangeListener(callback: () => void): void; + removeChangeListener(callback: () => void): void; + shouldDehydrate(): boolean; + emitChange(): void; +} + +export = BaseStore; diff --git a/types/dispatchr/addons/createStore.d.ts b/types/dispatchr/addons/createStore.d.ts new file mode 100644 index 0000000000..86a1f24fbb --- /dev/null +++ b/types/dispatchr/addons/createStore.d.ts @@ -0,0 +1,20 @@ +import { StoreClass, Store } from '../index'; + +type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; +type Omit = Pick>; + +interface StoreOptions { + storeName: string; + handlers: { [event: string]: string }; + statics?: { [prop: string]: any }; + mixins?: object[]; + initialize?(): void; + dehydrate?(): any; + rehydrate?(state: any): void; +} + +// see: https://github.com/yahoo/fluxible/blob/dispatchr-v1.2.0/packages/dispatchr/addons/createStore.js#L9 +type StoreThis = Omit & Store; + +declare function createStore(options: T & ThisType>): StoreClass; +export = createStore; diff --git a/types/dispatchr/dispatchr-tests.ts b/types/dispatchr/dispatchr-tests.ts new file mode 100644 index 0000000000..fcf0490f44 --- /dev/null +++ b/types/dispatchr/dispatchr-tests.ts @@ -0,0 +1,46 @@ +import { createDispatcher, Store } from 'dispatchr'; +import createStore = require('dispatchr/addons/createStore'); +import BaseStore = require('dispatchr/addons/BaseStore'); + +const TestStore = createStore({ + storeName: 'TestStore', + + handlers: { + ACTION_NAME: 'actionHandler' + }, + + statics: { + staticMethod() {} + }, + + initialize() { }, + + actionHandler() { + this.emitChange(); + this.additionalMethod(); + }, + + additionalMethod() {} +}); + +class ExtendedStore extends BaseStore { + static handlers = { + ACTION_NAME: 'actionHandler' + }; + + actionHandler() { + this.emitChange(); + } +} + +const dispatcher = createDispatcher({ + errorHandler(e, context) { + e.meta; + e.type; + e.message; + }, + stores: [TestStore] +}); + +const context = dispatcher.createContext({}); +context.dispatch('ACTION_NAME', {}); diff --git a/types/dispatchr/index.d.ts b/types/dispatchr/index.d.ts new file mode 100644 index 0000000000..b5cf63009d --- /dev/null +++ b/types/dispatchr/index.d.ts @@ -0,0 +1,66 @@ +// Type definitions for dispatchr 1.2 +// Project: https://github.com/yahoo/fluxible#readme +// Definitions by: Ragg +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.5 +/// +import { EventEmitter } from 'events'; + +export interface DispatcherState { + stores: { [storeName: string]: any }; +} + +export interface DispatcherOption { + stores?: StoreClass[]; + errorHandler?: (e: DispatcherError, context: DispatcherContext) => void; +} + +export interface StoreClass { + storeName: string; + new(): Store; +} + +export interface Store extends EventEmitter { + dehydrate?(): S; + rehydrate?(state: S): void; + shouldDehydrate?(): boolean; + emitChange(): void; +} + +export interface Dispatcher { + createContext(context: object): DispatcherContext; + registerStore(store: StoreClass): void; + isRegistered(store: StoreClass | string): boolean; + getStoreName(store: StoreClass | string): string; +} + +export interface DispatcherInterface { + getContext(): DispatcherContext; + getStore: DispatcherContext['getStore']; + waitFor: DispatcherContext['waitFor']; +} + +export interface DispatcherContext { + getStore(name: string): Store; + getStore(name: T): T; + + dispatch(actionName: string, payload: any): void; + + dehydrate(): DispatcherState; + rehydrate(dispatcherState: DispatcherState): void; + + waitFor(stores: ReadonlyArray, callback: () => void): void; + dispatcherInterface: DispatcherInterface; +} + +export interface DispatcherError { + message: string; + type: string; + meta: { + actionName?: string, + payload?: any, + error: Error + }; +} + +export function createDispatcher(options: DispatcherOption): Dispatcher; diff --git a/types/dispatchr/tsconfig.json b/types/dispatchr/tsconfig.json new file mode 100644 index 0000000000..e94ec73c3c --- /dev/null +++ b/types/dispatchr/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "esModuleInterop": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "addons/createStore.d.ts", + "addons/BaseStore.d.ts", + "dispatchr-tests.ts" + ] +} diff --git a/types/dispatchr/tslint.json b/types/dispatchr/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/dispatchr/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/dragula/index.d.ts b/types/dragula/index.d.ts index f91e8b70ac..51998fb583 100644 --- a/types/dragula/index.d.ts +++ b/types/dragula/index.d.ts @@ -13,7 +13,7 @@ declare namespace dragula { interface DragulaOptions { containers?: Element[]; isContainer?: (el?: Element) => boolean; - moves?: (el?: Element, container?: Element, handle?: Element) => boolean; + moves?: (el?: Element, container?: Element, handle?: Element, sibling?: Element) => boolean; accepts?: (el?: Element, target?: Element, source?: Element, sibling?: Element) => boolean; invalid?: (el?: Element, target?: Element) => boolean; direction?: string; diff --git a/types/duplicate-package-checker-webpack-plugin/index.d.ts b/types/duplicate-package-checker-webpack-plugin/index.d.ts index fd2906aa46..1eff56e9d5 100644 --- a/types/duplicate-package-checker-webpack-plugin/index.d.ts +++ b/types/duplicate-package-checker-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin#readme // Definitions by: Matt Traynham // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin } from 'webpack'; diff --git a/types/dwt/addon.pdf.d.ts b/types/dwt/addon.pdf.d.ts new file mode 100644 index 0000000000..ef0980abfd --- /dev/null +++ b/types/dwt/addon.pdf.d.ts @@ -0,0 +1,73 @@ +/*! +* Dynamsoft WebTwain PDF Addon +* Product: Dynamsoft Web Twain +* Web Site: http://www.dynamsoft.com +* +* Copyright 2018, Dynamsoft Corporation +* Author: Dynamsoft Support Team +* Version: 13.4 +*/ + +declare enum EnumDWT_ConverMode { + CM_DEFAULT = 0, + TWPT_CM_RENDERALLGRAY = 1 +} + +/** + * @class + */ +interface PDF { + /** + * Download and install pdf rasterizer add-on on the local system. + * @method Dynamsoft.WebTwain#Download + * @param {string} remoteFile specifies the value of which frame to get. + * @param {function} optionalAsyncSuccessFunc optional. + * The function to call when the download succeeds. Please refer to the function prototype OnSuccess. + * @param {function} optionalAsyncFailureFunc optional. + * The function to call when the download fails. Please refer to the function prototype OnFailure. + * @return {bool} + */ + Download(remoteFile: string, + optionalAsyncSuccessFunc?: () => void, + optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean; + + /** + * Input the password to decrypt PDF files using PDF Rasterizer add-on. + * @method Dynamsoft.WebTwain#SetPassword + * @param {string} password Specifies the PDF password. + * @return {bool} + */ + SetPassword(password: string): boolean; + + /** + * Set the image convert mode for PDF Rasterizer in Dynamic Web TWAIN. + * @method Dynamsoft.WebTwain#SetConvertMode + * @param {EnumDWT_ConverMode} convertMode Specifies the image convert mode. + * @return {bool} + */ + SetConvertMode(convertMode: EnumDWT_ConverMode): boolean; + + /** + * Set the output resolution for the PDF Rasterizer in Dynamic Web TWAIN. + * @method Dynamsoft.WebTwain#ReadRect + * @param {float} fResolution Specifies the resolution for convert image from PDF file. + * @return {bool} + */ + SetResolution(fResolution: number): boolean; + + /** + * Judges whether the local PDF is text-based or not. + * @method Dynamsoft.WebTwain#ReadRect + * @param {string} localFile specifies the local path of the target PDF. + * @return {bool} + */ + IsTextBasedPDF(localFile: string): boolean; +} + +interface WebTwainAddon { + PDF: PDF; +} + +interface WebTwain { + Addon: WebTwainAddon; +} diff --git a/types/dwt/dwt-tests.ts b/types/dwt/dwt-tests.ts index 16a56f1cd2..1be94acca1 100644 --- a/types/dwt/dwt-tests.ts +++ b/types/dwt/dwt-tests.ts @@ -103,8 +103,8 @@ function downloadImage() { function loadPDF() { const DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer'); if (DWObject) { - DWObject.Addon.PDF.SetResolution(200); - DWObject.Addon.PDF.SetConvertMode(1); + DWObject.Addon.PDF.SetResolution(200); + DWObject.Addon.PDF.SetConvertMode(1); DWObject.IfShowFileDialog = true; DWObject.LoadImageEx(" ", 5); } diff --git a/types/dwt/index.d.ts b/types/dwt/index.d.ts index b19980603e..b940c6ae4e 100644 --- a/types/dwt/index.d.ts +++ b/types/dwt/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for dwt 13.3 +// Type definitions for dwt 13.4 // Project: http://www.dynamsoft.com/Products/WebTWAIN_Overview.aspx // Definitions by: Xiao Ling // Josh Hall +// Lincoln Hu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -10,68 +11,11 @@ * Product: Dynamsoft Web Twain * Web Site: http://www.dynamsoft.com * -* Copyright 2017, Dynamsoft Corporation +* Copyright 2018, Dynamsoft Corporation * Author: Dynamsoft Support Team -* Version: 13.3 +* Version: 13.4 */ -/** - * Dynamsoft WebTwain Addon PDF - */ -declare enum EnumDWT_ConverMode { - CM_DEFAULT = 0, - TWPT_CM_RENDERALLGRAY = 1 -} - -/** - * @class - */ -interface PDF { - /** - * Download and install pdf rasterizer add-on on the local system. - * @method Dynamsoft.WebTwain#Download - * @param {string} remoteFile specifies the value of which frame to get. - * @param {function} optionalAsyncSuccessFunc optional. The function to call when the download succeeds. Please refer to the function prototype OnSuccess. - * @param {function} optionalAsyncFailureFunc optional. The function to call when the download fails. Please refer to the function prototype OnFailure. - * @return {bool} - */ - Download(remoteFile: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean; - - /** - * Input the password to decrypt PDF files using PDF Rasterizer add-on. - * @method Dynamsoft.WebTwain#SetPassword - * @param {string} password Specifies the PDF password. - * @return {bool} - */ - SetPassword(password: string): boolean; - - /** - * Set the image convert mode for PDF Rasterizer in Dynamic Web TWAIN. - * @method Dynamsoft.WebTwain#SetConvertMode - * @param {EnumDWT_ConverMode} convertMode Specifies the image convert mode. - * @return {bool} - */ - SetConvertMode(convertMode: EnumDWT_ConverMode): boolean; - - /** - * Set the output resolution for the PDF Rasterizer in Dynamic Web TWAIN. - * @method Dynamsoft.WebTwain#ReadRect - * @param {float} fResolution Specifies the resolution for convert image from PDF file. - * @return {bool} - */ - SetResolution(fResolution: number): boolean; - - /** - * Judges whether the local PDF is text-based or not. - * @method Dynamsoft.WebTwain#ReadRect - * @param {string} localFile specifies the local path of the target PDF. - * @return {bool} - */ - IsTextBasedPDF(localFile: string): boolean; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// - /** * @namespace Dynamsoft */ @@ -1318,21 +1262,11 @@ interface Container { Height: string | number; } -interface WebTwainAddon { - PDF: PDF; -} - /** * @class */ // properties (get/set) / sync functions interface WebTwain { - /** - * Returns addon. - * @type {WebTwainAddon} - */ - Addon: WebTwainAddon; - /** * Returns or sets whether multi-page selection is supported. * @type {bool} diff --git a/types/dwt/tsconfig.json b/types/dwt/tsconfig.json index db2ac6bbf4..13f35fcfbf 100644 --- a/types/dwt/tsconfig.json +++ b/types/dwt/tsconfig.json @@ -18,6 +18,7 @@ }, "files": [ "index.d.ts", + "addon.pdf.d.ts", "dwt-tests.ts" ] } \ No newline at end of file diff --git a/types/elasticsearch/elasticsearch-tests.ts b/types/elasticsearch/elasticsearch-tests.ts index 10c4659998..e21f84dc48 100644 --- a/types/elasticsearch/elasticsearch-tests.ts +++ b/types/elasticsearch/elasticsearch-tests.ts @@ -266,6 +266,30 @@ client.search({ } }); +client.updateByQuery({ + index: 'myIndex', + type: 'mytype', +}, (error, response) => { + const { + took, + timed_out, + updated, + deleted, + batches, + version_conflicts, + noops, + retries, + throttled_millis, + throttled_until_millis, + total, + failures + } = response; + + const { bulk, search } = retries; + + // ... +}); + client.indices.updateAliases({ body: { actions: [ diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index c6b05da9a0..e60e8d86c3 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -89,8 +89,8 @@ export class Client { termvectors(params: TermvectorsParams, callback: (error: any, response: any) => void): void; update(params: UpdateDocumentParams): Promise; update(params: UpdateDocumentParams, callback: (error: any, response: any) => void): void; - updateByQuery(params: UpdateDocumentByQueryParams): Promise; - updateByQuery(params: UpdateDocumentByQueryParams, callback: (error: any, response: any) => void): void; + updateByQuery(params: UpdateDocumentByQueryParams): Promise; + updateByQuery(params: UpdateDocumentByQueryParams, callback: (error: any, response: UpdateDocumentByQueryResponse) => void): void; close(): void; } @@ -785,6 +785,25 @@ export interface UpdateDocumentByQueryParams extends GenericParams { type: NameList; } +export interface UpdateDocumentByQueryResponse { + took: number; + timed_out: boolean; + updated: number; + deleted: number; + batches: number; + version_conflicts: number; + noops: number; + retries: { + bulk: number; + search: number; + }; + throttled_millis: number; + requests_per_second: number; + throttled_until_millis: number; + total: number; + failures: any[]; +} + export interface Cat { aliases(params: CatAliasesParams, callback: (error: any, response: any) => void): void; aliases(params: CatAliasesParams): Promise; diff --git a/types/ember-data/index.d.ts b/types/ember-data/index.d.ts index 7b78770489..9eec5ed467 100644 --- a/types/ember-data/index.d.ts +++ b/types/ember-data/index.d.ts @@ -23,6 +23,9 @@ declare module 'ember-data' { type AttributesFor = keyof Model; // TODO: filter to attr properties only (TS 2.8) type RelationshipsFor = keyof Model; // TODO: filter to hasMany/belongsTo properties only (TS 2.8) + export interface ChangedAttributes { + [key: string]: [any, any] | undefined; + } interface AttributeMeta { type: keyof TransformRegistry; options: object; @@ -500,7 +503,7 @@ declare module 'ember-data' { * Returns an object, whose keys are changed properties, and value is * an [oldProp, newProp] array. */ - changedAttributes(): {}; + changedAttributes(): ChangedAttributes; /** * If the model `hasDirtyAttributes` this function will discard any unsaved * changes. If the model `isNew` it will be removed from the store. diff --git a/types/ember-data/test/model.ts b/types/ember-data/test/model.ts index a18167dbee..63bda2588e 100644 --- a/types/ember-data/test/model.ts +++ b/types/ember-data/test/model.ts @@ -1,5 +1,5 @@ import Ember from 'ember'; -import DS from 'ember-data'; +import DS, { ChangedAttributes } from 'ember-data'; import { assertType } from "./lib/assert"; const Person = DS.Model.extend({ @@ -30,3 +30,7 @@ assertType(user.get('createdAt')); user.serialize(); user.serialize({ includeId: true }); +user.serialize({ includeId: true }); + +const attributes = user.changedAttributes(); +assertType(attributes); diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index a89d6bcc6f..dd3ed1ec64 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -2078,6 +2078,7 @@ declare module 'ember' { * Transition the application into another route. The route may * be either a single route or route path: */ + transitionTo(name: string, options?: {}): Transition; transitionTo(name: string, ...models: any[]): Transition; transitionTo(name: string, options: {}): Transition; } @@ -3305,6 +3306,7 @@ declare module 'ember' { * @param options optional hash with a queryParams property containing a * mapping of query parameters */ + isActive(routeName: string, options?: { queryParams: object }): boolean; isActive(routeName: string, models: RouteModel, options?: { queryParams: object }): boolean; isActive(routeName: string, modelsA: RouteModel, modelsB: RouteModel, options?: { queryParams: object }): boolean; isActive(routeName: string, modelsA: RouteModel, modelsB: RouteModel, modelsC: RouteModel, options?: { queryParams: object }): boolean; @@ -3322,6 +3324,7 @@ declare module 'ember' { * containing a mapping of query parameters * @returns the Transition object associated with this attempted transition */ + replaceWith(routeNameOrUrl: string, options?: { queryParams: object }): Ember.Transition; replaceWith(routeNameOrUrl: string, models: RouteModel, options?: { queryParams: object }): Ember.Transition; replaceWith(routeNameOrUrl: string, modelsA: RouteModel, modelsB: RouteModel, options?: { queryParams: object }): Ember.Transition; replaceWith(routeNameOrUrl: string, modelsA: RouteModel, modelsB: RouteModel, modelsC: RouteModel, options?: { queryParams: object }): Ember.Transition; @@ -3339,6 +3342,7 @@ declare module 'ember' { * containing a mapping of query parameters * @returns the Transition object associated with this attempted transition */ + transitionTo(routeNameOrUrl: string, options?: { queryParam: object }): Ember.Transition; transitionTo(routeNameOrUrl: string, models: RouteModel, options?: { queryParams: object }): Ember.Transition; transitionTo(routeNameOrUrl: string, modelsA: RouteModel, modelsB: RouteModel, options?: { queryParams: object }): Ember.Transition; transitionTo(routeNameOrUrl: string, modelsA: RouteModel, modelsB: RouteModel, modelsC: RouteModel, options?: { queryParams: object }): Ember.Transition; @@ -3355,6 +3359,7 @@ declare module 'ember' { * a mapping of query parameters * @returns the string representing the generated URL */ + urlFor(routeName: string, options?: { queryParams: object }): string; urlFor(routeName: string, models: RouteModel, options?: { queryParams: object }): string; urlFor(routeName: string, modelsA: RouteModel, modelsB: RouteModel, options?: { queryParams: object }): string; urlFor(routeName: string, modelsA: RouteModel, modelsB: RouteModel, modelsC: RouteModel, options?: { queryParams: object }): string; diff --git a/types/ember/test/router.ts b/types/ember/test/router.ts index 9ec79ce281..c663083679 100755 --- a/types/ember/test/router.ts +++ b/types/ember/test/router.ts @@ -22,3 +22,21 @@ AppRouter.map(function() { this.mount('my-engine'); this.mount('my-engine', { as: 'some-other-engine', path: '/some-other-engine'}); }); + +const RouterServiceConsumer = Ember.Service.extend({ + router: Ember.inject.service('router'), + transitionWithoutModel() { + Ember.get(this, 'router') + .transitionTo('some-route'); + }, + transitionWithModel() { + const model = Ember.Object.create(); + Ember.get(this, 'router') + .transitionTo('some.other.route', model); + }, + transitionWithModelAndOptions() { + const model = Ember.Object.create(); + Ember.get(this, 'router') + .transitionTo('index', model, { queryParams: { search: 'ember' }}); + } +}); diff --git a/types/enhanced-resolve/index.d.ts b/types/enhanced-resolve/index.d.ts index 5a39b4f6d0..1cf3a3397a 100644 --- a/types/enhanced-resolve/index.d.ts +++ b/types/enhanced-resolve/index.d.ts @@ -1,7 +1,8 @@ // Type definitions for enhanced-resolve v3.0.0 // Project: https://github.com/webpack/enhanced-resolve.git -// Definitions by: e-cloud , Onigoetz +// Definitions by: e-cloud , Onigoetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// /// diff --git a/types/enhanced-resolve/tsconfig.json b/types/enhanced-resolve/tsconfig.json index 9c87f7e7a1..c2716adaa1 100644 --- a/types/enhanced-resolve/tsconfig.json +++ b/types/enhanced-resolve/tsconfig.json @@ -14,7 +14,10 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "paths": { + "tapable": ["tapable/v0"] + } }, "files": [ "index.d.ts", diff --git a/types/es6-shim/index.d.ts b/types/es6-shim/index.d.ts index 51824fc932..2cf61a9362 100644 --- a/types/es6-shim/index.d.ts +++ b/types/es6-shim/index.d.ts @@ -500,7 +500,7 @@ interface PromiseConstructor { /** * Creates a new Promise. * @param executor A callback used to initialize the promise. This callback is passed two arguments: - * a resolve callback used resolve the promise with a value or the result of another promise, + * a resolve callback used to resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; diff --git a/types/event-emitter-es6/event-emitter-es6-tests.ts b/types/event-emitter-es6/event-emitter-es6-tests.ts new file mode 100644 index 0000000000..8001d2605e --- /dev/null +++ b/types/event-emitter-es6/event-emitter-es6-tests.ts @@ -0,0 +1,17 @@ +import EventEmitter = require("event-emitter-es6"); + +const ee = new EventEmitter(); +const ee1 = new EventEmitter({ emitDelay: 50 }); +const ee2 = new EventEmitter({ strictMode: true }); +const ee3 = new EventEmitter({ strictMode: false, emitDelay: 5 }); +const ee4 = new EventEmitter({}); + +ee.on("test", () => {}); +ee.once("test", () => {}); +ee.off("test", () => {}); +ee.off("test"); +ee.emit("test"); +ee.emit("test", 1, 2, 3, "a", "b", "c"); +ee.emitSync("test"); +ee.emitSync("test", 1, 2, 3, "a", "b", "c"); +ee.destroy(); diff --git a/types/event-emitter-es6/index.d.ts b/types/event-emitter-es6/index.d.ts new file mode 100644 index 0000000000..840f2ddf38 --- /dev/null +++ b/types/event-emitter-es6/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for event-emitter-es6 1.1 +// Project: https://github.com/insane-jo/event-emitter#readme +// Definitions by: Anton Strömkvist +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Options { + emitDelay?: number; + strictMode?: boolean; +} + +type Listener = (...args: any[]) => void; + +declare class EventEmitter { + constructor(options?: Options); + on(type: string, listener: Listener): void; + once(type: string, listener: Listener): void; + off(type: string, listener?: Listener): void; + emit(type: string, ...eventArgs: any[]): void; + emitSync(type: string, ...eventArgs: any[]): void; + destroy(): void; +} + +export = EventEmitter; diff --git a/types/event-emitter-es6/tsconfig.json b/types/event-emitter-es6/tsconfig.json new file mode 100644 index 0000000000..f450ea2a8a --- /dev/null +++ b/types/event-emitter-es6/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "event-emitter-es6-tests.ts" + ] +} diff --git a/types/event-emitter-es6/tslint.json b/types/event-emitter-es6/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/event-emitter-es6/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/excel-style-dataformatter/excel-style-dataformatter-tests.ts b/types/excel-style-dataformatter/excel-style-dataformatter-tests.ts new file mode 100644 index 0000000000..828771242e --- /dev/null +++ b/types/excel-style-dataformatter/excel-style-dataformatter-tests.ts @@ -0,0 +1,33 @@ +import * as DataFormatter from "excel-style-dataformatter"; +import * as enLocales from "excel-style-dataformatter/lib/locales/en-US"; +import * as ruLocales from "excel-style-dataformatter/lib/locales/ru"; + +const localesOptions: DataFormatter.LocalesOptions = { + name: "test", + months: ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'], + monthsShort: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'], + days: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'], + daysShort: ['su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'], + thousandSeparator: ',', + decimalSeparator: '.', + formats: { + 'Test format 1': '#.#', + 'Test format 2': '$ #,##0.00;[Red]$ -#,##0.00', + } +}; +const formatterOptions: DataFormatter.FormatterOptions = { + debug: true, + UTCOffset: 100, + locale: "test", + transformCode: (code: string): string => { + return code + "string"; + }, + locales: [localesOptions, ruLocales] +}; +const dataFormatter1 = new DataFormatter(formatterOptions); +const dataFormatter2 = new DataFormatter(); +dataFormatter2.defineLocales([enLocales, ruLocales]); +dataFormatter2.setLocale("ru"); +dataFormatter2.setUTCOffset(null); +dataFormatter2.setUTCOffset(100); +const result: DataFormatter.FormatResult = dataFormatter2.format("testValue", "testType", "testFormat"); diff --git a/types/excel-style-dataformatter/index.d.ts b/types/excel-style-dataformatter/index.d.ts new file mode 100644 index 0000000000..7f76ee6987 --- /dev/null +++ b/types/excel-style-dataformatter/index.d.ts @@ -0,0 +1,63 @@ +// Type definitions for excel-style-dataformatter 2.0 +// Project: https://github.com/fakundo/Excel-Style-Javascript-DataFormatter +// Definitions by: SanderDeWaal1992 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class DataFormatter { + constructor(options?: DataFormatter.FormatterOptions); + + /** + * Format a value + * @param value + * @param type value type + * @param format format preset + */ + format(value: any, type: string, format: string): DataFormatter.FormatResult; + /** + * Defines locales + * @param locales + */ + defineLocales(locales: DataFormatter.LocalesOptions[]): void; + /** + * Sets locale + * If locale doesn't exist, sets default + * @param locale + */ + setLocale(locale: string): void; + /** + * Sets UTC offset for dates + * @param offset in minutes + */ + setUTCOffset(offset: number | null): void; +} + +declare namespace DataFormatter { + interface LocalesOptions { + name: string; + months: string[]; + monthsShort: string[]; + days: string[]; + daysShort: string[]; + thousandSeparator: string; + decimalSeparator: string; + formats: { + [index: string]: string + }; + } + interface FormatterOptions { + debug?: boolean; + UTCOffset?: number | null; + locale?: string; + transformCode?: (code: any) => any; + locales?: LocalesOptions[]; + } + + interface FormatResult { + value: string; + align: string; + color: string; + pattern: string; + } +} + +export = DataFormatter; diff --git a/types/excel-style-dataformatter/lib/locales/en-US.d.ts b/types/excel-style-dataformatter/lib/locales/en-US.d.ts new file mode 100644 index 0000000000..591678aea8 --- /dev/null +++ b/types/excel-style-dataformatter/lib/locales/en-US.d.ts @@ -0,0 +1,4 @@ +import * as DataFormatter from "../../index"; + +declare const locale: DataFormatter.LocalesOptions; +export = locale; diff --git a/types/excel-style-dataformatter/lib/locales/ru.d.ts b/types/excel-style-dataformatter/lib/locales/ru.d.ts new file mode 100644 index 0000000000..591678aea8 --- /dev/null +++ b/types/excel-style-dataformatter/lib/locales/ru.d.ts @@ -0,0 +1,4 @@ +import * as DataFormatter from "../../index"; + +declare const locale: DataFormatter.LocalesOptions; +export = locale; diff --git a/types/excel-style-dataformatter/tsconfig.json b/types/excel-style-dataformatter/tsconfig.json new file mode 100644 index 0000000000..563681d3ac --- /dev/null +++ b/types/excel-style-dataformatter/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lib/locales/en-US.d.ts", + "lib/locales/ru.d.ts", + "excel-style-dataformatter-tests.ts" + ] +} diff --git a/types/excel-style-dataformatter/tslint.json b/types/excel-style-dataformatter/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/excel-style-dataformatter/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/execa/execa-tests.ts b/types/execa/execa-tests.ts index 2525091f2a..ecc966d3d5 100644 --- a/types/execa/execa-tests.ts +++ b/types/execa/execa-tests.ts @@ -1,46 +1,38 @@ import assert = require('assert'); import execa = require('execa'); -import { PassThrough } from "stream"; +import { PassThrough } from 'stream'; -execa('unicorns') - .then(result => { - assert(result.cmd === 'unicorns'); - assert(result.code === 0); - assert(result.failed === false); - assert(result.killed === false); - assert(result.signal === null); - assert(result.stderr === 'bad unicorns'); - assert(result.stdout === 'good unicorns'); - assert(result.timedOut === false); - }); +execa('unicorns').then(result => { + assert(result.cmd === 'unicorns'); + assert(result.code === 0); + assert(result.failed === false); + assert(result.killed === false); + assert(result.signal === null); + assert(result.stderr === 'bad unicorns'); + assert(result.stdout === 'good unicorns'); + assert(result.timedOut === false); +}); -execa('foo') - .catch(error => { - assert(error.cmd === 'foo'); - assert(error.code === 128); - assert(error.failed === true); - assert(error.killed === false); - assert(error.signal === 'SIGINT'); - assert(error.stderr === 'stderr'); - assert(error.stdout === 'stdout'); - assert(error.timedOut === false); - }); +execa('foo').catch(error => { + assert(error.cmd === 'foo'); + assert(error.code === 128); + assert(error.failed === true); + assert(error.killed === false); + assert(error.signal === 'SIGINT'); + assert(error.stderr === 'stderr'); + assert(error.stdout === 'stdout'); + assert(error.timedOut === false); +}); -execa('noop', ['foo']) - .then(result => result.stderr.toLocaleLowerCase()); +execa('noop', ['foo']).then(result => result.stderr.toLocaleLowerCase()); -execa.stdout('unicorns') - .then(stdout => stdout.toLocaleLowerCase()); -execa.stdout('echo', ['unicorns']) - .then(stdout => stdout.toLocaleLowerCase()); +execa.stdout('unicorns').then(stdout => stdout.toLocaleLowerCase()); +execa.stdout('echo', ['unicorns']).then(stdout => stdout.toLocaleLowerCase()); -execa.stderr('unicorns') - .then(stderr => stderr.toLocaleLowerCase()); -execa.stderr('echo', ['unicorns']) - .then(stderr => stderr.toLocaleLowerCase()); +execa.stderr('unicorns').then(stderr => stderr.toLocaleLowerCase()); +execa.stderr('echo', ['unicorns']).then(stderr => stderr.toLocaleLowerCase()); -execa.shell('echo unicorns') - .then(result => result.stdout.toLocaleLowerCase()); +execa.shell('echo unicorns').then(result => result.stdout.toLocaleLowerCase()); { let result: string; @@ -54,14 +46,14 @@ execa.shell('echo unicorns') execa('echo', ['unicorns']).stdout.pipe(process.stdout); execa('echo', ['unicorns']).stderr.pipe(process.stderr); -execa('forever', {extendEnv: false}).pid; -execa('forever', {argv0: 'hi'}).pid; -execa('forever', {localDir: '~'}).pid; -execa('forever', {reject: false}).pid; -execa('forever', {cleanup: false}).pid; -execa('forever', {stdin: 1}).pid; -execa('forever', {stdout: 'ignore'}).pid; -execa('forever', {stderr: undefined}).pid; +execa('forever', { extendEnv: false }).pid; +execa('forever', { argv0: 'hi' }).pid; +execa('forever', { localDir: '~' }).pid; +execa('forever', { reject: false }).pid; +execa('forever', { cleanup: false }).pid; +execa('forever', { stdin: 1 }).pid; +execa('forever', { stdout: 'ignore' }).pid; +execa('forever', { stderr: undefined }).pid; async () => { const { stdout } = await execa('noop', ['foo'], { stripEof: false }); @@ -119,7 +111,9 @@ async () => { } async () => { - const { timedOut, code } = await execa('delay', ['3000', '22'], { timeout: 9000 }); + const { timedOut, code } = await execa('delay', ['3000', '22'], { + timeout: 9000 + }); assert(timedOut === true); assert(code === 22); }; @@ -131,3 +125,10 @@ async () => { assert(stdout === 'foo'); }; + +const args: ReadonlyArray = ['bar']; +const stdio: ReadonlyArray<'ignore'> = ['ignore']; +execa('foo', args); +execa('foo', args, { + stdio +}); diff --git a/types/execa/index.d.ts b/types/execa/index.d.ts index c3aced26ee..067d36c368 100644 --- a/types/execa/index.d.ts +++ b/types/execa/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for execa 0.8 +// Type definitions for execa 0.9 // Project: https://github.com/sindresorhus/execa#readme // Definitions by: Douglas Duteil // BendingBender @@ -23,7 +23,11 @@ declare namespace execa { * Think of this as a mix of `child_process.execFile` and `child_process.spawn`. * @returns a `child_process` instance which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties. */ - (file: string, args?: string[], options?: Options): ExecaChildProcess; + ( + file: string, + args?: ReadonlyArray, + options?: Options + ): ExecaChildProcess; (file: string, options?: Options): ExecaChildProcess; /** @@ -32,7 +36,11 @@ declare namespace execa { * Think of this as a mix of `child_process.execFile` and `child_process.spawn`. * @returns a `child_process` instance which is enhanced to also be a `Promise` for `stdout`. */ - stdout(file: string, args?: string[], options?: Options): Promise; + stdout( + file: string, + args?: ReadonlyArray, + options?: Options + ): Promise; stdout(file: string, options?: Options): Promise; /** @@ -41,7 +49,11 @@ declare namespace execa { * Think of this as a mix of `child_process.execFile` and `child_process.spawn`. * @returns a `child_process` instance which is enhanced to also be a `Promise` for `stderr`. */ - stderr(file: string, args?: string[], options?: Options): Promise; + stderr( + file: string, + args?: ReadonlyArray, + options?: Options + ): Promise; stderr(file: string, options?: Options): Promise; /** @@ -59,7 +71,11 @@ declare namespace execa { * @returns the same result object as `child_process.spawnSync`. * @throws an `Error` if the command fails. */ - sync(file: string, args?: string[], options?: SyncOptions): ExecaReturns; + sync( + file: string, + args?: ReadonlyArray, + options?: SyncOptions + ): ExecaReturns; sync(file: string, options?: SyncOptions): ExecaReturns; /** @@ -71,7 +87,15 @@ declare namespace execa { shellSync(command: string, options?: Options): ExecaReturns; } - type StdIOOption = 'pipe' | 'ipc' | 'ignore' | Stream | number | null | undefined; + type StdIOOption = + | 'pipe' + | 'ipc' + | 'ignore' + | 'inherit' + | Stream + | number + | null + | undefined; interface CommonOptions { /** @@ -103,7 +127,7 @@ declare namespace execa { * * @see https://nodejs.org/api/child_process.html#child_process_options_stdio */ - stdio?: 'pipe' | 'ignore' | 'inherit' | StdIOOption[]; + stdio?: 'pipe' | 'ignore' | 'inherit' | ReadonlyArray; /** * Prepare child to run independently of its parent process. * Specific behavior depends on the platform. @@ -253,10 +277,16 @@ declare namespace execa { type ExecaError = Error & ExecaReturns; interface ExecaChildPromise { - catch(onrejected?: ((reason: ExecaError) => TResult | PromiseLike) | null): Promise; + catch( + onrejected?: + | ((reason: ExecaError) => TResult | PromiseLike) + | null + ): Promise; } - type ExecaChildProcess = ChildProcess & ExecaChildPromise & Promise; + type ExecaChildProcess = ChildProcess & + ExecaChildPromise & + Promise; } declare var execa: execa.ExecaStatic; diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index 187d62b2ee..d1b543c591 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -199,10 +199,7 @@ async () => { onError={(error) => console.log(error)} /> ); () => ( - + ); const barcodeReadCallback = () => {}; @@ -292,14 +289,37 @@ async () => { }; async () => { + // Video test const result = await ImagePicker.launchImageLibraryAsync({ - mediaTypes: ImagePicker.MediaTypeOptions.Videos + mediaTypes: ImagePicker.MediaTypeOptions.Videos, }); if (!result.cancelled) { result.uri; result.width; result.height; + result.duration; + result.type; + } +}; + +async () => { + // Image test + const result = await ImagePicker.launchImageLibraryAsync({ + mediaTypes: ImagePicker.MediaTypeOptions.Images, + base64: true, + aspect: [4, 3], + quality: 1, + exif: true, + }); + + if (!result.cancelled) { + result.uri; + result.width; + result.height; + result.exif; + result.base64; + result.type; } }; diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index a747a881e6..8661cac727 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -5,6 +5,7 @@ // Jan Aagaard // Sergio Sánchez // Fernando Helwanger +// Umidbek Karimov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -99,20 +100,16 @@ export namespace Amplitude { // #region AppLoading /** The following props are recommended, but optional for the sake of backwards compatibility (they were introduced in SDK21). If you do not provide any props, you are responsible for coordinating loading assets, handling errors, and updating state to unmount the `AppLoading` component. */ -export type AppLoadingProps = { +export interface AppLoadingProps { /** A `function` that returns a `Promise`. The `Promise` should resolve when the app is done loading data and assets. */ - startAsync: () => Promise; + startAsync?: () => Promise; /** Required if you provide `startAsync`. Called when `startAsync` resolves or rejects. This should be used to set state and unmount the `AppLoading` component. */ - onFinish: () => void; + onFinish?: () => void; /** If `startAsync` throws an error, it is caught and passed into the function provided to `onError`. */ onError?: (error: Error) => void; -} | { - startAsync: null; - onFinish: null; - onError?: null; -}; +} /** * A React component that tells Expo to keep the app loading screen open if it is the first and only component rendered in your app. When it is removed, the loading screen will disappear and your app will be visible. @@ -1421,6 +1418,10 @@ export namespace ImagePicker { uri: string; width: number; height: number; + type: 'video' | 'image'; + base64?: string; + exif?: object; + duration?: number; } type ImageResult = { cancelled: true } | ({ cancelled: false } & ImageInfo); @@ -1437,6 +1438,8 @@ export namespace ImagePicker { allowsEditing?: boolean; aspect?: [number, number]; quality?: number; + base64?: boolean; + exif?: boolean; mediaTypes?: keyof _MediaTypeOptions; } diff --git a/types/expo/tsconfig.json b/types/expo/tsconfig.json index 03b9c139b1..7711f49776 100644 --- a/types/expo/tsconfig.json +++ b/types/expo/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ + "dom", "es6" ], "jsx": "react", @@ -21,4 +22,4 @@ "index.d.ts", "expo-tests.tsx" ] -} \ No newline at end of file +} diff --git a/types/expo/v23/expo-tests.tsx b/types/expo/v23/expo-tests.tsx index 0764a4d53e..51b3f30d39 100644 --- a/types/expo/v23/expo-tests.tsx +++ b/types/expo/v23/expo-tests.tsx @@ -106,10 +106,7 @@ async () => { onError={(error) => console.log(error)} /> ); () => ( - + ); const barcodeReadCallback = () => {}; diff --git a/types/expo/v23/index.d.ts b/types/expo/v23/index.d.ts index 54154d8d6b..78de7bf415 100644 --- a/types/expo/v23/index.d.ts +++ b/types/expo/v23/index.d.ts @@ -330,15 +330,12 @@ export class Video extends Component { /** * AppLoading */ -export type AppLoadingProperties = { - startAsync: () => Promise; - onFinish: () => void; +export interface AppLoadingProperties { + startAsync?: () => Promise; + onFinish?: () => void; onError?: (error: Error) => void; -} | { - startAsync: null; - onFinish: null; - onError?: null; -}; +} + export class AppLoading extends Component { } /** diff --git a/types/expo/v23/tsconfig.json b/types/expo/v23/tsconfig.json index 3d85e281ed..295d9da342 100644 --- a/types/expo/v23/tsconfig.json +++ b/types/expo/v23/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "jsx": "react", "noImplicitAny": true, @@ -29,4 +30,4 @@ "index.d.ts", "expo-tests.tsx" ] -} \ No newline at end of file +} diff --git a/types/expo/v24/expo-tests.tsx b/types/expo/v24/expo-tests.tsx index 77f9bbba87..8749a5993c 100644 --- a/types/expo/v24/expo-tests.tsx +++ b/types/expo/v24/expo-tests.tsx @@ -196,10 +196,7 @@ async () => { onError={(error) => console.log(error)} /> ); () => ( - + ); const barcodeReadCallback = () => {}; diff --git a/types/expo/v24/index.d.ts b/types/expo/v24/index.d.ts index 4bf5e48dc9..829e9730a7 100644 --- a/types/expo/v24/index.d.ts +++ b/types/expo/v24/index.d.ts @@ -99,20 +99,16 @@ export namespace Amplitude { // #region AppLoading /** The following props are recommended, but optional for the sake of backwards compatibility (they were introduced in SDK21). If you do not provide any props, you are responsible for coordinating loading assets, handling errors, and updating state to unmount the `AppLoading` component. */ -export type AppLoadingProps = { +export interface AppLoadingProps { /** A `function` that returns a `Promise`. The `Promise` should resolve when the app is done loading data and assets. */ - startAsync: () => Promise; + startAsync?: () => Promise; /** Required if you provide `startAsync`. Called when `startAsync` resolves or rejects. This should be used to set state and unmount the `AppLoading` component. */ - onFinish: () => void; + onFinish?: () => void; /** If `startAsync` throws an error, it is caught and passed into the function provided to `onError`. */ onError?: (error: Error) => void; -} | { - startAsync: null; - onFinish: null; - onError?: null; -}; +} /** * A React component that tells Expo to keep the app loading screen open if it is the first and only component rendered in your app. When it is removed, the loading screen will disappear and your app will be visible. diff --git a/types/expo/v24/tsconfig.json b/types/expo/v24/tsconfig.json index 87b7b33224..dffdd0aa8c 100644 --- a/types/expo/v24/tsconfig.json +++ b/types/expo/v24/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "jsx": "react", "noImplicitAny": true, @@ -29,4 +30,4 @@ "index.d.ts", "expo-tests.tsx" ] -} \ No newline at end of file +} diff --git a/types/express-bunyan-logger/express-bunyan-logger-tests.ts b/types/express-bunyan-logger/express-bunyan-logger-tests.ts new file mode 100644 index 0000000000..daac949c0e --- /dev/null +++ b/types/express-bunyan-logger/express-bunyan-logger-tests.ts @@ -0,0 +1,24 @@ +import Bunyan = require('bunyan'); +import expressBunyan = require('express-bunyan-logger'); + +// works with no options +const middleware = expressBunyan({}); +const middleware2 = expressBunyan.errorLogger({}); + +// format accepts both string and function +const middleware3 = expressBunyan({ + format: ':name' +}); +const middleware4 = expressBunyan({ + format(meta: any) { + return 'foo'; + } +}); + +// works when provided a bunyan logger +const logger = Bunyan.createLogger({ + name: 'myLogger' +}); +const middleware5 = expressBunyan({ + logger +}); diff --git a/types/express-bunyan-logger/index.d.ts b/types/express-bunyan-logger/index.d.ts new file mode 100644 index 0000000000..6697a26a20 --- /dev/null +++ b/types/express-bunyan-logger/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for express-bunyan-logger 1.3 +// Project: https://github.com/villadora/express-bunyan-logger +// Definitions by: Shrey Jain +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import Bunyan = require('bunyan'); +import express = require('express'); + +export = Factory; + +declare function Factory(options?: Factory.Options): express.RequestHandler; + +declare namespace Factory { + type FormatFunction = (meta: any) => string; + type IncludesFunction = (req: express.Request, res: express.Response) => any; + type RequestIdGenFunction = (req: express.Request) => string; + type LevelFunction = (status: number, err: Error | null, meta: any) => string; + + interface Options { + logger?: Bunyan; + format?: string | FormatFunction; + parseUA?: boolean; + levelFn?: LevelFunction; + includesFn?: IncludesFunction; + excludes?: string[]; + obfuscate?: string[]; + obfuscatePlaceholder?: string; + serializers?: { [field: string]: Bunyan.Serializer }; + immediate?: boolean; + genReqId?: RequestIdGenFunction; + } + + function errorLogger(options?: Options): express.ErrorRequestHandler; +} diff --git a/types/express-bunyan-logger/tsconfig.json b/types/express-bunyan-logger/tsconfig.json new file mode 100644 index 0000000000..8079293b99 --- /dev/null +++ b/types/express-bunyan-logger/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-bunyan-logger-tests.ts" + ] +} diff --git a/types/express-bunyan-logger/tslint.json b/types/express-bunyan-logger/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-bunyan-logger/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/express-graphql/express-graphql-tests.ts b/types/express-graphql/express-graphql-tests.ts index 482b15c186..6fdfc0d945 100644 --- a/types/express-graphql/express-graphql-tests.ts +++ b/types/express-graphql/express-graphql-tests.ts @@ -14,13 +14,13 @@ const graphqlOption: graphqlHTTP.OptionsObj = { extensions: (args) => { } }; -const graphqlOptionRequest = (request: express.Request): graphqlHTTP.OptionsObj => ({ +const graphqlOptionRequest = (request: express.Request, response: express.Response): graphqlHTTP.OptionsObj => ({ graphiql: true, schema: schema, context: request.session }); -const graphqlOptionRequestAsync = async (request: express.Request): Promise => { +const graphqlOptionRequestAsync = async (request: express.Request, response: express.Response): Promise => { return { graphiql: true, schema: await Promise.resolve(schema), diff --git a/types/express-graphql/index.d.ts b/types/express-graphql/index.d.ts index 166bdae6e7..ade08f1729 100644 --- a/types/express-graphql/index.d.ts +++ b/types/express-graphql/index.d.ts @@ -16,7 +16,7 @@ declare namespace graphqlHTTP { * Used to configure the graphQLHTTP middleware by providing a schema * and other configuration options. */ - export type Options = ((req: Request) => OptionsObj) | ((req: Request) => Promise) | OptionsObj + export type Options = ((req: Request, res: Response) => OptionsObj) | ((req: Request, res: Response) => Promise) | OptionsObj export type OptionsObj = { /** * A GraphQL schema from graphql-js. diff --git a/types/extract-text-webpack-plugin/index.d.ts b/types/extract-text-webpack-plugin/index.d.ts index 9f17a66da0..61b381d253 100644 --- a/types/extract-text-webpack-plugin/index.d.ts +++ b/types/extract-text-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/webpack-contrib/extract-text-webpack-plugin // Definitions by: flying-sheep , kayo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin, NewLoader, OldLoader } from 'webpack'; diff --git a/types/ez-plus/ez-plus-tests.ts b/types/ez-plus/ez-plus-tests.ts new file mode 100644 index 0000000000..df442607f4 --- /dev/null +++ b/types/ez-plus/ez-plus-tests.ts @@ -0,0 +1,14 @@ +import { Options } from "ez-plus"; + +$(document).ready(() => { + // basic usage + $('#image').ezPlus(); + + // with options + const options: Options = { + zoomLens: true, + zoomType: 'lens', + cursor: 'crosshair' + }; + $('#image').ezPlus(options); +}); diff --git a/types/ez-plus/index.d.ts b/types/ez-plus/index.d.ts new file mode 100644 index 0000000000..3a372108d3 --- /dev/null +++ b/types/ez-plus/index.d.ts @@ -0,0 +1,214 @@ +// Type definitions for jQuery ElevateZoom Plus Plugin 1.2 +// Project: https://github.com/igorlino/elevatezoom-plus +// Definitions by: Anderson Friaça +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +export interface Options { + /** + * Activate responsivenes + */ + responsive?: boolean; + + /** + * Activate zoom on mouse scroll + */ + scrollZoom?: boolean; + + /** + * Activate simultaneous crossfade of images on gallery change + */ + imageCrossfade?: boolean; + + /** + * Activate spinner icon or url + */ + loadingIcon?: boolean | string; + + /** + * Activate easing + */ + easing?: boolean; + easingType?: string; + easingDuration?: number; + + /** + * Used when zoomType set to lens + */ + lensSize?: number; + + /** + * Width of the zoomWindow + */ + zoomWindowWidth?: number; + + /** + * Height of the zoomWindow + */ + zoomWindowHeight?: number; + + /** + * x-axis offset of the zoom window + */ + zoomWindowOffsetX?: number; + + /** + * y-axis offset of the zoom window + */ + zoomWindowOffsetY?: number; + zoomWindowPosition?: number | string; + + /** + * Speed of Lens fadeIn + */ + lensFadeIn?: number; + + /** + * Speed of Lens fadeOut + */ + lensFadeOut?: number; + + /** + * Speed of Window fadeIn + */ + zoomWindowFadeIn?: number; + + /** + * Speed of Window fadeOut + */ + zoomWindowFadeOut?: number; + + /** + * Speed of Tint fadeIn + */ + zoomTintFadeIn?: number; + + /** + * Speed of Tint fadeOut + */ + zoomTintFadeOut?: number; + + /** + * Border Size of the ZoomBox + */ + borderSize?: number; + + /** + * Enable Lens + */ + zoomLens?: boolean; + + /** + * Border Colour + */ + borderColour?: string; + + /** + * Width in pixels of the lens border + */ + lensBorder?: number; + + /** + * Type of lens + */ + lensShape?: 'square' | 'round'; + + /** + * Type of zoom + */ + zoomType?: 'lens' | 'window' | 'inner'; + containLensZoom?: boolean; + + /** + * Colour of the lens background + */ + lensColour?: string; + + /** + * Opacity of lens + */ + lensOpacity?: number; + lenszoom?: boolean; + + /** + * Enable a tint overlay + */ + tint?: boolean; + + /** + * Colour of the tin + */ + tintColour?: string; + + /** + * Opacity of the tint + */ + tintOpacity?: number; + + /** + * This assigns a set of gallery links to the zoom image + */ + gallery?: string; + + /** + * Type of cursor + */ + cursor?: 'default' | 'cursor' | 'crosshair'; + container?: string; + + /** + * Attribute to plugin use for zoom + */ + attrImageZoomSrc?: string; + + /** + * In pixels the dimensions you want to constrain on + */ + constrainSize?: number | false; + constrainType?: 'width' | 'height'; + debug?: boolean; + easingAmount?: number; + enabled?: boolean; + galleryActiveClass?: string; + gallerySelector?: string | false; + galleryItem?: string; + galleryEvent?: string; + mantainZoomAspectRatio?: boolean; + maxZoomLevel?: number | false; + minZoomLevel?: number; + preloading?: 0 | 1; + respond?: any[]; + + /** + * Steps of the scrollzoom + */ + scrollZoomIncrement?: number; + touchEnabled?: boolean; + zoomActivation?: 'click' | 'hover'; + + /** + * Zoom container parent selector + */ + zoomContainerAppendTo?: string; + + /** + * Identifier for the zoom container + */ + zoomId?: number; + + /** + * Zoom level of image + */ + zoomLevel?: number; + zIndex?: number; +} +declare global { + interface JQuery { + /** + * Initialize ElevateZoom Plugin + */ + ezPlus(options?: Options): JQuery; + } +} diff --git a/types/ez-plus/tsconfig.json b/types/ez-plus/tsconfig.json new file mode 100644 index 0000000000..14e9266312 --- /dev/null +++ b/types/ez-plus/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "ez-plus-tests.ts" + ] +} \ No newline at end of file diff --git a/types/ez-plus/tslint.json b/types/ez-plus/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/ez-plus/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file diff --git a/types/feathersjs__authentication-client/index.d.ts b/types/feathersjs__authentication-client/index.d.ts index 16f4f4a415..04275eb93c 100644 --- a/types/feathersjs__authentication-client/index.d.ts +++ b/types/feathersjs__authentication-client/index.d.ts @@ -2,6 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Abraao Alves , Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.3 export default function feathersAuthClient(config?: FeathersAuthClientConfig): () => void; diff --git a/types/feathersjs__authentication-jwt/index.d.ts b/types/feathersjs__authentication-jwt/index.d.ts index cc9e58be0d..b55adeed46 100644 --- a/types/feathersjs__authentication-jwt/index.d.ts +++ b/types/feathersjs__authentication-jwt/index.d.ts @@ -2,7 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Application } from '@feathersjs/feathers'; import { Request } from 'express'; @@ -45,7 +45,7 @@ export interface FeathersAuthenticationJWTOptions { } export class JWTVerifier { - constructor(app: Application, options: any); // the class constructor + constructor(app: Application, options: any); // the class constructor verify(req: Request, payload: any, done: (error: any, user?: any, info?: any) => void): void; } diff --git a/types/feathersjs__authentication-local/index.d.ts b/types/feathersjs__authentication-local/index.d.ts index 8b6af17a33..e935419263 100644 --- a/types/feathersjs__authentication-local/index.d.ts +++ b/types/feathersjs__authentication-local/index.d.ts @@ -2,7 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Application, @@ -57,7 +57,7 @@ export interface FeathersAuthenticationLocalOptions { } export class LocalVerifier { - constructor(app: Application, options: any); + constructor(app: Application, options: any); _comparePassword(entity: T, password: string): Promise; // compares password using bcrypt _normalizeResult(results: T[] | Paginated): Promise; // normalizes result from service to account for pagination diff --git a/types/feathersjs__authentication-oauth1/index.d.ts b/types/feathersjs__authentication-oauth1/index.d.ts index 54d4d2614a..eee59fd64a 100644 --- a/types/feathersjs__authentication-oauth1/index.d.ts +++ b/types/feathersjs__authentication-oauth1/index.d.ts @@ -2,7 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Application, @@ -60,7 +60,7 @@ export interface FeathersAuthenticationOAuth1Options { } export class OAuth1Verifier { - constructor(app: Application, options: any); + constructor(app: Application, options: any); _updateEntity(entity: any, data: { profile: any, accessToken: string, refreshToken: string }): Promise; // updates an existing entity _createEntity(data: { profile: any, accessToken: string, refreshToken: string }): Promise; // creates an entity if they didn't exist already diff --git a/types/feathersjs__authentication-oauth2/index.d.ts b/types/feathersjs__authentication-oauth2/index.d.ts index 5ac6976dac..fbce7514cd 100644 --- a/types/feathersjs__authentication-oauth2/index.d.ts +++ b/types/feathersjs__authentication-oauth2/index.d.ts @@ -2,7 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Application, @@ -62,7 +62,7 @@ export interface FeathersAuthenticationOAuth2Options { } export class OAuth2Verifier { - constructor(app: Application, options: any) + constructor(app: Application, options: any) _updateEntity(entity: any, data: { profile: any, accessToken: string, refreshToken: string }): Promise; // updates an existing entity _createEntity(data: { profile: any, accessToken: string, refreshToken: string }): Promise; // creates an entity if they didn't exist already diff --git a/types/feathersjs__configuration/index.d.ts b/types/feathersjs__configuration/index.d.ts index fe597c8360..abd7e53d70 100644 --- a/types/feathersjs__configuration/index.d.ts +++ b/types/feathersjs__configuration/index.d.ts @@ -2,6 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.3 import { Application } from '@feathersjs/feathers'; diff --git a/types/feathersjs__express/index.d.ts b/types/feathersjs__express/index.d.ts index eb49f00a78..f50203432f 100644 --- a/types/feathersjs__express/index.d.ts +++ b/types/feathersjs__express/index.d.ts @@ -2,7 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Application as FeathersApplication } from '@feathersjs/feathers'; import * as express from 'express'; diff --git a/types/feathersjs__primus-client/index.d.ts b/types/feathersjs__primus-client/index.d.ts index 4e51cd159c..fb348379ea 100644 --- a/types/feathersjs__primus-client/index.d.ts +++ b/types/feathersjs__primus-client/index.d.ts @@ -2,6 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.3 // primus removed its typings from the repo https://github.com/primus/primus/pull/623, as of 01/2018 there are none on DT export default function feathersPrimusClient(socket: any, options?: FeathersPrimusClientOptions): () => void; diff --git a/types/feathersjs__socketio-client/index.d.ts b/types/feathersjs__socketio-client/index.d.ts index f155bc50de..83fd71b0ed 100644 --- a/types/feathersjs__socketio-client/index.d.ts +++ b/types/feathersjs__socketio-client/index.d.ts @@ -2,6 +2,7 @@ // Project: http://feathersjs.com/ // Definitions by: Jan Lohage // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.3 /// diff --git a/types/feathersjs__socketio/index.d.ts b/types/feathersjs__socketio/index.d.ts index 7ba889dfbe..f0e082bf45 100644 --- a/types/feathersjs__socketio/index.d.ts +++ b/types/feathersjs__socketio/index.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript // TypeScript Version: 2.3 -/// /// +import SocketIO = require("socket.io"); export default function feathersSocketIO(callback?: (io: SocketIO.Server) => void): () => void; export default function feathersSocketIO(options: number | SocketIO.ServerOptions, callback?: (io: SocketIO.Server) => void): () => void; diff --git a/types/fetch-mock/fetch-mock-tests.ts b/types/fetch-mock/fetch-mock-tests.ts index 1d4b706105..84218fb9e1 100644 --- a/types/fetch-mock/fetch-mock-tests.ts +++ b/types/fetch-mock/fetch-mock-tests.ts @@ -61,6 +61,7 @@ fetchMock.patch("http://test.com", 200); fetchMock.patchOnce("http://test.com", 200); fetchMock.get("http://test.com", 200, {method: "GET"}); +fetchMock.get("http://test.com", 200, {method: "GET", overwriteRoutes: true}); fetchMock.post("http://test.com", 200, {method: "POST"}); fetchMock.put("http://test.com", 200, {method: "PUT"}); fetchMock.delete("http://test.com", 200, {method: "DELETE"}); diff --git a/types/fetch-mock/index.d.ts b/types/fetch-mock/index.d.ts index 15babcba34..fc94b18106 100644 --- a/types/fetch-mock/index.d.ts +++ b/types/fetch-mock/index.d.ts @@ -5,6 +5,7 @@ // Risto Keravuori // Chris Sinclair // Matt Tennison +// Quentin Bouygues // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -120,6 +121,12 @@ declare namespace fetchMock { * as specified above */ matcher?: MockMatcher; + /** + * This option allows for existing routes in a mock to be overwritten. + * It’s also possible to define multiple routes with ‘the same’ matcher. + * Default behaviour is to error + */ + overwriteRoutes?: boolean; /** * as specified above */ diff --git a/types/firefox-webext-browser/firefox-webext-browser-tests.ts b/types/firefox-webext-browser/firefox-webext-browser-tests.ts index 01d9cf9f3d..38169d573a 100644 --- a/types/firefox-webext-browser/firefox-webext-browser-tests.ts +++ b/types/firefox-webext-browser/firefox-webext-browser-tests.ts @@ -8,3 +8,7 @@ browser.manifest; // $ExpectError browser._manifest; // $ExpectType typeof _manifest browser._manifest.WebExtensionLangpackManifest; // $ExpectError browser._manifest.NativeManifest; // $ExpectError + +// browser.runtime +const port = browser.runtime.connect(); +port.postMessage(); // $ExpectError diff --git a/types/firefox-webext-browser/index.d.ts b/types/firefox-webext-browser/index.d.ts index dcbfb48648..d04b7f6aca 100644 --- a/types/firefox-webext-browser/index.d.ts +++ b/types/firefox-webext-browser/index.d.ts @@ -2296,10 +2296,10 @@ declare namespace browser.runtime { /** An object which allows two way communication with other pages. */ interface Port { name: string; - disconnect: () => void; + disconnect(): void; onDisconnect: events.Event; onMessage: events.Event; - postMessage: () => void; + postMessage(message: object): void; /** This property will **only** be present on ports passed to onConnect/onConnectExternal listeners. */ sender?: MessageSender; } diff --git a/types/frisby/index.d.ts b/types/frisby/index.d.ts index 366a3998d7..9057edae6d 100644 --- a/types/frisby/index.d.ts +++ b/types/frisby/index.d.ts @@ -18,16 +18,27 @@ export import Joi = require("joi"); // #region Frisby FrisbySpec Methods // Reference file: https://github.com/vlucas/frisby/blob/master/src/frisby/spec.js + +// **************************************CHANGE LOG************************************** +// C.E.W. This is an attempt to create some sort of changelog for these types. +// If you make any changes, please try and note those changes in this section. +// If this section gets too long we can always trim it. +// ## 2018-03-05 +// ### Changed +// - Update _Frisbyspec.get_, _Frisbyspec.post_, _Frisbyspec.put_, _Frisbyspec.del_, _Frisbyspec.patch_, _Frisbyspec.fetch_ to allow _params_ to be optional. +// - Update _FrisbySpec.then_ to allow _onRejected_ to be optional. +// **************************************CHANGE LOG************************************** + export class FrisbySpec { constructor(...args: any[]); catch(onRejected?: (error: Error) => void): FrisbySpec; - del(url: string, params: {}): FrisbySpec; + del(url: string, params?: {}): FrisbySpec; done(doneFn: (...args: any[]) => void): FrisbySpec; expect(expectName: string, ...args: any[]): FrisbySpec; expectNot(expectName: string): FrisbySpec; - fetch(url: string, params: {}, options?: {}): FrisbySpec; + fetch(url: string, params?: {}, options?: {}): FrisbySpec; fromJSON(json: {}): FrisbySpec; - get(url: string, params: {}): FrisbySpec; + get(url: string, params?: {}): FrisbySpec; getBaseUrl(): string | boolean; inspectBody(): FrisbySpec; inspectHeaders(): FrisbySpec; @@ -37,12 +48,12 @@ export class FrisbySpec { inspectRequestHeaders(): FrisbySpec; inspectResponse(): FrisbySpec; inspectStatus(): FrisbySpec; - patch(url: string, params: {}): FrisbySpec; - post(url: string, params: {}): FrisbySpec; + patch(url: string, params?: {}): FrisbySpec; + post(url: string, params?: {}): FrisbySpec; promise(): Promise; - put(url: string, params: {}): FrisbySpec; + put(url: string, params?: {}): FrisbySpec; setup(opts: {}, replace: boolean): FrisbySpec; - then(onFulfilled: {} | ((...args: any[]) => void), onRejected: (...args: any[]) => void): FrisbySpec; + then(onFulfilled: {} | ((...args: any[]) => void), onRejected?: (...args: any[]) => void): FrisbySpec; timeout(timeout: number): number; use(fn: (...args: any[]) => void): FrisbySpec; static addExpectHandler(expectName: string, expectFn: (...args: any[]) => any): void; diff --git a/types/generate-changelog/generate-changelog-tests.ts b/types/generate-changelog/generate-changelog-tests.ts new file mode 100644 index 0000000000..0b99857715 --- /dev/null +++ b/types/generate-changelog/generate-changelog-tests.ts @@ -0,0 +1,8 @@ +import * as changelog from 'generate-changelog'; + +changelog.generate({ + exclude: ['chore'], + minor: true, + repoUrl: 'https://github.com/lob/generate-changelog', + tag: 'v1.6.0...v1.7.0' +}).then(changelog => changelog.trim()); diff --git a/types/generate-changelog/index.d.ts b/types/generate-changelog/index.d.ts new file mode 100644 index 0000000000..2a6ba0ed56 --- /dev/null +++ b/types/generate-changelog/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for generate-changelog 1.7 +// Project: https://github.com/lob/generate-changelog#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Options { + /** exclude listed commit types (e.g. `['chore', 'style', 'refactor']`) */ + exclude?: string[]; + /** whether it should be a patch changelog */ + patch?: boolean; + /** whether it should be a minor changelog */ + minor?: boolean; + /** whether it should be a major changelog */ + major?: boolean; + /** repo URL that will be used when linking commits */ + repoUrl?: string; + /** generate from specific tag or range (e.g. `v1.2.3` or `v1.2.3..v1.2.4`)' */ + tag?: string; +} + +export function generate(options: Options): Promise; diff --git a/types/generate-changelog/tsconfig.json b/types/generate-changelog/tsconfig.json new file mode 100644 index 0000000000..458186fe12 --- /dev/null +++ b/types/generate-changelog/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "generate-changelog-tests.ts" + ] +} diff --git a/types/generate-changelog/tslint.json b/types/generate-changelog/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/generate-changelog/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/geojson/geojson-tests.ts b/types/geojson/geojson-tests.ts index ce8c62418e..c5c3fa2bdd 100644 --- a/types/geojson/geojson-tests.ts +++ b/types/geojson/geojson-tests.ts @@ -231,7 +231,7 @@ interface TestProperty { } const testProps: TestProperty = { - foo: "bar", + foo: "baz", hello: "world" }; @@ -248,3 +248,77 @@ const typedPropertiesFeatureCollection: FeatureCollection = { type: "FeatureCollection", features: [typedPropertiesFeature] }; + +// Strict Null Checks + +let isNull: null; +let isPoint: Point; +let isPointOrNull: Point | null; +let isProperty: TestProperty; +let isPropertyOrNull: TestProperty | null; + +const featureAllNull: Feature = { + type: "Feature", + properties: null, + geometry: null +}; + +const featurePropertyNull: Feature = { + type: "Feature", + properties: null, + geometry: point +}; + +const featureGeometryNull: Feature = { + type: "Feature", + properties: testProps, + geometry: null +}; + +const featureNoNull: Feature = { + type: "Feature", + properties: testProps, + geometry: point +}; + +const collectionAllNull: FeatureCollection = { + type: "FeatureCollection", + features: [featureAllNull], +}; + +const collectionMaybeNull: FeatureCollection = { + type: "FeatureCollection", + features: [featureAllNull, featurePropertyNull, featureGeometryNull, featureNoNull], +}; + +const collectionPropertyMaybeNull: FeatureCollection = { + type: "FeatureCollection", + features: [featurePropertyNull, featureNoNull], +}; + +const collectionGeometryMaybeNull: FeatureCollection = { + type: "FeatureCollection", + features: [featureGeometryNull, featureNoNull], +}; + +const collectionNoNull: FeatureCollection = { + type: "FeatureCollection", + features: [featureNoNull], +}; + +isNull = featureAllNull.geometry; +isPoint = featurePropertyNull.geometry; +isNull = featureAllNull.properties; +isProperty = featureGeometryNull.properties; + +isNull = collectionAllNull.features[0].geometry; +isPointOrNull = collectionMaybeNull.features[0].geometry; +isPoint = collectionPropertyMaybeNull.features[0].geometry; +isPointOrNull = collectionGeometryMaybeNull.features[0].geometry; +isPoint = collectionNoNull.features[0].geometry; + +isNull = collectionAllNull.features[0].properties; +isPropertyOrNull = collectionMaybeNull.features[0].properties; +isPropertyOrNull = collectionPropertyMaybeNull.features[0].properties; +isProperty = collectionGeometryMaybeNull.features[0].properties; +isProperty = collectionNoNull.features[0].properties; diff --git a/types/geojson/index.d.ts b/types/geojson/index.d.ts index 85f02aaad0..9a0ab3cd8b 100644 --- a/types/geojson/index.d.ts +++ b/types/geojson/index.d.ts @@ -139,12 +139,12 @@ export type GeoJsonProperties = { [name: string]: any; } | null; * A feature object which contains a geometry and associated properties. * https://tools.ietf.org/html/rfc7946#section-3.2 */ -export interface Feature extends GeoJsonObject { +export interface Feature extends GeoJsonObject { type: "Feature"; /** * The feature's geometry */ - geometry: G | null; + geometry: G; /** * A value that uniquely identifies this feature in a * https://tools.ietf.org/html/rfc7946#section-3.2. @@ -153,14 +153,14 @@ export interface Feature extend /** * Properties associated with this feature. */ - properties: P | null; + properties: P; } /** * A collection of feature objects. * https://tools.ietf.org/html/rfc7946#section-3.3 */ -export interface FeatureCollection extends GeoJsonObject { +export interface FeatureCollection extends GeoJsonObject { type: "FeatureCollection"; features: Array>; } diff --git a/types/geojson/tsconfig.json b/types/geojson/tsconfig.json index 071f17c65d..86021d5757 100644 --- a/types/geojson/tsconfig.json +++ b/types/geojson/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/gijgo/index.d.ts b/types/gijgo/index.d.ts index a76d98dd7f..19d17deb22 100644 --- a/types/gijgo/index.d.ts +++ b/types/gijgo/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Gijgo v0.6.2 +// Type definitions for Gijgo v1.8.2 // Project: http://gijgo.com // Definitions by: Atanas Atanasov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,23 +10,28 @@ declare module Gijgo { interface GridPager { limit?: number; sizes?: Array; - leftControls?: any; - rightControls?: any; + leftControls?: Array; + rightControls?: Array; } interface GridColumn { align?: string; cssClass?: string; decimalDigits?: number; + editField?: string; editor?: any; events?: any; field?: string; + filter?: any; + filterable?: boolean; format?: string; headerCssClass?: string; hidden?: boolean; icon?: string; minWidth?: number; + mode?: string; priority?: number; + renderer?: any; sortable?: boolean; stopPropagation?: boolean; title?: string; @@ -36,11 +41,13 @@ declare module Gijgo { width?: number; } - interface GridDefaultParams { + interface GridParamNames { direction?: string; limit?: string; page?: string; sortBy?: string; + groupBy?: string; + groupByDirection?: string; } interface GridMapping { @@ -48,24 +55,62 @@ declare module Gijgo { totalRecordsField?: string; } + interface GridIcons { + expandRow?: string; + collapseRow?: string; + expandGroup?: string; + collapseGroup?: string; + } + + interface GridGrouping { + groupBy: string; + } + + interface GridHeaderFilter { + type: string; + } + + interface GridInlineEditing { + mode?: string; + managementColumn?: boolean; + } + + interface GridOptimisticPersistence { + localStorage: Array; + sessionStorage: Array; + } + interface GridSettings { //Configuration options autoGenerateColumns?: boolean; autoLoad?: boolean; + columnReorder?: boolean; columns?: Array; dataSource?: any; defaultColumnSettings?: GridColumn; - defaultParams?: GridDefaultParams; detailTemplate?: string; + fixedHeader?: boolean; fontSize?: string; - mapping?: string; + grouping?: GridGrouping; + headerFilter?: GridHeaderFilter; + icons?: GridIcons; + iconsLibrary?: string; + inlineEditing?: GridInlineEditing; + keepExpandedRows?: boolean; + locale?: string; + mapping?: any; minWidth?: number; notFoundText?: string; + optimisticPersistence?: GridOptimisticPersistence; + orderNumberField?: string; pager?: GridPager; + paramNames?: GridParamNames; primaryKey?: string; resizableColumns?: boolean; resizeCheckInterval?: number; responsive?: boolean; + rowReorder?: boolean; + rowReorderColumn?: string; selectionMethod?: string; selectionType?: string; showHiddenColumnsAsDetails?: boolean; @@ -83,14 +128,16 @@ declare module Gijgo { columnShow?: (e: any, column: GridColumn) => any; dataBinding?: (e: any, records: Array) => any; dataBound?: (e: any, records: Array, totalRecords: number) => any; + dataFiltered?: (e: any, records: Array) => any; destroying?: (e: any) => any; - detailCollapse?: (e: any, detailWrapper: JQuery, record: Entity) => any; - detailExpand?: (e: any, detailWrapper: JQuery, record: Entity) => any; + detailCollapse?: (e: any, detailWrapper: JQuery, id: string) => any; + detailExpand?: (e: any, detailWrapper: JQuery, id: string) => any; initialized?: (e: any) => any; pageChanging?: (e: any, newPage: number) => any; pageSizeChange?: (e: any, newPage: number) => any; resize?: (e: any, newWidth: number, oldWidth: number) => any; rowDataBound?: (e: any, $row: JQuery, id: string, record: Entity) => any; + rowDataChanged?: (e: any, id: string, record: Entity) => any; rowRemoving?: (e: any, $row: JQuery, id: string, record: Entity) => any; rowSelect?: (e: any, $row: JQuery, id: string, record: Entity) => any; rowUnselect?: (e: any, $row: JQuery, id: string, record: Entity) => any; @@ -98,17 +145,23 @@ declare module Gijgo { interface Grid extends JQuery { addRow(record: Entity): Grid; + cancel(id: string): Grid; clear(showNotFoundText?: boolean): Grid; + collapseAll(): Grid; count(): number; destroy(keepTableTag?: boolean, keepWrapperTag?: boolean): void; + downloadCSV(filename?: string, includeAllRecords?: boolean): Grid; + edit(id: string): Grid; + expandAll(): Grid; //get(position: number): Entity; //TODO: rename to getByPosition to avoid conflicts with jquery.get getAll(): Array; getById(id: string): Entity; getChanges(): Array; + getCSV(includeAllRecords?: boolean): string; getSelected(): string; getSelections(): Array; hideColumn(field: string): Grid; - makeResponsive(): void; + makeResponsive(): Grid; reload(params?: Params): Grid; removeRow(id: string): Grid; render(response: any): Grid; @@ -117,22 +170,25 @@ declare module Gijgo { showColumn(field: string): Grid; title(text: any): any; unSelectAll(): Grid; + update(id: string): Grid; updateRow(id: string, record: Entity): Grid; } - //Dialog + // Dialog interface DialogSettings { - //Configuration options autoOpen?: boolean; + closeButtonInHeader?: boolean; closeOnEscape?: boolean; draggable?: boolean; height?: number | string; + locale?: string; maxHeight?: number; maxWidth?: number; minHeight?: number; minWidth?: number; modal?: boolean; resizable?: boolean; + scrollable?: boolean; title?: string; uiLibrary?: string; width?: number; @@ -153,9 +209,217 @@ declare module Gijgo { interface Dialog extends JQuery { close(): Dialog; + content(constent: string): string | Dialog; + destroy(keepHtml: boolean): void; isOpen(): boolean; open(): Dialog; } + + // Checkbox + interface CheckboxSettings { + uiLibrary?: string; + iconsLibrary?: string; + + //Events + change?: (e: any, state: string) => any; + } + + interface Checkbox extends JQuery { + //toggle(): Checkbox; + state(value: string): string | Checkbox; + destroy(): void; + } + + // DatePicker + interface DatePickerIcons { + rightIcon?: string; + } + + interface DatePickerSettings { + showOtherMonths?: boolean; + selectOtherMonths?: boolean; + width?: number; + minDate?: Date | string | Function; + maxDate?: Date | string | Function; + format?: string; + value?: string; + uiLibrary?: string; + iconsLibrary?: string; + weekStartDay?: number; + disableDates?: Array | Function; + disableDaysOfWeek?: Array; + calendarWeeks?: boolean; + keyboardNavigation?: boolean; + locale?: string; + icons?: DatePickerIcons; + + //Events + change?: (e: any) => any; + open?: (e: any) => any; + close?: (e: any) => any; + } + + interface DatePicker extends JQuery { + close(): DatePicker; + destroy(): void; + open(): DatePicker; + value(value: string): string | DatePicker; + } + + // DropDown + interface DropDownIcons { + dropdown?: string; + } + + interface DropDownSettings { + dataSource?: any; + textField?: string; + valueField?: string; + selectedField?: string; + width?: number; + maxHeight?: any; + uiLibrary?: string; + iconsLibrary?: string; + icons?: DropDownIcons; + + //Events + change?: (e: any) => any; + dataBound?: (e: any) => any; + } + + interface DropDown extends JQuery { + value(value: string): string | DropDown; + destroy(): void; + } + + // Editor + interface EditorSettings { + height?: number | string; + width?: number | string; + uiLibrary?: string; + iconsLibrary?: string; + locale?: string; + + //Events + changing?: (e: any) => any; + changed?: (e: any) => any; + } + + interface Editor extends JQuery { + content(html: string): string | Editor; + destroy(): void; + } + + // TimePicker + interface TimePickerSettings { + width?: number; + modal?: boolean; + header?: boolean; + footer?: boolean; + format?: string; + uiLibrary?: string; + value?: string; + mode?: string; + locale?: string; + + //Events + change?: (e: any) => any; + open?: (e: any) => any; + close?: (e: any) => any; + } + + interface TimePicker extends JQuery { + close(): TimePicker; + destroy(): void; + open(): TimePicker; + value(value: string): string | TimePicker; + } + + // Tree + interface TreeIcons { + expand?: string; + collapse?: string; + } + + interface TreeParamNames { + parentId?: string; + } + + interface TreeSettings { + autoLoad?: boolean; + selectionType?: string; + cascadeSelection?: boolean; + dataSource?: any; + primaryKey?: string; + textField?: string; + childrenField?: string; + hasChildrenField?: string; + imageCssClassField?: string; + imageUrlField?: string; + imageHtmlField?: string; + disabledField?: string; + width?: number; + border?: boolean; + uiLibrary?: string; + iconsLibrary?: string; + icons?: TreeIcons; + + checkboxes?: boolean; + checkedField?: string; + cascadeCheck?: boolean; + dragAndDrop?: boolean; + paramNames: TreeParamNames; + lazyLoading?: boolean; + + + //Events + initialized?: (e: any) => any; + dataBinding?: (e: any) => any; + dataBound?: (e: any) => any; + select?: (e: any, node: any, id: string) => any; + unselect?: (e: any, node: any, id: string) => any; + expand?: (e: any, node: any, id: string) => any; + collapse?: (e: any, node: any, id: string) => any; + enable?: (e: any, node: any, id: string) => any; + disable?: (e: any, node: any, id: string) => any; + destroying?: (e: any) => any; + nodeDataBound?: (e: any, node: any, id: string) => any; + checkboxChange?: (e: any, node: any, record: any, state: string) => any; + nodeDrop?: (e: any, id: string, parentId: string, orderNumber: number) => any; + } + + interface Tree extends JQuery { + reload(params: any): any; + render(response: any): any; + addNode(data: any, parentNode: any, position: number): Tree; + removeNode(node: any): Tree; + destroy(): void; + expand(node: any, cascade: boolean): Tree; + collapse(node: any, cascade: boolean) : Tree; + expandAll(): Tree; + collapseAll() : Tree; + getDataById(id: string) : any; + getDataByText(text: string) : any; + getNodeById(id: string) : any; + getNodeByText(id: string) : any; + getAll(): Array; + //select(node: any) : Tree; + unselect(node: any) : Tree; + selectAll() : Tree; + unselectAll() : Tree; + getSelections() : Array; + getChildren(node: any, cascade: boolean) : Array; + enable(node: any, cascade: boolean) : Tree; + disable(node: any, cascade: boolean) : Tree; + enableAll() : Tree; + disableAll() : Tree; + + getCheckedNodes() : Array; + checkAll() : Tree; + uncheckAll(): Tree; + check(node: any) : Tree; + uncheck(node: any) : Tree; + } } @@ -165,4 +429,16 @@ interface JQuery { grid(settings: Gijgo.GridSettings): Gijgo.Grid; dialog(settings: Gijgo.DialogSettings): Gijgo.Dialog; + + checkbox(settings: Gijgo.CheckboxSettings): Gijgo.Checkbox; + + datepicker(settings: Gijgo.DatePickerSettings): Gijgo.DatePicker; + + dropdown(settings: Gijgo.DropDownSettings): Gijgo.DropDown; + + editor(settings: Gijgo.EditorSettings): Gijgo.Editor; + + timepicker(settings: Gijgo.TimePickerSettings): Gijgo.TimePicker; + + tree(settings: Gijgo.TreeSettings): Gijgo.Tree; } diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index 7857bddbab..7048533295 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -52,6 +52,20 @@ got('todomvc.com', { encoding: 'utf8', hostname: 'todomvc' }).then(response => str = response.body); +got('todomvc.com', { + form: true, + body: [{}], + encoding: 'utf8', + hostname: 'todomvc', + timeout: 2000 +}).then(response => str = response.body); +got('todomvc.com', { + form: true, + body: [{}], + encoding: 'utf8', + hostname: 'todomvc', + timeout: {connect: 20, request: 20, socket: 20} +}).then(response => str = response.body); // following must lead to type checking error: got('todomvc.com', {form: true, body: ''}).then(response => str = response.body); got('todomvc.com', {encoding: null, hostname: 'todomvc'}).then(response => buf = response.body); diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 30a5b2c0be..5872b4f993 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -98,7 +98,11 @@ declare namespace got { json?: boolean; } - type GotOptions = http.RequestOptions & { + interface TimoutRequestOptions extends http.RequestOptions { + timeout?: any; + } + + interface GotOptions extends TimoutRequestOptions { encoding?: E; query?: string | object; timeout?: number | TimeoutOptions; @@ -106,7 +110,7 @@ declare namespace got { followRedirect?: boolean; decompress?: boolean; useElectronNet?: boolean; - }; + } interface TimeoutOptions { connect?: number; diff --git a/types/graphql-list-fields/graphql-list-fields-tests.ts b/types/graphql-list-fields/graphql-list-fields-tests.ts new file mode 100644 index 0000000000..7624a3cbd8 --- /dev/null +++ b/types/graphql-list-fields/graphql-list-fields-tests.ts @@ -0,0 +1,42 @@ +import getFieldNames = require("graphql-list-fields"); + +import { + GraphQLID, + GraphQLInterfaceType, + GraphQLObjectType, + GraphQLResolveInfo, + GraphQLSchema, + GraphQLString +} from "graphql"; + +const sampleGraphQLResolveInfo: GraphQLResolveInfo = { + fieldName: "", + fieldNodes: [], + returnType: GraphQLString, + parentType: new GraphQLInterfaceType({ + name: "Sample", + fields: { + name: { type: GraphQLString } + } + }), + path: undefined, + schema: new GraphQLSchema({ + query: new GraphQLObjectType({ + name: "SampleType", + fields: {} + }) + }), + fragments: {}, + rootValue: null, + operation: { + kind: "OperationDefinition", + operation: "query", + selectionSet: { + kind: "SelectionSet", + selections: [] + } + }, + variableValues: {} +}; + +const fieldNames: string[] = getFieldNames(sampleGraphQLResolveInfo); diff --git a/types/graphql-list-fields/index.d.ts b/types/graphql-list-fields/index.d.ts new file mode 100644 index 0000000000..362658deb9 --- /dev/null +++ b/types/graphql-list-fields/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for graphql-list-fields 2.0 +// Project: https://github.com/jakepusateri/graphql-list-fields#readme +// Definitions by: Chris Filipowski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { GraphQLResolveInfo } from "graphql"; + +declare function getFieldList(info: GraphQLResolveInfo): string[]; + +export = getFieldList; diff --git a/types/graphql-list-fields/tsconfig.json b/types/graphql-list-fields/tsconfig.json new file mode 100644 index 0000000000..6f53c2c900 --- /dev/null +++ b/types/graphql-list-fields/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "graphql-list-fields-tests.ts" + ] +} diff --git a/types/graphql-list-fields/tslint.json b/types/graphql-list-fields/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/graphql-list-fields/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts index 1e9a2395a4..519a3a4088 100644 --- a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts +++ b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts @@ -16,6 +16,17 @@ interface SomeTestResult { someTestResultProp: string; } +const asyncBatchFunction = async (sources: ReadonlyArray) => { + return new Promise(resolve => { + const res = [ + { + someTestResultProp: "" + } + ]; + resolve(res); + }); +}; + const withSourceAndResultTyped = createBatchResolver< SomeTestSource, SomeTestResult @@ -32,40 +43,25 @@ const withSourceAndResultTyped = createBatchResolver< const withSourceAndResultTypedAsPromise = createBatchResolver< SomeTestSource, SomeTestResult ->((sources, _, __) => { +>(async (sources, _, __) => { // $ExpectType ReadonlyArray const verifySources = sources; - - return sources.map(source => { - return new Promise(resolve => { - const res: SomeTestResult = { - someTestResultProp: "" - }; - - resolve(res); - }); - }); + const result = await asyncBatchFunction(sources); + return result; }); const withSourceAndArgsAndResultTyped = createBatchResolver< SomeTestSource, SomeTestResult, SomeTestArgs ->((sources, args, _) => { +>(async (sources, args, _) => { // $ExpectType ReadonlyArray const verifySources = sources; // $ExpectType string const verifyArgs = args.someArg; - return sources.map(source => { - return new Promise(resolve => { - const res: SomeTestResult = { - someTestResultProp: "" - }; - - resolve(res); - }); - }); + const result = await asyncBatchFunction(sources); + return result; }); const withSourceAndArgsAndContextTyped = createBatchResolver< @@ -73,7 +69,7 @@ const withSourceAndArgsAndContextTyped = createBatchResolver< SomeTestResult, SomeTestArgs, SomeTestContext ->((sources, args, context) => { +>(async (sources, args, context) => { // $ExpectType ReadonlyArray const verifySources = sources; // $ExpectType string @@ -81,13 +77,6 @@ const withSourceAndArgsAndContextTyped = createBatchResolver< // $ExpectType string const verifyContext = context.someContextProp; - return sources.map(source => { - return new Promise(resolve => { - const res: SomeTestResult = { - someTestResultProp: "" - }; - - resolve(res); - }); - }); + const result = await asyncBatchFunction(sources); + return result; }); diff --git a/types/graphql-resolve-batch/index.d.ts b/types/graphql-resolve-batch/index.d.ts index 46f354f7b7..e78ddafb37 100644 --- a/types/graphql-resolve-batch/index.d.ts +++ b/types/graphql-resolve-batch/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for graphql-resolve-batch 1.0 +// Type definitions for graphql-resolve-batch 1.1 // Project: https://github.com/calebmer/graphql-resolve-batch#readme // Definitions by: Rutger Hendrickx // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -17,10 +17,10 @@ export type ResolverFunction = ( source: TSource, args: TArgs, context: TContext -) => Promise; +) => Promise | Promise; export type BatchResolveFunction = ( sources: ReadonlyArray, args: TArgs, context: TContext -) => TReturn[] | Array>; +) => TReturn[] | Promise; diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index a8bead58fd..49185e11a1 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -12,6 +12,7 @@ // Tim Griesser // Dylan Stewart // Alessio Dionisi +// Divyendu Singh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -100,6 +101,9 @@ export { // Build a GraphQLSchema from a GraphQL schema language document. buildSchema, + // Get the description of an AST node + getDescription, + // Extends an existing GraphQLSchema from a parsed GraphQL Schema // language AST. extendSchema, diff --git a/types/graphql/type/schema.d.ts b/types/graphql/type/schema.d.ts index 3263274dd9..26500c6ed3 100644 --- a/types/graphql/type/schema.d.ts +++ b/types/graphql/type/schema.d.ts @@ -61,6 +61,27 @@ export class GraphQLSchema { getDirective(name: string): GraphQLDirective; } +export type GraphQLSchemaValidationOptions = { + /** + * When building a schema from a GraphQL service's introspection result, it + * might be safe to assume the schema is valid. Set to true to assume the + * produced schema is valid. + * + * Default: false + */ + assumeValid?: boolean; + + /** + * If provided, the schema will consider fields or types with names included + * in this list valid, even if they do not adhere to the specification's + * schema validation rules. + * + * This option is provided to ease adoption and may be removed in a future + * major release. + */ + allowedLegacyNames?: ReadonlyArray; +}; + export interface GraphQLSchemaConfig { query: GraphQLObjectType; mutation?: GraphQLObjectType; diff --git a/types/graphql/utilities/buildASTSchema.d.ts b/types/graphql/utilities/buildASTSchema.d.ts index b20c8fc856..6b8aa56327 100644 --- a/types/graphql/utilities/buildASTSchema.d.ts +++ b/types/graphql/utilities/buildASTSchema.d.ts @@ -1,6 +1,17 @@ -import { DocumentNode, Location } from '../language/ast'; +import { DocumentNode, Location, StringValueNode } from '../language/ast'; import { Source } from '../language/source'; -import { GraphQLSchema } from '../type/schema'; +import { GraphQLSchema, GraphQLSchemaValidationOptions } from '../type/schema'; + +interface BuildSchemaOptions extends GraphQLSchemaValidationOptions { + /** + * Descriptions are defined as preceding string literals, however an older + * experimental version of the SDL supported preceding comments as + * descriptions. Set to true to enable this deprecated behavior. + * + * Default: false + */ + commentDescriptions?: boolean; +} /** * This takes the ast of a schema document produced by the parse function in @@ -15,10 +26,18 @@ import { GraphQLSchema } from '../type/schema'; export function buildASTSchema(ast: DocumentNode): GraphQLSchema; /** - * Given an ast node, returns its string description based on a contiguous - * block full-line of comments preceding it. + * Given an ast node, returns its string description. + * + * Accepts options as a second argument: + * + * - commentDescriptions: + * Provide true to use preceding comments as the description. + * */ -export function getDescription(node: { loc?: Location }): string; +export function getDescription( + node: { description?: StringValueNode; loc?: Location }, + options: BuildSchemaOptions +): string; /** * A helper function to build a GraphQLSchema directly from a source diff --git a/types/graphql/utilities/index.d.ts b/types/graphql/utilities/index.d.ts index cd0e23948f..c2b2c182ff 100644 --- a/types/graphql/utilities/index.d.ts +++ b/types/graphql/utilities/index.d.ts @@ -27,7 +27,7 @@ export { getOperationAST } from './getOperationAST'; export { buildClientSchema } from './buildClientSchema'; // Build a GraphQLSchema from GraphQL Schema language. -export { buildASTSchema, buildSchema } from './buildASTSchema'; +export { buildASTSchema, buildSchema, getDescription } from './buildASTSchema'; // Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. export { extendSchema } from './extendSchema'; diff --git a/types/hapi-auth-jwt2/hapi-auth-jwt2-tests.ts b/types/hapi-auth-jwt2/hapi-auth-jwt2-tests.ts index fa28253a88..cf51162eb4 100644 --- a/types/hapi-auth-jwt2/hapi-auth-jwt2-tests.ts +++ b/types/hapi-auth-jwt2/hapi-auth-jwt2-tests.ts @@ -1,8 +1,7 @@ -import Hapi = require('hapi'); -import hapiAuthJwt2 = require('hapi-auth-jwt2'); +import { Server } from 'hapi'; +import * as hapiAuthJwt2 from 'hapi-auth-jwt2'; -const server = new Hapi.Server(); -server.connection({port: 8000}); +const server = new Server({port: 8000}); interface User { id: number; @@ -20,19 +19,28 @@ const users: Users = { } }; -function validate(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.ValidateCallback) { - callback(null, !!users[decoded.id]); -} - -server.register(hapiAuthJwt2, err => { - const options: hapiAuthJwt2.Options = { - key: 'NeverShareYourSecret', - validateFunc: validate, - verifyOptions: { - algorithms: ['HS256'] +server.register({ + plugin: hapiAuthJwt2, + options: { + async verify() { + return { + isValid: true, + }; + } } - }; - server.auth.strategy('jwt', 'jwt', options); +}) +.then(() => { + const opts: hapiAuthJwt2.Options = { + key: 'NeverShareYourSecret', + async validate(decoded: { id: number }, request) { + return { + isValid: !!users[decoded.id], + }; + }, + verifyOptions: { + algorithms: ['HS256'], + issuer: 'test', + } + }; + server.auth.strategy('jwt', 'jwt', opts); }); - -server.start(); diff --git a/types/hapi-auth-jwt2/index.d.ts b/types/hapi-auth-jwt2/index.d.ts index 91e8ef931e..a93f740bfc 100644 --- a/types/hapi-auth-jwt2/index.d.ts +++ b/types/hapi-auth-jwt2/index.d.ts @@ -1,39 +1,43 @@ -// Type definitions for hapi-auth-jwt2 7.0 +// Type definitions for hapi-auth-jwt2 8.0 // Project: https://github.com/dwyl/hapi-auth-jwt2 // Definitions by: Warren Seymour +// Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -import { Request, Response, PluginFunction } from 'hapi'; +import { Request, ResponseObject, Plugin, ResponseToolkit } from 'hapi'; +import { VerifyOptions } from 'jsonwebtoken'; + +declare module 'hapi' { + interface ServerAuth { + strategy(name: string, scheme: 'jwt', options?: hapiAuthJwt2.Options): void; + } +} declare namespace hapiAuthJwt2 { - /** - * A key lookup function - * - * @param decoded the *decoded* but *unverified* JWT received from client - * @param callback the key lookup callback - */ - type KeyLookup = (decoded: any, callback: KeyLookupCallback) => void; + interface ExtraInfo { + } - /** - * Called when key lookup function has completed - * - * @param err an internal error - * @param key the secret key - * @param extraInfo any additional information that you would like - * to use in `validateFunc` which can be accessed via - * `request.plugins['hapi-auth-jwt2'].extraInfo` - */ - type KeyLookupCallback = (err: any, key: string, extraInfo?: any) => void; - - /** - * Called when Validation has completed - * - * @param err an internal error - * @param valid `true` if the JWT was valid, otherwise `false` - * @param credentials alternative credentials to be set instead of `decoded` - */ - type ValidateCallback = (err: any, valid: boolean, credentials?: any) => void; + interface ErrorContext { + /** + * Boom method to call (eg. unauthorized) + */ + errorType: string; + /** + * message passed into the Boom method call + */ + message?: string; + /** + * schema passed into the Boom method call + */ + schema: string; + /** + * attributes passed into the Boom method call + */ + attributes?: { + [key: string]: string; + }; + } /** * Options passed to `hapi.auth.strategy` when this plugin is used @@ -42,41 +46,24 @@ declare namespace hapiAuthJwt2 { /** * The secret key used to check the signature of the token *or* a *key lookup function* */ - key?: string | KeyLookup; + key?: string | string[] | Promise<{ isValid: boolean; key: string; extraInfo?: ExtraInfo }>; /** * The function which is run once the Token has been decoded * * @param decoded the *decoded* and *verified* JWT received from the client in *request.headers.authorization* * @param request the original *request* received from the client - * @param callback the validation callback */ - validateFunc(decoded: {}, request: Request, callback: ValidateCallback): void; + validate(decoded: {}, request: Request, tk: ResponseToolkit): Promise<{ + isValid: boolean; + credentials?: any; + response?: ResponseObject + }>; /** * Settings to define how tokens are verified by the jsonwebtoken library */ - verifyOptions?: { - /** - * Ignore expired tokens - */ - ignoreExpiration?: boolean; - - /** - * Do not enforce token audience - */ - audience?: boolean; - - /** - * Do not require the issuer to be valid - */ - issuer?: boolean; - - /** - * List of allowed algorithms - */ - algorithms?: string[]; - }; + verifyOptions?: VerifyOptions; /** * function called to decorate the response with authentication headers @@ -85,7 +72,14 @@ declare namespace hapiAuthJwt2 { * @param request the Request object * @param reply is called if an error occurred */ - responseFunc?(request: Request, reply: (err: any, response: Response) => void): void; + responseFunc?(request: Request, reply: (err: any, response: ResponseObject) => void): void; + + /** + * + * @param ctx called when an error has been raised. + * It provides an extension point to allow the host the ability to customise the error messages returned. + */ + errorFunc?(ctx: ErrorContext): ErrorContext; /** * If you prefer to pass your token via url, simply add a token url @@ -125,8 +119,18 @@ declare namespace hapiAuthJwt2 { */ complete?: boolean; } + + interface RegisterOptions { + /** + * function which is run once the Token has been decoded (instead of a validate) with signature async function(decoded, request) where: + */ + verify?(decoded: any, request: Request): Promise<{ + isValid: boolean; + credentials?: any; + }>; + } } -declare var hapiAuthJwt2: PluginFunction<{}>; +declare const hapiAuthJwt2: Plugin; export = hapiAuthJwt2; diff --git a/types/hapi-auth-jwt2/tsconfig.json b/types/hapi-auth-jwt2/tsconfig.json index 19a6e785ac..0d58c0f507 100644 --- a/types/hapi-auth-jwt2/tsconfig.json +++ b/types/hapi-auth-jwt2/tsconfig.json @@ -13,20 +13,6 @@ "../" ], "types": [], - "paths": { - "boom": [ - "boom/v4" - ], - "catbox": [ - "catbox/v7" - ], - "hapi": [ - "hapi/v16" - ], - "inert": [ - "inert/v4" - ] - }, "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/hapi-auth-jwt2/tslint.json b/types/hapi-auth-jwt2/tslint.json index 3db14f85ea..4f44991c3c 100644 --- a/types/hapi-auth-jwt2/tslint.json +++ b/types/hapi-auth-jwt2/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-empty-interface": false + } +} diff --git a/types/hapi-auth-jwt2/v7/hapi-auth-jwt2-tests.ts b/types/hapi-auth-jwt2/v7/hapi-auth-jwt2-tests.ts new file mode 100644 index 0000000000..fa28253a88 --- /dev/null +++ b/types/hapi-auth-jwt2/v7/hapi-auth-jwt2-tests.ts @@ -0,0 +1,38 @@ +import Hapi = require('hapi'); +import hapiAuthJwt2 = require('hapi-auth-jwt2'); + +const server = new Hapi.Server(); +server.connection({port: 8000}); + +interface User { + id: number; + name: string; +} + +interface Users { + [id: number]: User; +} + +const users: Users = { + 1: { + id: 1, + name: 'Test User' + } +}; + +function validate(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.ValidateCallback) { + callback(null, !!users[decoded.id]); +} + +server.register(hapiAuthJwt2, err => { + const options: hapiAuthJwt2.Options = { + key: 'NeverShareYourSecret', + validateFunc: validate, + verifyOptions: { + algorithms: ['HS256'] + } + }; + server.auth.strategy('jwt', 'jwt', options); +}); + +server.start(); diff --git a/types/hapi-auth-jwt2/v7/index.d.ts b/types/hapi-auth-jwt2/v7/index.d.ts new file mode 100644 index 0000000000..91e8ef931e --- /dev/null +++ b/types/hapi-auth-jwt2/v7/index.d.ts @@ -0,0 +1,132 @@ +// Type definitions for hapi-auth-jwt2 7.0 +// Project: https://github.com/dwyl/hapi-auth-jwt2 +// Definitions by: Warren Seymour +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { Request, Response, PluginFunction } from 'hapi'; + +declare namespace hapiAuthJwt2 { + /** + * A key lookup function + * + * @param decoded the *decoded* but *unverified* JWT received from client + * @param callback the key lookup callback + */ + type KeyLookup = (decoded: any, callback: KeyLookupCallback) => void; + + /** + * Called when key lookup function has completed + * + * @param err an internal error + * @param key the secret key + * @param extraInfo any additional information that you would like + * to use in `validateFunc` which can be accessed via + * `request.plugins['hapi-auth-jwt2'].extraInfo` + */ + type KeyLookupCallback = (err: any, key: string, extraInfo?: any) => void; + + /** + * Called when Validation has completed + * + * @param err an internal error + * @param valid `true` if the JWT was valid, otherwise `false` + * @param credentials alternative credentials to be set instead of `decoded` + */ + type ValidateCallback = (err: any, valid: boolean, credentials?: any) => void; + + /** + * Options passed to `hapi.auth.strategy` when this plugin is used + */ + interface Options { + /** + * The secret key used to check the signature of the token *or* a *key lookup function* + */ + key?: string | KeyLookup; + + /** + * The function which is run once the Token has been decoded + * + * @param decoded the *decoded* and *verified* JWT received from the client in *request.headers.authorization* + * @param request the original *request* received from the client + * @param callback the validation callback + */ + validateFunc(decoded: {}, request: Request, callback: ValidateCallback): void; + + /** + * Settings to define how tokens are verified by the jsonwebtoken library + */ + verifyOptions?: { + /** + * Ignore expired tokens + */ + ignoreExpiration?: boolean; + + /** + * Do not enforce token audience + */ + audience?: boolean; + + /** + * Do not require the issuer to be valid + */ + issuer?: boolean; + + /** + * List of allowed algorithms + */ + algorithms?: string[]; + }; + + /** + * function called to decorate the response with authentication headers + * before the response headers or payload is written + * + * @param request the Request object + * @param reply is called if an error occurred + */ + responseFunc?(request: Request, reply: (err: any, response: Response) => void): void; + + /** + * If you prefer to pass your token via url, simply add a token url + * parameter to your request or use a custom parameter by setting `urlKey. + * To disable the url parameter set urlKey to `false` or ''. + * @default 'token' + */ + urlKey?: string | boolean; + + /** + * If you prefer to set your own cookie key or your project has a cookie + * called 'token' for another purpose, you can set a custom key for your + * cookie by setting `options.cookieKey='yourkeyhere'`. To disable cookies + * set cookieKey to `false` or ''. + * @default 'token' + */ + cookieKey?: string | boolean; + + /** + * If you want to set a custom key for your header token use the + * `headerKey` option. To disable header token set headerKey to `false` or + * ''. + * @default 'authorization' + */ + headerKey?: string | boolean; + + /** + * Allow custom token type, e.g. `Authorization: 12345678` + */ + tokenType?: string; + + /** + * Set to `true` to receive the complete token (`decoded.header`, + * `decoded.payload` and `decoded.signature`) as decoded argument to key + * lookup and `verifyFunc` callbacks (*not `validateFunc`*) + * @default false + */ + complete?: boolean; + } +} + +declare var hapiAuthJwt2: PluginFunction<{}>; + +export = hapiAuthJwt2; diff --git a/types/hapi-auth-jwt2/v7/tsconfig.json b/types/hapi-auth-jwt2/v7/tsconfig.json new file mode 100644 index 0000000000..45c3371617 --- /dev/null +++ b/types/hapi-auth-jwt2/v7/tsconfig.json @@ -0,0 +1,40 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "hapi-auth-jwt2": [ + "hapi-auth-jwt2/v7" + ], + "boom": [ + "boom/v4" + ], + "catbox": [ + "catbox/v7" + ], + "hapi": [ + "hapi/v16" + ], + "inert": [ + "inert/v4" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hapi-auth-jwt2-tests.ts" + ] +} diff --git a/types/hapi-auth-jwt2/v7/tslint.json b/types/hapi-auth-jwt2/v7/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hapi-auth-jwt2/v7/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index de1542f33f..220a96868f 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -120,7 +120,7 @@ export interface PluginBase { * * server - the server object with a plugin-specific server.realm. * * options - any options passed to the plugin during registration via server.register(). */ - register: (server: Server, options: T) => Promise; + register: (server: Server, options: T) => void | Promise; /** (optional) if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ multiple?: boolean; @@ -457,7 +457,7 @@ export interface Request extends Podium { * The response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to * override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). */ - response: ResponseObject | Boom.Boom | null; + response: ResponseObject | Boom | null; /** * Same as pre but represented as the response object created by the pre method. @@ -3873,7 +3873,7 @@ export namespace Lifecycle { type ReturnValueTypes = (null | string | number | boolean) | (Buffer) | - (Error | Boom.Boom) | + (Error | Boom) | (stream.Stream) | (object | object[]) | symbol | diff --git a/types/hapi/test/server/server-plugins.ts b/types/hapi/test/server/server-plugins.ts index 7f3d194f84..8de3fdc24f 100644 --- a/types/hapi/test/server/server-plugins.ts +++ b/types/hapi/test/server/server-plugins.ts @@ -13,6 +13,10 @@ interface Plugin3 { three: 3; } +interface Plugin4 { + four: 4; +} + declare module 'hapi' { interface PluginProperties { example: { @@ -42,6 +46,11 @@ const plugin3: Plugin = { register: async (server: Server, options: Plugin3) => {} }; +const plugin4: Plugin = { + name: 'plugin4', + register: (server: Server, options: Plugin4) => {} +}; + const server = new Server({ port: 8000, }); @@ -90,5 +99,9 @@ server.register([ { plugin: plugin1, options: {one: 1} + }, + { + plugin: plugin4, + options: {four: 4} } ]); diff --git a/types/heremaps/heremaps-tests.ts b/types/heremaps/heremaps-tests.ts index 9e92b92d72..40c0e92c5c 100644 --- a/types/heremaps/heremaps-tests.ts +++ b/types/heremaps/heremaps-tests.ts @@ -86,6 +86,21 @@ let polyline = new H.map.Polyline(new H.geo.Strip()); let clipArr: Array>; clipArr = polyline.clip(new H.geo.Rect(5, 5, 5, 5)); +let lineString = new H.geo.LineString(); +lineString.pushPoint({ lat: 53.3477, lng: -6.2597 }); +lineString.pushPoint({ lat: 51.5008, lng: -0.1224 }); +lineString.pushPoint({ lat: 48.8567, lng: 2.3508 }); +lineString.pushPoint({ lat: 52.5166, lng: 13.3833 }); +lineString.eachLatLngAlt((lat: number, lng: number, alt: number, i: number) => { + console.log(lat, lng, alt, i); +}); +lineString.getBounds(); +lineString.getPointCount(); +lineString.insertPoint(2, { lat: 53.3477, lng: -6.2597 }); +lineString.removePoint(2); + +let polyline2 = new H.map.Polyline(lineString); + let router = platform.getRoutingService(); let calculateRouteParams = { waypoint0: 'geo!52.5,13.4', diff --git a/types/heremaps/index.d.ts b/types/heremaps/index.d.ts index 8b68f11278..1fd1f3da29 100644 --- a/types/heremaps/index.d.ts +++ b/types/heremaps/index.d.ts @@ -756,6 +756,31 @@ declare namespace H { /***** geo *****/ namespace geo { + /** + * The base class for all geometry types. + */ + class AbstractGeometry { + /** + * Returns the bounding rectangle of the geometry. + * @return {H.geo.Rect} - the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates) + */ + getBounds(): H.geo.Rect; + + /** + * Checks whether the geometry is equal to the geometry supplied by the caller. + * Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values. + * @param other {any} - The geometry to check against + * @return {boolean} - true if the two geometries are equal, otherwise false + */ + equals(other: any): boolean; + + /** + * To obtain a Well-Known-Text (WKT) representation of the geometry. + * @return {string} - the resulting WKT string + */ + toString(): string; + } + /** * A Geographic coordinate that specifies the height of a point in meters. A value of undefined is treated as 0. */ @@ -812,6 +837,277 @@ declare namespace H { */ type Longitude = number; + class LineString { + /** + * Constructor + * @param opt_latLngAlts {number[]=} - An optional array of latitude, longitude and altitude triples to initialize the LineString with. + * @param opt_ctx {H.geo.AltitudeContext=} - An optional altitude context for all altitudes contained in this LineString. + * @throws {H.lang.InvalidArgumentError} - in case of invalid lat, lng, alt values + */ + constructor(opt_latLngAlts?: number[], opt_ctx?: H.geo.AltitudeContext); + + /** + * This method pushes a lat, lng, alt to the end of this LineString. + * @param lat {H.geo.Latitude} + * @param lng {H.geo.Longitude} + * @param alt {H.geo.Altitude} + * @throws {H.lang.InvalidArgumentError} - in case of invalid lat, lng, alt value + */ + pushLatLngAlt(lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude): void; + + /** + * This method splices the LineString at the provided index, removing the specified number of items at that index and inserting the lat, lng, alt array. + * @param index {number} - The index at which to splice + * @param opt_nRemove {number=} - The number of lat, lng, alt values to remove + * @param opt_latLngAlts {number[]=} - The lat, lng, alt values to add + * @return {number[]} - An array of removed elements + * @throws {H.lang.InvalidArgumentError} - in case of invalid opt_latLngAlts argument + */ + spliceLatLngAlts(index: number, opt_nRemove?: number, opt_latLngAlts?: number[]): number[]; + + /** + * This method inserts one set of lat, lng, alt values into the LineString at the specified index. + * @param index {number} - the index at which to add the element + * @param lat {H.geo.Latitude} - the latitude to insert + * @param lng {H.geo.Longitude} - the longitude to insert + * @param alt {H.geo.Altitude} - the altitude to insert + */ + insertLatLngAlt(index: number, lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude): void; + + /** + * This method removes one set of lat, lng, alt values from the LineString at the specified index + * @param index {number} + */ + removeLatLngAlt(index: number): void; + + /** + * This method pushes the lat, lng, alt values of a {H.geo.Point} to the end of this LineString. + * @param geoPoint {H.geo.IPoint} + * @throws {H.lang.InvalidArgumentError} - in case of invalid geoPoint argument + */ + pushPoint(geoPoint: H.geo.IPoint): void; + + /** + * This method inserts the lat, lng, alt values of a H.geo.Point into the list at the specified index. + * @param pointIndex {number} + * @param geoPoint {H.geo.IPoint} + */ + insertPoint(pointIndex: number, geoPoint: H.geo.IPoint): void; + + /** + * This method removes one set of lat, lng, alt values from this LineString at the virtual point index specified. + * @param pointIndex {number} - the virtual point index + */ + removePoint(pointIndex: number): void; + + /** + * This method extracts a H.geo.Point from this LineString at the virtual point index. + * If the extracted point has an alt value, the LineString's altitude context will be supplied to the point. + * @param pointIndex {number} - the virtual point index in the LineString + * @param opt_out {H.geo.Point=} - an optional point object to store the lat, lng, alt values + * @return {H.geo.Point} - Returns either the 'opt_out' point object or a new point object. + */ + extractPoint(pointIndex: number, opt_out?: H.geo.Point): H.geo.Point; + + /** + * A utility method to iterate over the points of a line string. + * @param eachFn {function(lat, lng, alt, index)} - The function to invoke for every point. It gets the point's latitude, longitude, altitude and index as arguments. + * @param opt_start {number=} - The point's start index (inclusive) to iterate from, defaults to 0. + * @param opt_end {number=} - The point's end index (exclusive) to iterate to, defaults to Infinity. + */ + eachLatLngAlt(eachFn: (lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude, index: number) => void, opt_start?: number, opt_end?: number): void; + + /** + * To obtain whether a leg (formed by the given two longitudes) crosses the International Date Line. + * @param lng1 {H.geo.Longitude} - The start longitude of the leg + * @param lng2 {H.geo.Longitude} - The end longitude of the leg + * @return {boolean} + */ + static isDBC(lng1: H.geo.Longitude, lng2: H.geo.Longitude): boolean; + + /** + * To obtain the number of times that this LineString cross the International Date Line. + * @param opt_asClosed {boolean=} - Indicates whether the LineString is treated as closed (the LineString's last and first coordinates form the closing leg of a polygon). + * It defaults to false. + * @return {number} + */ + getDBCs(opt_asClosed?: boolean): number; + + /** + * This method return the number of points stored in this LineString. + * @return {number} - The number of points in this LineString + */ + getPointCount(): number; + + /** + * Returns the vertices of the line segments as an array of alternating latitude, longitude and altitude coordinates. + * The returned array must be treated as read-only to not violate the integrity of the line-string. + * @return {number[]} - Returns the raw lat, lng, alt values of this LineString + */ + getLatLngAltArray(): number[]; + + /** + * This method returns the bounding box of this LineString. + * Note: The LineString is treated as an open path. If the bounding rectangle for a closed shape is required, the closing leg must be merged in an extra step. + * @return {H.geo.Rect} - This LineString's bounding rectangle + */ + getBounds(): H.geo.Rect; + + /** + * This method initializes a new LineString with an array of lat, lng values. Arrays are expected to have an even length with the format [lat, lng, lat, lng, ...]. + * @param latLngs {number[]} - the array of lat, lng value. + * @return {H.geo.LineString} - The LineString containing the lat, lng values + * @throws {H.lang.InvalidArgumentError} - throws an error in case the latLngs array has an odd length + */ + static fromLatLngArray(latLngs: number[]): H.geo.LineString; + + /** + * Checks whether the geometry is equal to the geometry supplied by the caller. + * Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values. + * @param other {any} - The geometry to check against + * @return {boolean} - true if the two geometries are equal, otherwise false + */ + equals(other: any): boolean; + + /** + * To obtain a Well-Known-Text (WKT) representation of the geometry. + * @return {string} - the resulting WKT string + */ + toString(): string; + } + + class MultiGeometry extends H.geo.AbstractGeometry { + /** + * The base class for a geometry that is a container for multiple geometries of a generic type. The type of the contained geometries is specified by the generic type parameter T + * @param geometries {T[]} - The list of geometries which are initially aggregated. + * @throws {H.lang.InvalidArgumentError} - if geometries parameter is not valid + */ + constructor(geometries: T[]); + + /** + * This method splices the specified MultiGeometry at the provided index, removing the specified number of items at that index and inserting new items. + * @param index {number} - The index at which to start changing the list. + * @param opt_deleteCount {number=} - The number of geometries to remove. + * @param opt_items {T[]=} - The geometries to add. + * @return {T[]} - the removed geometries. + */ + splice(index: number, opt_deleteCount?: number, opt_items?: T[]): T[]; + + /** + * Removes a contained geometry at the given index. + * @param index {number} - The index of the geometry to remove. + * @return {T} - the removed geometry. + * @throws {H.lang.OutOfRangeError} - if no geometry exists at the given index. + */ + removeAt(index: number): T; + + /** + * Removes the specified geometry from the multi-geometry + * @param geometry {T} - The geometry (by reference) to remove from this multi-geometry. + * @return {T} - the removed geometry or null if the geometry was not found + */ + remove(geometry: T): T; + + /** + * Returns the aggregated geometries of the multi-geometry. The returned geometries must be treated as read-only to not violate the integrity of the multi-geometry. + * @return {T[]} - An array of geometries + */ + getGeometries(): T[]; + + /** + * Adds the specified geometry to the current multi-geometry. + * @param geometry {T} - A geometry which will be added to the current multi-geometry + * @throws {H.lang.InvalidArgumentError} - in case of invalid geometry argument + */ + push(geometry: T): void; + + /** + * Returns the bounding rectangle of the geometry. + * @return {H.geo.Rect} - the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates) + */ + getBounds(): H.geo.Rect; + + /** + * Checks whether the geometry is equal to the geometry supplied by the caller. + * Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values. + * @param other {any} - The geometry to check against + * @return {boolean} - true if the two geometries are equal, otherwise false + */ + equals(other: any): boolean; + + /** + * To obtain a Well-Known-Text (WKT) representation of the geometry. + * @return {string} - the resulting WKT string + */ + toString(): string; + } + + class MultiLineString extends H.geo.MultiGeometry { + /** + * A MultiLineString is a collection of line strings represented as a H.geo.MultiGeometry with a H.geo.LineString as generic type parameter T. + * @param lineStrings {H.geo.LineString[]} - The list of line-strings which are initially represented by the MultiLineString. + * @throws {H.lang.InvalidArgumentError} - if the lineStrings argument is not valid + */ + constructor(lineStrings: H.geo.LineString[]); + + /** + * This method splices the specified MultiGeometry at the provided index, removing the specified number of items at that index and inserting new items. + * @param index {number} - The index at which to start changing the list. + * @param opt_deleteCount {number?} - The number of geometries to remove. + * @param opt_items {H.geo.LineString[]?} - The geometries to add. + * @return {H.geo.LineString[]} - the removed geometries + */ + splice(index: number, opt_deleteCount?: number, opt_items?: H.geo.LineString[]): H.geo.LineString[]; + + /** + * Removes a contained geometry at the given index. + * @param index {number} - The index of the geometry to remove. + * @return {H.geo.LineString} - the removed geometry. + * @throws {H.lang.OutOfRangeError} - if no geometry exists at the given index. + */ + removeAt(index: number): H.geo.LineString; + + /** + * Removes the specified geometry from the multi-geometry + * @param geometry {H.geo.LineString} -The geometry (by reference) to remove from this multi-geometry + * @return {H.geo.LineString} -the removed geometry or null if the geometry was not found + */ + remove(geometry: H.geo.LineString): H.geo.LineString; + + /** + * Returns the aggregated geometries of the multi-geometry. The returned geometries must be treated as read-only to not violate the integrity of the multi-geometry. + * @return {H.geo.LineString[]} - An array of geometries + */ + getGeometries(): H.geo.LineString[]; + + /** + * Adds the specified geometry to the current multi-geometry. + * @param geometry {H.geo.LineString} - A geometry which will be added to the current multi-geometry + * @throws {H.lang.InvalidArgumentError} - in case of invalid geometry argument + */ + push(geometry: H.geo.LineString): void; + + /** + * Returns the bounding rectangle of the geometry. + * @return {H.geo.Rect} - the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates) + */ + getBounds(): H.geo.Rect; + + /** + * Checks whether the geometry is equal to the geometry supplied by the caller. + * Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values. + * @param other {any} - The geometry to check against + * @return {boolean} - true if the two geometries are equal, otherwise false + */ + equals(other: any): boolean; + + /** + * To obtain a Well-Known-Text (WKT) representation of the geometry. + * @return {string} - the resulting WKT string + */ + toString(): string; + } + /** * PixelProjection transforms pixel world coordinates at a certain scale (zoom level) to geographical coordinates and vice versa. * By default, it uses the Mercator projection to transform geographic points into the 2d plane map points, which are adjusted to the current scale. @@ -2240,17 +2536,216 @@ declare namespace H { class Polyline extends H.map.GeoShape { /** * Constructor - * @param strip {H.geo.Strip} - the strip describing this polygon's vertices + * @param geometry {H.geo.Strip | H.geo.LineString | H.geo.MultiLineString} - The geometry that defines the line segments of the polyline * @param opt_options {H.map.Polyline.Options=} - optional initialization parameters */ - constructor(strip: H.geo.Strip, opt_options?: H.map.Polyline.Options); + constructor(geometry: H.geo.Strip | H.geo.LineString | H.geo.MultiLineString, opt_options?: H.map.Polyline.Options); /** - * This method clips this polyline against a rectangular area and returns the intersecting sub-lines. - * @param geoRect {H.geo.Rect} - * @returns {Array>} + * To set the polyline's geometry. If the given geometry is modified afterwards, it must be set again via setGeometry(geometry) to not violate the integrity of the polyline. + * @param geometry {H.geo.LineString | H.geo.MultiLineString} - the geometry to set. + * @return {H.map.Polyline} - The polyline instance itself. + */ + setGeometry(geometry: H.geo.LineString | H.geo.MultiLineString): H.map.Polyline; + + /** + * To obtain the polyline's geometry. If you modify the obtained geometry, you must call setGeometry(geometry) afterwards to not violate the integrity of the polyline. + * @return {H.geo.LineString | H.geo.MultiLineString} + */ + getGeometry(): H.geo.LineString | H.geo.MultiLineString; + + /** + * Clips the geometry of the Polyline to a rectangular area + * @param geoRect {H.geo.Rect} - The rectangle to clip against. + * @returns {Array>} - a list of geometry segments that intersecting the given rectangle. + * Each segment is represented as a list of alternating latitude and longitude coordinates that describes a line string. */ clip(geoRect: H.geo.Rect): number[][]; + + /** + * Returns the geometry. + * @deprecated since 3.0.15.0 + * @return {H.geo.Strip} - spatial object. + */ + getStrip(): H.geo.Strip; + + /** + * Sets the geometry. + * @deprecated since 3.0.15.0 + * @param strip {H.geo.Strip} - The strip which represents geometry. + * @return {H.map.GeoShape} - The given spatial object + */ + setStrip(strip: H.geo.Strip): H.map.GeoShape; + + /** + * Returns the smallest rectangle which encloses the whole geometry of the GeoShape. + * @return {H.geo.Rect} + */ + getBounds(): H.geo.Rect; + + /** + * This method retrieves the drawing style of the given spatial object. The returned style is treated as immutable and must not be modified afterwards to prevent inconsistencies! + * @return {H.map.SpatialStyle} - The given spatial object + */ + getStyle(): H.map.SpatialStyle; + + /** + * This method sets the drawing style of the given spatial object. If the argument opt_style is an instance of H.map.SpatialStyle, + * it is treated as immutable and must not be modified afterwards to prevent inconsistencies! + * @param opt_style {(H.map.SpatialStyle | H.map.SpatialStyle.Options)=} - The style to set. If it evaluates to a false, the H.map.SpatialStyle.DEFAULT_STYLE is used. + * @return {H.map.Spatial} - The given spatial object + */ + setStyle(opt_style?: H.map.SpatialStyle | H.map.SpatialStyle.Options): H.map.Spatial; + + /** + * This method retrieves the arrow style of the given spatial object or undefined if the style is not defined. + * The returned arrow style is treated as immutable and must not be modified afterwards to prevent inconsistencies! + * @return {H.map.ArrowStyle} - An object encapsulating information about the arrow style or undefined if the arrow style is not defined. + */ + getArrows(): H.map.ArrowStyle | undefined; + + /** + * This method sets the arrow style of the given spatial object. + * @param opt_arrows {(H.map.ArrowStyle | H.map.ArrowStyle.Options)=} - The arrow style to be applied + * @return {H.map.Spatial} - The given spatial object + */ + setArrows(opt_arrows?: H.map.ArrowStyle | H.map.ArrowStyle.Options): H.map.Spatial; + + /** + * This method indicates whether this spatial object represents a closed shape + * @return {boolean} - true if the given spatial object is a closed shape, false otherwise + */ + isClosed(): boolean; + + /** + * This method retrieves the ID of the given object. + * @return {any} The identifier of the given object. + */ + getId(): any; + + /** + * This method sets the visibility of the given object. + * @param opt_visibility {boolean=} - Indicates whether the map object should be visible. + * @return {H.map.Object} - The given object + */ + setVisibility(opt_visibility?: boolean): H.map.Object; + + /** + * This method retrieves a value indicating the visibility of the given object. + * @param opt_effective {boolean} - Indicates that the effective visibility is requested. In this case the visibility of all possible ancestor groups is also taken into account + * @return {boolean} - A value indicating if the object is visible (true) or not false + */ + getVisibility(opt_effective?: boolean): boolean; + + /** + * This method retrieves the z-index of the given object. + * @return {number} - A value reflecting the z-index of the given object. + */ + getZIndex(): number | undefined; + + /** + * This method sets the z-index of the given object. + * @param zIndex {number | undefined} - A value indicating the new z-index + * @return {H.map.Object} - The given object + */ + setZIndex(zIndex: number | undefined): H.map.Object; + + /** + * This method compares the rendering z-order of the given object with another object. (The 'given object' mean the object on which the method has been invoke.) + * @param other {H.map.Object} -The map object with which to compare the given object. + * @return {number} - A value lower than 0 indicates that the given object has a lower z-order. 0 indicates that both objects have the same z-order. + * A value greater than 0, indicates that the given object has a higher z-order. + */ + compareZOrder(other: H.map.Object): number; + + /** + * This method retrieves the parent group which contains the given object or null if the object is not contained in any group. + * @return {H.map.Group} - An object representing the containing group object or null if the given object is not contained in any group. + */ + getParentGroup(): H.map.Group; + + /** + * The root object to which the given object is attached or the object itself if it is not attached to another. + * @return {H.map.Object} - An object representing the root group for the given object or the given object if it is not part of a group. + */ + getRootGroup(): H.map.Object; + + /** + * This method checks whether the received object is an inclusive descendant of the given object. + * @param object {any} - The object to check. + * @return {boolean} - true if the given object is contained in the given object, otherwise false + */ + contains(object: any): boolean; + + /** + * This method obtains the current provider of the given object + * @return {H.map.provider.ObjectProvider} - An object representing the provider + */ + getProvider(): H.map.provider.ObjectProvider; + + /** + * This method retrieves the invalidation states for the given object. + * @return {H.map.provider.Invalidations} - An object containing the invalidation states + */ + getInvalidations(): H.map.provider.Invalidations; + + /** + * This method invalidates the given map object. + * @param flags {H.math.BitMask} - The flags indicating the types of changes to the given object + * @return {boolean} - Indicates whether a validation was executed (only if the object has a provider) + */ + invalidate(flags: H.math.BitMask): boolean; + + /** + * This method retrieves previously stored arbitrary data from the given object. + * @return {any} - The previously stored data or undefined if no data was stored. + */ + getData(): any; + + /** + * This method stores arbitrary data with the given map object. + * @param data {any} - The data to be stored + * @return {H.map.Object} - The given map object + */ + setData(data: any): H.map.Object; + + /** + * This method adds a listener for a specific event. + * Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it. + * @param type {string} - The name of the event + * @param handler {function()} - An event handler function + * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) + * @param opt_scope {{}=} - An object defining the scope for the handler function + */ + addEventListener(type: string, handler: () => void, opt_capture?: boolean, opt_scope?: {}): void; + + /** + * This method removes a previously added listener from the EventTarget instance. + * @param type {string} - The name of the event + * @param handler {function()} - An event handler function + * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) + * @param opt_scope {{}=} - An object defining the scope for the handler function + */ + removeEventListener(type: string, handler: () => void, opt_capture?: boolean, opt_scope?: {}): void; + + /** + * This method dispatches an event on the EventTarget object. + * @param evt {H.util.Event | string} - An object representing the event or a string with the event name + */ + dispatchEvent(evt: H.util.Event | string): void; + + /** + * This method removes listeners from the given object. + * Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. + */ + dispose(): void; + + /** + * This method adds a callback which is triggered when the EventTarget object is being disposed. + * @param callback {function()} - The callback function. + * @param opt_scope {{}=} - An optional scope for the callback function + */ + addOnDisposeCallback(callback: () => void, opt_scope?: {}): void; } namespace Polyline { @@ -3164,7 +3659,7 @@ declare namespace H { * sessions consistent IDs is needed (e.g. for storing provider data) this property must be specified. * @property min {number=} - The minimal supported zoom level, default is 0 * @property max {number=} - The maximal supported zoom level, default is 22 - * @property getCopyrights {(function(H.geo.Rect, number) : ?Array)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights + * @property getCopyrights {(function(H.geo.Rect, number): ?Array)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights * @property tileSize {number=} - The size of a tile as edge length in pixels. It must be 2^n where n is in range [0 ... 30], default is 256 * @property getURL {function(number, number, number)} - The function to create an URL for the specified tile. If it returns a falsy the tile is not requested. * @property crossOrigin {(string | boolean=)} - The CORS settings to use for the crossOrigin attribute for the image, if omitted or if the value evaluates to false no CORS settings @@ -3299,7 +3794,7 @@ declare namespace H { * Options which are used to initialize the MarkerTileProvider object. * @property min {number=} - The minimal supported zoom level, default is 0 * @property max {number=} - The maximal supported zoom level, default is 22 - * @property requestData {function(number, number, number, function(Array), Function) : H.util.ICancelable} - function that fetches marker data and creates array + * @property requestData {function(number, number, number, function(Array), Function): H.util.ICancelable} - function that fetches marker data and creates array * of H.map.AbstractMarker that is passed success callback, if function fails to fetch data onError callback must be called * @property providesDomMarkers {boolean=} - indicates if markers provided are of type H.map.DomMarker or H.map.Marker, default is H.map.Marker */ @@ -3463,7 +3958,7 @@ declare namespace H { * sessions consistent IDs is needed (e.g. for storing provider data) this property must be specified. * @property min {number=} - The minimal supported zoom level, default is 0 * @property max {number=} - The maximal supported zoom level, default is 22 - * @property getCopyrights {(function(H.geo.Rect, number) : ?Array)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights + * @property getCopyrights {(function(H.geo.Rect, number): ?Array)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights */ interface Options { uri?: string; @@ -6137,7 +6632,7 @@ declare namespace H { namespace ZoomRectangle { /** * @property alignment {H.ui.LayoutAlignment=} - the layout alignment which should be applied to this control, default is H.ui.LayoutAlignment.BOTTOM_RIGHT - * @property adjustZoom {function(number, H.Map) : number=} - optional function that defines how zoom level should be changed, by default zoom level is picked to fit the + * @property adjustZoom {function(number, H.Map): number=} - optional function that defines how zoom level should be changed, by default zoom level is picked to fit the * bounding rectangle into the view port. */ interface Options { @@ -6381,7 +6876,7 @@ declare namespace H { * Constructor * @param maxSize {number} - the maximum size of the cache * @param opt_onDrop {function(string, ?, number)=} - A callback to be invoked when a data element is dropped from the cache - * @param opt_filter {(function(string, ?, number) : boolean)=} - A function to filter data elements that are not to be cached + * @param opt_filter {(function(string, ?, number): boolean)=} - A function to filter data elements that are not to be cached */ constructor(maxSize: number, opt_onDrop?: (s: string, i: any, n: number) => void, opt_filter?: (s: string, i: any, n: number) => boolean); @@ -6432,14 +6927,14 @@ declare namespace H { * on those entries for which the predicated returns true. * @param callback {function(string, ?, number)} - the callback to be invoked for each entry * @param opt_ctx {Object=} - an optional context object to be used as this within the callback - * @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional match predicate to customize on which entries the callback will be called + * @param opt_matcher {(function(string, ?, number): boolean)=} - an optional match predicate to customize on which entries the callback will be called */ forEach(callback: (s: string, i: any, n: number) => void, opt_ctx?: any, opt_matcher?: (s: string, i: any, n: number) => boolean): void; /** * This method removes all data elements from the cache. If the optional match predicate is passed to this method only those data elements will be removed for which the predicate * return true. - * @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or + * @param opt_matcher {(function(string, ?, number): boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or * leave the entry in the cache respectively */ removeAll(opt_matcher?: (s: string, i: any, n: number) => boolean): void; @@ -6683,14 +7178,14 @@ declare namespace H { * those entries for which the predicated returns true. * @param callback {function(string, ?, number)} - the callback to be invoked for each entry * @param opt_ctx {Object=} - an optional context object to be used as this within the callback - * @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional match predicate to customize on which entries the callback will be called + * @param opt_matcher {(function(string, ?, number): boolean)=} - an optional match predicate to customize on which entries the callback will be called */ forEach(callback: (s: string, t: any, n: number) => void, opt_ctx?: {}, opt_matcher?: ((s: string, t: any, n: number) => boolean)): void; /** * This method removes all data elements from the cache. If the optional match predicate is passed to this method only those data elements will be removed for which the predicate * return true. - * @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or + * @param opt_matcher {(function(string, ?, number): boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or * leave the entry in the cache respectively */ removeAll(opt_matcher?: ((s: string, t: any, n: number) => boolean)): void; diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index 347c82576d..cf73a08e68 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -961,7 +961,7 @@ declare namespace Highcharts { * Use this in cases where a linear gradient between a minColor and maxColor is not sufficient. * The stops is an array of tuples, where the first item is a float between 0 and 1 assigning the relative position in the gradient, and the second item is the color. */ - stops?: Array<[number, string]>; + stops?: Array>; /** * The amount of ticks to draw on the axis. This opens up for aligning the ticks of multiple charts or panes within * a chart. This option overrides the tickPixelInterval option. @@ -1995,6 +1995,7 @@ declare namespace Highcharts { fontWeight?: string; left?: string; opacity?: number; + overflow?: string; padding?: string | number; position?: string; top?: string; @@ -3076,7 +3077,7 @@ declare namespace Highcharts { * @default ['50%', '50%'] * @since 2.3.0 */ - center?: [number | string, number | string]; + center?: Array; /** * The end angle of the polar X axis or gauge value axis, given in degrees where 0 is north. * @default startAngle + 360 diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index ad026a1e52..c4ea1bd7a8 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -1631,12 +1631,18 @@ function test_Gauge() { type: 'gauge' }, pane: { + center: ['50%', '85%'], startAngle: -150, endAngle: 150 }, yAxis: { min: 0, - max: 100 + max: 100, + stops: [ + [0.1, '#DF5353'], + [0.5, '#DDDF0D'], + [0.9, '#55BF3B'], + ], }, plotOptions: { gauge: { diff --git a/types/highland/highland-tests.ts b/types/highland/highland-tests.ts index e97c5c9416..5f1c734395 100644 --- a/types/highland/highland-tests.ts +++ b/types/highland/highland-tests.ts @@ -1,5 +1,3 @@ - - // Note: try to maintain the ordering and separators // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -49,18 +47,18 @@ var anyArrStream: Highland.Stream; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - interface Foo { - foo(): string; + foo(): string; } interface Bar { - bar(): string; + bar(): string; } interface StrFooArrMap { - [key:string]: Foo[]; + [key: string]: Foo[]; } interface StrBarArrMap { - [key:string]: Bar[]; + [key: string]: Bar[]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -128,9 +126,9 @@ fooStream = streamRedirect.to; fooStream = _(); fooStream = _(fooArr); fooStream = _((push, next) => { - push(null, foo); - push(err); - next(); + push(null, foo); + push(err); + next(); }); fooStream = _(fooStream); @@ -173,16 +171,23 @@ fooArrStream = fooStream.collect(); fooStream = fooStream.compact(); -barStream = fooStream.consume((err: Error, x: Foo, push: (err: Error, value?: Bar) => void, next: () => void) => { - push(err); - push(null, bar); - next(); -}); +barStream = fooStream.consume( + ( + err: Error, + x: Foo | Highland.Nil, + push: (err: Error, value?: Bar | Highland.Nil) => void, + next: () => void + ) => { + push(err); + push(null, bar); + next(); + } +); barStream = fooStream.consume((err, x, push, next) => { - push(err); - push(null, bar); - next(); + push(err); + push(null, bar); + next(); }); fooStream = fooStream.debounce(num); @@ -191,30 +196,32 @@ fooStream = fooStream.doto((x: Foo) => {}); fooStream = fooStream.drop(2); -fooStream = fooStream.errors((err: Error, push: (e: Error, x?: Foo) => void) => { - push(err); - push(null, x); - push(null, foo); -}); +fooStream = fooStream.errors( + (err: Error, push: (e: Error, x?: Foo) => void) => { + push(err); + push(null, x); + push(null, foo); + } +); fooStream = fooStream.errors((err, push) => { - push(err); - push(null, x); - push(null, foo); + push(err); + push(null, x); + push(null, foo); }); fooStream = fooStream.filter((x: Foo) => { - return bool; + return bool; }); fooStream = fooStream.find((x: Foo) => { - return bool; + return bool; }); fooStream = fooStream.findWhere(obj); strFooArrMapStream = fooStream.group((x: Foo) => { - return str; + return str; }); strFooArrMapStream = fooStream.group(str); @@ -227,7 +234,7 @@ fooStream = fooStream.last(); fooStream = fooStream.latest(); barStream = fooStream.map((x: Foo) => { - return bar; + return bar; }); barStream = fooStream.pluck(str); @@ -235,26 +242,24 @@ barStream = fooStream.pluck(str); fooStream = fooStream.ratelimit(3, 1000); barStream = fooStream.reduce(bar, (memo: Bar, x: Foo) => { - return memo; + return memo; }); barStream = fooStream.reduce1(bar, (memo: Bar, x: Foo) => { - return memo; + return memo; }); fooStream = fooStream.reject((x: Foo) => { - return bool; + return bool; }); barStream = fooStream.scan(bar, (memo: Bar, x: Foo) => { - return memo; + return memo; }); //missing scan1 -fooStream = fooStream.stopOnError((e: Error) => { - -}); +fooStream = fooStream.stopOnError((e: Error) => {}); fooStream = fooStream.take(num); @@ -264,7 +269,6 @@ fooStream = fooStream.throttle(num); fooStream = fooStream.where(obj); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // HIGHER-ORDER STREAMS // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -274,15 +278,15 @@ fooStream = fooStream.concat(fooStream); fooStream = fooStream.concat(fooArr); fooStream = fooStream.flatFilter((x: Foo) => { - return boolStream; + return boolStream; }); barStream = fooStream.flatMap((x: Foo) => { - return barStream; + return barStream; }); barStream = fooStream.flatMap((x: Foo) => { - return bar; + return bar; }); barStream = fooStream.flatten(); @@ -315,24 +319,16 @@ fooStream.apply(func); fooStream.done(() => {}); -fooStream.each((x: Foo) => { - -}); +fooStream.each((x: Foo) => {}); fooStream = fooStream.pipe(fooStream); barStream = fooStream.pipe(barStream); -fooStream.pull((err: Error, x: Foo) => { +fooStream.pull((err: Error, x: Foo) => {}); -}); +fooStream.pull((err, x) => {}); -fooStream.pull((err, x) => { - -}); - -fooStream.toArray((arr: Foo[]) => { - -}); +fooStream.toArray((arr: Foo[]) => {}); fooStream.toCallback((err: Error, x: Foo) => {}); fooStream.toCallback((err: Error) => {}); @@ -360,7 +356,6 @@ f = _.wrapCallback(func, num); f = _.wrapCallback(func, strArr); f = _.wrapCallback(func, fn); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // OBJECTS // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/types/highland/index.d.ts b/types/highland/index.d.ts index 3a2116a4d8..eff8fb2769 100644 --- a/types/highland/index.d.ts +++ b/types/highland/index.d.ts @@ -75,7 +75,7 @@ interface HighlandStatic { (): Highland.Stream; (xs: Highland.Stream[]): Highland.Stream; (xs: R[]): Highland.Stream; - (xs: (push: (err: Error | null, x?: R) => void, next: () => void) => void): Highland.Stream; + (xs: (push: (err: Error | null, x?: R | Highland.Nil) => void, next: () => void) => void): Highland.Stream; (xs: Highland.Stream): Highland.Stream; (xs: NodeJS.ReadableStream): Highland.Stream; @@ -563,7 +563,7 @@ declare namespace Highland { * @param {Function} f - the function to handle errors and values * @api public */ - consume(f: (err: Error, x: R, push: (err: Error | null, value?: U) => void, next: () => void) => void): Stream; + consume(f: (err: Error, x: R | Highland.Nil, push: (err: Error | null, value?: U | Highland.Nil) => void, next: () => void) => void): Stream; /** * Holds off pushing data events downstream until there has been no more @@ -614,9 +614,9 @@ declare namespace Highland { * * _([1, 2, 3, 4]).drop(2) // => 3, 4 */ - drop(n: number): Stream; + drop(n: number): Stream; - /** + /** * Extracts errors from a Stream and applies them to an error handler * function. Returns a new Stream with the errors removed (unless the error * handler chooses to rethrow them using `push`). Errors can also be @@ -653,7 +653,7 @@ declare namespace Highland { */ find(f: (x: R) => boolean): Stream; - /** + /** * A convenient form of [where](#where), which returns the first object from a * Stream that matches a set of property values. findWhere is to [where](#where) as [find](#find) is to [filter](#filter). * diff --git a/types/html-webpack-plugin/index.d.ts b/types/html-webpack-plugin/index.d.ts index 35774c1ac6..c3db12f4e7 100644 --- a/types/html-webpack-plugin/index.d.ts +++ b/types/html-webpack-plugin/index.d.ts @@ -4,7 +4,7 @@ // Benjamin Lim // Tomek Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin } from 'webpack'; import { Options as HtmlMinifierOptions } from 'html-minifier'; diff --git a/types/html-webpack-template/index.d.ts b/types/html-webpack-template/index.d.ts index b02be3c463..1436728a72 100644 --- a/types/html-webpack-template/index.d.ts +++ b/types/html-webpack-template/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/jaketrent/html-webpack-template // Definitions by: Benjamin Lim // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin'; diff --git a/types/iban/iban-tests.ts b/types/iban/iban-tests.ts index ac79e97a99..574769c461 100644 --- a/types/iban/iban-tests.ts +++ b/types/iban/iban-tests.ts @@ -39,7 +39,7 @@ function testIsValidBBAN() { */ function testPrintFormat() { var iban: string = 'BE68539007547034'; - var separator: string[] = ['fr']; + var separator: string = ' '; var format: string = IBAN.printFormat(iban, separator); } @@ -48,6 +48,6 @@ function testPrintFormat() { */ function testToBBAN() { var iban: string = 'BE68539007547034'; - var separator: string[] = ['-']; + var separator: string = '-'; var bban: string = IBAN.toBBAN(iban, separator); -} \ No newline at end of file +} diff --git a/types/iban/index.d.ts b/types/iban/index.d.ts index a47cfa618f..2b14d73954 100644 --- a/types/iban/index.d.ts +++ b/types/iban/index.d.ts @@ -42,17 +42,17 @@ interface IBANStatic { /** * @summary Returns the IBAN in a print format. * @param {string} iban The IBAN to convert. - * @param {string} The IBAN in print format. + * @param {string} separator The separator to use between IBAN blocks, defaults to ' '. */ - printFormat(iban: string, separator: string[]): string; + printFormat(iban: string, separator?: string): string; /** * @summary Convert the passed IBAN to a country-specific BBAN. * @param {string} iban The IBAN to convert. - * @param {string[]} Separator the separator to use between BBAN blocks. + * @param {string} separator The separator to use between BBAN blocks, defaults to ' '. * @returns {string} The BBAN */ - toBBAN(iban: string, separator: string[]): string; + toBBAN(iban: string, separator?: string): string; } declare var IBAN: IBANStatic; diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index 32c54fa99e..67d8fd29ac 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -3,16 +3,21 @@ // Definitions by: Qubo // Parvez // Jouderian +// Qibang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// -import through = require('through'); +import through = require("through"); declare namespace inquirer { type Prompts = { [name: string]: PromptModule }; type ChoiceType = string | objects.ChoiceOption | objects.Separator; - type Questions = Question | Question[] | Rx.Observable; + type Questions = + | Question + | Question[] + | Rx.Observable>; interface Inquirer { restoreDefaultPrompts(): void; @@ -32,19 +37,19 @@ declare namespace inquirer { * @param cb Callback being passed the user answers * @return */ - prompt(questions: Questions, cb: (answers: Answers) => any): ui.Prompt; - prompt(questions: Questions): Promise; + prompt(questions: Questions, cb: (answers: T) => any): ui.Prompt; + prompt(questions: Questions): Promise; prompts: Prompts; Separator: objects.SeparatorStatic; ui: { BottomBar: ui.BottomBar; Prompt: ui.Prompt; - } + }; } interface PromptModule { - (questions: Questions): Promise; - (questions: Questions, cb: (answers: Answers) => any): ui.Prompt; + (questions: Questions): Promise; + (questions: Questions, cb: (answers: T) => any): ui.Prompt; /** * Register a prompt type * @param name Prompt type name @@ -57,7 +62,7 @@ declare namespace inquirer { restoreDefaultPrompts(): void; } - interface Question { + interface Question { /** * Type of the prompt. * Possible values: @@ -79,24 +84,24 @@ declare namespace inquirer { * The question to print. If defined as a function, * the first parameter will be the current inquirer session answers. */ - message?: string | ((answers: Answers) => string); + message?: string | ((answers: T) => string); /** * Default value(s) to use if nothing is entered, or a function that returns the default value(s). * If defined as a function, the first parameter will be the current inquirer session answers. */ - default?: any | ((answers: Answers) => any); + default?: any | ((answers: T) => any); /** * Choices array or a function returning a choices array. If defined as a function, * the first parameter will be the current inquirer session answers. * Array values can be simple strings, or objects containing a name (to display) and a value properties * (to save in the answers hash). Values can also be a Separator. */ - choices?: ChoiceType[] | ((answers: Answers) => ChoiceType[]); + choices?: ChoiceType[] | ((answers: T) => ChoiceType[]); /** * Receive the user input and should return true if the value is valid, and an error message (String) * otherwise. If false is returned, a default error message is provided. */ - validate?(input: string, answers?: Answers): boolean | string; + validate?(input: string, answers?: T): boolean | string; /** * Receive the user input and return the filtered value to be used inside the program. * The value returned will be added to the Answers hash. @@ -106,7 +111,7 @@ declare namespace inquirer { * Receive the current user answers hash and should return true or false depending on whether or * not this question should be asked. The value can also be a simple boolean. */ - when?: boolean | ((answers: Answers) => boolean); + when?: boolean | ((answers: T) => boolean); paginated?: boolean; /** * Change the number of lines that will be rendered when using list, rawList, expand or checkbox. @@ -143,10 +148,10 @@ declare namespace inquirer { * Once all prompt are over */ onCompletion(): void; - processQuestion(question: Question): any; - fetchAnswer(question: Question): any; - setDefaultType(question: Question): any; - filterIfRunnable(question: Question): any; + processQuestion(question: Question): any; + fetchAnswer(question: Question): any; + setDefaultType(question: Question): any; + filterIfRunnable(question: Question): any; } /** @@ -237,7 +242,7 @@ declare namespace inquirer { extra?: any; key?: string; checked?: boolean; - disabled?: string | ((answers: Answers) => any); + disabled?: string | ((answers: T) => any); } /** @@ -247,7 +252,10 @@ declare namespace inquirer { * @param choices All `choice` to keep in the collection */ interface Choices { - new (choices: (string | Separator | ChoiceOption)[], answers?: Answers): Choices; + new ( + choices: (string | Separator | ChoiceOption)[], + answers?: T + ): Choices; choices: Choice[]; realChoices: Choice[]; length: number; diff --git a/types/inquirer/inquirer-tests.ts b/types/inquirer/inquirer-tests.ts index 4a43dcc98e..bd1d6a5ac4 100644 --- a/types/inquirer/inquirer-tests.ts +++ b/types/inquirer/inquirer-tests.ts @@ -1,9 +1,13 @@ -import inquirer = require('inquirer'); +import inquirer = require("inquirer"); - -inquirer.prompt([/* Pass your questions in here */], function( answers: inquirer.Answers ) { - // Use user feedback for... whatever!! -}); +inquirer.prompt( + [ + /* Pass your questions in here */ + ], + function(answers: inquirer.Answers) { + // Use user feedback for... whatever!! + } +); // // examples/bottom-bar.js @@ -13,29 +17,25 @@ inquirer.prompt([/* Pass your questions in here */], function( answers: inquirer var BottomBar = inquirer.ui.BottomBar; declare var cmdify: any; -var loader = [ - "/ Installing", - "| Installing", - "\\ Installing", - "- Installing" -]; +var loader = ["/ Installing", "| Installing", "\\ Installing", "- Installing"]; var i = 4; var ui = new BottomBar({ bottomBar: loader[i % 4] }); setInterval(function() { - ui.updateBottomBar( loader[i++ % 4] ); -}, 300 ); + ui.updateBottomBar(loader[i++ % 4]); +}, 300); var spawn = require("child_process").spawn; -var cmd = spawn(cmdify("npm"), [ "-g", "install", "inquirer" ], { stdio: "pipe" }); -cmd.stdout.pipe( ui.log ); -cmd.on( "close", function() { +var cmd = spawn(cmdify("npm"), ["-g", "install", "inquirer"], { + stdio: "pipe" +}); +cmd.stdout.pipe(ui.log); +cmd.on("close", function() { ui.updateBottomBar("Installation done!\n"); process.exit(); }); - // // examples/checkbox.js // @@ -47,49 +47,51 @@ cmd.on( "close", function() { "use strict"; //var inquirer = require("../lib/inquirer"); -inquirer.prompt([ - { - type: "checkbox", - message: "Select toppings", - name: "toppings", - choices: [ - new inquirer.Separator("The usual:"), - { - name: "Pepperoni" - }, - { - name: "Cheese", - checked: true - }, - { - name: "Mushroom" - }, - new inquirer.Separator("The extras:"), - { - name: "Pineapple", - }, - { - name: "Bacon" - }, - { - name: "Olives", - disabled: "out of stock" - }, - { - name: "Extra cheese" +inquirer.prompt<{ toppings: string }>( + [ + { + type: "checkbox", + message: "Select toppings", + name: "toppings", + choices: [ + new inquirer.Separator("The usual:"), + { + name: "Pepperoni" + }, + { + name: "Cheese", + checked: true + }, + { + name: "Mushroom" + }, + new inquirer.Separator("The extras:"), + { + name: "Pineapple" + }, + { + name: "Bacon" + }, + { + name: "Olives", + disabled: "out of stock" + }, + { + name: "Extra cheese" + } + ], + validate: function(answer) { + if (answer.length < 1) { + return "You must choose at least one topping."; + } + return true; } - ], - validate: function( answer ) { - if ( answer.length < 1 ) { - return "You must choose at least one topping."; - } - return true; } + ], + function(answers) { + console.log(JSON.stringify(answers, null, " ")); } -], function( answers: inquirer.Answers ) { - console.log( JSON.stringify(answers, null, " ") ); -}); - +); // // examples/expand.js @@ -102,39 +104,41 @@ inquirer.prompt([ "use strict"; //var inquirer = require("../lib/inquirer"); -inquirer.prompt([ - { - type: "expand", - message: "Conflict on `file.js`: ", - name: "overwrite", - choices: [ - { - key: "y", - name: "Overwrite", - value: "overwrite" - }, - { - key: "a", - name: "Overwrite this one and all next", - value: "overwrite_all" - }, - { - key: "d", - name: "Show diff", - value: "diff" - }, - new inquirer.Separator(), - { - key: "x", - name: "Abort", - value: "abort" - } - ] +inquirer.prompt( + [ + { + type: "expand", + message: "Conflict on `file.js`: ", + name: "overwrite", + choices: [ + { + key: "y", + name: "Overwrite", + value: "overwrite" + }, + { + key: "a", + name: "Overwrite this one and all next", + value: "overwrite_all" + }, + { + key: "d", + name: "Show diff", + value: "diff" + }, + new inquirer.Separator(), + { + key: "x", + name: "Abort", + value: "abort" + } + ] + } + ], + function(answers: inquirer.Answers) { + console.log(JSON.stringify(answers, null, " ")); } -], function( answers: inquirer.Answers ) { - console.log( JSON.stringify(answers, null, " ") ); -}); - +); // // examples/input.js @@ -152,21 +156,25 @@ var questions = [ type: "input", name: "first_name", message: "What's your first name", - prefix: "1 - ", + prefix: "1 - " }, { type: "input", name: "last_name", message: "What's your last name", - default: function () { return "Doe"; }, + default: function() { + return "Doe"; + }, suffix: "!!" }, { type: "input", name: "phone", message: "What's your phone number", - validate: function( value: string ): string|boolean { - var pass = value.match(/^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i); + validate: function(value: string): string | boolean { + var pass = value.match( + /^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i + ); if (pass) { return true; } else { @@ -176,15 +184,14 @@ var questions = [ } ]; -inquirer.prompt( questions, function( answers ) { - console.log( JSON.stringify(answers, null, " ") ); +inquirer.prompt(questions, function(answers) { + console.log(JSON.stringify(answers, null, " ")); }); // // examples/list.js // - /** * List prompt example */ @@ -192,29 +199,34 @@ inquirer.prompt( questions, function( answers ) { "use strict"; //var inquirer = require("../lib/inquirer"); -inquirer.prompt([ - { - type: "list", - name: "theme", - message: "What do you want to do?", - choices: [ - "Order a pizza", - "Make a reservation", - new inquirer.Separator(), - "Ask opening hours", - "Talk to the receptionist" - ] - }, - { - type: "list", - name: "size", - message: "What size do you need", - choices: [ "Jumbo", "Large", "Standard", "Medium", "Small", "Micro" ], - filter: function( val: string ) { return val.toLowerCase(); } +inquirer.prompt( + [ + { + type: "list", + name: "theme", + message: "What do you want to do?", + choices: [ + "Order a pizza", + "Make a reservation", + new inquirer.Separator(), + "Ask opening hours", + "Talk to the receptionist" + ] + }, + { + type: "list", + name: "size", + message: "What size do you need", + choices: ["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"], + filter: function(val: string) { + return val.toLowerCase(); + } + } + ], + function(answers: inquirer.Answers) { + console.log(JSON.stringify(answers, null, " ")); } -], function( answers: inquirer.Answers ) { - console.log( JSON.stringify(answers, null, " ") ); -}); +); // // examples/long-list.js @@ -227,30 +239,35 @@ inquirer.prompt([ "use strict"; //var inquirer = require("../lib/inquirer"); -var choices = Array.apply(0, new Array(26)).map(function(x: number,y: number) { +var choices = Array.apply(0, new Array(26)).map(function(x: number, y: number) { return String.fromCharCode(y + 65); }); choices.push("Multiline option \n super cool feature"); -choices.push("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium."); +choices.push( + "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium." +); -inquirer.prompt([ - { - type : "list", - name : "letter", - message : "What's your favorite letter?", - paginated : true, - choices : choices - }, - { - type : "checkbox", - name : "name", - message : "Select the letter contained in your name:", - paginated : true, - choices : choices +inquirer.prompt( + [ + { + type: "list", + name: "letter", + message: "What's your favorite letter?", + paginated: true, + choices: choices + }, + { + type: "checkbox", + name: "name", + message: "Select the letter contained in your name:", + paginated: true, + choices: choices + } + ], + function(answers: inquirer.Answers) { + console.log(JSON.stringify(answers, null, " ")); } -], function( answers: inquirer.Answers ) { - console.log( JSON.stringify(answers, null, " ") ); -}); +); // // examples/nested-call.js @@ -263,19 +280,22 @@ inquirer.prompt([ "use strict"; //var inquirer = require("../lib/inquirer"); -inquirer.prompt({ - type: "list", - name: "chocolate", - message: "What's your favorite chocolate?", - choices: [ "Mars", "Oh Henry", "Hershey" ] -}, function( answers: inquirer.Answers ) { - inquirer.prompt({ +inquirer.prompt( + { type: "list", - name: "beverage", - message: "And your favorite beverage?", - choices: [ "Pepsi", "Coke", "7up", "Mountain Dew", "Red Bull" ] - }); -}); + name: "chocolate", + message: "What's your favorite chocolate?", + choices: ["Mars", "Oh Henry", "Hershey"] + }, + function(answers: inquirer.Answers) { + inquirer.prompt({ + type: "list", + name: "beverage", + message: "And your favorite beverage?", + choices: ["Pepsi", "Coke", "7up", "Mountain Dew", "Red Bull"] + }); + } +); // // examples/password.js @@ -288,15 +308,18 @@ inquirer.prompt({ "use strict"; //var inquirer = require("../lib/inquirer"); -inquirer.prompt([ - { - type: "password", - message: "Enter your git password", - name: "password" +inquirer.prompt( + [ + { + type: "password", + message: "Enter your git password", + name: "password" + } + ], + function(answers: inquirer.Answers) { + console.log(JSON.stringify(answers, null, " ")); } -], function( answers: inquirer.Answers ) { - console.log( JSON.stringify(answers, null, " ") ); -}); +); // // examples/pizza.js @@ -323,8 +346,10 @@ var questions2 = [ type: "input", name: "phone", message: "What's your phone number", - validate: function( value: string ): string|boolean { - var pass = value.match(/^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i); + validate: function(value: string): string | boolean { + var pass = value.match( + /^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i + ); if (pass) { return true; } else { @@ -336,14 +361,16 @@ var questions2 = [ type: "list", name: "size", message: "What size do you need", - choices: [ "Large", "Medium", "Small" ], - filter: function( val: string ) { return val.toLowerCase(); } + choices: ["Large", "Medium", "Small"], + filter: function(val: string) { + return val.toLowerCase(); + } }, { type: "input", name: "quantity", message: "How many do you need", - validate: function( value: string ) { + validate: function(value: string) { var valid = !isNaN(parseFloat(value)); return valid || "Please enter a number"; }, @@ -375,7 +402,7 @@ var questions2 = [ type: "rawlist", name: "beverage", message: "You also get a free 2L beverage", - choices: [ "Pepsi", "7up", "Coke" ] + choices: ["Pepsi", "7up", "Coke"] }, { type: "input", @@ -387,16 +414,16 @@ var questions2 = [ type: "list", name: "prize", message: "For leaving a comments, you get a freebie", - choices: [ "cake", "fries" ], - when: function( answers: inquirer.Answers ) { - return answers['comments'] !== "Nope, all good!"; + choices: ["cake", "fries"], + when: function(answers: inquirer.Answers) { + return answers["comments"] !== "Nope, all good!"; } } ]; -inquirer.prompt( questions, function( answers ) { +inquirer.prompt(questions, function(answers) { console.log("\nOrder receipt:"); - console.log( JSON.stringify(answers, null, " ") ); + console.log(JSON.stringify(answers, null, " ")); }); // @@ -410,29 +437,34 @@ inquirer.prompt( questions, function( answers ) { "use strict"; //var inquirer = require("../lib/inquirer"); -inquirer.prompt([ - { - type: "rawlist", - name: "theme", - message: "What do you want to do?", - choices: [ - "Order a pizza", - "Make a reservation", - new inquirer.Separator(), - "Ask opening hours", - "Talk to the receptionist" - ] - }, - { - type: "rawlist", - name: "size", - message: "What size do you need", - choices: [ "Jumbo", "Large", "Standard", "Medium", "Small", "Micro" ], - filter: function( val: string ) { return val.toLowerCase(); } +inquirer.prompt( + [ + { + type: "rawlist", + name: "theme", + message: "What do you want to do?", + choices: [ + "Order a pizza", + "Make a reservation", + new inquirer.Separator(), + "Ask opening hours", + "Talk to the receptionist" + ] + }, + { + type: "rawlist", + name: "size", + message: "What size do you need", + choices: ["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"], + filter: function(val: string) { + return val.toLowerCase(); + } + } + ], + function(answers: inquirer.Answers) { + console.log(JSON.stringify(answers, null, " ")); } -], function( answers: inquirer.Answers ) { - console.log( JSON.stringify(answers, null, " ") ); -}); +); // // examples/recursive.js @@ -445,7 +477,7 @@ inquirer.prompt([ "use strict"; //var inquirer = require("../lib/inquirer"); -var output2: (string|boolean)[] = []; +var output2: (string | boolean)[] = []; var questions3 = [ { @@ -456,18 +488,21 @@ var questions3 = [ { type: "confirm", name: "askAgain", - message: "Want to enter another TV show favorite (just hit enter for YES)?", + message: + "Want to enter another TV show favorite (just hit enter for YES)?", default: true } ]; function ask() { - inquirer.prompt( questions3, function( answers: inquirer.Answers ) { - output2.push( answers['tvShow'] ); - if ( answers['askAgain'] ) { + inquirer.prompt<{ tvShow: string; askAgain: boolean }>(questions3, function( + answers + ) { + output2.push(answers.tvShow); + if (answers.askAgain) { ask(); } else { - console.log( "Your favorite TV Shows:", output2.join(", ") ); + console.log("Your favorite TV Shows:", output2.join(", ")); } }); } @@ -478,14 +513,17 @@ ask(); // examples/when.js // - /** * When example */ "use strict"; //var inquirer = require("../lib/inquirer"); - +interface Answers4 { + bacon: boolean; + favorite: string; + pizza: boolean; +} var questions4 = [ { type: "confirm", @@ -496,32 +534,32 @@ var questions4 = [ type: "input", name: "favorite", message: "Bacon lover, what is your favorite type of bacon?", - when: function ( answers: inquirer.Answers ) { - return answers['bacon']; + when: function(answers: Answers4) { + return answers.bacon; } }, { type: "confirm", name: "pizza", message: "Ok... Do you like pizza?", - when: function (answers: inquirer.Answers) { - return !likesFood( "bacon" )(answers); + when: function(answers: Answers4) { + return !likesFood("bacon")(answers); } }, { type: "input", name: "favorite", message: "Whew! What is your favorite type of pizza?", - when: likesFood( "pizza" ) + when: likesFood("pizza") } ]; -function likesFood ( aFood: string ) { - return function ( answers: inquirer.Answers ) { - return answers[ aFood ]; - } +function likesFood(aFood: string) { + return function(answers: inquirer.Answers) { + return answers[aFood]; + }; } -inquirer.prompt(questions, function (answers) { - console.log( JSON.stringify(answers, null, " ") ); +inquirer.prompt(questions, function(answers) { + console.log(JSON.stringify(answers, null, " ")); }); diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index de71a9f083..d072e003a8 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -595,6 +595,7 @@ declare namespace IORedis { hget(key: string, field: string, callback?: (err: Error, res: string) => void): Pipeline; hmset(key: string, field: string, value: any, ...args: string[]): Pipeline; + hmset(key: string, data: any, callback?: (err: Error, res: 0 | 1) => void): Pipeline; hmget(key: string, ...fields: string[]): Pipeline; diff --git a/types/johnny-five/index.d.ts b/types/johnny-five/index.d.ts index b8c108f63b..297069f0f1 100644 --- a/types/johnny-five/index.d.ts +++ b/types/johnny-five/index.d.ts @@ -597,12 +597,12 @@ export declare class Pin { mode: number; static write(pin: number, value: number): void; - static read(pin: number, cb: (data: number) => void): void; + static read(pin: number, cb: (error: Error, data: number) => void): void; query(cb: (pin: PinState) => void): void; high(): void; low(): void; write(value: number): void; - read(cb: (value: number) => void): void; + read(cb: (error: Error, value: number) => void): void; on(event: string, cb: () => void): this; on(event: "high", cb: () => void): this; on(event: "low", cb: () => void): this; diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index 94ffd188cf..6e2b7be6c7 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -10,6 +10,7 @@ // Youngrok Kim // Dan Kraus // Anjun Wang +// Rafael Kallis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -376,7 +377,7 @@ export interface AnySchema extends JoiObject { * override, that error will be returned and the override will be ignored (unless the `abortEarly` * option has been set to `false`). */ - error?(err: Error | ValidationErrorFunction): this; + error(err: Error | ValidationErrorFunction): this; /** * Returns a plain object representing the schema's rules and properties diff --git a/types/jquery.browser/index.d.ts b/types/jquery.browser/index.d.ts new file mode 100644 index 0000000000..01141b67db --- /dev/null +++ b/types/jquery.browser/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for jQuery Browser Plugin 0.1 +// Project: https://github.com/gabceb/jquery-browser-plugin +// Definitions by: Anderson Friaça +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +export interface Matchs { + version?: string; + versionNumber?: number; + platform?: string; + mobile?: boolean; + desktop?: boolean; + webkit?: boolean; + name?: string; + android?: boolean; + bb?: boolean; + blackberry?: boolean; + ipad?: boolean; + iphone?: boolean; + ipod?: boolean; + kindle?: boolean; + playbook?: boolean; + silk?: boolean; + ['windows phone']?: boolean; + cros?: boolean; + mac?: boolean; + linux?: boolean; + win?: boolean; + chrome?: boolean; + opr?: boolean; + safari?: boolean; + rv?: boolean; + iemobile?: boolean; + msie?: boolean; + msedge?: boolean; + uaMatch: ((ua?: string) => Matchs); +} +declare global { + interface Window { + jQBrowser: Matchs; + } + interface JQueryStatic { + browser: Matchs; + } +} diff --git a/types/jquery.browser/jquery.browser-tests.ts b/types/jquery.browser/jquery.browser-tests.ts new file mode 100644 index 0000000000..aacc014524 --- /dev/null +++ b/types/jquery.browser/jquery.browser-tests.ts @@ -0,0 +1,7 @@ +// basic usage +$.browser; +$.browser.android; +$.browser.uaMatch(); +window.jQBrowser; +window.jQBrowser.android; +window.jQBrowser.uaMatch(); diff --git a/types/jquery.browser/tsconfig.json b/types/jquery.browser/tsconfig.json new file mode 100644 index 0000000000..89c26d12bb --- /dev/null +++ b/types/jquery.browser/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "jquery.browser-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jquery.browser/tslint.json b/types/jquery.browser/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/jquery.browser/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 90f6ffbd03..8422f3ec5c 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -152,7 +152,7 @@ interface JQueryStatic { * @since 1.4 */ (selector_object_callback?: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery | - JQuery.PlainObject | + JQuery.PlainObject | Window | ((this: Document, $: JQueryStatic) => void)): JQuery; /** * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. diff --git a/types/jquery/test/jquery-slim-window-module-tests.ts b/types/jquery/test/jquery-slim-window-module-tests.ts index 76870e7a04..b47707cb23 100644 --- a/types/jquery/test/jquery-slim-window-module-tests.ts +++ b/types/jquery/test/jquery-slim-window-module-tests.ts @@ -1,4 +1,4 @@ -import * as jq from 'jquery/dist/jquery.slim'; +import jq = require('jquery/dist/jquery.slim'); const $window = jq(window); // $ExpectType JQuery diff --git a/types/jquery/test/jquery-window-module-tests.ts b/types/jquery/test/jquery-window-module-tests.ts index 71e20bc4a0..6bc5486fb9 100644 --- a/types/jquery/test/jquery-window-module-tests.ts +++ b/types/jquery/test/jquery-window-module-tests.ts @@ -1,4 +1,4 @@ -import * as jq from 'jquery'; +import jq = require('jquery'); const $window = jq(window); // $ExpectType JQuery diff --git a/types/js-money/index.d.ts b/types/js-money/index.d.ts new file mode 100644 index 0000000000..e778cf1fdb --- /dev/null +++ b/types/js-money/index.d.ts @@ -0,0 +1,166 @@ +// Type definitions for js-money 0.6 +// Project: https://github.com/davidkalosi/js-money +// Definitions by: Kanat Kubash +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Currency } from './lib/currency'; + +interface MoneyObjectOut { + amount: number; + currency: string; +} + +type Rounders = 'round' | 'floor' | 'ceil'; + +type RoundFunction = (num: number) => number; + +declare class Money { + constructor(amount: number, currency: string | Currency); + amount: number; + currency: string; + static fromInteger(amount: number, currency: string | Currency): Money; + static fromDecimal(amount: number, currency: string | Currency, rounder?: Rounders | RoundFunction): Money; + equals(other: Money): boolean; + add(other: Money): Money; + subtract(other: Money): Money; + multiply(multiplier: number, rounder?: RoundFunction): Money; + divide(divisor: number, rounder?: RoundFunction): Money; + allocate(ratios: number[]): Money[]; + compare(other: Money): number; + greaterThan(other: Money): boolean; + greaterThanOrEqual(other: Money): boolean; + lessThan(other: Money): boolean; + lessThanOrEqual(other: Money): boolean; + isZero(): boolean; + isPositive(): boolean; + isNegative(): boolean; + toDecimal(): number; + toString(): string; + toJSON(): MoneyObjectOut; + getAmount(): number; + getCurrency(): string; + //#region Currencies + static USD: Currency; + static CAD: Currency; + static EUR: Currency; + static BTC: Currency; + static AED: Currency; + static AFN: Currency; + static ALL: Currency; + static AMD: Currency; + static ARS: Currency; + static AUD: Currency; + static AZN: Currency; + static BAM: Currency; + static BDT: Currency; + static BGN: Currency; + static BHD: Currency; + static BIF: Currency; + static BND: Currency; + static BOB: Currency; + static BRL: Currency; + static BWP: Currency; + static BYR: Currency; + static BZD: Currency; + static CDF: Currency; + static CHF: Currency; + static CLP: Currency; + static CNY: Currency; + static COP: Currency; + static CRC: Currency; + static CVE: Currency; + static CZK: Currency; + static DJF: Currency; + static DKK: Currency; + static DOP: Currency; + static DZD: Currency; + static EEK: Currency; + static EGP: Currency; + static ERN: Currency; + static ETB: Currency; + static GBP: Currency; + static GEL: Currency; + static GHS: Currency; + static GNF: Currency; + static GTQ: Currency; + static HKD: Currency; + static HNL: Currency; + static HRK: Currency; + static HUF: Currency; + static IDR: Currency; + static ILS: Currency; + static INR: Currency; + static IQD: Currency; + static IRR: Currency; + static ISK: Currency; + static JMD: Currency; + static JOD: Currency; + static JPY: Currency; + static KES: Currency; + static KHR: Currency; + static KMF: Currency; + static KRW: Currency; + static KWD: Currency; + static KZT: Currency; + static LAK: Currency; + static LBP: Currency; + static LKR: Currency; + static LTL: Currency; + static LVL: Currency; + static LYD: Currency; + static MAD: Currency; + static MDL: Currency; + static MGA: Currency; + static MKD: Currency; + static MMK: Currency; + static MOP: Currency; + static MUR: Currency; + static MXN: Currency; + static MYR: Currency; + static MZN: Currency; + static NAD: Currency; + static NGN: Currency; + static NIO: Currency; + static NOK: Currency; + static NPR: Currency; + static NZD: Currency; + static OMR: Currency; + static PAB: Currency; + static PEN: Currency; + static PHP: Currency; + static PKR: Currency; + static PLN: Currency; + static PYG: Currency; + static QAR: Currency; + static RON: Currency; + static RSD: Currency; + static RUB: Currency; + static RWF: Currency; + static SAR: Currency; + static SDG: Currency; + static SEK: Currency; + static SGD: Currency; + static SOS: Currency; + static SYP: Currency; + static THB: Currency; + static TND: Currency; + static TOP: Currency; + static TRY: Currency; + static TTD: Currency; + static TWD: Currency; + static TZS: Currency; + static UAH: Currency; + static UGX: Currency; + static UYU: Currency; + static UZS: Currency; + static VEF: Currency; + static VND: Currency; + static XAF: Currency; + static XOF: Currency; + static YER: Currency; + static ZAR: Currency; + static ZMK: Currency; + //#endregion +} + +export = Money; diff --git a/types/js-money/js-money-tests.ts b/types/js-money/js-money-tests.ts new file mode 100644 index 0000000000..a75d41ac53 --- /dev/null +++ b/types/js-money/js-money-tests.ts @@ -0,0 +1,63 @@ +import Money = require('js-money'); +import * as CurrencyObjects from 'js-money/lib/currency'; + +const money = new Money(1500, 'USD'); +const other = new Money(100, Money.THB); + +// instance method checks +new Money(123, Money.TRY); // $ExpectType Money +new Money(1500, 'USD'); // $ExpectType Money +money.amount; // $ExpectType number +money.currency; // $ExpectType string +money.equals(other); // $ExpectType boolean +money.add(other); // $ExpectType Money +money.subtract(other); // $ExpectType Money +money.multiply(1); // $ExpectType Money +money.multiply(2, Math.round); // $ExpectType Money +money.divide(1); // $ExpectType Money +money.divide(1, Math.ceil); // $ExpectType Money +money.allocate([1, 2, 3]); // $ExpectType Money[] +money.compare(other); // $ExpectType number +money.greaterThan(other); // $ExpectType boolean +money.greaterThanOrEqual(other); // $ExpectType boolean +money.lessThan(other); // $ExpectType boolean +money.lessThanOrEqual(other); // $ExpectType boolean +money.isZero(); // $ExpectType boolean +money.isPositive(); // $ExpectType boolean +money.isNegative(); // $ExpectType boolean +money.toDecimal(); // $ExpectType number +money.toString(); // $ExpectType string +money.toJSON(); // $ExpectType MoneyObjectOut +money.toJSON().amount; // $ExpectType number +money.toJSON().currency; // $ExpectType string +money.getAmount(); // $ExpectType number +money.getCurrency(); // $ExpectType string + +// static method checks +Money.fromInteger(100, 'USD'); // $ExpectType Money +Money.fromDecimal(100, Money.KZT, 'ceil'); // $ExpectType Money +Money.fromDecimal(100, Money.KZT); // $ExpectType Money +Money.fromDecimal(100, Money.KZT, Math.ceil); // $ExpectType Money + +// static properties (currency) check +Money.KZT; // $ExpectType Currency +Money.RUB; // $ExpectType Currency +Money.BLABLA; // $ExpectError +// currency object check +Money.RUB.code; // $ExpectType string +Money.RUB.decimal_digits; // $ExpectType number +Money.RUB.name; // $ExpectType string +Money.RUB.name_plural; // $ExpectType string +Money.RUB.rounding; // $ExpectType number +Money.RUB.symbol; // $ExpectType string +Money.RUB.symbol_native; // $ExpectType string + +// Currency module check +CurrencyObjects.NIO.code; // $ExpectType string +CurrencyObjects.NIO.decimal_digits; // $ExpectType number +CurrencyObjects.NIO.name; // $ExpectType string +CurrencyObjects.NIO.name_plural; // $ExpectType string +CurrencyObjects.NIO.rounding; // $ExpectType number +CurrencyObjects.NIO.symbol; // $ExpectType string +CurrencyObjects.NIO.symbol_native; // $ExpectType string +CurrencyObjects['UAH'].code; // $ExpectType string diff --git a/types/js-money/lib/currency.d.ts b/types/js-money/lib/currency.d.ts new file mode 100644 index 0000000000..20be23cc7e --- /dev/null +++ b/types/js-money/lib/currency.d.ts @@ -0,0 +1,142 @@ +// Type definitions for js-money 0.6 +// Project: https://github.com/davidkalosi/js-money#readme +// Definitions by: Kanat Kubash +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace Currencies { + interface Currency { + symbol: string; + name: string; + symbol_native: string; + decimal_digits: number; + rounding: number; + code: string; + name_plural: string; + } + interface Currencies { + [key: string]: Currencies.Currency; + USD: Currencies.Currency; + CAD: Currencies.Currency; + EUR: Currencies.Currency; + BTC: Currencies.Currency; + AED: Currencies.Currency; + AFN: Currencies.Currency; + ALL: Currencies.Currency; + AMD: Currencies.Currency; + ARS: Currencies.Currency; + AUD: Currencies.Currency; + AZN: Currencies.Currency; + BAM: Currencies.Currency; + BDT: Currencies.Currency; + BGN: Currencies.Currency; + BHD: Currencies.Currency; + BIF: Currencies.Currency; + BND: Currencies.Currency; + BOB: Currencies.Currency; + BRL: Currencies.Currency; + BWP: Currencies.Currency; + BYR: Currencies.Currency; + BZD: Currencies.Currency; + CDF: Currencies.Currency; + CHF: Currencies.Currency; + CLP: Currencies.Currency; + CNY: Currencies.Currency; + COP: Currencies.Currency; + CRC: Currencies.Currency; + CVE: Currencies.Currency; + CZK: Currencies.Currency; + DJF: Currencies.Currency; + DKK: Currencies.Currency; + DOP: Currencies.Currency; + DZD: Currencies.Currency; + EEK: Currencies.Currency; + EGP: Currencies.Currency; + ERN: Currencies.Currency; + ETB: Currencies.Currency; + GBP: Currencies.Currency; + GEL: Currencies.Currency; + GHS: Currencies.Currency; + GNF: Currencies.Currency; + GTQ: Currencies.Currency; + HKD: Currencies.Currency; + HNL: Currencies.Currency; + HRK: Currencies.Currency; + HUF: Currencies.Currency; + IDR: Currencies.Currency; + ILS: Currencies.Currency; + INR: Currencies.Currency; + IQD: Currencies.Currency; + IRR: Currencies.Currency; + ISK: Currencies.Currency; + JMD: Currencies.Currency; + JOD: Currencies.Currency; + JPY: Currencies.Currency; + KES: Currencies.Currency; + KHR: Currencies.Currency; + KMF: Currencies.Currency; + KRW: Currencies.Currency; + KWD: Currencies.Currency; + KZT: Currencies.Currency; + LAK: Currencies.Currency; + LBP: Currencies.Currency; + LKR: Currencies.Currency; + LTL: Currencies.Currency; + LVL: Currencies.Currency; + LYD: Currencies.Currency; + MAD: Currencies.Currency; + MDL: Currencies.Currency; + MGA: Currencies.Currency; + MKD: Currencies.Currency; + MMK: Currencies.Currency; + MOP: Currencies.Currency; + MUR: Currencies.Currency; + MXN: Currencies.Currency; + MYR: Currencies.Currency; + MZN: Currencies.Currency; + NAD: Currencies.Currency; + NGN: Currencies.Currency; + NIO: Currencies.Currency; + NOK: Currencies.Currency; + NPR: Currencies.Currency; + NZD: Currencies.Currency; + OMR: Currencies.Currency; + PAB: Currencies.Currency; + PEN: Currencies.Currency; + PHP: Currencies.Currency; + PKR: Currencies.Currency; + PLN: Currencies.Currency; + PYG: Currencies.Currency; + QAR: Currencies.Currency; + RON: Currencies.Currency; + RSD: Currencies.Currency; + RUB: Currencies.Currency; + RWF: Currencies.Currency; + SAR: Currencies.Currency; + SDG: Currencies.Currency; + SEK: Currencies.Currency; + SGD: Currencies.Currency; + SOS: Currencies.Currency; + SYP: Currencies.Currency; + THB: Currencies.Currency; + TND: Currencies.Currency; + TOP: Currencies.Currency; + TRY: Currencies.Currency; + TTD: Currencies.Currency; + TWD: Currencies.Currency; + TZS: Currencies.Currency; + UAH: Currencies.Currency; + UGX: Currencies.Currency; + UYU: Currencies.Currency; + UZS: Currencies.Currency; + VEF: Currencies.Currency; + VND: Currencies.Currency; + XAF: Currencies.Currency; + XOF: Currencies.Currency; + YER: Currencies.Currency; + ZAR: Currencies.Currency; + ZMK: Currencies.Currency; + } +} + +declare var Currencies: Currencies.Currencies; +export = Currencies; \ No newline at end of file diff --git a/types/js-money/tsconfig.json b/types/js-money/tsconfig.json new file mode 100644 index 0000000000..9277913003 --- /dev/null +++ b/types/js-money/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "strictFunctionTypes": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "js-money-tests.ts" + ] +} \ No newline at end of file diff --git a/types/js-money/tslint.json b/types/js-money/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/js-money/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/js-string-escape/index.d.ts b/types/js-string-escape/index.d.ts new file mode 100644 index 0000000000..e9f888e6d0 --- /dev/null +++ b/types/js-string-escape/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for js-string-escape 1.0 +// Project: https://github.com/joliss/js-string-escape +// Definitions by: Jamie Davies +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function jsStringEscape(str: string): string; + +export = jsStringEscape; diff --git a/types/js-string-escape/js-string-escape-tests.ts b/types/js-string-escape/js-string-escape-tests.ts new file mode 100644 index 0000000000..88d691beeb --- /dev/null +++ b/types/js-string-escape/js-string-escape-tests.ts @@ -0,0 +1,3 @@ +import jsStringEscape = require('js-string-escape'); + +jsStringEscape('hello world'); diff --git a/types/js-string-escape/tsconfig.json b/types/js-string-escape/tsconfig.json new file mode 100644 index 0000000000..b119a31f6e --- /dev/null +++ b/types/js-string-escape/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "js-string-escape-tests.ts" + ] +} diff --git a/types/js-string-escape/tslint.json b/types/js-string-escape/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/js-string-escape/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/json2csv/JSON2CSVBase.d.ts b/types/json2csv/JSON2CSVBase.d.ts new file mode 100644 index 0000000000..165497b4c8 --- /dev/null +++ b/types/json2csv/JSON2CSVBase.d.ts @@ -0,0 +1,108 @@ +export declare namespace json2csv { + export interface FieldValueCallback { + (row: T, field: string): string; + } + + export interface FieldInfo { + label: string; + default?: string; + value?: string | FieldValueCallback; + } + + export interface Options { + fields?: (string | FieldInfo); + ndjson?: boolean; + unwind?: string | string[]; + flatten?: boolean; + defaultValue?: string; + quote?: string; + doubleQuote?: string; + delimiter?: string; + eol?: string; + excelStrings?: boolean; + header?: boolean; + includeEmptyRows?: boolean; + withBOM?: boolean; + } +} + +declare abstract class JSON2CSVBase { + constructor(opts?: json2csv.Options); + + /** + * Check passing opts and set defaults. + * + * @param {json2csv.Options} opts Options object containing fields, + * delimiter, default value, quote mark, header, etc. + * @returns {json2csv.Options} preprocessed Options object + */ + protected preprocessOpts(opts?: json2csv.Options) : json2csv.Options; + + /** + * Create the title row with all the provided fields as column headings + * + * @returns {string} titles as a string + */ + protected getHeader(): string; + + /** + * Preprocess each object according to the give opts (unwind, flatten, etc.). + * + * @param {object} row JSON object to be converted in a CSV row + */ + protected preprocessRow(row: T): object; + + /** + * Create the content of a specific CSV row + * + * @param {object} row JSON object to be converted in a CSV row + * @returns {string} CSV string (row) + */ + protected processRow(row: T): string; + + /** + * Create the content of a specfic CSV row cell + * + * @param {object} row JSON object representing the CSV row that the cell belongs to + * @param {object} fieldInfo Details of the field to process to be a CSV cell + * @returns {string} CSV string (cell) + */ + protected processCell(row: T, fieldInfo: json2csv.FieldInfo) : string; + + /** + * Create the content of a specfic CSV row cell + * + * @param {object} row JSON object representing the CSV row that the cell belongs to + * @param {json2csv.FieldInfo} fieldInfo Details of the field to process to be a CSV cell + * @returns {any} Field value + */ + protected getValue(row: T, fieldInfo: json2csv.FieldInfo): any; + + /** + * Create the content of a specfic CSV row cell + * + * @param {any} value Value to be included in a CSV cell + * @param {Boolean} stringify Details of the field to process to be a CSV cell + * @returns {string} Value stringified and processed + */ + protected processValue(value: any, stringify: Boolean): string; + + /** + * Performs the flattening of a data row recursively + * + * @param {object} dataRow Original JSON object + * @returns {object} Flattened object + */ + protected flatten(dataRow: T): object; + + /** + * Performs the unwind recursively in specified sequence + * + * @param {object[]} dataRow Original JSON object + * @param {string[]} unwindPaths The paths as strings to be used to deconstruct the array + * @returns {Array} Array of objects containing all rows after unwind of chosen paths + */ + protected unwindData(dataRow: Array, unwindPaths: Array): Array; +} + +export default JSON2CSVBase; diff --git a/types/json2csv/JSON2CSVParser.d.ts b/types/json2csv/JSON2CSVParser.d.ts new file mode 100644 index 0000000000..1f134f874c --- /dev/null +++ b/types/json2csv/JSON2CSVParser.d.ts @@ -0,0 +1,30 @@ +import JSON2CSVBase from './JSON2CSVBase'; + +declare class JSON2CSVParser extends JSON2CSVBase { + /** + * Main function that converts json to csv. + * + * @param {object|object[]} data Array of JSON objects to be converted to CSV + * @returns {string} The CSV formated data as a string + */ + public parse(data: Readonly | ReadonlyArray): string; + + /** + * Preprocess the data according to the give opts (unwind, flatten, etc.) + and calculate the fields and field names if they are not provided. + * + * @param {object|object[]} data Array or object to be converted to CSV + * @returns {object[]} Preprocessed data ready to be processed + */ + protected preprocessData(data: T | Array): Array; + + /** + * Create the content row by row below the header + * + * @param {object[]} data Array of JSON objects to be converted to CSV + * @returns {string} CSV string (body) + */ + protected processData(data: Array): string; +} + +export default JSON2CSVParser; diff --git a/types/json2csv/JSON2CSVTransform.d.ts b/types/json2csv/JSON2CSVTransform.d.ts new file mode 100644 index 0000000000..1785e09214 --- /dev/null +++ b/types/json2csv/JSON2CSVTransform.d.ts @@ -0,0 +1,97 @@ +/// + +import { json2csv } from './JSON2CSVBase'; +import JSON2CSVBase from './JSON2CSVBase'; +import { Transform, TransformOptions } from 'stream'; + +declare class JSON2CSVTransform extends Transform { // implements JSON2CSVBase + constructor(opts?: json2csv.Options, transformOpts?: TransformOptions); + + /** + * Transforms an incoming json data to csv and pushes it downstream. + * + * @param {object} data JSON object to be converted in a CSV row + */ + protected pushLine(data: T): void; + + /******************************************************************************* + * Everything below is copy-pasted from JSON2CSVBase and should be keep in sync * + ********************************************************************************/ + + /** + * Check passing opts and set defaults. + * + * @param {json2csv.Options} opts Options object containing fields, + * delimiter, default value, quote mark, header, etc. + * @returns {json2csv.Options} preprocessed Options object + */ + protected preprocessOpts(opts?: json2csv.Options) : json2csv.Options; + + /** + * Create the title row with all the provided fields as column headings + * + * @returns {string} titles as a string + */ + protected getHeader(): string; + + /** + * Preprocess each object according to the give opts (unwind, flatten, etc.). + * + * @param {object} row JSON object to be converted in a CSV row + */ + protected preprocessRow(row: T): object; + + /** + * Create the content of a specific CSV row + * + * @param {object} row JSON object to be converted in a CSV row + * @returns {string} CSV string (row) + */ + protected processRow(row: T): string; + + /** + * Create the content of a specfic CSV row cell + * + * @param {object} row JSON object representing the CSV row that the cell belongs to + * @param {object} fieldInfo Details of the field to process to be a CSV cell + * @returns {string} CSV string (cell) + */ + protected processCell(row: T, fieldInfo: json2csv.FieldInfo) : string; + + /** + * Create the content of a specfic CSV row cell + * + * @param {object} row JSON object representing the CSV row that the cell belongs to + * @param {json2csv.FieldInfo} fieldInfo Details of the field to process to be a CSV cell + * @returns {any} Field value + */ + protected getValue(row: T, fieldInfo: json2csv.FieldInfo): any; + + /** + * Create the content of a specfic CSV row cell + * + * @param {any} value Value to be included in a CSV cell + * @param {Boolean} stringify Details of the field to process to be a CSV cell + * @returns {string} Value stringified and processed + */ + protected processValue(value: any, stringify: Boolean): string; + + /** + * Performs the flattening of a data row recursively + * + * @param {object} dataRow Original JSON object + * @returns {object} Flattened object + */ + protected flatten(dataRow: T): object; + + /** + * Performs the unwind recursively in specified sequence + * + * @param {object[]} dataRow Original JSON object + * @param {string[]} unwindPaths The paths as strings to be used to deconstruct the array + * @returns {Array} Array of objects containing all rows after unwind of chosen paths + */ + protected unwindData(dataRow: Array, unwindPaths: Array): Array; +} + +export default JSON2CSVTransform; diff --git a/types/json2csv/index.d.ts b/types/json2csv/index.d.ts new file mode 100644 index 0000000000..159dec6eb1 --- /dev/null +++ b/types/json2csv/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for json2csv 4.0 +// Project: https://github.com/zemirco/json2csv +// Definitions by: Juanjo Diaz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { json2csv } from './JSON2CSVBase'; +import JSON2CSVParser from './JSON2CSVParser'; +import JSON2CSVTransform from './JSON2CSVTransform'; + +export { + json2csv, + JSON2CSVParser as Parser, + JSON2CSVTransform as Transform +}; + +// Convenience method to keep the API similar to version 3.X +export function parse(data: Readonly | ReadonlyArray, opts?: json2csv.Options): string; diff --git a/types/json2csv/json2csv-tests.ts b/types/json2csv/json2csv-tests.ts new file mode 100644 index 0000000000..566cc06cee --- /dev/null +++ b/types/json2csv/json2csv-tests.ts @@ -0,0 +1,98 @@ +import { json2csv, parse, Parser, Transform } from 'json2csv'; +import { Transform as NodeTransform } from 'stream'; + +let s: string; +let obj: object; + +interface ExampleObj { + str?: string; + num?: number; + obj?: object; +} + +/************** + * Public API * + **************/ +parse({}); +parse([]); +parse({}, {}); + +new Parser(); +const parser: Parser = new Parser({}); +s = parser.parse({ str: '', num: 1, obj: {} }); +parser.parse([]); +const transform: Transform = new Transform({ quote: '' }); +const nodeTransform: NodeTransform = transform; + +/******************** + * Internal Methods * + ********************/ +class ParserExt extends Parser { + constructor() { + super(); + // Parser methods + obj = this.preprocessData({}); + obj = this.preprocessData({ str: '', num: 1, obj: {} }); + obj = this.preprocessData([]); + s = this.processData([]); + + // JSON2CSVBase methods + let opts: json2csv.Options; + opts = this.preprocessOpts(); + opts = this.preprocessOpts(opts); + s = this.getHeader(); + obj = this.preprocessRow({}); + obj = this.preprocessRow({ str: '', num: 1, obj: {} }); + s = this.processRow({}); + s = this.processRow({ str: '', num: 1, obj: {} }); + s = this.processCell({}, { label: 'test', default: 'test2', value: 'field' }); + s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: 'field' }); + s = this.processCell({}, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' }); + s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' }); + this.getValue({}, { label: 'test' }); + this.getValue({ str: '', num: 1, obj: {} }, { label: 'test' }); + s = this.processValue(undefined, true); + s = this.processValue(null, true); + s = this.processValue(1, true); + s = this.processValue('test', true); + s = this.processValue(new Date(), true); + s = this.processValue({}, true); + s = this.processValue([], true); + const flattenedData: object = this.flatten({}); + const unwindedData: object[] = this.unwindData([], []); + } +} + +class TransformExt extends Transform { + constructor() { + super(); + // Transform methods + this.pushLine({}); + this.pushLine({ str: '', num: 1, obj: {} }); + + // JSON2CSVBase methods + let opts: json2csv.Options; + opts = this.preprocessOpts(); + opts = this.preprocessOpts(opts); + s = this.getHeader(); + obj = this.preprocessRow({}); + obj = this.preprocessRow({ str: '', num: 1, obj: {} }); + s = this.processRow({}); + s = this.processRow({ str: '', num: 1, obj: {} }); + s = this.processCell({}, { label: 'test', default: 'test2', value: 'field' }); + s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: 'field' }); + s = this.processCell({}, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' }); + s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' }); + this.getValue({}, { label: 'test' }); + this.getValue({ str: '', num: 1, obj: {} }, { label: 'test' }); + s = this.processValue(undefined, true); + s = this.processValue(null, true); + s = this.processValue(1, true); + s = this.processValue('test', true); + s = this.processValue(new Date(), true); + s = this.processValue({}, true); + s = this.processValue([], true); + const flattenedData: object = this.flatten({}); + const unwindedData: object[] = this.unwindData([], []); + } +} diff --git a/types/json2csv/tsconfig.json b/types/json2csv/tsconfig.json new file mode 100644 index 0000000000..23d379918c --- /dev/null +++ b/types/json2csv/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "json2csv-tests.ts" + ] +} \ No newline at end of file diff --git a/types/json2csv/tslint.json b/types/json2csv/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/json2csv/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/kcors/index.d.ts b/types/kcors/index.d.ts index 04c45d365a..c4c33bbb4f 100644 --- a/types/kcors/index.d.ts +++ b/types/kcors/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/koajs/cors // Definitions by: Xavier Stouder , Izayoi Ko // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 import * as Koa from "koa"; @@ -11,7 +11,7 @@ export = cors; declare namespace cors { interface Options { - origin?: ((req: Koa.Request) => string) | string; + origin?: ((ctx: Koa.Context) => string) | string; allowMethods?: string[] | string; exposeHeaders?: string[] | string; allowHeaders?: string[] | string; diff --git a/types/kendo-ui/index.d.ts b/types/kendo-ui/index.d.ts index 6ea7fea725..b854d92b29 100644 --- a/types/kendo-ui/index.d.ts +++ b/types/kendo-ui/index.d.ts @@ -18894,6 +18894,7 @@ declare namespace kendo.ooxml { cells?: WorkbookSheetRowCell[]; index?: number; height?: number; + type?: "header" | "footer" | "groupHeader" | "groupFooter" | "data"; } interface WorkbookSheet { diff --git a/types/kurento-utils/index.d.ts b/types/kurento-utils/index.d.ts index 8074661881..a8a30005b6 100644 --- a/types/kurento-utils/index.d.ts +++ b/types/kurento-utils/index.d.ts @@ -1,10 +1,13 @@ -// Type definitions for kurento-utils 6.6 +// Type definitions for kurento-utils 6.7 // Project: https://github.com/Kurento/kurento-utils-js // Definitions by: Miloslav Nenadál +// Benjamin Riggs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export class WebRtcPeer { +import { EventEmitter } from 'events'; + +export class WebRtcPeer extends EventEmitter { /** * Using this property the user can get the peerConnection and use it directly. */ @@ -60,7 +63,7 @@ export class WebRtcPeer { */ addIceCandidate: ( iceCandidate: RTCIceCandidate, - callback?: () => void + callback?: (error: string | undefined) => void ) => void; /** * Using this method the user can get peerconnection’s local session descriptor. @@ -73,8 +76,9 @@ export class WebRtcPeer { /** * Creates an offer that is a request to find a remote peer with a specific configuration. */ - generateOffer: (error: string | undefined, sdp: string) => void; - + generateOffer: ( + callback: (error: string | undefined, sdp: string) => void + ) => void; /** * Create a WebRtcPeer as receive only. */ diff --git a/types/kurento-utils/kurento-utils-tests.ts b/types/kurento-utils/kurento-utils-tests.ts index 5866a2e157..380b1b1019 100644 --- a/types/kurento-utils/kurento-utils-tests.ts +++ b/types/kurento-utils/kurento-utils-tests.ts @@ -4,6 +4,10 @@ import * as kurentoUtils from 'kurento-utils'; const peer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv({}, error => {}); peer.showLocalVideo(); peer.getLocalStream().getAudioTracks(); + peer.generateOffer((error, sdp) => {}); + peer.on('icecandidate', (candidate: any) => { + peer.addIceCandidate(candidate, error => {}); + }); peer.getRemoteStream().getAudioTracks(); peer.processAnswer('answer', error => {}); peer.processOffer('offer', (error, {}) => {}); diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index eabb98c710..41b4fbd84c 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -182,6 +182,10 @@ export class Point { y: number; } +export interface Coords extends Point { + z: number; +} + export type PointExpression = Point | PointTuple; export function point(x: number, y: number, round?: boolean): Point; @@ -420,6 +424,8 @@ export class Layer extends Evented { getEvents?(): {[name: string]: (event: LeafletEvent) => void}; getAttribution?(): string | null; beforeAdd?(map: Map): this; + + protected _map: Map; } export interface GridLayerOptions { @@ -439,6 +445,19 @@ export interface GridLayerOptions { keepBuffer?: number; } +export type DoneCallback = (error?: Error, tile?: HTMLElement) => void; + +export interface InternalTiles { + [key: string]: { + active?: boolean, + coords: Coords, + current: boolean, + el: HTMLElement, + loaded?: Date, + retain?: boolean, + }; +} + export class GridLayer extends Layer { constructor(options?: GridLayerOptions); bringToFront(): this; @@ -449,6 +468,12 @@ export class GridLayer extends Layer { isLoading(): boolean; redraw(): this; getTileSize(): Point; + + protected createTile(coords: Coords, done: DoneCallback): HTMLElement; + protected _tileCoordsToKey(coords: Coords): string; + + protected _tiles: InternalTiles; + protected _tileZoom?: number; } export function gridLayer(options?: GridLayerOptions): GridLayer; @@ -472,6 +497,9 @@ export class TileLayer extends GridLayer { constructor(urlTemplate: string, options?: TileLayerOptions); setUrl(url: string, noRedraw?: boolean): this; + protected _abortLoading(): void; + protected _getZoomForUrl(): number; + options: TileLayerOptions; } diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index c4f73e5b84..a22ab91248 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -510,3 +510,50 @@ lg = new L.LayerGroup([new L.Layer(), new L.Layer()], { pane: 'overlayPane', attribution: 'test' }); + +// adapted from GridLayer documentation +const CanvasLayer = L.GridLayer.extend({ + createTile(coords: L.Coords, done: L.DoneCallback) { + const tile = (L.DomUtil.create('canvas', 'leaflet-tile') as HTMLCanvasElement); + const size = this.getTileSize(); + tile.width = size.x; + tile.height = size.y; + return tile; + } +}); + +// adapted from GridLayer documentation +const AsyncCanvasLayer = L.GridLayer.extend({ + createTile(coords: L.Coords, done: L.DoneCallback) { + const tile = (L.DomUtil.create('canvas', 'leaflet-tile') as HTMLCanvasElement); + const size = this.getTileSize(); + tile.width = size.x; + tile.height = size.y; + setTimeout(() => done(undefined, tile), 1000); + return tile; + } +}); + +export class ExtendedTileLayer extends L.TileLayer { + options: L.TileLayerOptions; + createTile(coords: L.Coords, done: L.DoneCallback) { + const newCoords: L.Coords = (new L.Point(coords.x, coords.y) as L.Coords); + newCoords.z = coords.z; + return super.createTile(newCoords, done); + } + _abortLoading() { + // adapted from TileLayer's implementation + for (const i in this._tiles) { + if (this._tiles[i].coords.z !== this._tileZoom) { + const tile = this._tiles[i].el; + tile.onload = L.Util.falseFn; + tile.onerror = L.Util.falseFn; + if (tile instanceof HTMLImageElement && !tile.complete) { + tile.src = L.Util.emptyImageUrl; + L.DomUtil.remove(tile); + this._tiles[i] = undefined; + } + } + } + } +} diff --git a/types/listr/index.d.ts b/types/listr/index.d.ts new file mode 100644 index 0000000000..303c1d4a07 --- /dev/null +++ b/types/listr/index.d.ts @@ -0,0 +1,48 @@ +// Type definitions for listr 0.13 +// Project: https://github.com/samverschueren/listr#readme +// Definitions by: Dusan Radovanovic +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as stream from "stream"; + +declare namespace Listr { + interface ListrRenderer { + nonTTY: boolean; + render(): void; + end(): void; + } + + interface ListrOptions { + concurrent?: boolean | number; + exitOnError?: boolean; + renderer?: "silent" | "default" | "verbose" | ListrRenderer; + nonTTYRenderer?: "silent" | "default" | "verbose" | ListrRenderer; + } + + interface ListrTask { + title: string; + output?: string; + task: (ctx: any, task: ListrTaskWrapper) => void | string | Promise | stream.Readable | Listr; + skip?: (ctx: any, task: ListrTaskWrapper) => boolean | Promise | string | void; + enabled?: (ctx: any, task: ListrTaskWrapper) => boolean | Promise; + } + + interface ListrTaskWrapper { + title: string; + output: any; + report(error: Error): void; + skip(message: string): void; + run(ctx?: any): Promise; + } +} + +declare class Listr { + constructor(tasks?: ReadonlyArray, options?: Listr.ListrOptions); + constructor(options?: Listr.ListrOptions); + add(tasks: Listr.ListrTask | ReadonlyArray): void; + run(ctx?: any): Promise; +} + +export = Listr; diff --git a/types/listr/listr-tests.ts b/types/listr/listr-tests.ts new file mode 100644 index 0000000000..e9ac72b5dc --- /dev/null +++ b/types/listr/listr-tests.ts @@ -0,0 +1,167 @@ +import Listr = require("listr"); +import * as fs from "fs"; + +const tasks = new Listr([ + { + title: 'Git', + task: () => { + return new Listr([ + { + title: 'Checking git status', + task: () => new Promise(resolve => resolve()) + .then(result => { + if (result !== '') { + throw new Error('Unclean working tree. Commit or stash changes first.'); + } + }) + }, + { + title: 'Checking remote history', + task: () => new Promise(resolve => resolve()) + .then(result => { + if (result !== '0') { + throw new Error('Remote history differ. Please pull changes.'); + } + }) + } + ], + { concurrent: true }); + } + }, + { + title: 'Install package dependencies with Yarn', + task: (ctx, task) => new Promise(resolve => resolve()) + .catch(() => { + ctx.yarn = false; + + task.skip('Yarn not available, install it via `npm install -g yarn`'); + }) + }, + { + title: 'Install package dependencies with npm', + enabled: ctx => ctx.yarn === false, + task: () => new Promise(resolve => resolve()) + }, + { + title: 'Run tests', + task: () => new Promise(resolve => resolve()) + }, + { + title: 'Publish package', + task: () => new Promise(resolve => resolve()) + } +]); + +tasks.run().catch(err => { +}); + +const tasks21 = new Listr([ + { + title: 'Success', + task: () => 'Foo' + }, + { + title: 'Failure', + task: () => { + throw new Error('Bar'); + } + } +]); + +const taskA: Listr.ListrTask = { + title: 'Success', + task: () => 'Foo' +}; + +const taskB: Listr.ListrTask = { + title: 'Failure', + task: () => { + throw new Error('Bar'); + } +}; + +const tasks22 = new Listr([taskA, taskB]); + +const tasks3 = new Listr([ + { + title: 'Success', + task: () => Promise.resolve('Foo') + }, + { + title: 'Failure', + task: () => Promise.reject(new Error('Bar')) + } +]); + +const tasks4 = new Listr([ + { + title: 'File', + task: () => fs.createReadStream('data.txt', 'utf8') + } +]); + +const tasks5 = new Listr([ + { + title: 'Task 1', + task: () => Promise.resolve('Foo') + }, + { + title: 'Can be skipped', + skip: () => { + if (Math.random() > 0.5) { + return 'Reason for skipping'; + } + }, + task: () => 'Bar' + }, + { + title: 'Task 3', + task: () => Promise.resolve('Bar') + } +]); + +const tasks6 = new Listr([ + { + title: 'Install package dependencies with Yarn', + task: (ctx, task) => new Promise(resolve => resolve()) + .catch(() => { + ctx.yarn = false; + + task.skip('Yarn not available, install it via `npm install -g yarn`'); + }) + }, + { + title: 'Install package dependencies with npm', + enabled: ctx => ctx.yarn === false, + task: () => new Promise(resolve => resolve()) + } +]); + +const tasks7 = new Listr([ + { + title: 'Task 1', + skip: ctx => ctx.foo === 'bar', + task: () => Promise.resolve('Foo') + }, + { + title: 'Can be skipped', + skip: () => { + if (Math.random() > 0.5) { + return 'Reason for skipping'; + } + }, + task: ctx => { + ctx.unicorn = 'rainbow'; + } + }, + { + title: 'Task 3', + task: ctx => Promise.resolve(`${ctx.foo} ${ctx.bar}`) + } +]); + +tasks.run({ + foo: 'bar' +}).then(ctx => { + console.log(ctx); +}); diff --git a/types/bingmaps/tsconfig.json b/types/listr/tsconfig.json similarity index 51% rename from types/bingmaps/tsconfig.json rename to types/listr/tsconfig.json index 421876221b..cae79d1480 100644 --- a/types/bingmaps/tsconfig.json +++ b/types/listr/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -19,19 +19,6 @@ }, "files": [ "index.d.ts", - "Autosuggest.d.ts", - "Clustering.d.ts", - "Contour.d.ts", - "DataBinning.d.ts", - "Directions.d.ts", - "DrawingTools.d.ts", - "GeoJson.d.ts", - "HeatMapLayer.d.ts", - "Search.d.ts", - "SpatialDataService.d.ts", - "SpatialMath.d.ts", - "Traffic.d.ts", - "WellKnownText.d.ts", - "bingmaps-tests.ts" + "listr-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/listr/tslint.json b/types/listr/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/listr/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/loader-utils/index.d.ts b/types/loader-utils/index.d.ts index 37ce2e461f..18aa16d7e4 100644 --- a/types/loader-utils/index.d.ts +++ b/types/loader-utils/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Gyusun Yeom // Totooria Hyperion // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 /// diff --git a/types/lodash-webpack-plugin/index.d.ts b/types/lodash-webpack-plugin/index.d.ts index e7e2dfd4db..505c54b5c4 100644 --- a/types/lodash-webpack-plugin/index.d.ts +++ b/types/lodash-webpack-plugin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/lodash/lodash-webpack-plugin#readme // Definitions by: Benjamin Lim // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Plugin } from 'webpack'; diff --git a/types/lodash/common/collection.d.ts b/types/lodash/common/collection.d.ts index 31e5b1c212..c8b2770610 100644 --- a/types/lodash/common/collection.d.ts +++ b/types/lodash/common/collection.d.ts @@ -36,14 +36,6 @@ declare module "../index" { iteratee?: ListIteratee ): Dictionary; - /** - * @see _.countBy - */ - countBy( - collection: NumericDictionary | null | undefined, - iteratee?: NumericDictionaryIteratee - ): Dictionary; - /** * @see _.countBy */ @@ -77,14 +69,6 @@ declare module "../index" { this: LoDashImplicitWrapper, iteratee?: ObjectIteratee ): LoDashImplicitWrapper>; - - /** - * @see _.countBy - */ - countBy( - this: LoDashImplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIteratee - ): LoDashImplicitWrapper>; } interface LoDashExplicitWrapper { @@ -111,14 +95,6 @@ declare module "../index" { this: LoDashExplicitWrapper, iteratee?: ObjectIteratee ): LoDashExplicitWrapper>; - - /** - * @see _.countBy - */ - countBy( - this: LoDashExplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIteratee - ): LoDashExplicitWrapper>; } // each @@ -217,14 +193,6 @@ declare module "../index" { predicate?: ListIterateeCustom ): boolean; - /** - * @see _.every - */ - every( - collection: NumericDictionary | null | undefined, - predicate?: NumericDictionaryIterateeCustom - ): boolean; - /** * @see _.every */ @@ -250,14 +218,6 @@ declare module "../index" { this: LoDashImplicitWrapper, predicate?: ObjectIterateeCustom ): boolean; - - /** - * @see _.every - */ - every( - this: LoDashImplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIterateeCustom - ): boolean; } interface LoDashExplicitWrapper { @@ -276,14 +236,6 @@ declare module "../index" { this: LoDashExplicitWrapper, predicate?: ObjectIterateeCustom ): LoDashExplicitWrapper; - - /** - * @see _.every - */ - every( - this: LoDashExplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIterateeCustom - ): LoDashExplicitWrapper; } // filter @@ -712,14 +664,6 @@ declare module "../index" { iteratee: ListIterator> ): TResult[]; - /** - * @see _.flatMap - */ - flatMap( - collection: NumericDictionary | null | undefined, - iteratee: NumericDictionaryIterator> - ): TResult[]; - /** * @see _.flatMap */ @@ -772,14 +716,6 @@ declare module "../index" { iteratee: ObjectIterator> ): LoDashImplicitWrapper; - /** - * @see _.flatMap - */ - flatMap( - this: LoDashImplicitWrapper | null | undefined>, - iteratee: NumericDictionaryIterator> - ): LoDashImplicitWrapper; - /** * @see _.flatMap */ @@ -814,14 +750,6 @@ declare module "../index" { iteratee: ListIterator> ): LoDashExplicitWrapper; - /** - * @see _.flatMap - */ - flatMap( - this: LoDashExplicitWrapper | null | undefined>, - iteratee: NumericDictionaryIterator> - ): LoDashExplicitWrapper; - /** * @see _.flatMap */ @@ -878,14 +806,6 @@ declare module "../index" { iteratee: ListIterator | TResult> ): TResult[]; - /** - * @see _.flatMapDeep - */ - flatMapDeep( - collection: NumericDictionary | null | undefined, - iteratee: NumericDictionaryIterator | TResult> - ): TResult[]; - /** * @see _.flatMapDeep */ @@ -927,14 +847,6 @@ declare module "../index" { iteratee: ListIterator | TResult> ): LoDashImplicitWrapper; - /** - * @see _.flatMapDeep - */ - flatMapDeep( - this: LoDashImplicitWrapper | null | undefined>, - iteratee: NumericDictionaryIterator | TResult> - ): LoDashImplicitWrapper; - /** * @see _.flatMapDeep */ @@ -976,14 +888,6 @@ declare module "../index" { iteratee: ListIterator | TResult> ): LoDashExplicitWrapper; - /** - * @see _.flatMapDeep - */ - flatMapDeep( - this: LoDashExplicitWrapper | null | undefined>, - iteratee: NumericDictionaryIterator | TResult> - ): LoDashExplicitWrapper; - /** * @see _.flatMapDeep */ @@ -1044,15 +948,6 @@ declare module "../index" { depth?: number ): TResult[]; - /** - * @see _.flatMapDepth - */ - flatMapDepth( - collection: NumericDictionary | null | undefined, - iteratee: NumericDictionaryIterator | TResult>, - depth?: number - ): TResult[]; - /** * @see _.flatMapDepth */ @@ -1098,15 +993,6 @@ declare module "../index" { depth?: number ): LoDashImplicitWrapper; - /** - * @see _.flatMapDepth - */ - flatMapDepth( - this: LoDashImplicitWrapper | null | undefined>, - iteratee: NumericDictionaryIterator | TResult>, - depth?: number - ): LoDashImplicitWrapper; - /** * @see _.flatMapDepth */ @@ -1152,15 +1038,6 @@ declare module "../index" { depth?: number ): LoDashExplicitWrapper; - /** - * @see _.flatMapDepth - */ - flatMapDepth( - this: LoDashExplicitWrapper | null | undefined>, - iteratee: NumericDictionaryIterator | TResult>, - depth?: number - ): LoDashExplicitWrapper; - /** * @see _.flatMapDepth */ @@ -1446,14 +1323,6 @@ declare module "../index" { iteratee?: ListIteratee ): Dictionary; - /** - * @see _.groupBy - */ - groupBy( - collection: NumericDictionary | null | undefined, - iteratee?: NumericDictionaryIteratee - ): Dictionary; - /** * @see _.groupBy */ @@ -1487,14 +1356,6 @@ declare module "../index" { this: LoDashImplicitWrapper, iteratee?: ObjectIteratee ): LoDashImplicitWrapper>>; - - /** - * @see _.groupBy - */ - groupBy( - this: LoDashImplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIteratee - ): LoDashImplicitWrapper>; } interface LoDashExplicitWrapper { @@ -1514,14 +1375,6 @@ declare module "../index" { iteratee?: ListIteratee ): LoDashExplicitWrapper>; - /** - * @see _.groupBy - */ - groupBy( - this: LoDashExplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIteratee - ): LoDashExplicitWrapper>; - /** * @see _.groupBy */ @@ -1544,7 +1397,7 @@ declare module "../index" { * @return True if the target element is found, else false. */ includes( - collection: List|Dictionary | null | undefined, + collection: List | Dictionary | NumericDictionary | null | undefined, target: T, fromIndex?: number ): boolean; @@ -1555,7 +1408,7 @@ declare module "../index" { * @see _.includes */ includes( - this: LoDashImplicitWrapper | Dictionary | null | undefined>, + this: LoDashImplicitWrapper | Dictionary | NumericDictionary | null | undefined>, target: T, fromIndex?: number ): boolean; @@ -1566,7 +1419,7 @@ declare module "../index" { * @see _.includes */ includes( - this: LoDashExplicitWrapper | Dictionary | null | undefined>, + this: LoDashExplicitWrapper | Dictionary | NumericDictionary | null | undefined>, target: T, fromIndex?: number ): LoDashExplicitWrapper; @@ -1673,14 +1526,6 @@ declare module "../index" { collection: T | null | undefined, iteratee?: ObjectIterateeCustom ): Dictionary; - - /** - * @see _.keyBy - */ - keyBy( - collection: NumericDictionary | null | undefined, - iteratee?: NumericDictionaryIterateeCustom - ): Dictionary; } interface LoDashImplicitWrapper { @@ -1707,14 +1552,6 @@ declare module "../index" { this: LoDashImplicitWrapper, iteratee?: ObjectIterateeCustom ): LoDashImplicitWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - this: LoDashImplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIterateeCustom - ): LoDashImplicitWrapper>; } interface LoDashExplicitWrapper { @@ -1741,14 +1578,6 @@ declare module "../index" { this: LoDashExplicitWrapper, iteratee?: ObjectIterateeCustom ): LoDashExplicitWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - this: LoDashExplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIterateeCustom - ): LoDashExplicitWrapper>; } // map @@ -1780,6 +1609,14 @@ declare module "../index" { * @param thisArg The this binding of iteratee. * @return Returns the new mapped array. */ + map( + collection: T[] | null | undefined, + iteratee: ArrayIterator + ): TResult[]; + + /** + * @see _.map + */ map( collection: List | null | undefined, iteratee: ListIterator @@ -1788,46 +1625,48 @@ declare module "../index" { /** * @see _.map */ - map(collection: List | Dictionary | null | undefined): T[]; + map(collection: List | Dictionary | NumericDictionary | null | undefined): T[]; /** * @see _.map */ - map( - collection: Dictionary | null | undefined, - iteratee: DictionaryIterator + map( + collection: T | null | undefined, + iteratee: ObjectIterator ): TResult[]; /** @see _.map */ map( - collection: List | Dictionary | null | undefined, + collection: List | Dictionary | NumericDictionary | null | undefined, iteratee: K ): Array; - /** @see _.map */ - map( - collection: NumericDictionary | null | undefined, - iteratee?: NumericDictionaryIterator - ): TResult[]; - - /** - * @see _.map - */ - map( - collection: List|Dictionary|NumericDictionary | null | undefined, - iteratee?: string - ): TResult[]; - /** * @see _.map */ map( - collection: List|Dictionary|NumericDictionary | null | undefined, + collection: List | Dictionary | NumericDictionary | null | undefined, + iteratee?: string + ): any[]; + + /** + * @see _.map + */ + map( + collection: List | Dictionary | NumericDictionary | null | undefined, iteratee?: object ): boolean[]; } interface LoDashImplicitWrapper { + /** + * @see _.map + */ + map( + this: LoDashImplicitWrapper, + iteratee: ArrayIterator + ): LoDashImplicitWrapper; + /** * @see _.map */ @@ -1839,35 +1678,29 @@ declare module "../index" { /** * @see _.map */ - map(this: LoDashImplicitWrapper | Dictionary | null | undefined>): LoDashImplicitWrapper; + map(this: LoDashImplicitWrapper | Dictionary | NumericDictionary | null | undefined>): LoDashImplicitWrapper; /** * @see _.map */ - map( - this: LoDashImplicitWrapper | null | undefined>, - iteratee: DictionaryIterator + map( + this: LoDashImplicitWrapper, + iteratee: ObjectIterator ): LoDashImplicitWrapper; /** @see _.map */ map( - this: LoDashImplicitWrapper | Dictionary | null | undefined>, + this: LoDashImplicitWrapper | Dictionary | NumericDictionary | null | undefined>, iteratee: K ): LoDashImplicitWrapper>; - /** @see _.map */ - map( - this: LoDashImplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIterator - ): LoDashImplicitWrapper; - /** * @see _.map */ - map( + map( this: LoDashImplicitWrapper | Dictionary | NumericDictionary | null | undefined>, iteratee?: string - ): LoDashImplicitWrapper; + ): LoDashImplicitWrapper; /** * @see _.map @@ -1879,6 +1712,14 @@ declare module "../index" { } interface LoDashExplicitWrapper { + /** + * @see _.map + */ + map( + this: LoDashExplicitWrapper, + iteratee: ArrayIterator + ): LoDashExplicitWrapper; + /** * @see _.map */ @@ -1890,37 +1731,29 @@ declare module "../index" { /** * @see _.map */ - map(this: LoDashExplicitWrapper | Dictionary | null | undefined>): LoDashExplicitWrapper; + map(this: LoDashExplicitWrapper | Dictionary | NumericDictionary | null | undefined>): LoDashExplicitWrapper; /** * @see _.map */ - map( - this: LoDashExplicitWrapper | null | undefined>, - iteratee: DictionaryIterator + map( + this: LoDashExplicitWrapper, + iteratee: ObjectIterator ): LoDashExplicitWrapper; /** @see _.map */ map( - this: LoDashExplicitWrapper | Dictionary | null | undefined>, + this: LoDashExplicitWrapper | Dictionary | NumericDictionary | null | undefined>, iteratee: K ): LoDashExplicitWrapper>; /** * @see _.map */ - map( - this: LoDashExplicitWrapper | null | undefined>, - iteratee?: NumericDictionaryIterator - ): LoDashExplicitWrapper; - - /** - * @see _.map - */ - map( + map( this: LoDashExplicitWrapper | Dictionary | NumericDictionary | null | undefined>, iteratee?: string - ): LoDashExplicitWrapper; + ): LoDashExplicitWrapper; /** * @see _.map @@ -1991,24 +1824,6 @@ declare module "../index" { iteratees?: Many>, orders?: Many ): Array; - - /** - * @see _.orderBy - */ - orderBy( - collection: NumericDictionary | null | undefined, - iteratees?: Many>, - orders?: Many - ): T[]; - - /** - * @see _.orderBy - */ - orderBy( - collection: NumericDictionary | null | undefined, - iteratees?: Many>, - orders?: Many - ): T[]; } interface LoDashImplicitWrapper { @@ -2047,24 +1862,6 @@ declare module "../index" { iteratees?: Many>, orders?: Many ): LoDashImplicitWrapper>; - - /** - * @see _.orderBy - */ - orderBy( - this: LoDashImplicitWrapper | null | undefined>, - iteratees?: Many>, - orders?: Many - ): LoDashImplicitWrapper; - - /** - * @see _.orderBy - */ - orderBy( - this: LoDashImplicitWrapper | null | undefined>, - iteratees?: Many>, - orders?: Many - ): LoDashImplicitWrapper; } interface LoDashExplicitWrapper { @@ -2103,24 +1900,6 @@ declare module "../index" { iteratees?: Many>, orders?: Many ): LoDashExplicitWrapper>; - - /** - * @see _.orderBy - */ - orderBy( - this: LoDashExplicitWrapper | null | undefined>, - iteratees?: Many>, - orders?: Many - ): LoDashExplicitWrapper; - - /** - * @see _.orderBy - */ - orderBy( - this: LoDashExplicitWrapper | null | undefined>, - iteratees?: Many>, - orders?: Many - ): LoDashExplicitWrapper; } // partition @@ -2233,15 +2012,6 @@ declare module "../index" { accumulator: TResult ): TResult; - /** - * @see _.reduce - **/ - reduce( - collection: NumericDictionary | null | undefined, - callback: MemoListIterator>, - accumulator: TResult - ): TResult; - /** * @see _.reduce **/ @@ -2265,14 +2035,6 @@ declare module "../index" { collection: T | null | undefined, callback: MemoObjectIterator ): TResult | undefined; - - /** - * @see _.reduce - **/ - reduce( - collection: NumericDictionary | null | undefined, - callback: MemoListIterator> - ): TResult | undefined; } interface LoDashImplicitWrapper { @@ -2303,15 +2065,6 @@ declare module "../index" { accumulator: TResult ): TResult; - /** - * @see _.reduce - **/ - reduce( - this: LoDashImplicitWrapper | null | undefined>, - callback: MemoListIterator>, - accumulator: TResult - ): TResult; - /** * @see _.reduce **/ @@ -2335,14 +2088,6 @@ declare module "../index" { this: LoDashImplicitWrapper, callback: MemoObjectIterator ): TResult | undefined; - - /** - * @see _.reduce - **/ - reduce( - this: LoDashImplicitWrapper | null | undefined>, - callback: MemoListIterator> - ): TResult | undefined; } interface LoDashExplicitWrapper { @@ -2373,15 +2118,6 @@ declare module "../index" { accumulator: TResult ): LoDashExplicitWrapper; - /** - * @see _.reduce - **/ - reduce( - this: LoDashExplicitWrapper | null | undefined>, - callback: MemoListIterator>, - accumulator: TResult - ): LoDashExplicitWrapper; - /** * @see _.reduce **/ @@ -2405,14 +2141,6 @@ declare module "../index" { this: LoDashExplicitWrapper, callback: MemoObjectIterator ): LoDashExplicitWrapper; - - /** - * @see _.reduce - **/ - reduce( - this: LoDashExplicitWrapper | null | undefined>, - callback: MemoListIterator> - ): LoDashExplicitWrapper; } // reduceRight @@ -2450,15 +2178,6 @@ declare module "../index" { accumulator: TResult ): TResult; - /** - * @see _.reduceRight - **/ - reduceRight( - collection: NumericDictionary | null | undefined, - callback: MemoListIterator>, - accumulator: TResult - ): TResult; - /** * @see _.reduceRight **/ @@ -2482,14 +2201,6 @@ declare module "../index" { collection: T | null | undefined, callback: MemoObjectIterator ): TResult | undefined; - - /** - * @see _.reduceRight - **/ - reduceRight( - collection: NumericDictionary | null | undefined, - callback: MemoListIterator> - ): TResult | undefined; } interface LoDashImplicitWrapper { @@ -2520,15 +2231,6 @@ declare module "../index" { accumulator: TResult ): TResult; - /** - * @see _.reduceRight - **/ - reduceRight( - this: LoDashImplicitWrapper | null | undefined>, - callback: MemoListIterator>, - accumulator: TResult - ): TResult; - /** * @see _.reduceRight **/ @@ -2552,14 +2254,6 @@ declare module "../index" { this: LoDashImplicitWrapper, callback: MemoObjectIterator ): TResult | undefined; - - /** - * @see _.reduceRight - **/ - reduceRight( - this: LoDashImplicitWrapper | null | undefined>, - callback: MemoListIterator> - ): TResult | undefined; } interface LoDashExplicitWrapper { @@ -2590,15 +2284,6 @@ declare module "../index" { accumulator: TResult ): LoDashExplicitWrapper; - /** - * @see _.reduceRight - **/ - reduceRight( - this: LoDashExplicitWrapper | null | undefined>, - callback: MemoListIterator>, - accumulator: TResult - ): LoDashExplicitWrapper; - /** * @see _.reduceRight **/ @@ -2622,14 +2307,6 @@ declare module "../index" { this: LoDashExplicitWrapper, callback: MemoObjectIterator ): LoDashExplicitWrapper; - - /** - * @see _.reduceRight - **/ - reduceRight( - this: LoDashExplicitWrapper | null | undefined>, - callback: MemoListIterator> - ): LoDashExplicitWrapper; } // reject @@ -2731,13 +2408,6 @@ declare module "../index" { collection: List | Dictionary | NumericDictionary | null | undefined ): T | undefined; - /** - * @see _.sample - */ - sample( - collection: T - ): T[keyof T]; - /** * @see _.sample */ @@ -2754,13 +2424,6 @@ declare module "../index" { this: LoDashImplicitWrapper | Dictionary | NumericDictionary | null | undefined> ): T | undefined; - /** - * @see _.sample - */ - sample( - this: LoDashImplicitWrapper, - ): T[keyof T]; - /** * @see _.sample */ @@ -2777,13 +2440,6 @@ declare module "../index" { this: LoDashExplicitWrapper | Dictionary | NumericDictionary | null | undefined> ): LoDashExplicitWrapper; - /** - * @see _.sample - */ - sample( - this: LoDashExplicitWrapper, - ): LoDashExplicitWrapper; - /** * @see _.sample */ @@ -2803,7 +2459,7 @@ declare module "../index" { * @return Returns the random elements. */ sampleSize( - collection: List|Dictionary|NumericDictionary | null | undefined, + collection: List | Dictionary | NumericDictionary | null | undefined, n?: number ): T[]; @@ -2821,7 +2477,7 @@ declare module "../index" { * @see _.sampleSize */ sampleSize( - this: LoDashImplicitWrapper|Dictionary|NumericDictionary | null | undefined>, + this: LoDashImplicitWrapper | Dictionary | NumericDictionary | null | undefined>, n?: number ): LoDashImplicitWrapper; @@ -2839,7 +2495,7 @@ declare module "../index" { * @see _.sampleSize */ sampleSize( - this: LoDashExplicitWrapper|Dictionary|NumericDictionary | null | undefined>, + this: LoDashExplicitWrapper | Dictionary | NumericDictionary | null | undefined>, n?: number ): LoDashExplicitWrapper; @@ -2943,14 +2599,6 @@ declare module "../index" { collection: T | null | undefined, predicate?: ObjectIterateeCustom ): boolean; - - /** - * @see _.some - */ - some( - collection: NumericDictionary | null | undefined, - predicate?: NumericDictionaryIterateeCustom - ): boolean; } interface LoDashImplicitWrapper { @@ -2969,14 +2617,6 @@ declare module "../index" { this: LoDashImplicitWrapper, predicate?: ObjectIterateeCustom ): boolean; - - /** - * @see _.some - */ - some( - this: LoDashImplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIterateeCustom - ): boolean; } interface LoDashExplicitWrapper { @@ -2995,14 +2635,6 @@ declare module "../index" { this: LoDashExplicitWrapper, predicate?: ObjectIterateeCustom ): LoDashExplicitWrapper; - - /** - * @see _.some - */ - some( - this: LoDashExplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIterateeCustom - ): LoDashExplicitWrapper; } // sortBy diff --git a/types/lodash/common/common.d.ts b/types/lodash/common/common.d.ts index ac3e137b12..468019ea53 100644 --- a/types/lodash/common/common.d.ts +++ b/types/lodash/common/common.d.ts @@ -188,17 +188,9 @@ declare module "../index" { // Note: key should be string, not keyof T, because the actual object may contain extra properties that were not specified in the type. type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; type ObjectIteratee = ObjectIterator | string | [string, any] | PartialDeep; - type ObjectIterateeCustom = ObjectIterator | string | object | [string, any] | PartialDeep; + type ObjectIterateeCustom = ObjectIterator | string | [string, any] | PartialDeep; type ObjectIteratorTypeGuard = (value: TObject[keyof TObject], key: string, collection: TObject) => value is S; - type DictionaryIterator = ObjectIterator, TResult>; - type DictionaryIteratee = ObjectIteratee>; - type DictionaryIteratorTypeGuard = ObjectIteratorTypeGuard, S>; - - type NumericDictionaryIterator = (value: T, key: number, collection: NumericDictionary) => TResult; - type NumericDictionaryIteratee = NumericDictionaryIterator | string | [string, any] | PartialDeep; - type NumericDictionaryIterateeCustom = NumericDictionaryIterator | string | [string, any] | PartialDeep; - type StringIterator = (char: string, index: number, string: string) => TResult; type MemoVoidIterator = (prev: TResult, curr: T, indexOrKey: any, list: T[]) => void; @@ -230,6 +222,11 @@ declare module "../index" { [index: number]: T; } + // Crazy typedef needed get _.omit to work properly with Dictionary and NumericDictionary + type AnyKindOfDictionary = + | Dictionary<{} | null | undefined> + | NumericDictionary<{} | null | undefined>; + interface Cancelable { cancel(): void; flush(): void; @@ -252,4 +249,12 @@ declare module "../index" { type LoDashExplicitNillableObjectWrapper = LoDashExplicitWrapper; type LoDashExplicitNumberArrayWrapper = LoDashExplicitWrapper; type LoDashExplicitStringWrapper = LoDashExplicitWrapper; + + type DictionaryIterator = ObjectIterator, TResult>; + type DictionaryIteratee = ObjectIteratee>; + type DictionaryIteratorTypeGuard = ObjectIteratorTypeGuard, S>; + // NOTE: keys of objects at run time are always strings, even when a NumericDictionary is being iterated. + type NumericDictionaryIterator = (value: T, key: string, collection: NumericDictionary) => TResult; + type NumericDictionaryIteratee = NumericDictionaryIterator | string | [string, any] | PartialDeep; + type NumericDictionaryIterateeCustom = NumericDictionaryIterator | string | [string, any] | PartialDeep; } diff --git a/types/lodash/common/object.d.ts b/types/lodash/common/object.d.ts index 6100e25c43..3063072b17 100644 --- a/types/lodash/common/object.d.ts +++ b/types/lodash/common/object.d.ts @@ -718,7 +718,7 @@ declare module "../index" { * @return Returns the new array of picked elements. */ at( - object: List | Dictionary | null | undefined, + object: List | Dictionary | NumericDictionary | null | undefined, ...props: PropertyPath[] ): T[]; @@ -736,7 +736,7 @@ declare module "../index" { * @see _.at */ at( - this: LoDashImplicitWrapper | Dictionary | null | undefined>, + this: LoDashImplicitWrapper | Dictionary | NumericDictionary | null | undefined>, ...props: PropertyPath[] ): LoDashImplicitWrapper; @@ -754,7 +754,7 @@ declare module "../index" { * @see _.at */ at( - this: LoDashExplicitWrapper | Dictionary | null | undefined>, + this: LoDashExplicitWrapper | Dictionary | NumericDictionary | null | undefined>, ...props: PropertyPath[] ): LoDashExplicitWrapper; @@ -987,7 +987,7 @@ declare module "../index" { /** * @see _.toPairs */ - entries(object?: Dictionary): Array<[string, T]>; + entries(object?: Dictionary | NumericDictionary): Array<[string, T]>; /** * @see _.toPairs @@ -999,7 +999,7 @@ declare module "../index" { /** * @see _.toPairs */ - entries(this: LoDashImplicitWrapper>): LoDashImplicitWrapper>; + entries(this: LoDashImplicitWrapper | NumericDictionary>): LoDashImplicitWrapper>; /** * @see _.toPairs @@ -1011,7 +1011,7 @@ declare module "../index" { /** * @see _.toPairs */ - entries(this: LoDashExplicitWrapper>): LoDashExplicitWrapper>; + entries(this: LoDashExplicitWrapper | NumericDictionary>): LoDashExplicitWrapper>; /** * @see _.toPairs @@ -1025,7 +1025,7 @@ declare module "../index" { /** * @see _.entriesIn */ - entriesIn(object?: Dictionary): Array<[string, T]>; + entriesIn(object?: Dictionary | NumericDictionary): Array<[string, T]>; /** * @see _.entriesIn @@ -1037,7 +1037,7 @@ declare module "../index" { /** * @see _.entriesIn */ - entriesIn(this: LoDashImplicitWrapper>): LoDashImplicitWrapper>; + entriesIn(this: LoDashImplicitWrapper | NumericDictionary>): LoDashImplicitWrapper>; /** * @see _.entriesIn @@ -1049,7 +1049,7 @@ declare module "../index" { /** * @see _.entriesIn */ - entriesIn(this: LoDashExplicitWrapper>): LoDashExplicitWrapper>; + entriesIn(this: LoDashExplicitWrapper | NumericDictionary>): LoDashExplicitWrapper>; /** * @see _.entriesIn @@ -2210,18 +2210,10 @@ declare module "../index" { /** * @see _.mapKeys */ - mapKeys( - object: Dictionary | null | undefined, - iteratee?: DictionaryIteratee - ): Dictionary; - - /** - * @see _.mapKeys - */ - mapKeys( - object: object | null | undefined, - iteratee?: ObjectIteratee - ): Dictionary; + mapKeys( + object: T | null | undefined, + iteratee?: ObjectIteratee + ): Dictionary; } interface LoDashImplicitWrapper { @@ -2236,18 +2228,10 @@ declare module "../index" { /** * @see _.mapKeys */ - mapKeys( - this: LoDashImplicitWrapper | null | undefined>, - iteratee?: DictionaryIteratee - ): LoDashImplicitWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - this: LoDashImplicitWrapper, - iteratee?: ObjectIteratee - ): LoDashImplicitWrapper>; + mapKeys( + this: LoDashImplicitWrapper, + iteratee?: ObjectIteratee + ): LoDashImplicitWrapper>; } interface LoDashExplicitWrapper { @@ -2262,18 +2246,10 @@ declare module "../index" { /** * @see _.mapKeys */ - mapKeys( - this: LoDashExplicitWrapper | null | undefined>, - iteratee?: DictionaryIteratee - ): LoDashExplicitWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - this: LoDashExplicitWrapper, - iteratee?: ObjectIteratee - ): LoDashExplicitWrapper>; + mapKeys( + this: LoDashExplicitWrapper, + iteratee?: ObjectIteratee + ): LoDashExplicitWrapper>; } // mapValues @@ -2298,8 +2274,27 @@ declare module "../index" { * @param [thisArg] The `this` binding of `iteratee`. * @return Returns the new mapped object. */ + mapValues(obj: string | null | undefined, callback: StringIterator): NumericDictionary; + + /** + * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. + */ + mapValues(obj: Dictionary | NumericDictionary | null | undefined, callback: ObjectIterator, TResult>): Dictionary; + + /** + * @see _.mapValues + */ mapValues(obj: T | null | undefined, callback: ObjectIterator): { [P in keyof T]: TResult }; + /** + * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. + */ + mapValues(obj: Dictionary | NumericDictionary | null | undefined, iteratee: object): Dictionary; + /** * @see _.mapValues */ @@ -2307,23 +2302,34 @@ declare module "../index" { /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ - mapValues(obj: Dictionary | null | undefined, iteratee: TKey): Dictionary; + mapValues(obj: Dictionary | NumericDictionary | null | undefined, iteratee: TKey): Dictionary; + + /** + * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. + */ + mapValues(obj: Dictionary | NumericDictionary | null | undefined, iteratee: string): Dictionary; /** * @see _.mapValues */ - mapValues(obj: T | null | undefined, iteratee: string): { [P in keyof T]: any }; + mapValues(obj: T | null | undefined, iteratee: string): { [P in keyof T]: any }; /** * @see _.mapValues */ - mapValues(obj: string | null | undefined, callback: StringIterator): NumericDictionary; + mapValues(obj: string | null | undefined): NumericDictionary; /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ - mapValues(obj: Dictionary | null | undefined): Dictionary; + mapValues(obj: Dictionary | NumericDictionary | null | undefined): Dictionary; /** * @see _.mapValues @@ -2333,15 +2339,28 @@ declare module "../index" { /** * @see _.mapValues */ - mapValues(obj: T | null | undefined): T | {}; - - /** - * @see _.mapValues - */ - mapValues(obj: string | null | undefined): NumericDictionary; + mapValues(obj: T | null | undefined): PartialObject; } interface LoDashImplicitWrapper { + /** + * @see _.mapValues + */ + mapValues( + this: LoDashImplicitWrapper, + callback: StringIterator + ): LoDashImplicitWrapper>; + + /** + * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. + */ + mapValues( + this: LoDashImplicitWrapper | NumericDictionary | null | undefined>, + callback: ObjectIterator, TResult> + ): LoDashImplicitWrapper>; + /** * @see _.mapValues */ @@ -2350,6 +2369,16 @@ declare module "../index" { callback: ObjectIterator ): LoDashImplicitWrapper<{ [P in keyof T]: TResult }>; + /** + * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. + */ + mapValues( + this: LoDashImplicitWrapper | NumericDictionary | null | undefined>, + iteratee: object + ): LoDashImplicitWrapper>; + /** * @see _.mapValues */ @@ -2360,16 +2389,28 @@ declare module "../index" { /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ mapValues( - this: LoDashImplicitWrapper | null | undefined>, + this: LoDashImplicitWrapper | NumericDictionary | null | undefined>, iteratee: TKey ): LoDashImplicitWrapper>; /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ - mapValues( + mapValues( + this: LoDashImplicitWrapper | NumericDictionary | null | undefined>, + iteratee: string + ): LoDashImplicitWrapper>; + + /** + * @see _.mapValues + */ + mapValues( this: LoDashImplicitWrapper, iteratee: string ): LoDashImplicitWrapper<{ [P in keyof T]: any }>; @@ -2377,15 +2418,14 @@ declare module "../index" { /** * @see _.mapValues */ - mapValues( - this: LoDashImplicitWrapper, - callback: StringIterator - ): LoDashImplicitWrapper>; + mapValues(this: LoDashImplicitWrapper): LoDashImplicitWrapper>; /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ - mapValues(this: LoDashImplicitWrapper | null | undefined>): LoDashImplicitWrapper>; + mapValues(this: LoDashImplicitWrapper | NumericDictionary | null | undefined>): LoDashImplicitWrapper>; /** * @see _.mapValues @@ -2395,15 +2435,28 @@ declare module "../index" { /** * @see _.mapValues */ - mapValues(this: LoDashImplicitWrapper): LoDashImplicitWrapper; - - /** - * @see _.mapValues - */ - mapValues(this: LoDashImplicitWrapper): LoDashImplicitWrapper>; + mapValues(this: LoDashImplicitWrapper): LoDashImplicitWrapper>; } interface LoDashExplicitWrapper { + /** + * @see _.mapValues + */ + mapValues( + this: LoDashExplicitWrapper, + callback: StringIterator + ): LoDashExplicitWrapper>; + + /** + * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. + */ + mapValues( + this: LoDashExplicitWrapper | NumericDictionary | null | undefined>, + callback: ObjectIterator, TResult> + ): LoDashExplicitWrapper>; + /** * @see _.mapValues */ @@ -2412,6 +2465,16 @@ declare module "../index" { callback: ObjectIterator ): LoDashExplicitWrapper<{ [P in keyof T]: TResult }>; + /** + * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. + */ + mapValues( + this: LoDashExplicitWrapper | NumericDictionary | null | undefined>, + iteratee: object + ): LoDashExplicitWrapper>; + /** * @see _.mapValues */ @@ -2422,16 +2485,28 @@ declare module "../index" { /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ mapValues( - this: LoDashExplicitWrapper | null | undefined>, + this: LoDashExplicitWrapper | NumericDictionary | null | undefined>, iteratee: TKey ): LoDashExplicitWrapper>; /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ - mapValues( + mapValues( + this: LoDashExplicitWrapper | NumericDictionary | null | undefined>, + iteratee: string + ): LoDashExplicitWrapper>; + + /** + * @see _.mapValues + */ + mapValues( this: LoDashExplicitWrapper, iteratee: string ): LoDashExplicitWrapper<{ [P in keyof T]: any }>; @@ -2439,15 +2514,14 @@ declare module "../index" { /** * @see _.mapValues */ - mapValues( - this: LoDashExplicitWrapper, - callback: StringIterator - ): LoDashExplicitWrapper>; + mapValues(this: LoDashExplicitWrapper): LoDashExplicitWrapper>; /** * @see _.mapValues + * TODO: This would be better if we had a separate overload for obj: NumericDictionary that returned a NumericDictionary, + * but TypeScript cannot select overload signatures based on number vs string index key type. */ - mapValues(this: LoDashExplicitWrapper | null | undefined>): LoDashExplicitWrapper>; + mapValues(this: LoDashExplicitWrapper | NumericDictionary | null | undefined>): LoDashExplicitWrapper>; /** * @see _.mapValues @@ -2457,12 +2531,7 @@ declare module "../index" { /** * @see _.mapValues */ - mapValues(this: LoDashExplicitWrapper): LoDashExplicitWrapper; - - /** - * @see _.mapValues - */ - mapValues(this: LoDashExplicitWrapper): LoDashExplicitWrapper>; + mapValues(this: LoDashExplicitWrapper): LoDashExplicitWrapper>; } // merge @@ -2773,10 +2842,10 @@ declare module "../index" { * _.omit(object, ['a', 'c']); * // => { 'b': '2' } */ - omit( - object: Dictionary, + omit( + object: T | null | undefined, ...paths: PropertyPath[] - ): Dictionary; + ): T; /** * @see _.omit @@ -2791,10 +2860,10 @@ declare module "../index" { /** * @see _.omit */ - omit( - this: LoDashImplicitWrapper>, + omit( + this: LoDashImplicitWrapper, ...paths: PropertyPath[] - ): LoDashImplicitWrapper>; + ): LoDashImplicitWrapper; /** * @see _.omit @@ -2809,10 +2878,10 @@ declare module "../index" { /** * @see _.omit */ - omit( - this: LoDashExplicitWrapper>, + omit( + this: LoDashExplicitWrapper, ...paths: PropertyPath[] - ): LoDashExplicitWrapper>; + ): LoDashExplicitWrapper; /** * @see _.omit @@ -3164,7 +3233,7 @@ declare module "../index" { * @param object The object to query. * @return Returns the new array of key-value pairs. */ - toPairs(object?: Dictionary): Array<[string, T]>; + toPairs(object?: Dictionary | NumericDictionary): Array<[string, T]>; /** * @see _.toPairs @@ -3176,7 +3245,7 @@ declare module "../index" { /** * @see _.toPairs */ - toPairs(this: LoDashImplicitWrapper>): LoDashImplicitWrapper>; + toPairs(this: LoDashImplicitWrapper | NumericDictionary>): LoDashImplicitWrapper>; /** * @see _.toPairs @@ -3188,7 +3257,7 @@ declare module "../index" { /** * @see _.toPairs */ - toPairs(this: LoDashExplicitWrapper>): LoDashExplicitWrapper>; + toPairs(this: LoDashExplicitWrapper | NumericDictionary>): LoDashExplicitWrapper>; /** * @see _.toPairs @@ -3205,7 +3274,7 @@ declare module "../index" { * @param object The object to query. * @return Returns the new array of key-value pairs. */ - toPairsIn(object?: Dictionary): Array<[string, T]>; + toPairsIn(object?: Dictionary | NumericDictionary): Array<[string, T]>; /** * @see _.toPairsIn @@ -3217,7 +3286,7 @@ declare module "../index" { /** * @see _.toPairsIn */ - toPairsIn(this: LoDashImplicitWrapper>): LoDashImplicitWrapper>; + toPairsIn(this: LoDashImplicitWrapper | NumericDictionary>): LoDashImplicitWrapper>; /** * @see _.toPairsIn @@ -3229,7 +3298,7 @@ declare module "../index" { /** * @see _.toPairsIn */ - toPairsIn(this: LoDashExplicitWrapper>): LoDashExplicitWrapper>; + toPairsIn(this: LoDashExplicitWrapper | NumericDictionary>): LoDashExplicitWrapper>; /** * @see _.toPairsIn @@ -3563,7 +3632,7 @@ declare module "../index" { * @param object The object to query. * @return Returns an array of property values. */ - values(object: Dictionary|NumericDictionary|List | null | undefined): T[]; + values(object: Dictionary | NumericDictionary | List | null | undefined): T[]; /** * @see _.values diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 7646cd02a6..20bde973aa 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -109,11 +109,11 @@ namespace TestChunk { { let result: AbcObject[][]; - result = _.chunk(array); - result = _.chunk(array, 42); + result = _.chunk(array); + result = _.chunk(array, 42); - result = _.chunk(list); - result = _.chunk(list, 42); + result = _.chunk(list); + result = _.chunk(list, 42); } { @@ -122,8 +122,8 @@ namespace TestChunk { result = _(array).chunk(); result = _(array).chunk(42); - result = _(list).chunk(); - result = _(list).chunk(42); + result = _(list).chunk(); + result = _(list).chunk(42); } { @@ -133,8 +133,8 @@ namespace TestChunk { result = _(array).chain().chunk(); result = _(array).chain().chunk(42); - result = _(list).chain().chunk(); - result = _(list).chain().chunk(42); + result = _(list).chain().chunk(); + result = _(list).chain().chunk(42); } } @@ -148,8 +148,8 @@ namespace TestCompact { { let result: AbcObject[]; - result = _.compact(array); - result = _.compact(list); + result = _.compact(array); + result = _.compact(list); result = _.compact(array2); result = _.compact(list2); } @@ -158,14 +158,14 @@ namespace TestCompact { let result: _.LoDashImplicitArrayWrapper; result = _(array).compact(); - result = _(list).compact(); + result = _(list).compact(); } { let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().compact(); - result = _(list).chain().compact(); + result = _(list).chain().compact(); } } @@ -198,10 +198,10 @@ namespace TestDifference { result = _(array).difference(listParam, arrayParam); result = _(array).difference(arrayParam, listParam, arrayParam); - result = _(list).difference(); - result = _(list).difference(listParam); - result = _(list).difference(arrayParam, listParam); - result = _(list).difference(listParam, arrayParam, listParam); + result = _(list).difference(); + result = _(list).difference(listParam); + result = _(list).difference(arrayParam, listParam); + result = _(list).difference(listParam, arrayParam, listParam); } { @@ -212,10 +212,10 @@ namespace TestDifference { result = _(array).chain().difference(listParam, arrayParam); result = _(array).chain().difference(arrayParam, listParam, arrayParam); - result = _(list).chain().difference(); - result = _(list).chain().difference(listParam); - result = _(list).chain().difference(arrayParam, listParam); - result = _(list).chain().difference(listParam, arrayParam, listParam); + result = _(list).chain().difference(); + result = _(list).chain().difference(listParam); + result = _(list).chain().difference(arrayParam, listParam); + result = _(list).chain().difference(listParam, arrayParam, listParam); } } @@ -231,12 +231,12 @@ namespace TestDifferenceBy { let result: AbcObject[]; result = _.differenceBy(array); - result = _.differenceBy(array, arrayParam); - result = _.differenceBy(array, listParam, arrayParam); - result = _.differenceBy(array, arrayParam, listParam, arrayParam); - result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam); - result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam); - result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); + result = _.differenceBy(array, arrayParam); + result = _.differenceBy(array, listParam, arrayParam); + result = _.differenceBy(array, arrayParam, listParam, arrayParam); + result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam); + result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam); + result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); result = _.differenceBy(array, arrayParam, iteratee); result = _.differenceBy(array, listParam, arrayParam, iteratee); @@ -260,12 +260,12 @@ namespace TestDifferenceBy { result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _.differenceBy(list); - result = _.differenceBy(list, listParam); - result = _.differenceBy(list, arrayParam, listParam); - result = _.differenceBy(list, listParam, arrayParam, listParam); - result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam); - result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam); - result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); + result = _.differenceBy(list, listParam); + result = _.differenceBy(list, arrayParam, listParam); + result = _.differenceBy(list, listParam, arrayParam, listParam); + result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam); + result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam); + result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); result = _.differenceBy(list, listParam, iteratee); result = _.differenceBy(list, arrayParam, listParam, iteratee); @@ -292,12 +292,12 @@ namespace TestDifferenceBy { { let result: _.LoDashImplicitWrapper; - result = _(array).differenceBy(arrayParam); - result = _(array).differenceBy(listParam, arrayParam); - result = _(array).differenceBy(arrayParam, listParam, arrayParam); - result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam); - result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam); - result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); + result = _(array).differenceBy(arrayParam); + result = _(array).differenceBy(listParam, arrayParam); + result = _(array).differenceBy(arrayParam, listParam, arrayParam); + result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam); + result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam); + result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); result = _(array).differenceBy(arrayParam, iteratee); result = _(array).differenceBy(listParam, arrayParam, iteratee); @@ -320,12 +320,12 @@ namespace TestDifferenceBy { result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); - result = _(list).differenceBy(listParam); - result = _(list).differenceBy(arrayParam, listParam); - result = _(list).differenceBy(listParam, arrayParam, listParam); - result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam); - result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam); - result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); + result = _(list).differenceBy(listParam); + result = _(list).differenceBy(arrayParam, listParam); + result = _(list).differenceBy(listParam, arrayParam, listParam); + result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam); + result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam); + result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); result = _(list).differenceBy(listParam, iteratee); result = _(list).differenceBy(arrayParam, listParam, iteratee); @@ -352,12 +352,12 @@ namespace TestDifferenceBy { { let result: _.LoDashExplicitWrapper; - result = _(array).chain().differenceBy(arrayParam); - result = _(array).chain().differenceBy(listParam, arrayParam); - result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam); - result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam); - result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam); - result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); + result = _(array).chain().differenceBy(arrayParam); + result = _(array).chain().differenceBy(listParam, arrayParam); + result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam); + result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam); + result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam); + result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); result = _(array).chain().differenceBy(arrayParam, iteratee); result = _(array).chain().differenceBy(listParam, arrayParam, iteratee); @@ -380,12 +380,12 @@ namespace TestDifferenceBy { result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); - result = _(list).chain().differenceBy(listParam); - result = _(list).chain().differenceBy(arrayParam, listParam); - result = _(list).chain().differenceBy(listParam, arrayParam, listParam); - result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam); - result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam); - result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); + result = _(list).chain().differenceBy(listParam); + result = _(list).chain().differenceBy(arrayParam, listParam); + result = _(list).chain().differenceBy(listParam, arrayParam, listParam); + result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam); + result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam); + result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); result = _(list).chain().differenceBy(listParam, iteratee); result = _(list).chain().differenceBy(arrayParam, listParam, iteratee); @@ -653,11 +653,11 @@ namespace TestDifferenceBy { { let result: AbcObject[]; - result = _.drop(array); - result = _.drop(array, 42); + result = _.drop(array); + result = _.drop(array, 42); - result = _.drop(list); - result = _.drop(list, 42); + result = _.drop(list); + result = _.drop(list, 42); } { @@ -666,8 +666,8 @@ namespace TestDifferenceBy { result = _(array).drop(); result = _(array).drop(42); - result = _(list).drop(); - result = _(list).drop(42); + result = _(list).drop(); + result = _(list).drop(42); } { @@ -676,8 +676,8 @@ namespace TestDifferenceBy { result = _(array).chain().drop(); result = _(array).chain().drop(42); - result = _(list).chain().drop(); - result = _(list).chain().drop(42); + result = _(list).chain().drop(); + result = _(list).chain().drop(42); } } @@ -689,11 +689,11 @@ namespace TestDropRight { { let result: AbcObject[]; - result = _.dropRight(array); - result = _.dropRight(array, 42); + result = _.dropRight(array); + result = _.dropRight(array, 42); - result = _.dropRight(list); - result = _.dropRight(list, 42); + result = _.dropRight(list); + result = _.dropRight(list, 42); } { @@ -702,8 +702,8 @@ namespace TestDropRight { result = _(array).dropRight(); result = _(array).dropRight(42); - result = _(list).dropRight(); - result = _(list).dropRight(42); + result = _(list).dropRight(); + result = _(list).dropRight(42); } { @@ -712,8 +712,8 @@ namespace TestDropRight { result = _(array).chain().dropRight(); result = _(array).chain().dropRight(42); - result = _(list).chain().dropRight(); - result = _(list).chain().dropRight(42); + result = _(list).chain().dropRight(); + result = _(list).chain().dropRight(42); } } @@ -726,14 +726,14 @@ namespace TestDropRightWhile { { let result: AbcObject[]; - result = _.dropRightWhile(array); - result = _.dropRightWhile(array, predicateFn); - result = _.dropRightWhile(array, ''); + result = _.dropRightWhile(array); + result = _.dropRightWhile(array, predicateFn); + result = _.dropRightWhile(array, ''); result = _.dropRightWhile(array, {a: 42}); - result = _.dropRightWhile(list); - result = _.dropRightWhile(list, predicateFn); - result = _.dropRightWhile(list, ''); + result = _.dropRightWhile(list); + result = _.dropRightWhile(list, predicateFn); + result = _.dropRightWhile(list, ''); result = _.dropRightWhile(list, {a: 42}); } @@ -745,9 +745,9 @@ namespace TestDropRightWhile { result = _(array).dropRightWhile(''); result = _(array).dropRightWhile({a: 42}); - result = _(list).dropRightWhile(); - result = _(list).dropRightWhile(predicateFn); - result = _(list).dropRightWhile(''); + result = _(list).dropRightWhile(); + result = _(list).dropRightWhile(predicateFn); + result = _(list).dropRightWhile(''); result = _(list).dropRightWhile({a: 42}); } @@ -759,9 +759,9 @@ namespace TestDropRightWhile { result = _(array).chain().dropRightWhile(''); result = _(array).chain().dropRightWhile({a: 42}); - result = _(list).chain().dropRightWhile(); - result = _(list).chain().dropRightWhile(predicateFn); - result = _(list).chain().dropRightWhile(''); + result = _(list).chain().dropRightWhile(); + result = _(list).chain().dropRightWhile(predicateFn); + result = _(list).chain().dropRightWhile(''); result = _(list).chain().dropRightWhile({a: 42}); } } @@ -775,14 +775,14 @@ namespace TestDropWhile { { let result: AbcObject[]; - result = _.dropWhile(array); - result = _.dropWhile(array, predicateFn); - result = _.dropWhile(array, ''); + result = _.dropWhile(array); + result = _.dropWhile(array, predicateFn); + result = _.dropWhile(array, ''); result = _.dropWhile(array, {a: 42}); - result = _.dropWhile(list); - result = _.dropWhile(list, predicateFn); - result = _.dropWhile(list, ''); + result = _.dropWhile(list); + result = _.dropWhile(list, predicateFn); + result = _.dropWhile(list, ''); result = _.dropWhile(list, {a: 42}); } @@ -794,9 +794,9 @@ namespace TestDropWhile { result = _(array).dropWhile(''); result = _(array).dropWhile({a: 42}); - result = _(list).dropWhile(); - result = _(list).dropWhile(predicateFn); - result = _(list).dropWhile(''); + result = _(list).dropWhile(); + result = _(list).dropWhile(predicateFn); + result = _(list).dropWhile(''); result = _(list).dropWhile({a: 42}); } @@ -808,9 +808,9 @@ namespace TestDropWhile { result = _(array).chain().dropWhile(''); result = _(array).chain().dropWhile({a: 42}); - result = _(list).chain().dropWhile(); - result = _(list).chain().dropWhile(predicateFn); - result = _(list).chain().dropWhile(''); + result = _(list).chain().dropWhile(); + result = _(list).chain().dropWhile(predicateFn); + result = _(list).chain().dropWhile(''); result = _(list).chain().dropWhile({a: 42}); } } @@ -879,17 +879,17 @@ namespace TestFindIndex { { let result: number; - result = _.findIndex(array); - result = _.findIndex(array, predicateFn); - result = _.findIndex(array, ''); + result = _.findIndex(array); + result = _.findIndex(array, predicateFn); + result = _.findIndex(array, ''); result = _.findIndex(array, {a: 42}); - result = _.findIndex(array, predicateFn, fromIndex); + result = _.findIndex(array, predicateFn, fromIndex); - result = _.findIndex(list); - result = _.findIndex(list, predicateFn); - result = _.findIndex(list, ''); + result = _.findIndex(list); + result = _.findIndex(list, predicateFn); + result = _.findIndex(list, ''); result = _.findIndex(list, {a: 42}); - result = _.findIndex(list, predicateFn, fromIndex); + result = _.findIndex(list, predicateFn, fromIndex); result = _.findIndex([{ b: 5 }], ['b', 5]); result = _(array).findIndex(); @@ -899,10 +899,10 @@ namespace TestFindIndex { result = _(array).findIndex(predicateFn, fromIndex); result = _(list).findIndex(); - result = _(list).findIndex(predicateFn); + result = _(list).findIndex(predicateFn); result = _(list).findIndex(''); result = _(list).findIndex<{a: number}>({a: 42}); - result = _(list).findIndex(predicateFn, fromIndex); + result = _(list).findIndex(predicateFn, fromIndex); } { @@ -915,10 +915,10 @@ namespace TestFindIndex { result = _(array).chain().findIndex(predicateFn, fromIndex); result = _(list).chain().findIndex(); - result = _(list).chain().findIndex(predicateFn); + result = _(list).chain().findIndex(predicateFn); result = _(list).chain().findIndex(''); result = _(list).chain().findIndex<{a: number}>({a: 42}); - result = _(list).chain().findIndex(predicateFn, fromIndex); + result = _(list).chain().findIndex(predicateFn, fromIndex); } } @@ -933,17 +933,17 @@ namespace TestFindLastIndex { { let result: number; - result = _.findLastIndex(array); - result = _.findLastIndex(array, predicateFn); - result = _.findLastIndex(array, ''); + result = _.findLastIndex(array); + result = _.findLastIndex(array, predicateFn); + result = _.findLastIndex(array, ''); result = _.findLastIndex(array, {a: 42}); - result = _.findLastIndex(array, predicateFn, fromIndex); + result = _.findLastIndex(array, predicateFn, fromIndex); - result = _.findLastIndex(list); - result = _.findLastIndex(list, predicateFn); - result = _.findLastIndex(list, ''); + result = _.findLastIndex(list); + result = _.findLastIndex(list, predicateFn); + result = _.findLastIndex(list, ''); result = _.findLastIndex(list, {a: 42}); - result = _.findLastIndex(list, predicateFn, fromIndex); + result = _.findLastIndex(list, predicateFn, fromIndex); result = _.findLastIndex([{ b: 5 }], ['b', 5]); result = _(array).findLastIndex(); @@ -953,10 +953,10 @@ namespace TestFindLastIndex { result = _(array).findLastIndex(predicateFn, fromIndex); result = _(list).findLastIndex(); - result = _(list).findLastIndex(predicateFn); + result = _(list).findLastIndex(predicateFn); result = _(list).findLastIndex(''); result = _(list).findLastIndex<{a: number}>({a: 42}); - result = _(list).findLastIndex(predicateFn, fromIndex); + result = _(list).findLastIndex(predicateFn, fromIndex); } { @@ -969,10 +969,10 @@ namespace TestFindLastIndex { result = _(array).chain().findLastIndex(predicateFn, fromIndex); result = _(list).chain().findLastIndex(); - result = _(list).chain().findLastIndex(predicateFn); + result = _(list).chain().findLastIndex(predicateFn); result = _(list).chain().findLastIndex(''); result = _(list).chain().findLastIndex<{a: number}>({a: 42}); - result = _(list).chain().findLastIndex(predicateFn, fromIndex); + result = _(list).chain().findLastIndex(predicateFn, fromIndex); } } @@ -991,11 +991,11 @@ namespace TestFirst { { let result: AbcObject | undefined; - result = _.first(array); - result = _.first(list); + result = _.first(array); + result = _.first(list); result = _(array).first(); - result = _(list).first(); + result = _(list).first(); } { @@ -1240,11 +1240,11 @@ namespace TestHead { { let result: AbcObject | undefined; - result = _.head(array); - result = _.head(list); + result = _.head(array); + result = _.head(list); result = _(array).head(); - result = _(list).head(); + result = _(list).head(); } { @@ -1270,21 +1270,21 @@ namespace TestIndexOf { { let result: number; - result = _.indexOf(array, value); - result = _.indexOf(array, value, true); - result = _.indexOf(array, value, 42); + result = _.indexOf(array, value); + result = _.indexOf(array, value, true); + result = _.indexOf(array, value, 42); - result = _.indexOf(list, value); - result = _.indexOf(list, value, true); - result = _.indexOf(list, value, 42); + result = _.indexOf(list, value); + result = _.indexOf(list, value, true); + result = _.indexOf(list, value, 42); result = _(array).indexOf(value); result = _(array).indexOf(value, true); result = _(array).indexOf(value, 42); - result = _(list).indexOf(value); - result = _(list).indexOf(value, true); - result = _(list).indexOf(value, 42); + result = _(list).indexOf(value); + result = _(list).indexOf(value, true); + result = _(list).indexOf(value, 42); } { @@ -1294,9 +1294,9 @@ namespace TestIndexOf { result = _(array).chain().indexOf(value, true); result = _(array).chain().indexOf(value, 42); - result = _(list).chain().indexOf(value); - result = _(list).chain().indexOf(value, true); - result = _(list).chain().indexOf(value, 42); + result = _(list).chain().indexOf(value); + result = _(list).chain().indexOf(value, true); + result = _(list).chain().indexOf(value, 42); } } @@ -1309,17 +1309,17 @@ namespace TestIndexOf { { let result: number; - result = _.sortedIndexOf(array, value); - result = _.sortedIndexOf(list, value); + result = _.sortedIndexOf(array, value); + result = _.sortedIndexOf(list, value); result = _(array).sortedIndexOf(value); - result = _(list).sortedIndexOf(value); + result = _(list).sortedIndexOf(value); } { let result: _.LoDashExplicitWrapper; result = _(array).chain().sortedIndexOf(value); - result = _(list).chain().sortedIndexOf(value); + result = _(list).chain().sortedIndexOf(value); } } @@ -1331,22 +1331,22 @@ namespace TestInitial { { let result: AbcObject[]; - result = _.initial(array); - result = _.initial(list); + result = _.initial(array); + result = _.initial(list); } { let result: _.LoDashImplicitArrayWrapper; result = _(array).initial(); - result = _(list).initial(); + result = _(list).initial(); } { let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().initial(); - result = _(list).chain().initial(); + result = _(list).chain().initial(); } } @@ -1360,28 +1360,28 @@ namespace TestIntersection { { let result: AbcObject[]; - result = _.intersection(array, list); - result = _.intersection(list, array, list); + result = _.intersection(array, list); + result = _.intersection(list, array, list); } { let result: _.LoDashImplicitArrayWrapper; - result = _(array).intersection(arrayParam); - result = _(array).intersection(listParam, arrayParam); + result = _(array).intersection(arrayParam); + result = _(array).intersection(listParam, arrayParam); - result = _(list).intersection(arrayParam); - result = _(list).intersection(listParam, arrayParam); + result = _(list).intersection(arrayParam); + result = _(list).intersection(listParam, arrayParam); } { let result: _.LoDashExplicitArrayWrapper; - result = _(array).chain().intersection(arrayParam); - result = _(array).chain().intersection(listParam, arrayParam); + result = _(array).chain().intersection(arrayParam); + result = _(array).chain().intersection(listParam, arrayParam); - result = _(list).chain().intersection(arrayParam); - result = _(list).chain().intersection(listParam, arrayParam); + result = _(list).chain().intersection(arrayParam); + result = _(list).chain().intersection(listParam, arrayParam); } } @@ -1632,11 +1632,11 @@ namespace TestLast { { let result: AbcObject | undefined; - result = _.last(array); - result = _.last(list); + result = _.last(array); + result = _.last(list); result = _(array).last(); - result = _(list).last(); + result = _(list).last(); } { @@ -1667,21 +1667,21 @@ namespace TestLastIndexOf { { let result: number; - result = _.lastIndexOf(array, value); - result = _.lastIndexOf(array, value, true); - result = _.lastIndexOf(array, value, 42); + result = _.lastIndexOf(array, value); + result = _.lastIndexOf(array, value, true); + result = _.lastIndexOf(array, value, 42); - result = _.lastIndexOf(list, value); - result = _.lastIndexOf(list, value, true); - result = _.lastIndexOf(list, value, 42); + result = _.lastIndexOf(list, value); + result = _.lastIndexOf(list, value, true); + result = _.lastIndexOf(list, value, 42); result = _(array).lastIndexOf(value); result = _(array).lastIndexOf(value, true); result = _(array).lastIndexOf(value, 42); - result = _(list).lastIndexOf(value); - result = _(list).lastIndexOf(value, true); - result = _(list).lastIndexOf(value, 42); + result = _(list).lastIndexOf(value); + result = _(list).lastIndexOf(value, true); + result = _(list).lastIndexOf(value, 42); } { @@ -1691,9 +1691,9 @@ namespace TestLastIndexOf { result = _(array).chain().lastIndexOf(value, true); result = _(array).chain().lastIndexOf(value, 42); - result = _(list).chain().lastIndexOf(value); - result = _(list).chain().lastIndexOf(value, true); - result = _(list).chain().lastIndexOf(value, 42); + result = _(list).chain().lastIndexOf(value); + result = _(list).chain().lastIndexOf(value, true); + result = _(list).chain().lastIndexOf(value, 42); } } @@ -1706,15 +1706,15 @@ namespace TestNth { { let result: AbcObject | undefined; - result = _.nth(array); + result = _.nth(array); - result = _.nth(array, 42); + result = _.nth(array, 42); result = _(array).nth(); result = _(array).nth(42); - result = _(list).nth(); - result = _(list).nth(42); + result = _(list).nth(); + result = _(list).nth(42); } { @@ -1723,8 +1723,8 @@ namespace TestNth { result = _(array).chain().nth(); result = _(array).chain().nth(42); - result = _(list).chain().nth(); - result = _(list).chain().nth(42); + result = _(list).chain().nth(); + result = _(list).chain().nth(42); } } @@ -1737,19 +1737,19 @@ namespace TestPull { { let result: AbcObject[]; - result = _.pull(array); - result = _.pull(array, value); - result = _.pull(array, value, value); - result = _.pull(array, value, value, value); + result = _.pull(array); + result = _.pull(array, value); + result = _.pull(array, value, value); + result = _.pull(array, value, value, value); } { let result: _.List; - result = _.pull(list); - result = _.pull(list, value); - result = _.pull(list, value, value); - result = _.pull(list, value, value, value); + result = _.pull(list); + result = _.pull(list, value); + result = _.pull(list, value, value); + result = _.pull(list, value, value, value); } { @@ -1764,10 +1764,10 @@ namespace TestPull { { let result: _.LoDashImplicitObjectWrapper<_.List>; - result = _(list).pull(); - result = _(list).pull(value); - result = _(list).pull(value, value); - result = _(list).pull(value, value, value); + result = _(list).pull(); + result = _(list).pull(value); + result = _(list).pull(value, value); + result = _(list).pull(value, value, value); } { @@ -1782,10 +1782,10 @@ namespace TestPull { { let result: _.LoDashExplicitObjectWrapper<_.List>; - result = _(list).chain().pull(); - result = _(list).chain().pull(value); - result = _(list).chain().pull(value, value); - result = _(list).chain().pull(value, value, value); + result = _(list).chain().pull(); + result = _(list).chain().pull(value); + result = _(list).chain().pull(value, value); + result = _(list).chain().pull(value, value, value); } } @@ -1797,19 +1797,19 @@ namespace TestPullAt { { let result: AbcObject[]; - result = _.pullAt(array); - result = _.pullAt(array, 1); - result = _.pullAt(array, [2, 3], 1); - result = _.pullAt(array, 4, [2, 3], 1); + result = _.pullAt(array); + result = _.pullAt(array, 1); + result = _.pullAt(array, [2, 3], 1); + result = _.pullAt(array, 4, [2, 3], 1); } { let result: ArrayLike; - result = _.pullAt(list); - result = _.pullAt(list, 1); - result = _.pullAt(list, [2, 3], 1); - result = _.pullAt(list, 4, [2, 3], 1); + result = _.pullAt(list); + result = _.pullAt(list, 1); + result = _.pullAt(list, [2, 3], 1); + result = _.pullAt(list, 4, [2, 3], 1); } { @@ -2117,14 +2117,14 @@ namespace TestRemove { { let result: AbcObject[]; - result = _.remove(array); - result = _.remove(array, predicateFn); - result = _.remove(array, ''); + result = _.remove(array); + result = _.remove(array, predicateFn); + result = _.remove(array, ''); result = _.remove(array, {a: 42}); - result = _.remove(list); - result = _.remove(list, predicateFn); - result = _.remove(list, ''); + result = _.remove(list); + result = _.remove(list, predicateFn); + result = _.remove(list, ''); result = _.remove(list, {a: 42}); } @@ -2136,9 +2136,9 @@ namespace TestRemove { result = _(array).remove(''); result = _(array).remove({a: 42}); - result = _(list).remove(); - result = _(list).remove(predicateFn); - result = _(list).remove(''); + result = _(list).remove(); + result = _(list).remove(predicateFn); + result = _(list).remove(''); result = _(list).remove({a: 42}); } @@ -2150,9 +2150,9 @@ namespace TestRemove { result = _(array).chain().remove(''); result = _(array).chain().remove({a: 42}); - result = _(list).chain().remove(); - result = _(list).chain().remove(predicateFn); - result = _(list).chain().remove(''); + result = _(list).chain().remove(); + result = _(list).chain().remove(predicateFn); + result = _(list).chain().remove(''); result = _(list).chain().remove({a: 42}); } } @@ -2165,22 +2165,22 @@ namespace TestTail { { let result: AbcObject[]; - result = _.tail(array); - result = _.tail(list); + result = _.tail(array); + result = _.tail(list); } { let result: _.LoDashImplicitArrayWrapper; result = _(array).tail(); - result = _(list).tail(); + result = _(list).tail(); } { let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().tail(); - result = _(list).chain().tail(); + result = _(list).chain().tail(); } } @@ -2191,7 +2191,7 @@ namespace TestSlice { { let result: AbcObject[]; - result = _.slice(array); + result = _.slice(array); result = _.slice(array, 42); result = _.slice(array, 42, 42); } @@ -2405,11 +2405,11 @@ namespace TestTake { { let result: AbcObject[]; - result = _.take(array); - result = _.take(array, 42); + result = _.take(array); + result = _.take(array, 42); - result = _.take(list); - result = _.take(list, 42); + result = _.take(list); + result = _.take(list, 42); } { @@ -2418,8 +2418,8 @@ namespace TestTake { result = _(array).take(); result = _(array).take(42); - result = _(list).take(); - result = _(list).take(42); + result = _(list).take(); + result = _(list).take(42); } { @@ -2428,8 +2428,8 @@ namespace TestTake { result = _(array).chain().take(); result = _(array).chain().take(42); - result = _(list).chain().take(); - result = _(list).chain().take(42); + result = _(list).chain().take(); + result = _(list).chain().take(42); } } @@ -2441,11 +2441,11 @@ namespace TestTakeRight { { let result: AbcObject[]; - result = _.takeRight(array); - result = _.takeRight(array, 42); + result = _.takeRight(array); + result = _.takeRight(array, 42); - result = _.takeRight(list); - result = _.takeRight(list, 42); + result = _.takeRight(list); + result = _.takeRight(list, 42); } { @@ -2454,8 +2454,8 @@ namespace TestTakeRight { result = _(array).takeRight(); result = _(array).takeRight(42); - result = _(list).takeRight(); - result = _(list).takeRight(42); + result = _(list).takeRight(); + result = _(list).takeRight(42); } { @@ -2464,8 +2464,8 @@ namespace TestTakeRight { result = _(array).chain().takeRight(); result = _(array).chain().takeRight(42); - result = _(list).chain().takeRight(); - result = _(list).chain().takeRight(42); + result = _(list).chain().takeRight(); + result = _(list).chain().takeRight(42); } } @@ -2478,14 +2478,14 @@ namespace TestTakeRightWhile { { let result: AbcObject[]; - result = _.takeRightWhile(array); - result = _.takeRightWhile(array, predicateFn); - result = _.takeRightWhile(array, ''); + result = _.takeRightWhile(array); + result = _.takeRightWhile(array, predicateFn); + result = _.takeRightWhile(array, ''); result = _.takeRightWhile(array, {a: 42}); - result = _.takeRightWhile(list); - result = _.takeRightWhile(list, predicateFn); - result = _.takeRightWhile(list, ''); + result = _.takeRightWhile(list); + result = _.takeRightWhile(list, predicateFn); + result = _.takeRightWhile(list, ''); result = _.takeRightWhile(list, {a: 42}); } @@ -2497,9 +2497,9 @@ namespace TestTakeRightWhile { result = _(array).takeRightWhile(''); result = _(array).takeRightWhile({a: 42}); - result = _(list).takeRightWhile(); - result = _(list).takeRightWhile(predicateFn); - result = _(list).takeRightWhile(''); + result = _(list).takeRightWhile(); + result = _(list).takeRightWhile(predicateFn); + result = _(list).takeRightWhile(''); result = _(list).takeRightWhile({a: 42}); } @@ -2511,9 +2511,9 @@ namespace TestTakeRightWhile { result = _(array).chain().takeRightWhile(''); result = _(array).chain().takeRightWhile({a: 42}); - result = _(list).chain().takeRightWhile(); - result = _(list).chain().takeRightWhile(predicateFn); - result = _(list).chain().takeRightWhile(''); + result = _(list).chain().takeRightWhile(); + result = _(list).chain().takeRightWhile(predicateFn); + result = _(list).chain().takeRightWhile(''); result = _(list).chain().takeRightWhile({a: 42}); } } @@ -2527,14 +2527,14 @@ namespace TestTakeWhile { { let result: AbcObject[]; - result = _.takeWhile(array); - result = _.takeWhile(array, predicateFn); - result = _.takeWhile(array, ''); + result = _.takeWhile(array); + result = _.takeWhile(array, predicateFn); + result = _.takeWhile(array, ''); result = _.takeWhile(array, {a: 42}); - result = _.takeWhile(list); - result = _.takeWhile(list, predicateFn); - result = _.takeWhile(list, ''); + result = _.takeWhile(list); + result = _.takeWhile(list, predicateFn); + result = _.takeWhile(list, ''); result = _.takeWhile(list, {a: 42}); } @@ -2546,9 +2546,9 @@ namespace TestTakeWhile { result = _(array).takeWhile(''); result = _(array).takeWhile({a: 42}); - result = _(list).takeWhile(); - result = _(list).takeWhile(predicateFn); - result = _(list).takeWhile(''); + result = _(list).takeWhile(); + result = _(list).takeWhile(predicateFn); + result = _(list).takeWhile(''); result = _(list).takeWhile({a: 42}); } @@ -2560,9 +2560,9 @@ namespace TestTakeWhile { result = _(array).chain().takeWhile(''); result = _(array).chain().takeWhile({a: 42}); - result = _(list).chain().takeWhile(); - result = _(list).chain().takeWhile(predicateFn); - result = _(list).chain().takeWhile(''); + result = _(list).chain().takeWhile(); + result = _(list).chain().takeWhile(predicateFn); + result = _(list).chain().takeWhile(''); result = _(list).chain().takeWhile({a: 42}); } } @@ -2575,15 +2575,16 @@ namespace TestUnion { { let result: AbcObject[]; - result = _.union(); + // $ExpectType {}[] + _.union(); - result = _.union(array); - result = _.union(array, list); - result = _.union(array, list, array); + result = _.union(array); + result = _.union(array, list); + result = _.union(array, list, array); - result = _.union(list); - result = _.union(list, array); - result = _.union(list, array, list); + result = _.union(list); + result = _.union(list, array); + result = _.union(list, array, list); } { @@ -2593,13 +2594,13 @@ namespace TestUnion { result = _(array).union(list); result = _(array).union(list, array); - result = _(array).union(); - result = _(array).union(list); - result = _(array).union(list, array); + result = _(array).union(); + result = _(array).union(list); + result = _(array).union(list, array); - result = _(list).union(); - result = _(list).union(array); - result = _(list).union(array, list); + result = _(list).union(); + result = _(list).union(array); + result = _(list).union(array, list); } { @@ -2609,13 +2610,13 @@ namespace TestUnion { result = _(array).chain().union(list); result = _(array).chain().union(list, array); - result = _(array).chain().union(); - result = _(array).chain().union(list); - result = _(array).chain().union(list, array); + result = _(array).chain().union(); + result = _(array).chain().union(list); + result = _(array).chain().union(list, array); - result = _(list).chain().union(); - result = _(list).chain().union(array); - result = _(list).chain().union(array, list); + result = _(list).chain().union(); + result = _(list).chain().union(array); + result = _(list).chain().union(array, list); } } @@ -2628,20 +2629,21 @@ namespace TestUnionBy { { let result: AbcObject[]; - result = _.unionBy(array, array); - result = _.unionBy(array, list, array); - result = _.unionBy(array, array, list, array); - result = _.unionBy(array, list, array, list, array); - result = _.unionBy(array, array, list, array, list, array); + result = _.unionBy(array, array); + result = _.unionBy(array, list, array); + result = _.unionBy(array, array, list, array); + result = _.unionBy(array, list, array, list, array); + result = _.unionBy(array, array, list, array, list, array); - result = _.unionBy(array, array, iteratee); - result = _.unionBy(array, list, array, iteratee); - result = _.unionBy(array, array, list, array, iteratee); - result = _.unionBy(array, list, array, list, array, iteratee); - result = _.unionBy(array, array, list, array, list, array, iteratee); + result = _.unionBy(array, array, iteratee); + result = _.unionBy(array, list, array, iteratee); + result = _.unionBy(array, array, list, array, iteratee); + result = _.unionBy(array, list, array, list, array, iteratee); + result = _.unionBy(array, array, list, array, list, array, iteratee); - result = _.unionBy(array, array, 'a'); - result = _.unionBy(array, list, array, 'a'); + result = _.unionBy(array, array, 'a'); + result = _.unionBy(array, list, array, 'a'); + // param needed for TS 2.3 result = _.unionBy(array, array, list, array, 'a'); result = _.unionBy(array, list, array, list, array, 'a'); result = _.unionBy(array, array, list, array, list, array, 'a'); @@ -2650,22 +2652,23 @@ namespace TestUnionBy { result = _.unionBy(array, list, array, {a: 1}); result = _.unionBy(array, array, list, array, {a: 1}); result = _.unionBy(array, list, array, list, array, {a: 1}); - result = _.unionBy(array, list, array, list, array, list, {a: 1}); + result = _.unionBy(array, list, array, list, array, list, {a: 1}); - result = _.unionBy(list, list); - result = _.unionBy(list, array, list); - result = _.unionBy(list, list, array, list); - result = _.unionBy(list, array, list, array, list); - result = _.unionBy(list, list, array, list, array, list); + result = _.unionBy(list, list); + result = _.unionBy(list, array, list); + result = _.unionBy(list, list, array, list); + result = _.unionBy(list, array, list, array, list); + result = _.unionBy(list, list, array, list, array, list); - result = _.unionBy(list, list, iteratee); - result = _.unionBy(list, array, list, iteratee); - result = _.unionBy(list, list, array, list, iteratee); - result = _.unionBy(list, array, list, array, list, iteratee); - result = _.unionBy(list, list, array, list, array, list, iteratee); + result = _.unionBy(list, list, iteratee); + result = _.unionBy(list, array, list, iteratee); + result = _.unionBy(list, list, array, list, iteratee); + result = _.unionBy(list, array, list, array, list, iteratee); + result = _.unionBy(list, list, array, list, array, list, iteratee); - result = _.unionBy(list, list, 'a'); - result = _.unionBy(list, array, list, 'a'); + result = _.unionBy(list, list, 'a'); + result = _.unionBy(list, array, list, 'a'); + // param needed for TS 2.3 result = _.unionBy(list, list, array, list, 'a'); result = _.unionBy(list, array, list, array, list, 'a'); result = _.unionBy(list, list, array, list, array, list, 'a'); @@ -2674,26 +2677,27 @@ namespace TestUnionBy { result = _.unionBy(list, array, list, {a: 1}); result = _.unionBy(list, list, array, list, {a: 1}); result = _.unionBy(list, array, list, array, list, {a: 1}); - result = _.unionBy(list, array, list, array, list, array, {a: 1}); + result = _.unionBy(list, array, list, array, list, array, {a: 1}); } { let result: _.LoDashImplicitArrayWrapper; - result = _(array).unionBy(array); - result = _(array).unionBy(list, array); - result = _(array).unionBy(array, list, array); - result = _(array).unionBy(list, array, list, array); - result = _(array).unionBy(array, list, array, list, array); + result = _(array).unionBy(array); + result = _(array).unionBy(list, array); + result = _(array).unionBy(array, list, array); + result = _(array).unionBy(list, array, list, array); + result = _(array).unionBy(array, list, array, list, array); - result = _(array).unionBy(array, iteratee); - result = _(array).unionBy(list, array, iteratee); - result = _(array).unionBy(array, list, array, iteratee); - result = _(array).unionBy(list, array, list, array, iteratee); - result = _(array).unionBy(array, list, array, list, array, iteratee); + result = _(array).unionBy(array, iteratee); + result = _(array).unionBy(list, array, iteratee); + result = _(array).unionBy(array, list, array, iteratee); + result = _(array).unionBy(list, array, list, array, iteratee); + result = _(array).unionBy(array, list, array, list, array, iteratee); - result = _(array).unionBy(array, 'a'); - result = _(array).unionBy(list, array, 'a'); + result = _(array).unionBy(array, 'a'); + result = _(array).unionBy(list, array, 'a'); + // param needed for TS 2.3 result = _(array).unionBy(array, list, array, 'a'); result = _(array).unionBy(list, array, list, array, 'a'); result = _(array).unionBy(array, list, array, list, array, 'a'); @@ -2702,22 +2706,23 @@ namespace TestUnionBy { result = _(array).unionBy(list, array, {a: 1}); result = _(array).unionBy(array, list, array, {a: 1}); result = _(array).unionBy(list, array, list, array, {a: 1}); - result = _(array).unionBy(list, array, list, array, list, {a: 1}); + result = _(array).unionBy(list, array, list, array, list, {a: 1}); - result = _(list).unionBy(list); - result = _(list).unionBy(array, list); - result = _(list).unionBy(list, array, list); - result = _(list).unionBy(array, list, array, list); - result = _(list).unionBy(list, array, list, array, list); + result = _(list).unionBy(list); + result = _(list).unionBy(array, list); + result = _(list).unionBy(list, array, list); + result = _(list).unionBy(array, list, array, list); + result = _(list).unionBy(list, array, list, array, list); - result = _(list).unionBy(list, iteratee); - result = _(list).unionBy(array, list, iteratee); - result = _(list).unionBy(list, array, list, iteratee); - result = _(list).unionBy(array, list, array, list, iteratee); - result = _(list).unionBy(list, array, list, array, list, iteratee); + result = _(list).unionBy(list, iteratee); + result = _(list).unionBy(array, list, iteratee); + result = _(list).unionBy(list, array, list, iteratee); + result = _(list).unionBy(array, list, array, list, iteratee); + result = _(list).unionBy(list, array, list, array, list, iteratee); - result = _(list).unionBy(list, 'a'); - result = _(list).unionBy(array, list, 'a'); + result = _(list).unionBy(list, 'a'); + result = _(list).unionBy(array, list, 'a'); + // param needed for TS 2.3 result = _(list).unionBy(list, array, list, 'a'); result = _(list).unionBy(array, list, array, list, 'a'); result = _(list).unionBy(list, array, list, array, list, 'a'); @@ -2726,27 +2731,28 @@ namespace TestUnionBy { result = _(list).unionBy(array, list, {a: 1}); result = _(list).unionBy(list, array, list, {a: 1}); result = _(list).unionBy(array, list, array, list, {a: 1}); - result = _(list).unionBy(array, list, array, list, array, {a: 1}); + result = _(list).unionBy(array, list, array, list, array, {a: 1}); } { let result: _.LoDashExplicitArrayWrapper; - result = _(array).chain().unionBy(array); - result = _(array).chain().unionBy(list, array); - result = _(array).chain().unionBy(array, list, array); - result = _(array).chain().unionBy(list, array, list, array); - result = _(array).chain().unionBy(array, list, array, list, array); + result = _(array).chain().unionBy(array); + result = _(array).chain().unionBy(list, array); + result = _(array).chain().unionBy(array, list, array); + result = _(array).chain().unionBy(list, array, list, array); + result = _(array).chain().unionBy(array, list, array, list, array); - result = _(array).chain().unionBy(array, iteratee); - result = _(array).chain().unionBy(list, array, iteratee); - result = _(array).chain().unionBy(array, list, array, iteratee); - result = _(array).chain().unionBy(list, array, list, array, iteratee); - result = _(array).chain().unionBy(array, list, array, list, array, iteratee); + result = _(array).chain().unionBy(array, iteratee); + result = _(array).chain().unionBy(list, array, iteratee); + result = _(array).chain().unionBy(array, list, array, iteratee); + result = _(array).chain().unionBy(list, array, list, array, iteratee); + result = _(array).chain().unionBy(array, list, array, list, array, iteratee); - result = _(array).chain().unionBy(array, 'a'); - result = _(array).chain().unionBy(list, array, 'a'); - result = _(array).chain().unionBy(array, list, array, 'a'); + result = _(array).chain().unionBy(array, 'a'); + result = _(array).chain().unionBy(list, array, 'a'); + result = _(array).chain().unionBy(array, list, array, 'a'); + // param needed for TS 2.3 result = _(array).chain().unionBy(list, array, list, array, 'a'); result = _(array).chain().unionBy(array, list, array, list, array, 'a'); @@ -2754,23 +2760,24 @@ namespace TestUnionBy { result = _(array).chain().unionBy(list, array, {a: 1}); result = _(array).chain().unionBy(array, list, array, {a: 1}); result = _(array).chain().unionBy(list, array, list, array, {a: 1}); - result = _(array).chain().unionBy(list, array, list, array, list, {a: 1}); + result = _(array).chain().unionBy(list, array, list, array, list, {a: 1}); - result = _(list).chain().unionBy(list); - result = _(list).chain().unionBy(array, list); - result = _(list).chain().unionBy(list, array, list); - result = _(list).chain().unionBy(array, list, array, list); - result = _(list).chain().unionBy(list, array, list, array, list); + result = _(list).chain().unionBy(list); + result = _(list).chain().unionBy(array, list); + result = _(list).chain().unionBy(list, array, list); + result = _(list).chain().unionBy(array, list, array, list); + result = _(list).chain().unionBy(list, array, list, array, list); - result = _(list).chain().unionBy(list, iteratee); - result = _(list).chain().unionBy(array, list, iteratee); - result = _(list).chain().unionBy(list, array, list, iteratee); - result = _(list).chain().unionBy(array, list, array, list, iteratee); - result = _(list).chain().unionBy(list, array, list, array, list, iteratee); + result = _(list).chain().unionBy(list, iteratee); + result = _(list).chain().unionBy(array, list, iteratee); + result = _(list).chain().unionBy(list, array, list, iteratee); + result = _(list).chain().unionBy(array, list, array, list, iteratee); + result = _(list).chain().unionBy(list, array, list, array, list, iteratee); - result = _(list).chain().unionBy(list, 'a'); - result = _(list).chain().unionBy(array, list, 'a'); - result = _(list).chain().unionBy(list, array, list, 'a'); + result = _(list).chain().unionBy(list, 'a'); + result = _(list).chain().unionBy(array, list, 'a'); + result = _(list).chain().unionBy(list, array, list, 'a'); + // param needed for TS 2.3 result = _(list).chain().unionBy(array, list, array, list, 'a'); result = _(list).chain().unionBy(list, array, list, array, list, 'a'); @@ -2778,7 +2785,7 @@ namespace TestUnionBy { result = _(list).chain().unionBy(array, list, {a: 1}); result = _(list).chain().unionBy(list, array, list, {a: 1}); result = _(list).chain().unionBy(array, list, array, list, {a: 1}); - result = _(list).chain().unionBy(array, list, array, list, array, {a: 1}); + result = _(list).chain().unionBy(array, list, array, list, array, {a: 1}); } } @@ -3155,15 +3162,16 @@ namespace TestXor { { let result: AbcObject[]; - result = _.xor(); + // $ExpectType {}[] + _.xor(); - result = _.xor(array); - result = _.xor(array, list); - result = _.xor(array, list, array); + result = _.xor(array); + result = _.xor(array, list); + result = _.xor(array, list, array); - result = _.xor(list); - result = _.xor(list, array); - result = _.xor(list, array, list); + result = _.xor(list); + result = _.xor(list, array); + result = _.xor(list, array, list); } { @@ -3173,9 +3181,9 @@ namespace TestXor { result = _(array).xor(list); result = _(array).xor(list, array); - result = _(list).xor(); - result = _(list).xor(array); - result = _(list).xor(array, list); + result = _(list).xor(); + result = _(list).xor(array); + result = _(list).xor(array, list); } { @@ -3185,9 +3193,9 @@ namespace TestXor { result = _(array).chain().xor(list); result = _(array).chain().xor(list, array); - result = _(list).chain().xor(); - result = _(list).chain().xor(array); - result = _(list).chain().xor(array, list); + result = _(list).chain().xor(); + result = _(list).chain().xor(array); + result = _(list).chain().xor(array, list); } } @@ -3198,18 +3206,18 @@ namespace TestXor { { // $ExpectType (AbcObject | undefined)[][] - _.zip(array); + _.zip(array); // $ExpectType (AbcObject | undefined)[][] - _.zip(array, list); + _.zip(array, list); // $ExpectType (AbcObject | undefined)[][] - _.zip(array, list, array); + _.zip(array, list, array); // $ExpectType (AbcObject | undefined)[][] - _.zip(list); + _.zip(list); // $ExpectType (AbcObject | undefined)[][] - _.zip(list, array); + _.zip(list, array); // $ExpectType (AbcObject | undefined)[][] - _.zip(list, array, list); + _.zip(list, array, list); // $ExpectType (AbcObject | undefined)[][] _.zip(list, array, list, array, list, array); @@ -3217,26 +3225,26 @@ namespace TestXor { { // $ExpectType LoDashImplicitWrapper<(AbcObject | undefined)[][]> - _(array).zip(list); + _(array).zip(list); // $ExpectType LoDashImplicitWrapper<(AbcObject | undefined)[][]> - _(array).zip(list, array); + _(array).zip(list, array); // $ExpectType LoDashImplicitWrapper<(AbcObject | undefined)[][]> - _(list).zip(array); + _(list).zip(array); // $ExpectType LoDashImplicitWrapper<(AbcObject | undefined)[][]> - _(list).zip(array, list); + _(list).zip(array, list); } { // $ExpectType LoDashExplicitWrapper<(AbcObject | undefined)[][]> - _(array).chain().zip(list); + _(array).chain().zip(list); // $ExpectType LoDashExplicitWrapper<(AbcObject | undefined)[][]> - _(array).chain().zip(list, array); + _(array).chain().zip(list, array); // $ExpectType LoDashExplicitWrapper<(AbcObject | undefined)[][]> - _(list).chain().zip(array); + _(list).chain().zip(array); // $ExpectType LoDashExplicitWrapper<(AbcObject | undefined)[][]> - _(list).chain().zip(array, list); + _(list).chain().zip(array, list); } { @@ -4062,29 +4070,52 @@ namespace TestAt { let array: AbcObject[] | null | undefined = [] as any; let list: _.List | null | undefined = [] as any; let dictionary: _.Dictionary | null | undefined = anything; + let numericDictionary: _.NumericDictionary | null | undefined = anything; + let abcObject: AbcObject | null | undefined = anything; { let result: AbcObject[]; - result = _.at(array, 0, '1', [2], ['3'], [4, '5']); - result = _.at(list, 0, '1', [2], ['3'], [4, '5']); - result = _.at(dictionary, 0, '1', [2], ['3'], [4, '5']); + result = _.at(array, 0, '1', [2], ['3'], [4, '5']); + result = _.at(list, 0, '1', [2], ['3'], [4, '5']); + result = _.at(dictionary, 0, '1', [2], ['3'], [4, '5']); + result = _.at(numericDictionary, 0, '1', [2], ['3'], [4, '5']); + } + + { + let result: Array; + + result = _.at(abcObject, 'a', ['b'], ['a', 'b']); } { let result: _.LoDashImplicitArrayWrapper; result = _(array).at(0, '1', [2], ['3'], [4, '5']); - result = _(list).at(0, '1', [2], ['3'], [4, '5']); - result = _(dictionary).at(0, '1', [2], ['3'], [4, '5']); + result = _(list).at(0, '1', [2], ['3'], [4, '5']); + result = _(dictionary).at(0, '1', [2], ['3'], [4, '5']); + result = _(numericDictionary).at(0, '1', [2], ['3'], [4, '5']); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(abcObject).at('a', ['b'], ['a', 'b']); } { let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().at(0, '1', [2], ['3'], [4, '5']); - result = _(list).chain().at(0, '1', [2], ['3'], [4, '5']); - result = _(dictionary).chain().at(0, '1', [2], ['3'], [4, '5']); + result = _(list).chain().at(0, '1', [2], ['3'], [4, '5']); + result = _(dictionary).chain().at(0, '1', [2], ['3'], [4, '5']); + result = _(numericDictionary).chain().at(0, '1', [2], ['3'], [4, '5']); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(abcObject).chain().at('a', ['b'], ['a', 'b']); } } @@ -4099,37 +4130,34 @@ namespace TestCountBy { let stringIterator: (value: string, index: number, collection: string) => any = (value: string, index: number, collection: string) => 1; let listIterator: (value: AbcObject, index: number, collection: _.List) => any = (value: AbcObject, index: number, collection: _.List) => 1; let dictionaryIterator: (value: AbcObject, key: string, collection: _.Dictionary) => any = (value: AbcObject, key: string, collection: _.Dictionary) => 1; - let numericDictionaryIterator: (value: AbcObject, key: number, collection: _.NumericDictionary) => any = (value: AbcObject, key: number, collection: _.NumericDictionary) => 1; + let numericDictionaryIterator: (value: AbcObject, key: string, collection: _.NumericDictionary) => any = (value: AbcObject, key: string, collection: _.NumericDictionary) => 1; { let result: _.Dictionary; - result = _.countBy(''); - result = _.countBy('', stringIterator); + result = _.countBy(''); + result = _.countBy('', stringIterator); - result = _.countBy(array); - result = _.countBy(array, listIterator); - result = _.countBy(array, ''); + result = _.countBy(array); + result = _.countBy(array, listIterator); + result = _.countBy(array, ''); + result = _.countBy(array, {a: 42}); result = _.countBy(array, {a: 42}); - result = _.countBy(array, {a: 42}); - result = _.countBy(list); - result = _.countBy(list, listIterator); - result = _.countBy(list, ''); + result = _.countBy(list); + result = _.countBy(list, listIterator); + result = _.countBy(list, ''); result = _.countBy(list, {a: 42}); - result = _.countBy(list, {a: 42}); - result = _.countBy(dictionary); + result = _.countBy(dictionary); result = _.countBy(dictionary, dictionaryIterator); - result = _.countBy(dictionary, ''); + result = _.countBy(dictionary, ''); result = _.countBy(dictionary, {a: 42}); - result = _.countBy(dictionary, {a: 42}); - result = _.countBy(numericDictionary); - result = _.countBy(numericDictionary, numericDictionaryIterator); - result = _.countBy(numericDictionary, ''); + result = _.countBy(numericDictionary); + result = _.countBy(numericDictionary, numericDictionaryIterator); + result = _.countBy(numericDictionary, ''); result = _.countBy(numericDictionary, {a: 42}); - result = _.countBy(numericDictionary, {a: 42}); } { @@ -4145,7 +4173,7 @@ namespace TestCountBy { result = _(array).countBy({a: 42}); result = _(list).countBy(); - result = _(list).countBy(listIterator); + result = _(list).countBy(listIterator); result = _(list).countBy(''); result = _(list).countBy<{a: number}>({a: 42}); result = _(list).countBy({a: 42}); @@ -4153,13 +4181,11 @@ namespace TestCountBy { result = _(dictionary).countBy(); result = _(dictionary).countBy(dictionaryIterator); result = _(dictionary).countBy(''); - result = _(dictionary).countBy<{a: number}>({a: 42}); result = _(dictionary).countBy({a: 42}); result = _(numericDictionary).countBy(); - result = _(numericDictionary).countBy(numericDictionaryIterator); + result = _(numericDictionary).countBy(numericDictionaryIterator); result = _(numericDictionary).countBy(''); - result = _(numericDictionary).countBy<{a: number}>({a: 42}); result = _(numericDictionary).countBy({a: 42}); } @@ -4172,25 +4198,21 @@ namespace TestCountBy { result = _(array).chain().countBy(); result = _(array).chain().countBy(listIterator); result = _(array).chain().countBy(''); - result = _(array).chain().countBy<{a: number}>({a: 42}); result = _(array).chain().countBy({a: 42}); result = _(list).chain().countBy(); - result = _(list).chain().countBy(listIterator); + result = _(list).chain().countBy(listIterator); result = _(list).chain().countBy(''); - result = _(list).chain().countBy<{a: number}>({a: 42}); result = _(list).chain().countBy({a: 42}); result = _(dictionary).chain().countBy(); result = _(dictionary).chain().countBy(dictionaryIterator); result = _(dictionary).chain().countBy(''); - result = _(dictionary).chain().countBy<{a: number}>({a: 42}); result = _(dictionary).chain().countBy({a: 42}); result = _(numericDictionary).chain().countBy(); - result = _(numericDictionary).chain().countBy(numericDictionaryIterator); + result = _(numericDictionary).chain().countBy(numericDictionaryIterator); result = _(numericDictionary).chain().countBy(''); - result = _(numericDictionary).chain().countBy<{a: number}>({a: 42}); result = _(numericDictionary).chain().countBy({a: 42}); } } @@ -4271,7 +4293,7 @@ namespace TestEach { { let result: _.LoDashImplicitObjectWrapper<_.List>; - result = _(list).each(listIterator); + result = _(list).each(listIterator); } { @@ -4295,7 +4317,7 @@ namespace TestEach { { let result: _.LoDashExplicitObjectWrapper<_.List>; - result = _(list).chain().each(listIterator); + result = _(list).chain().each(listIterator); } { @@ -4381,7 +4403,7 @@ namespace TestEachRight { { let result: _.LoDashImplicitObjectWrapper<_.List>; - result = _(list).eachRight(listIterator); + result = _(list).eachRight(listIterator); } { @@ -4405,7 +4427,7 @@ namespace TestEachRight { { let result: _.LoDashExplicitObjectWrapper<_.List>; - result = _(list).chain().eachRight(listIterator); + result = _(list).chain().eachRight(listIterator); } { @@ -4427,34 +4449,34 @@ namespace TestEvery { let listIterator = (value: SampleObject, index: number, collection: _.List) => true; let dictionaryIterator = (value: SampleObject, key: string, collection: _.Dictionary) => true; - let numericDictionaryIterator = (value: SampleObject, key: number, collection: _.NumericDictionary) => true; + let numericDictionaryIterator = (value: SampleObject, key: string, collection: _.NumericDictionary) => true; { let result: boolean; - result = _.every(array); - result = _.every(array, listIterator); - result = _.every(array, 'a'); - result = _.every(array, ['a', 42]); - result = _.every(array, {a: 42}); + result = _.every(array); + result = _.every(array, listIterator); + result = _.every(array, 'a'); + result = _.every(array, ['a', 42]); + result = _.every(array, {a: 42}); - result = _.every(list); - result = _.every(list, listIterator); - result = _.every(list, 'a'); - result = _.every(list, ['a', 42]); - result = _.every(list, {a: 42}); + result = _.every(list); + result = _.every(list, listIterator); + result = _.every(list, 'a'); + result = _.every(list, ['a', 42]); + result = _.every(list, {a: 42}); - result = _.every(dictionary); + result = _.every(dictionary); result = _.every(dictionary, dictionaryIterator); - result = _.every(dictionary, 'a'); - result = _.every(dictionary, ['a', 42]); - result = _.every(dictionary, {a: 42}); + result = _.every(dictionary, 'a'); + result = _.every(dictionary, ['a', 42]); + result = _.every(dictionary, {a: 42}); - result = _.every(numericDictionary); - result = _.every(numericDictionary, numericDictionaryIterator); - result = _.every(numericDictionary, 'a'); - result = _.every(numericDictionary, ['a', 42]); - result = _.every(numericDictionary, {a: 42}); + result = _.every(numericDictionary); + result = _.every(numericDictionary, numericDictionaryIterator); + result = _.every(numericDictionary, 'a'); + result = _.every(numericDictionary, ['a', 42]); + result = _.every(numericDictionary, {a: 42}); result = _(array).every(); result = _(array).every(listIterator); @@ -4462,20 +4484,20 @@ namespace TestEvery { result = _(array).every(['a', 42]); result = _(array).every({a: 42}); - result = _(list).every(); - result = _(list).every(listIterator); + result = _(list).every(); + result = _(list).every(listIterator); result = _(list).every('a'); result = _(list).every(['a', 42]); result = _(list).every({a: 42}); - result = _(dictionary).every(); + result = _(dictionary).every(); result = _(dictionary).every(dictionaryIterator); result = _(dictionary).every('a'); result = _(dictionary).every(['a', 42]); result = _(dictionary).every({a: 42}); - result = _(numericDictionary).every(); - result = _(numericDictionary).every(numericDictionaryIterator); + result = _(numericDictionary).every(); + result = _(numericDictionary).every(numericDictionaryIterator); result = _(numericDictionary).every('a'); result = _(numericDictionary).every(['a', 42]); result = _(numericDictionary).every({a: 42}); @@ -4490,23 +4512,23 @@ namespace TestEvery { result = _(array).chain().every(['a', 42]); result = _(array).chain().every({a: 42}); - result = _(list).chain().every(); - result = _(list).chain().every(listIterator); + result = _(list).chain().every(); + result = _(list).chain().every(listIterator); result = _(list).chain().every('a'); result = _(list).chain().every(['a', 42]); - result = _(list).chain().every({a: 42}); + result = _(list).chain().every({a: 42}); - result = _(dictionary).chain().every(); + result = _(dictionary).chain().every(); result = _(dictionary).chain().every(dictionaryIterator); result = _(dictionary).chain().every('a'); result = _(dictionary).chain().every(['a', 42]); - result = _(dictionary).chain().every({a: 42}); + result = _(dictionary).chain().every({a: 42}); - result = _(numericDictionary).chain().every(); - result = _(numericDictionary).chain().every(numericDictionaryIterator); + result = _(numericDictionary).chain().every(); + result = _(numericDictionary).chain().every(numericDictionaryIterator); result = _(numericDictionary).chain().every('a'); result = _(numericDictionary).chain().every(['a', 42]); - result = _(numericDictionary).chain().every<{a: number}>({a: 42}); + result = _(numericDictionary).chain().every({a: 42}); } } @@ -4530,15 +4552,15 @@ namespace TestFilter { { let result: AbcObject[]; - result = _.filter(array, listIterator); - result = _.filter(array, ''); - result = _.filter(array, {a: 42}); - result = _.filter(array, ["a", 42]); + result = _.filter(array, listIterator); + result = _.filter(array, ''); + result = _.filter(array, {a: 42}); + result = _.filter(array, ["a", 42]); - result = _.filter(list, listIterator); - result = _.filter(list, ''); - result = _.filter(list, {a: 42}); - result = _.filter(list, ["a", 42]); + result = _.filter(list, listIterator); + result = _.filter(list, ''); + result = _.filter(list, {a: 42}); + result = _.filter(list, ["a", 42]); result = _.filter(dictionary, dictionaryIterator); result = _.filter(dictionary, ''); @@ -4560,10 +4582,10 @@ namespace TestFilter { result = _(array).filter({a: 42}); result = _(array).filter(["a", 42]); - result = _(list).filter(listIterator); - result = _(list).filter(''); - result = _(list).filter({a: 42}); - result = _(list).filter(["a", 42]); + result = _(list).filter(listIterator); + result = _(list).filter(''); + result = _(list).filter({a: 42}); + result = _(list).filter(["a", 42]); result = _(dictionary).filter(dictionaryIterator); result = _(dictionary).filter(''); @@ -4585,10 +4607,10 @@ namespace TestFilter { result = _(array).chain().filter({a: 42}); result = _(array).chain().filter(["a", 42]); - result = _(list).chain().filter(listIterator); - result = _(list).chain().filter(''); - result = _(list).chain().filter({a: 42}); - result = _(list).chain().filter(["a", 42]); + result = _(list).chain().filter(listIterator); + result = _(list).chain().filter(''); + result = _(list).chain().filter({a: 42}); + result = _(list).chain().filter(["a", 42]); result = _(dictionary).chain().filter(dictionaryIterator); result = _(dictionary).chain().filter(''); @@ -4623,28 +4645,25 @@ namespace TestFind { let result: AbcObject | undefined; result = _.find(array); - result = _.find(array); - result = _.find(array, listIterator); - result = _.find(array, listIterator, 1); - result = _.find(array, ''); - result = _.find(array, '', 1); - result = _.find(array, {a: 42}); - result = _.find(array, {a: 42}, 1); + result = _.find(array, listIterator); + result = _.find(array, listIterator, 1); + result = _.find(array, ''); + result = _.find(array, '', 1); + result = _.find(array, {a: 42}); + result = _.find(array, {a: 42}, 1); result = _.find(array, ['a', 5]); result = _.find(array, ['a', 5], 1); result = _.find(list); - result = _.find(list); - result = _.find(list, listIterator); - result = _.find(list, listIterator, 1); - result = _.find(list, ''); - result = _.find(list, '', 1); - result = _.find(list, {a: 42}); - result = _.find(list, {a: 42}, 1); + result = _.find(list, listIterator); + result = _.find(list, listIterator, 1); + result = _.find(list, ''); + result = _.find(list, '', 1); + result = _.find(list, {a: 42}); + result = _.find(list, {a: 42}, 1); result = _.find(list, ['a', 5]); result = _.find(list, ['a', 5], 1); - result = _.find(dictionary); result = _.find(dictionary); result = _.find(dictionary, dictionaryIterator); result = _.find(dictionary, dictionaryIterator, 1); @@ -4665,15 +4684,15 @@ namespace TestFind { result = _(array).find(['a', 5]); result = _(array).find(['a', 5], 1); - result = _(list).find(); - result = _(list).find(listIterator); - result = _(list).find(listIterator, 1); - result = _(list).find(''); - result = _(list).find('', 1); - result = _(list).find({a: 42}); - result = _(list).find({a: 42}, 1); - result = _(list).find(['a', 5]); - result = _(list).find(['a', 5], 1); + result = _(list).find(); + result = _(list).find(listIterator); + result = _(list).find(listIterator, 1); + result = _(list).find(''); + result = _(list).find('', 1); + result = _(list).find({a: 42}); + result = _(list).find({a: 42}, 1); + result = _(list).find(['a', 5]); + result = _(list).find(['a', 5], 1); result = _(dictionary).find(); result = _(dictionary).find(dictionaryIterator); @@ -4702,24 +4721,23 @@ namespace TestFindLast { let result: AbcObject | undefined; result = _.findLast(array); - result = _.findLast(array); - result = _.findLast(array, listIterator); - result = _.findLast(array, listIterator, 1); - result = _.findLast(array, ''); - result = _.findLast(array, '', 1); - result = _.findLast(array, {a: 42}); - result = _.findLast(array, {a: 42}, 1); + result = _.findLast(array, listIterator); + result = _.findLast(array, listIterator, 1); + result = _.findLast(array, ''); + result = _.findLast(array, '', 1); + result = _.findLast(array, {a: 42}); + result = _.findLast(array, {a: 42}, 1); result = _.findLast(array, ['a', 5]); result = _.findLast(array, ['a', 5], 1); result = _.findLast(list); - result = _.findLast(list); - result = _.findLast(list, listIterator); - result = _.findLast(list, listIterator, 1); - result = _.findLast(list, ''); - result = _.findLast(list, '', 1); - result = _.findLast(list, {a: 42}); - result = _.findLast(list, {a: 42}, 1); + result = _.findLast(list); + result = _.findLast(list, listIterator); + result = _.findLast(list, listIterator, 1); + result = _.findLast(list, ''); + result = _.findLast(list, '', 1); + result = _.findLast(list, {a: 42}); + result = _.findLast(list, {a: 42}, 1); result = _.findLast(list, ['a', 5]); result = _.findLast(list, ['a', 5], 1); @@ -4744,15 +4762,15 @@ namespace TestFindLast { result = _(array).findLast(['a', 5]); result = _(array).findLast(['a', 5], 1); - result = _(list).findLast(); - result = _(list).findLast(listIterator); - result = _(list).findLast(listIterator, 1); - result = _(list).findLast(''); - result = _(list).findLast('', 1); - result = _(list).findLast({a: 42}); - result = _(list).findLast({a: 42}, 1); - result = _(list).findLast(['a', 5]); - result = _(list).findLast(['a', 5], 1); + result = _(list).findLast(); + result = _(list).findLast(listIterator); + result = _(list).findLast(listIterator, 1); + result = _(list).findLast(''); + result = _(list).findLast('', 1); + result = _(list).findLast({a: 42}); + result = _(list).findLast({a: 42}, 1); + result = _(list).findLast(['a', 5]); + result = _(list).findLast(['a', 5], 1); result = _(dictionary).findLast(); result = _(dictionary).findLast(dictionaryIterator); @@ -4789,7 +4807,7 @@ namespace TestFlatMap { let dictionaryIterator: (value: number|number[], key: string, collection: _.Dictionary) => number|number[] = (a, b, c) => 1; - let numericDictionaryIterator: (value: number|number[], key: number, collection: _.NumericDictionary) => number|number[] = (a, b, c) => 1; + let numericDictionaryIterator: (value: number|number[], key: string, collection: _.NumericDictionary) => number|number[] = (a, b, c) => 1; { let result: string[]; @@ -4831,7 +4849,6 @@ namespace TestFlatMap { result = _.flatMap(numNumericDictionary); result = _.flatMap(numNumericDictionary, numericDictionaryIterator); - result = _.flatMap(numNumericDictionary, numericDictionaryIterator); result = _.flatMap(objNumericDictionary, 'a'); } @@ -4861,20 +4878,20 @@ namespace TestFlatMap { { let result: _.LoDashImplicitArrayWrapper; - result = _(numArray).flatMap(); + result = _(numArray).flatMap(); result = _(numArray).flatMap(listIterator); result = _(objArray).flatMap('a'); - result = _(numList).flatMap(); - result = _(numList).flatMap(listIterator); + result = _(numList).flatMap(); + result = _(numList).flatMap(listIterator); result = _(objList).flatMap('a'); - result = _(numDictionary).flatMap(); + result = _(numDictionary).flatMap(); result = _(numDictionary).flatMap(dictionaryIterator); result = _(objDictionary).flatMap('a'); - result = _(numNumericDictionary).flatMap(); - result = _(numNumericDictionary).flatMap(numericDictionaryIterator); + result = _(numNumericDictionary).flatMap(); + result = _(numNumericDictionary).flatMap(numericDictionaryIterator); result = _(objNumericDictionary).flatMap('a'); } @@ -4903,20 +4920,20 @@ namespace TestFlatMap { { let result: _.LoDashExplicitArrayWrapper; - result = _(numArray).chain().flatMap(); + result = _(numArray).chain().flatMap(); result = _(numArray).chain().flatMap(listIterator); result = _(objArray).chain().flatMap('a'); - result = _(numList).chain().flatMap(); - result = _(numList).chain().flatMap(listIterator); + result = _(numList).chain().flatMap(); + result = _(numList).chain().flatMap(listIterator); result = _(objList).chain().flatMap('a'); - result = _(numDictionary).chain().flatMap(); + result = _(numDictionary).chain().flatMap(); result = _(numDictionary).chain().flatMap(dictionaryIterator); result = _(objDictionary).chain().flatMap('a'); - result = _(numNumericDictionary).chain().flatMap(); - result = _(numNumericDictionary).chain().flatMap(numericDictionaryIterator); + result = _(numNumericDictionary).chain().flatMap(); + result = _(numNumericDictionary).chain().flatMap(numericDictionaryIterator); result = _(objNumericDictionary).chain().flatMap('a'); } @@ -4972,7 +4989,7 @@ namespace TestFlatMapDeep { let dictionaryIterator: (value: number|number[], key: string, collection: _.Dictionary) =>_.ListOfRecursiveArraysOrValues = (a, b, c) => [1]; - let numericDictionaryIterator: (value: number|number[], key: number, collection: _.NumericDictionary) => _.ListOfRecursiveArraysOrValues = (a, b, c) => [1]; + let numericDictionaryIterator: (value: number|number[], key: string, collection: _.NumericDictionary) => _.ListOfRecursiveArraysOrValues = (a, b, c) => [1]; { let result: string[]; @@ -5133,7 +5150,7 @@ namespace TestFlatMapDepth { let dictionaryIterator: (value: number|number[], key: string, collection: _.Dictionary) => _.ListOfRecursiveArraysOrValues = (a, b, c) => [1]; - let numericDictionaryIterator: (value: number|number[], key: number, collection: _.NumericDictionary) => _.ListOfRecursiveArraysOrValues = (a, b, c) => [1]; + let numericDictionaryIterator: (value: number|number[], key: string, collection: _.NumericDictionary) => _.ListOfRecursiveArraysOrValues = (a, b, c) => [1]; { let result: string[]; @@ -5276,219 +5293,242 @@ namespace TestFlatMapDepth { // _.forEach namespace TestForEach { - let array: AbcObject[] = []; - let list: _.List = []; - let dictionary: _.Dictionary = {}; - let nilArray: AbcObject[] | null | undefined = [] as any; - let nilList: _.List | null | undefined = [] as any; - let nilDictionary: _.Dictionary | null | undefined = anything; + const str: string = anything; + const nilStr: string | null | undefined = anything; + const array: AbcObject[] = anything; + const list: _.List = anything; + const dictionary: _.Dictionary = anything; + const numericDictionary: _.NumericDictionary = anything; + const nilArray: AbcObject[] | null | undefined = anything; + const nilList: _.List | null | undefined = anything; + const nilDictionary: _.Dictionary | null | undefined = anything; + const nilNumericDictionary: _.NumericDictionary | null | undefined = anything; + const abcObject: AbcObject = anything; + const nilAbcObject: AbcObject | null | undefined = anything; - let listIterator: (value: AbcObject, index: number, collection: _.List) => any = (value, index, collection) => 1; - let dictionaryIterator: (value: AbcObject, key: string, collection: _.Dictionary) => any = (value, key, collection) => 1; - let objectIterator: (value: number | string | boolean, key: string, collection: AbcObject) => any = (value, key, collection) => 1; + // $ExpectType string + _.forEach(str, (value, index, collection) => { + value; // $ExpectType string + index; // $ExpectType number + collection; // $ExpectType string + }); - { - let result: string; + // $ExpectType string | null | undefined + _.forEach(nilStr, (value, index, collection) => { + value; // $ExpectType string + index; // $ExpectType number + collection; // $ExpectType string + }); - result = _.forEach('', (value, index, collection) => { - value; // $ExpectType string - index; // $ExpectType number - collection; // $ExpectType string - }); - } + // $ExpectType AbcObject[] + _.forEach(array, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + }); - { - let result: string | null | undefined; + // $ExpectType AbcObject[] | null | undefined + _.forEach(nilArray, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + }); - result = _.forEach('' as (string | null | undefined), (value, index, collection) => { - value; // $ExpectType string - index; // $ExpectType number - collection; // $ExpectType string - }); - } + // $ExpectType ArrayLike + _.forEach(list, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + }); - { - let result: AbcObject[]; - result = _.forEach(array, (value, index, collection: ArrayLike) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - }); - result = _.forEach(array, (value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType AbcObject[] - }); - } + // $ExpectType ArrayLike | null | undefined + _.forEach(nilList, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + }); - { - let result: AbcObject[] | null | undefined; + // $ExpectType Dictionary + _.forEach(dictionary, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType string + collection; // $ExpectType Dictionary + }); - result = _.forEach(array, (value, index, collection: ArrayLike) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - }); - result = _.forEach(nilArray, (value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType AbcObject[] - }); - } + // $ExpectType Dictionary | null | undefined + _.forEach(nilDictionary, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType string + collection; // $ExpectType Dictionary + }); - { - let result: _.List; + // $ExpectType NumericDictionary + _.forEach(numericDictionary, (value, index, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + index; // $ExpectType string + collection; // $ExpectType NumericDictionary + }); - result = _.forEach(list, (value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType ArrayLike - }); - } + // $ExpectType NumericDictionary | null | undefined + _.forEach(nilNumericDictionary, (value, index, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + index; // $ExpectType string + collection; // $ExpectType NumericDictionary + }); - { - let result: _.List | null | undefined; + // $ExpectType AbcObject + _.forEach(abcObject, (value, index, collection) => { + value; // $ExpectType string | number | boolean + index; // $ExpectType string + collection; // $ExpectType AbcObject + }); - result = _.forEach(nilList, (value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType ArrayLike - }); - } + // $ExpectType AbcObject | null | undefined + _.forEach(nilAbcObject, (value, index, collection) => { + value; // $ExpectType string | number | boolean + index; // $ExpectType string + collection; // $ExpectType AbcObject + }); - { - let result: _.Dictionary; + // $ExpectType LoDashImplicitWrapper + _(str).forEach((value, index, collection) => { + value; // $ExpectType string + index; // $ExpectType number + collection; // $ExpectType string + }); - result = _.forEach(dictionary, (value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType string - collection; // $ExpectType Dictionary - }); - } + // $ExpectType LoDashImplicitWrapper + _(nilStr).forEach((value, index, collection) => { + value; // $ExpectType string + index; // $ExpectType number + collection; // $ExpectType string + }); - { - let result: _.Dictionary | null | undefined; + // $ExpectType LoDashImplicitWrapper + _(array).forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + }); - result = _.forEach(nilDictionary, (value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType string - collection; // $ExpectType Dictionary - }); - } + // $ExpectType LoDashImplicitWrapper + _(nilArray).forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + }); - { - let sample1: AbcObject = anything; - sample1 = _.forEach(sample1, objectIterator); + // $ExpectType LoDashImplicitWrapper> + _(list).forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + }); - let sample2: AbcObject | null | undefined = anything; - sample2 = _.forEach(sample2, objectIterator); - } + // $ExpectType LoDashImplicitWrapper | null | undefined> + _(nilList).forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + }); - { - let result: _.LoDashImplicitWrapper; + // $ExpectType LoDashImplicitWrapper> + _(dictionary).forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType string + collection; // $ExpectType Dictionary + }); - result = _('').forEach((value, index, collection) => { - value; // $ExpectType string - index; // $ExpectType number - collection; // $ExpectType string - }); - } + // $ExpectType LoDashImplicitWrapper | null | undefined> + _(nilDictionary).forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType string + collection; // $ExpectType Dictionary + }); - { - let result: _.LoDashImplicitArrayWrapper; + // $ExpectType LoDashImplicitWrapper> + _(numericDictionary).forEach((value, index, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + index; // $ExpectType string + collection; // $ExpectType NumericDictionary + }); - result = _(array).forEach((value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType AbcObject[] - }); - } + // $ExpectType LoDashImplicitWrapper | null | undefined> + _(nilNumericDictionary).forEach((value, index, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + index; // $ExpectType string + collection; // $ExpectType NumericDictionary + }); - { - let result: _.LoDashImplicitNillableArrayWrapper; + // $ExpectType LoDashExplicitWrapper + _(str).chain().forEach((value, index, collection) => { + value; // $ExpectType string + index; // $ExpectType number + collection; // $ExpectType string + }); - result = _(nilArray).forEach((value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType AbcObject[] - }); - } + // $ExpectType LoDashExplicitWrapper + _(nilStr).chain().forEach((value, index, collection) => { + value; // $ExpectType string + index; // $ExpectType number + collection; // $ExpectType string + }); - { - let result: _.LoDashImplicitObjectWrapper<_.List>; + // $ExpectType LoDashExplicitWrapper + _(array).chain().forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + }); - result = _(list).forEach(listIterator); - } + // $ExpectType LoDashExplicitWrapper + _(nilArray).chain().forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + }); - { - let result: _.LoDashImplicitNillableObjectWrapper<_.List>; + // $ExpectType LoDashExplicitWrapper> + _(list).chain().forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + }); - result = _(nilList).forEach(listIterator); - } + // $ExpectType LoDashExplicitWrapper | null | undefined> + _(nilList).chain().forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + }); - { - let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; + // $ExpectType LoDashExplicitWrapper> + _(dictionary).chain().forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType string + collection; // $ExpectType Dictionary + }); - result = _(dictionary).forEach(dictionaryIterator); - } + // $ExpectType LoDashExplicitWrapper | null | undefined> + _(nilDictionary).chain().forEach((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType string + collection; // $ExpectType Dictionary + }); - { - let result: _.LoDashImplicitNillableObjectWrapper<_.Dictionary>; + // $ExpectType LoDashExplicitWrapper> + _(numericDictionary).chain().forEach((value, index, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + index; // $ExpectType string + collection; // $ExpectType NumericDictionary + }); - result = _(nilDictionary).forEach(dictionaryIterator); - } - - { - let result: _.LoDashExplicitWrapper; - - result = _('').chain().forEach((value, index, collection) => { - value; // $ExpectType string - index; // $ExpectType number - collection; // $ExpectType string - }); - } - - { - let result: _.LoDashExplicitArrayWrapper; - - result = _(array).chain().forEach((value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType AbcObject[] - }); - } - - { - let result: _.LoDashExplicitNillableArrayWrapper; - - result = _(nilArray).chain().forEach((value, index, collection) => { - value; // $ExpectType AbcObject - index; // $ExpectType number - collection; // $ExpectType AbcObject[] - }); - } - - { - let result: _.LoDashExplicitObjectWrapper<_.List>; - - result = _(list).chain().forEach(listIterator); - } - - { - let result: _.LoDashExplicitNillableObjectWrapper<_.List>; - - result = _(nilList).chain().forEach(listIterator); - } - - { - let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; - - result = _(dictionary).chain().forEach(dictionaryIterator); - } - - { - let result: _.LoDashExplicitNillableObjectWrapper<_.Dictionary>; - - result = _(nilDictionary).chain().forEach(dictionaryIterator); - } + // $ExpectType LoDashExplicitWrapper | null | undefined> + _(nilNumericDictionary).chain().forEach((value, index, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + index; // $ExpectType string + collection; // $ExpectType NumericDictionary + }); } // _.forEachRight @@ -5608,13 +5648,13 @@ namespace TestForEachRight { { let result: _.LoDashImplicitObjectWrapper<_.List>; - result = _(list).forEachRight(listIterator); + result = _(list).forEachRight(listIterator); } { let result: _.LoDashImplicitNillableObjectWrapper<_.List>; - result = _(nilList).forEachRight(listIterator); + result = _(nilList).forEachRight(listIterator); } { @@ -5668,7 +5708,7 @@ namespace TestForEachRight { { let result: _.LoDashExplicitNillableObjectWrapper<_.List>; - result = _(nilList).chain().forEachRight(listIterator); + result = _(nilList).chain().forEachRight(listIterator); } { @@ -5690,8 +5730,7 @@ namespace TestGroupBy { let array: SampleType[] | null | undefined = [] as any; let list: _.List | null | undefined = [] as any; - let obj: any = {}; - let dictionary: _.Dictionary | null | undefined = obj; + let dictionary: _.Dictionary | null | undefined = anything; let stringIterator = (char: string, index: number, string: string) => 0; let listIterator = (value: SampleType, index: number, collection: _.List) => 0; @@ -5738,15 +5777,15 @@ namespace TestGroupBy { result = _(array).groupBy(''); result = _(array).groupBy({a: 42}); - result = _(list).groupBy(); - result = _(list).groupBy(listIterator); - result = _(list).groupBy(''); - result = _(list).groupBy({a: 42}); + result = _(list).groupBy(); + result = _(list).groupBy(listIterator); + result = _(list).groupBy(''); + result = _(list).groupBy({a: 42}); - result = _(dictionary).groupBy(); + result = _(dictionary).groupBy(); result = _(dictionary).groupBy(dictionaryIterator); - result = _(dictionary).groupBy(''); - result = _(dictionary).groupBy({a: 42}); + result = _(dictionary).groupBy(''); + result = _(dictionary).groupBy({a: 42}); } { @@ -5764,15 +5803,15 @@ namespace TestGroupBy { result = _(array).chain().groupBy(''); result = _(array).chain().groupBy({a: 42}); - result = _(list).chain().groupBy(); - result = _(list).chain().groupBy(listIterator); - result = _(list).chain().groupBy(''); - result = _(list).chain().groupBy({a: 42}); + result = _(list).chain().groupBy(); + result = _(list).chain().groupBy(listIterator); + result = _(list).chain().groupBy(''); + result = _(list).chain().groupBy({a: 42}); - result = _(dictionary).chain().groupBy(); + result = _(dictionary).chain().groupBy(); result = _(dictionary).chain().groupBy(dictionaryIterator); - result = _(dictionary).chain().groupBy(''); - result = _(dictionary).chain().groupBy({a: 42}); + result = _(dictionary).chain().groupBy(''); + result = _(dictionary).chain().groupBy({a: 42}); } } @@ -5836,7 +5875,7 @@ namespace TestKeyBy { let stringIterator = (value: string, index: number, collection: string) => "a"; let listIterator = (value: SampleObject, index: number, collection: _.List) => 1; let dictionaryIterator = (value: SampleObject, key: string, collection: _.Dictionary) => Symbol.name; - let numericDictionaryIterator = (value: SampleObject, key: number, collection: _.NumericDictionary) => "a"; + let numericDictionaryIterator = (value: SampleObject, key: string, collection: _.NumericDictionary) => "a"; { let result: _.Dictionary; @@ -5848,20 +5887,20 @@ namespace TestKeyBy { { let result: _.Dictionary; - result = _.keyBy(array); - result = _.keyBy(array, listIterator); - result = _.keyBy(array, 'a'); - result = _.keyBy(array, {a: 42}); + result = _.keyBy(array); + result = _.keyBy(array, listIterator); + result = _.keyBy(array, 'a'); + result = _.keyBy(array, {a: 42}); - result = _.keyBy(list); - result = _.keyBy(list, listIterator); - result = _.keyBy(list, 'a'); - result = _.keyBy(list, {a: 42}); + result = _.keyBy(list); + result = _.keyBy(list, listIterator); + result = _.keyBy(list, 'a'); + result = _.keyBy(list, {a: 42}); - result = _.keyBy(numericDictionary); - result = _.keyBy(numericDictionary, numericDictionaryIterator); - result = _.keyBy(numericDictionary, 'a'); - result = _.keyBy(numericDictionary, {a: 42}); + result = _.keyBy(numericDictionary); + result = _.keyBy(numericDictionary, numericDictionaryIterator); + result = _.keyBy(numericDictionary, 'a'); + result = _.keyBy(numericDictionary, {a: 42}); result = _.keyBy(dictionary); result = _.keyBy(dictionary, dictionaryIterator); @@ -5884,15 +5923,15 @@ namespace TestKeyBy { result = _(array).keyBy('a'); result = _(array).keyBy({a: 42}); - result = _(list).keyBy(); - result = _(list).keyBy(listIterator); - result = _(list).keyBy('a'); - result = _(list).keyBy({a: 42}); + result = _(list).keyBy(); + result = _(list).keyBy(listIterator); + result = _(list).keyBy('a'); + result = _(list).keyBy({a: 42}); - result = _(numericDictionary).keyBy(); - result = _(numericDictionary).keyBy(numericDictionaryIterator); - result = _(numericDictionary).keyBy('a'); - result = _(numericDictionary).keyBy({a: 42}); + result = _(numericDictionary).keyBy(); + result = _(numericDictionary).keyBy(numericDictionaryIterator); + result = _(numericDictionary).keyBy('a'); + result = _(numericDictionary).keyBy({a: 42}); result = _(dictionary).keyBy(); result = _(dictionary).keyBy(dictionaryIterator); @@ -5915,15 +5954,15 @@ namespace TestKeyBy { result = _(array).chain().keyBy('a'); result = _(array).chain().keyBy({a: 42}); - result = _(list).chain().keyBy(); - result = _(list).chain().keyBy(listIterator); - result = _(list).chain().keyBy('a'); - result = _(list).chain().keyBy({a: 42}); + result = _(list).chain().keyBy(); + result = _(list).chain().keyBy(listIterator); + result = _(list).chain().keyBy('a'); + result = _(list).chain().keyBy({a: 42}); - result = _(numericDictionary).chain().keyBy(); - result = _(numericDictionary).chain().keyBy(numericDictionaryIterator); - result = _(numericDictionary).chain().keyBy('a'); - result = _(numericDictionary).chain().keyBy({a: 42}); + result = _(numericDictionary).chain().keyBy(); + result = _(numericDictionary).chain().keyBy(numericDictionaryIterator); + result = _(numericDictionary).chain().keyBy('a'); + result = _(numericDictionary).chain().keyBy({a: 42}); result = _(dictionary).chain().keyBy(); result = _(dictionary).chain().keyBy(dictionaryIterator); @@ -6065,66 +6104,170 @@ namespace TestInvokeMap { // _.map namespace TestMap { - let array: number[] | null | undefined = [] as any; - let list: _.List | null | undefined = [] as any; - let obj: any = {}; - let dictionary: _.Dictionary | null | undefined = obj; - - let listIterator: (value: number, index: number, collection: _.List) => AbcObject = (value: number, index: number, collection: _.List) => ({ a: 1, b: "", c: true }); - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => AbcObject = (value: number, key: string, collection: _.Dictionary) => ({ a: 1, b: "", c: true }); + const array: AbcObject[] | null | undefined = anything; + const list: _.List | null | undefined = anything; + const dictionary: _.Dictionary | null | undefined = anything; + const numericDictionary: _.NumericDictionary | null | undefined = anything; + const abcObject: AbcObject = anything; { - _.map(array); // $ExpectType number[] - _.map(array, listIterator); // $ExpectType AbcObject[] + _.map(array); // $ExpectType AbcObject[] + // $ExpectType number[] + _.map(array, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + return 0; + }); - _.map(list); // $ExpectType number[] - _.map(list, listIterator); // $ExpectType AbcObject[] + _.map(list); // $ExpectType AbcObject[] + // $ExpectType number[] + _.map(list, (value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + return 0; + }); - _.map(dictionary); // $ExpectType number[] - _.map(dictionary, dictionaryIterator); // $ExpectType AbcObject[] - } + _.map(dictionary); // $ExpectType AbcObject[] + // $ExpectType number[] + _.map(dictionary, (value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return 0; + }); + + _.map(numericDictionary); // $ExpectType AbcObject[] + // $ExpectType number[] + _.map(numericDictionary, (value, key, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + key; // $ExpectType string + collection; // $ExpectType NumericDictionary + return 0; + }); + + _.map(array, 'a'); // $ExpectType number[] + _.map(list, 'a'); // $ExpectType number[] + _.map(dictionary, 'a'); // $ExpectType number[] + _.map(numericDictionary, 'a'); // $ExpectType number[] + + _.map(array, 'd.0.b'); // $ExpectType any[] + _.map(list, 'd.0.b'); // $ExpectType any[] + _.map(dictionary, 'd.0.b'); // $ExpectType any[] + _.map(numericDictionary, 'd.0.b'); // $ExpectType any[] - { // _.matches iteratee shorthand. _.map(array, {}); // $ExpectType boolean[] _.map(list, {}); // $ExpectType boolean[] _.map(dictionary, {}); // $ExpectType boolean[] + _.map(numericDictionary, {}); // $ExpectType boolean[] } { - _(array).map().value(); // $ExpectType number[] - _(array).map(listIterator).value(); // $ExpectType AbcObject[] + _(array).map(); // $ExpectType LoDashImplicitWrapper + // $ExpectType LoDashImplicitWrapper + _(array).map((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + return 0; + }); - _(list).map().value(); // $ExpectType number[] - _(list).map(listIterator).value(); // $ExpectType AbcObject[] + _(list).map(); // $ExpectType LoDashImplicitWrapper + // $ExpectType LoDashImplicitWrapper + _(list).map((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + return 0; + }); - _(dictionary).map().value(); // $ExpectType number[] - _(dictionary).map(dictionaryIterator).value(); // $ExpectType AbcObject[] + _(dictionary).map(); // $ExpectType LoDashImplicitWrapper + // $ExpectType LoDashImplicitWrapper + _(dictionary).map((value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return 0; + }); + + _(numericDictionary).map(); // $ExpectType LoDashImplicitWrapper + // $ExpectType LoDashImplicitWrapper + _(numericDictionary).map((value, key, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + key; // $ExpectType string + collection; // $ExpectType NumericDictionary + return 0; + }); + + _(array).map('a'); // $ExpectType LoDashImplicitWrapper + _(list).map('a'); // $ExpectType LoDashImplicitWrapper + _(dictionary).map('a'); // $ExpectType LoDashImplicitWrapper + _(numericDictionary).map('a'); // $ExpectType LoDashImplicitWrapper + + _(array).map('d.0.b'); // $ExpectType LoDashImplicitWrapper + _(list).map('d.0.b'); // $ExpectType LoDashImplicitWrapper + _(dictionary).map('d.0.b'); // $ExpectType LoDashImplicitWrapper + _(numericDictionary).map('d.0.b'); // $ExpectType LoDashImplicitWrapper + + _(array).map({}); // $ExpectType LoDashImplicitWrapper + _(list).map({}); // $ExpectType LoDashImplicitWrapper + _(dictionary).map({}); // $ExpectType LoDashImplicitWrapper + _(numericDictionary).map({}); // $ExpectType LoDashImplicitWrapper } { - _(array).map({}).value(); // $ExpectType boolean[] - _(list).map({}).value(); // $ExpectType boolean[] - _(dictionary).map({}).value(); // $ExpectType boolean[] - } + _(array).chain().map(); // $ExpectType LoDashExplicitWrapper + // $ExpectType LoDashExplicitWrapper + _(array).chain().map((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType AbcObject[] + return 0; + }); - { - _(array).chain().map().value(); // $ExpectType number[] - _(array).chain().map(listIterator).value(); // $ExpectType AbcObject[] + _(list).chain().map(); // $ExpectType LoDashExplicitWrapper + // $ExpectType LoDashExplicitWrapper + _(list).chain().map((value, index, collection) => { + value; // $ExpectType AbcObject + index; // $ExpectType number + collection; // $ExpectType ArrayLike + return 0; + }); - _(list).chain().map().value(); // $ExpectType number[] - _(list).chain().map(listIterator).value(); // $ExpectType AbcObject[] + _(dictionary).chain().map(); // $ExpectType LoDashExplicitWrapper + // $ExpectType LoDashExplicitWrapper + _(dictionary).chain().map((value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return 0; + }); - _(dictionary).chain().map().value(); // $ExpectType number[] - _(dictionary).chain().map(dictionaryIterator).value(); // $ExpectType AbcObject[] - } + _(numericDictionary).chain().map(); // $ExpectType LoDashExplicitWrapper + // $ExpectType LoDashExplicitWrapper + _(numericDictionary).chain().map((value, key, collection) => { + /* Broken in TS 2.4: value; // AbcObject */ + key; // $ExpectType string + collection; // $ExpectType NumericDictionary + return 0; + }); - { - let result: _.LoDashExplicitArrayWrapper; + _(array).chain().map('a'); // $ExpectType LoDashExplicitWrapper + _(list).chain().map('a'); // $ExpectType LoDashExplicitWrapper + _(dictionary).chain().map('a'); // $ExpectType LoDashExplicitWrapper + _(numericDictionary).chain().map('a'); // $ExpectType LoDashExplicitWrapper - result = _(array).chain().map({}); - result = _(list).chain().map({}); - result = _(dictionary).chain().map({}); + _(array).chain().map('d.0.b'); // $ExpectType LoDashExplicitWrapper + _(list).chain().map('d.0.b'); // $ExpectType LoDashExplicitWrapper + _(dictionary).chain().map('d.0.b'); // $ExpectType LoDashExplicitWrapper + _(numericDictionary).chain().map('d.0.b'); // $ExpectType LoDashExplicitWrapper + + _(array).chain().map({}); // $ExpectType LoDashExplicitWrapper + _(list).chain().map({}); // $ExpectType LoDashExplicitWrapper + _(dictionary).chain().map({}); // $ExpectType LoDashExplicitWrapper + _(numericDictionary).chain().map({}); // $ExpectType LoDashExplicitWrapper } { @@ -6290,69 +6433,6 @@ namespace TestPartition { } } -// TODO -// _.map with iteratee shorthand -// module TestMapInsteadOfPluck { -// interface SampleObject { -// d: {b: AbcObject}[]; -// } -// -// let array: SampleObject[] = []; -// let list: _.List = []; -// let dictionary: _.Dictionary = {}; -// -// { -// let result: any[]; -// -// result = _.map(array, 'd.0.b'); -// result = _.map(array, ['d', 0, 'b']); -// -// result = _.map(list, 'd.0.b'); -// result = _.map(list, ['d', 0, 'b']); -// -// result = _.map(dictionary, 'd.0.b'); -// result = _.map(dictionary, ['d', 0, 'b']); -// } -// -// { -// let result: AbcObject[]; -// -// result = _.map(array, 'd.0.b'); -// result = _.map(array, ['d', 0, 'b']); -// -// result = _.map(list, 'd.0.b'); -// result = _.map(list, ['d', 0, 'b']); -// -// result = _.map(dictionary, 'd.0.b'); -// result = _.map(dictionary, ['d', 0, 'b']); -// } -// -// { -// let result: _.LoDashImplicitArrayWrapper; -// -// result = _(array).map('d.0.b'); -// result = _(array).map(['d', 0, 'b']); -// -// result = _(list).map('d.0.b'); -// result = _(list).map(['d', 0, 'b']); -// -// result = _(dictionary).map('d.0.b'); -// result = _(dictionary).map(['d', 0, 'b']); -// } -// -// { -// let result: _.LoDashExplicitArrayWrapper; -// -// result = _(array).chain().map('d.0.b'); -// result = _(array).chain().map(['d', 0, 'b']); -// -// result = _(list).chain().map('d.0.b'); -// result = _(list).chain().map(['d', 0, 'b']); -// -// result = _(dictionary).chain().map('d.0.b'); -// result = _(dictionary).chain().map(['d', 0, 'b']); -// } -// } namespace TestReduce { interface ABC { [key: string]: number; @@ -6412,12 +6492,12 @@ namespace TestReject { { let result: AbcObject[]; - result = _.reject(array, listIterator); - result = _.reject(array, ''); + result = _.reject(array, listIterator); + result = _.reject(array, ''); result = _.reject(array, {a: 42}); - result = _.reject(list, listIterator); - result = _.reject(list, ''); + result = _.reject(list, listIterator); + result = _.reject(list, ''); result = _.reject(list, {a: 42}); result = _.reject(dictionary, dictionaryIterator); @@ -6438,8 +6518,8 @@ namespace TestReject { result = _(array).reject(''); result = _(array).reject({a: 42}); - result = _(list).reject(listIterator); - result = _(list).reject(''); + result = _(list).reject(listIterator); + result = _(list).reject(''); result = _(list).reject({a: 42}); result = _(dictionary).reject(dictionaryIterator); @@ -6460,8 +6540,8 @@ namespace TestReject { result = _(array).chain().reject(''); result = _(array).chain().reject({a: 42}); - result = _(list).chain().reject(listIterator); - result = _(list).chain().reject(''); + result = _(list).chain().reject(listIterator); + result = _(list).chain().reject(''); result = _(list).chain().reject({a: 42}); result = _(dictionary).chain().reject(dictionaryIterator); @@ -6587,8 +6667,8 @@ namespace TestShuffle { { let result: AbcObject[]; - result = _.shuffle(array); - result = _.shuffle(list); + result = _.shuffle(array); + result = _.shuffle(list); result = _.shuffle(dictionary); } @@ -6602,7 +6682,7 @@ namespace TestShuffle { let result: _.LoDashImplicitArrayWrapper; result = _(array).shuffle(); - result = _(list).shuffle(); + result = _(list).shuffle(); result = _(dictionary).shuffle(); } @@ -6616,7 +6696,7 @@ namespace TestShuffle { let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().shuffle(); - result = _(list).chain().shuffle(); + result = _(list).chain().shuffle(); result = _(dictionary).chain().shuffle(); } } @@ -6667,47 +6747,46 @@ namespace TestSome { let listIterator = (value: SampleObject, index: number, collection: _.List) => true; let dictionaryIterator = (value: SampleObject, key: string, collection: _.Dictionary) => true; - let numericDictionaryIterator = (value: SampleObject, key: number, collection: _.NumericDictionary) => true; + let numericDictionaryIterator = (value: SampleObject, key: string, collection: _.NumericDictionary) => true; let objectIterator = (value: any, key: string, collection: any) => true; { let result: boolean; - result = _.some(array); - result = _.some(array, listIterator); - result = _.some(array, 'a'); - result = _.some(array, ['a', 42]); - result = _.some(array, {a: 42}); + result = _.some(array); + result = _.some(array, listIterator); + result = _.some(array, 'a'); + result = _.some(array, ['a', 42]); + result = _.some(array, {a: 42}); - result = _.some(list); - result = _.some(list, listIterator); - result = _.some(list, 'a'); - result = _.some(list, ['a', 42]); - result = _.some(list, {a: 42}); + result = _.some(list); + result = _.some(list, listIterator); + result = _.some(list, 'a'); + result = _.some(list, ['a', 42]); + result = _.some(list, {a: 42}); - result = _.some(dictionary); - result = _.some(numericDictionary, numericDictionaryIterator); + result = _.some(dictionary); + result = _.some(numericDictionary, numericDictionaryIterator); result = _.some(dictionary, (value, key, collection) => { value; // $ExpectType SampleObject key; // $ExpectType string collection; // $ExpectType Dictionary return true; }); - result = _.some(dictionary, 'a'); - result = _.some(dictionary, ['a', 42]); - result = _.some(dictionary, {a: 42}); + result = _.some(dictionary, 'a'); + result = _.some(dictionary, ['a', 42]); + result = _.some(dictionary, {a: 42}); - result = _.some(numericDictionary); - result = _.some(numericDictionary, numericDictionaryIterator); - result = _.some(numericDictionary, 'a'); - result = _.some(numericDictionary, ['a', 42]); - result = _.some(numericDictionary, {a: 42}); + result = _.some(numericDictionary); + result = _.some(numericDictionary, numericDictionaryIterator); + result = _.some(numericDictionary, 'a'); + result = _.some(numericDictionary, ['a', 42]); + result = _.some(numericDictionary, {a: 42}); result = _.some(sampleObject); result = _.some(sampleObject, objectIterator); result = _.some(sampleObject, 'a'); result = _.some(sampleObject, ['a', 42]); - result = _.some<{a: number}>(sampleObject, {a: 42}); result = _(array).some(); result = _(array).some(listIterator); @@ -6715,29 +6794,28 @@ namespace TestSome { result = _(array).some(['a', 42]); result = _(array).some({a: 42}); - result = _(list).some(); - result = _(list).some(listIterator); + result = _(list).some(); + result = _(list).some(listIterator); result = _(list).some('a'); result = _(list).some(['a', 42]); - result = _(list).some({a: 42}); + result = _(list).some({a: 42}); - result = _(dictionary).some(); + result = _(dictionary).some(); result = _(dictionary).some(dictionaryIterator); result = _(dictionary).some('a'); result = _(dictionary).some(['a', 42]); - result = _(dictionary).some({a: 42}); + result = _(dictionary).some({a: 42}); - result = _(numericDictionary).some(); - result = _(numericDictionary).some(numericDictionaryIterator); + result = _(numericDictionary).some(); + result = _(numericDictionary).some(numericDictionaryIterator); result = _(numericDictionary).some('a'); result = _(numericDictionary).some(['a', 42]); - result = _(numericDictionary).some({a: 42}); + result = _(numericDictionary).some({a: 42}); result = _(sampleObject).some(); result = _(sampleObject).some(objectIterator); result = _(sampleObject).some('a'); result = _(sampleObject).some(['a', 42]); - result = _(sampleObject).some({a: 42}); } { @@ -6749,29 +6827,28 @@ namespace TestSome { result = _(array).chain().some(['a', 42]); result = _(array).chain().some({a: 42}); - result = _(list).chain().some(); - result = _(list).chain().some(listIterator); + result = _(list).chain().some(); + result = _(list).chain().some(listIterator); result = _(list).chain().some('a'); result = _(list).chain().some(['a', 42]); - result = _(list).chain().some({a: 42}); + result = _(list).chain().some({a: 42}); - result = _(dictionary).chain().some(); + result = _(dictionary).chain().some(); result = _(dictionary).chain().some(dictionaryIterator); result = _(dictionary).chain().some('a'); result = _(dictionary).chain().some(['a', 42]); - result = _(dictionary).chain().some({a: 42}); + result = _(dictionary).chain().some({a: 42}); - result = _(numericDictionary).chain().some(); - result = _(numericDictionary).chain().some(numericDictionaryIterator); + result = _(numericDictionary).chain().some(); + result = _(numericDictionary).chain().some(numericDictionaryIterator); result = _(numericDictionary).chain().some('a'); result = _(numericDictionary).chain().some(['a', 42]); - result = _(numericDictionary).chain().some({a: 42}); + result = _(numericDictionary).chain().some({a: 42}); result = _(sampleObject).chain().some(); result = _(sampleObject).chain().some(objectIterator); result = _(sampleObject).chain().some('a'); result = _(sampleObject).chain().some(['a', 42]); - result = _(sampleObject).chain().some({a: 42}); } } @@ -6873,23 +6950,15 @@ namespace TestorderBy { result = _.orderBy(array, iteratees); result = _.orderBy(array, iteratees, orders); - result = _.orderBy(array, iteratees); - result = _.orderBy(array, iteratees, orders); result = _.orderBy(list, iteratees); result = _.orderBy(list, iteratees, orders); - result = _.orderBy(list, iteratees); - result = _.orderBy(list, iteratees, orders); result = _.orderBy(numericDictionary, iteratees); result = _.orderBy(numericDictionary, iteratees, orders); - result = _.orderBy(numericDictionary, iteratees); - result = _.orderBy(numericDictionary, iteratees, orders); result = _.orderBy(dictionary, iteratees); result = _.orderBy(dictionary, iteratees, orders); - result = _.orderBy(dictionary, iteratees); - result = _.orderBy(dictionary, iteratees, orders); } { @@ -6901,18 +6970,12 @@ namespace TestorderBy { result = _(list).orderBy(iteratees); result = _(list).orderBy(iteratees, orders); - result = _(list).orderBy(iteratees); - result = _(list).orderBy(iteratees, orders); result = _(numericDictionary).orderBy(iteratees); result = _(numericDictionary).orderBy(iteratees, orders); - result = _(numericDictionary).orderBy(iteratees); - result = _(numericDictionary).orderBy(iteratees, orders); result = _(dictionary).orderBy(iteratees); result = _(dictionary).orderBy(iteratees, orders); - result = _(dictionary).orderBy(iteratees); - result = _(dictionary).orderBy(iteratees, orders); } { @@ -6924,18 +6987,12 @@ namespace TestorderBy { result = _(list).chain().orderBy(iteratees); result = _(list).chain().orderBy(iteratees, orders); - result = _(list).chain().orderBy(iteratees); - result = _(list).chain().orderBy(iteratees, orders); result = _(numericDictionary).chain().orderBy(iteratees); result = _(numericDictionary).chain().orderBy(iteratees, orders); - result = _(numericDictionary).chain().orderBy(iteratees); - result = _(numericDictionary).chain().orderBy(iteratees, orders); result = _(dictionary).chain().orderBy(iteratees); result = _(dictionary).chain().orderBy(iteratees, orders); - result = _(dictionary).chain().orderBy(iteratees); - result = _(dictionary).chain().orderBy(iteratees, orders); } } @@ -9261,10 +9318,10 @@ namespace TestToArray { { let result: AbcObject[]; - result = _.toArray(array); - result = _.toArray(list); - result = _.toArray(dictionary); - result = _.toArray(numericDictionary); + result = _.toArray(array); + result = _.toArray(list); + result = _.toArray(dictionary); + result = _.toArray(numericDictionary); result = _.toArray(array); result = _.toArray(list); @@ -9284,18 +9341,18 @@ namespace TestToArray { let result: _.LoDashImplicitArrayWrapper; result = _(array).toArray(); - result = _(list).toArray(); - result = _(dictionary).toArray(); - result = _(numericDictionary).toArray(); + result = _(list).toArray(); + result = _(dictionary).toArray(); + result = _(numericDictionary).toArray(); } { let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().toArray(); - result = _(list).chain().toArray(); - result = _(dictionary).chain().toArray(); - result = _(numericDictionary).chain().toArray(); + result = _(list).chain().toArray(); + result = _(dictionary).chain().toArray(); + result = _(numericDictionary).chain().toArray(); } } @@ -10488,53 +10545,51 @@ result = _(TestDefaultsDeepObject).defaultsDeep(TestDefaults // _.entries namespace TestEntries { - let object: _.Dictionary = {}; + const dictionary: _.Dictionary = anything; + const numericDictionary: _.NumericDictionary = anything; + const abcObject: AbcObject = anything; { - let result: Array<[string, string]>; - - result = _.entries(object); + _.entries(dictionary); // $ExpectType [string, number][] + _.entries(numericDictionary); // $ExpectType [string, number][] + _.entries(abcObject); // $ExpectType [string, any][] } { - let result: _.LoDashImplicitArrayWrapper<[string, string]>; - - result = _(object).entries(); + _(dictionary).entries(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(numericDictionary).entries(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(abcObject).entries(); // $ExpectType LoDashImplicitWrapper<[string, any][]> } { - let result: _.LoDashExplicitArrayWrapper<[string, string]>; - - result = _(object).chain().entries(); + _(dictionary).chain().entries(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(numericDictionary).chain().entries(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(abcObject).chain().entries(); // $ExpectType LoDashExplicitWrapper<[string, any][]> } } // _.entriesIn namespace TestEntriesIn { - let object: _.Dictionary = {}; + const dictionary: _.Dictionary = anything; + const numericDictionary: _.NumericDictionary = anything; + const abcObject: AbcObject = anything; { - let result: Array<[string, string]>; - - result = _.entriesIn(object); + _.entriesIn(dictionary); // $ExpectType [string, number][] + _.entriesIn(numericDictionary); // $ExpectType [string, number][] + _.entriesIn(abcObject); // $ExpectType [string, any][] } { - let result: _.LoDashImplicitArrayWrapper<[string, string]>; - - result = _(object).entriesIn(); + _(dictionary).entriesIn(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(numericDictionary).entriesIn(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(abcObject).entriesIn(); // $ExpectType LoDashImplicitWrapper<[string, any][]> } { - let result: _.LoDashExplicitArrayWrapper<[string, string]>; - - result = _(object).chain().entriesIn(); - } - - { - let result: _.LoDashExplicitArrayWrapper<[string, any]>; - - result = _(object).chain().entriesIn(); + _(dictionary).chain().entriesIn(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(numericDictionary).chain().entriesIn(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(abcObject).chain().entriesIn(); // $ExpectType LoDashExplicitWrapper<[string, any][]> } } @@ -11556,65 +11611,280 @@ namespace TestMapKeys { let array: AbcObject[] | null | undefined = [] as any; let list: _.List| null | undefined = [] as any; let dictionary: _.Dictionary | null | undefined = anything; + let numericDictionary: _.NumericDictionary | null | undefined = anything; + let abcObject: AbcObject = anything; let listIterator = (value: AbcObject, index: number, collection: _.List) => ""; let dictionaryIterator = (value: AbcObject, key: string, collection: _.Dictionary) => ""; + let numericDictionaryIterator = (value: AbcObject, key: string, collection: _.NumericDictionary) => ""; + let abcObjectIterator = (value: AbcObject[keyof AbcObject], key: string, collection: AbcObject) => ""; { - let result: _.Dictionary; + _.mapKeys(array); // $ExpectType Dictionary + _.mapKeys(array, listIterator); // $ExpectType Dictionary + _.mapKeys(array, ''); // $ExpectType Dictionary + _.mapKeys(array, {}); // $ExpectType Dictionary - result = _.mapKeys(array); - result = _.mapKeys(array, listIterator); - result = _.mapKeys(array, ''); - result = _.mapKeys(array, {}); + _.mapKeys(list); // $ExpectType Dictionary + _.mapKeys(list, listIterator); // $ExpectType Dictionary + _.mapKeys(list, ''); // $ExpectType Dictionary + _.mapKeys(list, {}); // $ExpectType Dictionary - result = _.mapKeys(list); - result = _.mapKeys(list, listIterator); - result = _.mapKeys(list, ''); - result = _.mapKeys(list, {}); + _.mapKeys(dictionary); // $ExpectType Dictionary + _.mapKeys(dictionary, dictionaryIterator); // $ExpectType Dictionary + _.mapKeys(dictionary, ''); // $ExpectType Dictionary + _.mapKeys(dictionary, {}); // $ExpectType Dictionary - result = _.mapKeys(dictionary); - result = _.mapKeys(dictionary, dictionaryIterator); - result = _.mapKeys(dictionary, ''); - result = _.mapKeys(dictionary, {}); + /* Broken in TS 2.4 + _.mapKeys(numericDictionary); // Dictionary + _.mapKeys(numericDictionary, numericDictionaryIterator); // Dictionary + _.mapKeys(numericDictionary, ''); // Dictionary + _.mapKeys(numericDictionary, {}); // Dictionary + */ } { - let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; - - result = _(array).mapKeys(); - result = _(array).mapKeys(listIterator); - result = _(array).mapKeys(''); - result = _(array).mapKeys({}); - - result = _(list).mapKeys(); - result = _(list).mapKeys(listIterator); - result = _(list).mapKeys(''); - result = _(list).mapKeys({}); - - result = _(dictionary).mapKeys(); - result = _(dictionary).mapKeys(dictionaryIterator); - result = _(dictionary).mapKeys(''); - result = _(dictionary).mapKeys({}); + _.mapKeys(abcObject); // $ExpectType Dictionary + _.mapKeys(abcObject, abcObjectIterator); // $ExpectType Dictionary + _.mapKeys(abcObject, ''); // $ExpectType Dictionary } { - let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; + _(array).mapKeys(); // $ExpectType LoDashImplicitWrapper> + _(array).mapKeys(listIterator); // $ExpectType LoDashImplicitWrapper> + _(array).mapKeys(''); // $ExpectType LoDashImplicitWrapper> + _(array).mapKeys({}); // $ExpectType LoDashImplicitWrapper> - result = _(array).chain().mapKeys(); - result = _(array).chain().mapKeys(listIterator); - result = _(array).chain().mapKeys(''); - result = _(array).chain().mapKeys({}); + _(list).mapKeys(); // $ExpectType LoDashImplicitWrapper> + _(list).mapKeys(listIterator); // $ExpectType LoDashImplicitWrapper> + _(list).mapKeys(''); // $ExpectType LoDashImplicitWrapper> + _(list).mapKeys({}); // $ExpectType LoDashImplicitWrapper> - result = _(list).chain().mapKeys(); - result = _(list).chain().mapKeys(listIterator); - result = _(list).chain().mapKeys(''); - result = _(list).chain().mapKeys({}); + _(dictionary).mapKeys(); // $ExpectType LoDashImplicitWrapper> + _(dictionary).mapKeys(dictionaryIterator); // $ExpectType LoDashImplicitWrapper> + _(dictionary).mapKeys(''); // $ExpectType LoDashImplicitWrapper> + _(dictionary).mapKeys({}); // $ExpectType LoDashImplicitWrapper> - result = _(dictionary).chain().mapKeys(); - result = _(dictionary).chain().mapKeys(dictionaryIterator); - result = _(dictionary).chain().mapKeys(''); - result = _(dictionary).chain().mapKeys({}); + /* Broken in TS 2.4 + _(numericDictionary).mapKeys(); // LoDashImplicitWrapper> + _(numericDictionary).mapKeys(numericDictionaryIterator); // LoDashImplicitWrapper> + _(numericDictionary).mapKeys(''); // LoDashImplicitWrapper> + _(numericDictionary).mapKeys({}); // LoDashImplicitWrapper> + */ + } + + { + _(abcObject).mapKeys(); // $ExpectType LoDashImplicitWrapper> + _(abcObject).mapKeys(abcObjectIterator); // $ExpectType LoDashImplicitWrapper> + _(abcObject).mapKeys(''); // $ExpectType LoDashImplicitWrapper> + } + + { + _(array).chain().mapKeys(); // $ExpectType LoDashExplicitWrapper> + _(array).chain().mapKeys(listIterator); // $ExpectType LoDashExplicitWrapper> + _(array).chain().mapKeys(''); // $ExpectType LoDashExplicitWrapper> + _(array).chain().mapKeys({}); // $ExpectType LoDashExplicitWrapper> + + _(list).chain().mapKeys(); // $ExpectType LoDashExplicitWrapper> + _(list).chain().mapKeys(listIterator); // $ExpectType LoDashExplicitWrapper> + _(list).chain().mapKeys(''); // $ExpectType LoDashExplicitWrapper> + _(list).chain().mapKeys({}); // $ExpectType LoDashExplicitWrapper> + + _(dictionary).chain().mapKeys(); // $ExpectType LoDashExplicitWrapper> + _(dictionary).chain().mapKeys(dictionaryIterator); // $ExpectType LoDashExplicitWrapper> + _(dictionary).chain().mapKeys(''); // $ExpectType LoDashExplicitWrapper> + _(dictionary).chain().mapKeys({}); // $ExpectType LoDashExplicitWrapper> + + /* Broken in TS 2.4 + _(numericDictionary).chain().mapKeys(); // LoDashExplicitWrapper> + _(numericDictionary).chain().mapKeys(numericDictionaryIterator); // LoDashExplicitWrapper> + _(numericDictionary).chain().mapKeys(''); // LoDashExplicitWrapper> + _(numericDictionary).chain().mapKeys({}); // LoDashExplicitWrapper> + */ + } + + { + _(abcObject).chain().mapKeys(); // $ExpectType LoDashExplicitWrapper> + _(abcObject).chain().mapKeys(abcObjectIterator); // $ExpectType LoDashExplicitWrapper> + _(abcObject).chain().mapKeys(''); // $ExpectType LoDashExplicitWrapper> + } +} + +// _.mapValues +{ + const dictionary: _.Dictionary | null | undefined = anything; + const numericDictionary: _.NumericDictionary | null | undefined = anything; + const abcObject: AbcObject = anything; + const abcObjectOrNull: AbcObject | null = anything; + const key: string = anything; + + { + // $ExpectType NumericDictionary + _.mapValues("foo", (char, index, str) => { + char; // $ExpectType string + index; // $ExpectType number + str; // $ExpectType string + return abcObject; + }); + + // $ExpectType Dictionary + _.mapValues(dictionary, (value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return ""; + }); + + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + // $ExpectType Dictionary + _.mapValues(numericDictionary, (value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return ""; + }); + + // $ExpectType { a: string; b: string; c: string; } + _.mapValues(abcObject, (value, key, collection) => { + value; // $ExpectType string | number | boolean + key; // $ExpectType string + collection; // $ExpectType AbcObject + return ""; + }); + + _.mapValues(dictionary, {}); // $ExpectType Dictionary + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _.mapValues(numericDictionary, {}); // $ExpectType Dictionary + _.mapValues(abcObject, {}); // $ExpectType { a: boolean; b: boolean; c: boolean; } + + _.mapValues(dictionary, "a"); // $ExpectType Dictionary + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _.mapValues(numericDictionary, "a"); // $ExpectType Dictionary + + _.mapValues(abcObject, key); // $ExpectType { a: any; b: any; c: any; } + _.mapValues(dictionary, key); // $ExpectType Dictionary + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _.mapValues(numericDictionary, key); // $ExpectType Dictionary + + _.mapValues("a"); // $ExpectType NumericDictionary + _.mapValues(dictionary); // $ExpectType Dictionary + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _.mapValues(numericDictionary); // $ExpectType Dictionary + _.mapValues(abcObject); // $ExpectType AbcObject + _.mapValues(abcObjectOrNull); // $ExpectType Partial + } + + { + // $ExpectType LoDashImplicitWrapper> + _("foo").mapValues((char, index, str) => { + char; // $ExpectType string + index; // $ExpectType number + str; // $ExpectType string + return abcObject; + }); + + // $ExpectType LoDashImplicitWrapper> + _(dictionary).mapValues((value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return ""; + }); + + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + // $ExpectType LoDashImplicitWrapper> + _(numericDictionary).mapValues((value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return ""; + }); + + // $ExpectType LoDashImplicitWrapper<{ a: string; b: string; c: string; }> + _(abcObject).mapValues((value, key, collection) => { + value; // $ExpectType string | number | boolean + key; // $ExpectType string + collection; // $ExpectType AbcObject + return ""; + }); + + _(dictionary).mapValues({}); // $ExpectType LoDashImplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).mapValues({}); // $ExpectType LoDashImplicitWrapper> + _(abcObject).mapValues({}); // $ExpectType LoDashImplicitWrapper<{ a: boolean; b: boolean; c: boolean; }> + + _(dictionary).mapValues("a"); // $ExpectType LoDashImplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).mapValues("a"); // $ExpectType LoDashImplicitWrapper> + + _(abcObject).mapValues(key); // $ExpectType LoDashImplicitWrapper<{ a: any; b: any; c: any; }> + _(dictionary).mapValues(key); // $ExpectType LoDashImplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).mapValues(key); // $ExpectType LoDashImplicitWrapper> + + _("a").mapValues(); // $ExpectType LoDashImplicitWrapper> + _(dictionary).mapValues(); // $ExpectType LoDashImplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).mapValues(); // $ExpectType LoDashImplicitWrapper> + _(abcObject).mapValues(); // $ExpectType LoDashImplicitWrapper + _(abcObjectOrNull).mapValues(); // $ExpectType LoDashImplicitWrapper> + } + + { + // $ExpectType LoDashExplicitWrapper> + _("foo").chain().mapValues((char, index, str) => { + char; // $ExpectType string + index; // $ExpectType number + str; // $ExpectType string + return abcObject; + }); + + // $ExpectType LoDashExplicitWrapper> + _(dictionary).chain().mapValues((value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return ""; + }); + + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + // $ExpectType LoDashExplicitWrapper> + _(numericDictionary).chain().mapValues((value, key, collection) => { + value; // $ExpectType AbcObject + key; // $ExpectType string + collection; // $ExpectType Dictionary + return ""; + }); + + // $ExpectType LoDashExplicitWrapper<{ a: string; b: string; c: string; }> + _(abcObject).chain().mapValues((value, key, collection) => { + value; // $ExpectType string | number | boolean + key; // $ExpectType string + collection; // $ExpectType AbcObject + return ""; + }); + + _(dictionary).chain().mapValues({}); // $ExpectType LoDashExplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).chain().mapValues({}); // $ExpectType LoDashExplicitWrapper> + _(abcObject).chain().mapValues({}); // $ExpectType LoDashExplicitWrapper<{ a: boolean; b: boolean; c: boolean; }> + + _(dictionary).chain().mapValues("a"); // $ExpectType LoDashExplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).chain().mapValues("a"); // $ExpectType LoDashExplicitWrapper> + + _(abcObject).chain().mapValues(key); // $ExpectType LoDashExplicitWrapper<{ a: any; b: any; c: any; }> + _(dictionary).chain().mapValues(key); // $ExpectType LoDashExplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).chain().mapValues(key); // $ExpectType LoDashExplicitWrapper> + + _("a").chain().mapValues(); // $ExpectType LoDashExplicitWrapper> + _(dictionary).chain().mapValues(); // $ExpectType LoDashExplicitWrapper> + // Can't really support NumericDictionary fully, but it at least gets treated like a Dictionary + _(numericDictionary).chain().mapValues(); // $ExpectType LoDashExplicitWrapper> + + _(abcObject).chain().mapValues(); // $ExpectType LoDashExplicitWrapper + _(abcObjectOrNull).chain().mapValues(); // $ExpectType LoDashExplicitWrapper> } } @@ -11741,36 +12011,55 @@ namespace TestMergeWith { // _.omit namespace TestOmit { let obj: AbcObject | null | undefined = anything; - let dict: { [key: string]: AbcObject } = { }; + let dictionary:_.Dictionary = anything; + let numericDictionary:_.NumericDictionary = anything; + let dictionaryWithNull:_.Dictionary = anything; + let numericDictionaryWithNull:_.NumericDictionary = anything; + let dictionaryWithUndefined:_.Dictionary = anything; + let numericDictionaryWithUndefined:_.NumericDictionary = anything; + let dictionaryWithNullAndUndefined:_.Dictionary = anything; + let numericDictionaryWithNullAndUndefined:_.NumericDictionary = anything; { - let result: Partial; - - result = _.omit(obj, 'a'); - result = _.omit(obj, 0, 'a'); - result = _.omit(obj, ['b', 1], 0, 'a'); - - dict = _.omit(dict, 'a'); + _.omit(obj, 'a'); // $ExpectType Partial + _.omit(obj, 0, 'a'); // $ExpectType Partial + _.omit(obj, ['b', 1], 0, 'a'); // $ExpectType Partial + _.omit(dictionary, 'a'); // $ExpectType Dictionary + _.omit(numericDictionary, 'a'); // $ExpectType NumericDictionary + _.omit(dictionaryWithNull, 'a'); // $ExpectType Dictionary + _.omit(numericDictionaryWithNull, 'a'); // $ExpectType NumericDictionary + _.omit(dictionaryWithUndefined, 'a'); // $ExpectType Dictionary + _.omit(numericDictionaryWithUndefined, 'a'); // $ExpectType NumericDictionary + _.omit(dictionaryWithNullAndUndefined, 'a'); // $ExpectType Dictionary + _.omit(numericDictionaryWithNullAndUndefined, 'a'); // $ExpectType NumericDictionary } { - let result: _.LoDashImplicitWrapper>; - - result = _(obj).omit('a'); - result = _(obj).omit(0, 'a'); - result = _(obj).omit(['b', 1], 0, 'a'); - - dict = _(dict).omit('a').value(); + _(obj).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(obj).omit(0, 'a'); // $ExpectType LoDashImplicitWrapper> + _(obj).omit(['b', 1], 0, 'a'); // $ExpectType LoDashImplicitWrapper> + _(dictionary).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(numericDictionary).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(dictionaryWithNull).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(numericDictionaryWithNull).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(dictionaryWithUndefined).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(numericDictionaryWithUndefined).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(dictionaryWithNullAndUndefined).omit('a'); // $ExpectType LoDashImplicitWrapper> + _(numericDictionaryWithNullAndUndefined).omit('a'); // $ExpectType LoDashImplicitWrapper> } { - let result: _.LoDashExplicitWrapper>; - - result = _(obj).chain().omit('a'); - result = _(obj).chain().omit(0, 'a'); - result = _(obj).chain().omit(['b', 1], 0, 'a'); - - dict = _(dict).chain().omit('a').value(); + _(obj).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(obj).chain().omit(0, 'a'); // $ExpectType LoDashExplicitWrapper> + _(obj).chain().omit(['b', 1], 0, 'a'); // $ExpectType LoDashExplicitWrapper> + _(dictionary).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(numericDictionary).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(dictionaryWithNull).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(numericDictionaryWithNull).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(dictionaryWithUndefined).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(numericDictionaryWithUndefined).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(dictionaryWithNullAndUndefined).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> + _(numericDictionaryWithNullAndUndefined).chain().omit('a'); // $ExpectType LoDashExplicitWrapper> } } @@ -11788,13 +12077,13 @@ namespace TestOmitBy { { let result: _.LoDashImplicitWrapper>; - result = _(obj).omitBy(predicate); + result = _(obj).omitBy(predicate); } { let result: _.LoDashExplicitWrapper>; - result = _(obj).chain().omitBy(predicate); + result = _(obj).chain().omitBy(predicate); } } @@ -11810,7 +12099,8 @@ namespace TestPick { _.pick(obj1, 0, 'a'); // $ExpectType PartialDeep _.pick(obj1, ['b', 1], 0, 'a'); // $ExpectType PartialDeep _.pick(obj1, readonlyArray); // $ExpectType PartialDeep - _.pick(obj2, 'a', 'b'); // $ExpectType Pick + // Broken in TS 2.4 + // _.pick(obj2, 'a', 'b'); // Pick _.pick(obj2, literalsArray); // $ExpectType Pick _.pick(obj2, roLiteralsArray); // $ExpectType Pick @@ -11818,7 +12108,8 @@ namespace TestPick { _(obj1).pick(0, 'a'); // $ExpectType LoDashImplicitWrapper> _(obj1).pick(['b', 1], 0, 'a'); // $ExpectType LoDashImplicitWrapper> _(obj1).pick(readonlyArray); // $ExpectType LoDashImplicitWrapper> - _(obj2).pick('a', 'b'); // $ExpectType LoDashImplicitWrapper> + // Broken in TS 2.4 + // _(obj2).pick('a', 'b'); // LoDashImplicitWrapper> _(obj2).pick(literalsArray); // $ExpectType LoDashImplicitWrapper> _(obj2).pick(roLiteralsArray); // $ExpectType LoDashImplicitWrapper> @@ -11826,7 +12117,8 @@ namespace TestPick { _.chain(obj1).pick(0, 'a'); // $ExpectType LoDashExplicitWrapper> _.chain(obj1).pick(['b', 1], 0, 'a'); // $ExpectType LoDashExplicitWrapper> _.chain(obj1).pick(readonlyArray); // $ExpectType LoDashExplicitWrapper> - _.chain(obj2).pick('a', 'b'); // $ExpectType LoDashExplicitWrapper> + // Broken in TS 2.4 + // _.chain(obj2).pick('a', 'b'); // LoDashExplicitWrapper> _.chain(obj2).pick(literalsArray); // $ExpectType LoDashExplicitWrapper> _.chain(obj2).pick(roLiteralsArray); // $ExpectType LoDashExplicitWrapper> } @@ -11845,13 +12137,13 @@ namespace TestPickBy { { let result: _.LoDashImplicitWrapper>; - result = _(obj).pickBy(predicate); + result = _(obj).pickBy(predicate); } { let result: _.LoDashExplicitWrapper>; - result = _(obj).chain().pickBy(predicate); + result = _(obj).chain().pickBy(predicate); } } @@ -12013,53 +12305,51 @@ namespace TestSetWith { // _.toPairs namespace TestToPairs { - let object: _.Dictionary = {}; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; + let abcObject: AbcObject = anything; { - let result: Array<[string, string]>; - - result = _.toPairs(object); + _.toPairs(dictionary); // $ExpectType [string, number][] + _.toPairs(numericDictionary); // $ExpectType [string, number][] + _.toPairs(abcObject); // $ExpectType [string, any][] } { - let result: _.LoDashImplicitArrayWrapper<[string, string]>; - - result = _(object).toPairs(); + _(dictionary).toPairs(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(numericDictionary).toPairs(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(abcObject).toPairs(); // $ExpectType LoDashImplicitWrapper<[string, any][]> } { - let result: _.LoDashExplicitArrayWrapper<[string, string]>; - - result = _(object).chain().toPairs(); + _(dictionary).chain().toPairs(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(numericDictionary).chain().toPairs(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(abcObject).chain().toPairs(); // $ExpectType LoDashExplicitWrapper<[string, any][]> } } // _.toPairsIn namespace TestToPairsIn { - let object: _.Dictionary = {}; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; + let abcObject: AbcObject = anything; { - let result: Array<[string, string]>; - - result = _.toPairsIn(object); + _.toPairsIn(dictionary); // $ExpectType [string, number][] + _.toPairsIn(numericDictionary); // $ExpectType [string, number][] + _.toPairsIn(abcObject); // $ExpectType [string, any][] } { - let result: _.LoDashImplicitArrayWrapper<[string, string]>; - - result = _(object).toPairsIn(); + _(dictionary).toPairsIn(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(numericDictionary).toPairsIn(); // $ExpectType LoDashImplicitWrapper<[string, number][]> + _(abcObject).toPairsIn(); // $ExpectType LoDashImplicitWrapper<[string, any][]> } { - let result: _.LoDashExplicitArrayWrapper<[string, string]>; - - result = _(object).chain().toPairsIn(); - } - - { - let result: _.LoDashExplicitArrayWrapper<[string, any]>; - - result = _(object).chain().toPairsIn(); + _(dictionary).chain().toPairsIn(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(numericDictionary).chain().toPairsIn(); // $ExpectType LoDashExplicitWrapper<[string, number][]> + _(abcObject).chain().toPairsIn(); // $ExpectType LoDashExplicitWrapper<[string, any][]> } } @@ -12256,7 +12546,7 @@ namespace TestValues { result = _.values(dict); result = _.values(numDict); result = _.values(list); - result = _.values(object); + result = _.values(object); } // Implicit wrapper @@ -12295,10 +12585,10 @@ namespace TestValues { let object: {a: SampleObject} = { a: { a: {} } }; let result: _.LoDashImplicitArrayWrapper; - result = _(dict).values(); - result = _(numDict).values(); - result = _(list).values(); - result = _(object).values(); + result = _(dict).values(); + result = _(numDict).values(); + result = _(list).values(); + result = _(object).values(); } // Explicit wrapper @@ -12337,10 +12627,10 @@ namespace TestValues { let object: {a: SampleObject} = { a: { a: {} } }; let result: _.LoDashExplicitArrayWrapper; - result = _(dict).chain().values(); - result = _(numDict).chain().values(); - result = _(list).chain().values(); - result = _(object).chain().values(); + result = _(dict).chain().values(); + result = _(numDict).chain().values(); + result = _(list).chain().values(); + result = _(object).chain().values(); } } @@ -12364,19 +12654,19 @@ namespace TestValuesIn { { let result: AbcObject[]; - result = _.values(object); + result = _.valuesIn(object); } { let result: _.LoDashImplicitArrayWrapper; - result = _(object).valuesIn(); + result = _(object).valuesIn(); } { let result: _.LoDashExplicitArrayWrapper; - result = _(object).chain().valuesIn(); + result = _(object).chain().valuesIn(); } } @@ -13340,7 +13630,7 @@ namespace TestMatches { { let result: (value: any) => boolean; - result = _.matches(source); + result = _.matches(source); } { @@ -13350,12 +13640,12 @@ namespace TestMatches { { let result: _.LoDashImplicitObjectWrapper<(value: AbcObject) => boolean>; - result = _(source).matches(); + result = _(source).matches(); } { let result: _.LoDashExplicitObjectWrapper<(value: AbcObject) => boolean>; - result = _(source).chain().matches(); + result = _(source).chain().matches(); } } @@ -13367,7 +13657,7 @@ namespace TestMatches { { let result: (value: any) => boolean; - result = _.matchesProperty(path, source); + result = _.matchesProperty(path, source); } { @@ -13379,7 +13669,7 @@ namespace TestMatches { { let result: _.LoDashImplicitObjectWrapper<(value: any) => boolean>; - result = _(path).matchesProperty(source); + result = _(path).matchesProperty(source); } { @@ -13391,7 +13681,7 @@ namespace TestMatches { { let result: _.LoDashExplicitObjectWrapper<(value: any) => boolean>; - result = _(path).chain().matchesProperty(source); + result = _(path).chain().matchesProperty(source); } { diff --git a/types/lory.js/index.d.ts b/types/lory.js/index.d.ts index 37ff46d4be..dd37fb8efa 100644 --- a/types/lory.js/index.d.ts +++ b/types/lory.js/index.d.ts @@ -4,7 +4,7 @@ // philip bulley // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare var lory: LoryStatic; +export declare var lory: LoryStatic; interface LoryStatic { (element: Element, options?: LoryOptions): LoryStatic; diff --git a/types/lory.js/lory.js-tests.ts b/types/lory.js/lory.js-tests.ts index bad97dadf3..616073f180 100644 --- a/types/lory.js/lory.js-tests.ts +++ b/types/lory.js/lory.js-tests.ts @@ -1,4 +1,4 @@ - +import { lory } from 'lory.js'; (function() { var elm = document.querySelector('.js-foo'); diff --git a/types/meow/index.d.ts b/types/meow/index.d.ts index 20e40c63f7..db3d697691 100644 --- a/types/meow/index.d.ts +++ b/types/meow/index.d.ts @@ -1,20 +1,27 @@ // Type definitions for meow 4.x // Project: https://github.com/sindresorhus/meow -// Definitions by: KnisterPeter , Lindsey Smith +// Definitions by: KnisterPeter +// Lindsey Smith +// Jason Dreyzehner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import * as buildOptions from "minimist-options"; +import * as buildOptions from 'minimist-options'; -declare function meow(helpMessage: string | string[], options: meow.Options): meow.Result; -declare function meow(options: string | string[] | meow.Options): meow.Result; +declare function meow( + helpMessage: string | ReadonlyArray, + options: meow.Options +): meow.Result; +declare function meow( + options: string | ReadonlyArray | meow.Options +): meow.Result; declare namespace meow { interface Options { description?: string | boolean; help?: string | boolean; version?: string | boolean; pkg?: any; - argv?: string[]; + argv?: ReadonlyArray; inferType?: boolean; flags?: buildOptions.Options; autoHelp?: boolean; @@ -24,7 +31,7 @@ declare namespace meow { interface Result { input: string[]; flags: { [name: string]: any }; - pkg: object; + pkg: any; help: string; showHelp(code?: number): void; showVersion(): void; diff --git a/types/meow/meow-tests.ts b/types/meow/meow-tests.ts index 8915603292..1b044881b5 100644 --- a/types/meow/meow-tests.ts +++ b/types/meow/meow-tests.ts @@ -1,28 +1,31 @@ import meow = require('meow'); -const cli = meow("Help text", - { - flags: { - unicorn: { - type: 'boolean', - alias: 'u' - }, - fooBar: { - type: 'string', - default: 'foo' - } +const cli = meow('Help text', { + flags: { + unicorn: { + type: 'boolean', + alias: 'u' + }, + fooBar: { + type: 'string', + default: 'foo' } } -); +}); -const cli2 = meow("Help text"); +const input: string = cli.input[0]; +const version: string = cli.pkg.version; + +const cli2 = meow('Help text'); + +const args: ReadonlyArray = ['foo', 'bar']; const cli3 = meow({ - description: "version string", - help: "help string", - version: "1.0.0", + description: 'version string', + help: 'help string', + version: '1.0.0', pkg: {}, - argv: ['foo', 'bar'], + argv: args, inferType: true, autoHelp: true, autoVersion: true, diff --git a/types/microrouter/index.d.ts b/types/microrouter/index.d.ts index 6d65adc8a1..934affd630 100644 --- a/types/microrouter/index.d.ts +++ b/types/microrouter/index.d.ts @@ -8,12 +8,13 @@ import { IncomingMessage, ServerResponse, Server } from 'http'; import { RequestHandler } from 'micro'; - +export type ServerResponse = ServerResponse; +export type ServerRequest = IncomingMessage & { + params: { [key: string]: string }, + query: { [key: string]: string } +}; export type AugmentedRequestHandler = ( - req: IncomingMessage & { - params: {[key: string]: string}, - query: {[key: string]: string} - }, + req: ServerRequest, res: ServerResponse ) => any; diff --git a/types/mock-knex/index.d.ts b/types/mock-knex/index.d.ts index a21ab2eb0a..bad0aadb01 100644 --- a/types/mock-knex/index.d.ts +++ b/types/mock-knex/index.d.ts @@ -48,7 +48,10 @@ export interface Tracker extends EventEmitter { * * @param callback A function that gets executed on 'query' event. */ - on(event: 'query', callback: (query: QueryDetails, step: number) => void): this; + on( + event: "query", + callback: (query: QueryDetails, step: number) => void + ): this; } /** @@ -56,6 +59,8 @@ export interface Tracker extends EventEmitter { * Object properties signature matches with knex toSQL() output with additional method returns(values). */ export interface QueryDetails extends Knex.Sql { + transacting: boolean; + /** * Function that needs to be called to mock database query result for knex. * diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index b7c5e52792..ba27943739 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -43,7 +43,7 @@ export class MongoClient extends EventEmitter { close(force?: boolean): Promise; close(force: boolean, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#db */ - db(name: string, options?: MongoClientCommonOption): Db + db(dbName?: string, options?: MongoClientCommonOption): Db /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#isConnected */ isConnected(name: string, options?: MongoClientCommonOption): boolean; /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#logout */ diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index a6d8a7b822..50496fc9da 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1543,9 +1543,12 @@ declare module "mongoose" { findOneAndUpdate(callback?: (err: any, doc: DocType | null) => void): DocumentQuery; findOneAndUpdate(update: any, callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery; - findOneAndUpdate(query: any | Query, update: any, + findOneAndUpdate(query: any, update: any, callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery; - findOneAndUpdate(query: any | Query, update: any, options: QueryFindOneAndUpdateOptions, + findOneAndUpdate(query: any, update: any, + options: { upsert: true, new: true } & QueryFindOneAndUpdateOptions, + callback?: (err: any, doc: DocType, res: any) => void): DocumentQuery; + findOneAndUpdate(query: any, update: any, options: QueryFindOneAndUpdateOptions, callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery; /** @@ -2520,6 +2523,9 @@ declare module "mongoose" { findByIdAndUpdate(): DocumentQuery; findByIdAndUpdate(id: any | number | string, update: any, callback?: (err: any, res: T | null) => void): DocumentQuery; + findByIdAndUpdate(id: any | number | string, update: any, + options: { upsert: true, new: true } & ModelFindByIdAndUpdateOptions, + callback?: (err: any, res: T) => void): DocumentQuery; findByIdAndUpdate(id: any | number | string, update: any, options: ModelFindByIdAndUpdateOptions, callback?: (err: any, res: T | null) => void): DocumentQuery; @@ -2565,6 +2571,9 @@ declare module "mongoose" { findOneAndUpdate(): DocumentQuery; findOneAndUpdate(conditions: any, update: any, callback?: (err: any, doc: T | null, res: any) => void): DocumentQuery; + findOneAndUpdate(conditions: any, update: any, + options: { upsert: true, new: true } & ModelFindOneAndUpdateOptions, + callback?: (err: any, doc: T, res: any) => void): DocumentQuery; findOneAndUpdate(conditions: any, update: any, options: ModelFindOneAndUpdateOptions, callback?: (err: any, doc: T | null, res: any) => void): DocumentQuery; diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index bf2f61f4a3..fc43549f8e 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -758,6 +758,7 @@ query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}, { }, cb); query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}, cb); query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}); +query.findOneAndUpdate({}, {}, { upsert: true, new: true }); query.findOneAndUpdate({name: 'bb'}, cb); query.findOneAndUpdate({name: 'bb'}); query.findOneAndUpdate(cb); @@ -1387,6 +1388,7 @@ MongoModel.findByIdAndRemove(999); MongoModel.findByIdAndRemove(); MongoModel.findByIdAndUpdate(999, {}, {}, cb); MongoModel.findByIdAndUpdate(999, {}, {}); +MongoModel.findByIdAndUpdate(999, {}, { upsert: true, new: true }); MongoModel.findByIdAndUpdate(999, {}, cb); MongoModel.findByIdAndUpdate(999, {}); MongoModel.findByIdAndUpdate(); @@ -1415,6 +1417,7 @@ MongoModel.findOneAndRemove({}); MongoModel.findOneAndRemove(); MongoModel.findOneAndUpdate({}, {}, {}, cb); MongoModel.findOneAndUpdate({}, {}, {}); +MongoModel.findOneAndUpdate({}, {}, { upsert: true, new: true }); MongoModel.findOneAndUpdate({}, {}, cb); MongoModel.findOneAndUpdate({}, {}); MongoModel.findOneAndUpdate(); diff --git a/types/mongoose/v4/index.d.ts b/types/mongoose/v4/index.d.ts index 4a4b7d224e..c680f3c980 100644 --- a/types/mongoose/v4/index.d.ts +++ b/types/mongoose/v4/index.d.ts @@ -1600,9 +1600,12 @@ declare module "mongoose" { findOneAndUpdate(callback?: (err: any, doc: DocType | null) => void): DocumentQuery; findOneAndUpdate(update: any, callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery; - findOneAndUpdate(query: any | Query, update: any, + findOneAndUpdate(query: any, update: any, callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery; - findOneAndUpdate(query: any | Query, update: any, options: QueryFindOneAndUpdateOptions, + findOneAndUpdate(query: any, update: any, + options: { upsert: true, new: true } & QueryFindOneAndUpdateOptions, + callback?: (err: any, doc: DocType, res: any) => void): DocumentQuery; + findOneAndUpdate(query: any, update: any, options: QueryFindOneAndUpdateOptions, callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery; /** @@ -2528,6 +2531,9 @@ declare module "mongoose" { findByIdAndUpdate(): DocumentQuery; findByIdAndUpdate(id: any | number | string, update: any, callback?: (err: any, res: T | null) => void): DocumentQuery; + findByIdAndUpdate(id: any | number | string, update: any, + options: { upsert: true, new: true } & ModelFindByIdAndUpdateOptions, + callback?: (err: any, res: T) => void): DocumentQuery; findByIdAndUpdate(id: any | number | string, update: any, options: ModelFindByIdAndUpdateOptions, callback?: (err: any, res: T | null) => void): DocumentQuery; @@ -2573,6 +2579,9 @@ declare module "mongoose" { findOneAndUpdate(): DocumentQuery; findOneAndUpdate(conditions: any, update: any, callback?: (err: any, doc: T | null, res: any) => void): DocumentQuery; + findOneAndUpdate(conditions: any, update: any, + options: { upsert: true, new: true } & ModelFindOneAndUpdateOptions, + callback?: (err: any, doc: T, res: any) => void): DocumentQuery; findOneAndUpdate(conditions: any, update: any, options: ModelFindOneAndUpdateOptions, callback?: (err: any, doc: T | null, res: any) => void): DocumentQuery; diff --git a/types/mongoose/v4/mongoose-tests.ts b/types/mongoose/v4/mongoose-tests.ts index 64214fe983..170a005b49 100644 --- a/types/mongoose/v4/mongoose-tests.ts +++ b/types/mongoose/v4/mongoose-tests.ts @@ -743,6 +743,8 @@ query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}, { }, cb); query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}, cb); query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}); +query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}, { }); +query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}, { upsert: true, new: true }); query.findOneAndUpdate({name: 'bb'}, cb); query.findOneAndUpdate({name: 'bb'}); query.findOneAndUpdate(cb); @@ -1371,6 +1373,7 @@ MongoModel.findByIdAndRemove(999); MongoModel.findByIdAndRemove(); MongoModel.findByIdAndUpdate(999, {}, {}, cb); MongoModel.findByIdAndUpdate(999, {}, {}); +MongoModel.findByIdAndUpdate(999, {}, { new: true, upsert: true }, cb); MongoModel.findByIdAndUpdate(999, {}, cb); MongoModel.findByIdAndUpdate(999, {}); MongoModel.findByIdAndUpdate(); @@ -1399,6 +1402,7 @@ MongoModel.findOneAndRemove({}); MongoModel.findOneAndRemove(); MongoModel.findOneAndUpdate({}, {}, {}, cb); MongoModel.findOneAndUpdate({}, {}, {}); +MongoModel.findOneAndUpdate({}, {}, { upsert: true, new: true }); MongoModel.findOneAndUpdate({}, {}, cb); MongoModel.findOneAndUpdate({}, {}); MongoModel.findOneAndUpdate(); diff --git a/types/muicss/index.d.ts b/types/muicss/index.d.ts new file mode 100644 index 0000000000..f195ae5d23 --- /dev/null +++ b/types/muicss/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for muicss React bindings 0.9 +// Project: https://www.muicss.com/ +// Definitions by: Samuel Neff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +// all definitions in react.d.ts and subdirs diff --git a/types/muicss/lib/react/appbar.d.ts b/types/muicss/lib/react/appbar.d.ts new file mode 100644 index 0000000000..3da725be31 --- /dev/null +++ b/types/muicss/lib/react/appbar.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Appbar extends React.Component {} diff --git a/types/muicss/lib/react/button.d.ts b/types/muicss/lib/react/button.d.ts new file mode 100644 index 0000000000..df641cf4c4 --- /dev/null +++ b/types/muicss/lib/react/button.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Button extends React.Component {} diff --git a/types/muicss/lib/react/checkbox.d.ts b/types/muicss/lib/react/checkbox.d.ts new file mode 100644 index 0000000000..dda10e0ade --- /dev/null +++ b/types/muicss/lib/react/checkbox.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Checkbox extends React.Component {} diff --git a/types/muicss/lib/react/col.d.ts b/types/muicss/lib/react/col.d.ts new file mode 100644 index 0000000000..a052122a04 --- /dev/null +++ b/types/muicss/lib/react/col.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Col extends React.Component {} diff --git a/types/muicss/lib/react/container.d.ts b/types/muicss/lib/react/container.d.ts new file mode 100644 index 0000000000..6845cd981b --- /dev/null +++ b/types/muicss/lib/react/container.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Container extends React.Component {} diff --git a/types/muicss/lib/react/divider.d.ts b/types/muicss/lib/react/divider.d.ts new file mode 100644 index 0000000000..ce2ea1f3d6 --- /dev/null +++ b/types/muicss/lib/react/divider.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Divider extends React.Component {} diff --git a/types/muicss/lib/react/dropdown-item.d.ts b/types/muicss/lib/react/dropdown-item.d.ts new file mode 100644 index 0000000000..07dbcd77b9 --- /dev/null +++ b/types/muicss/lib/react/dropdown-item.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class DropdownItem extends React.Component {} diff --git a/types/muicss/lib/react/dropdown.d.ts b/types/muicss/lib/react/dropdown.d.ts new file mode 100644 index 0000000000..c34154133e --- /dev/null +++ b/types/muicss/lib/react/dropdown.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Dropdown extends React.Component {} diff --git a/types/muicss/lib/react/form.d.ts b/types/muicss/lib/react/form.d.ts new file mode 100644 index 0000000000..ca09da6102 --- /dev/null +++ b/types/muicss/lib/react/form.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Form extends React.Component {} diff --git a/types/muicss/lib/react/input.d.ts b/types/muicss/lib/react/input.d.ts new file mode 100644 index 0000000000..2e8edfd7f7 --- /dev/null +++ b/types/muicss/lib/react/input.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Input extends React.Component {} diff --git a/types/muicss/lib/react/option.d.ts b/types/muicss/lib/react/option.d.ts new file mode 100644 index 0000000000..59514c5cbc --- /dev/null +++ b/types/muicss/lib/react/option.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Option extends React.Component {} diff --git a/types/muicss/lib/react/panel.d.ts b/types/muicss/lib/react/panel.d.ts new file mode 100644 index 0000000000..b92359f19e --- /dev/null +++ b/types/muicss/lib/react/panel.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Panel extends React.Component {} diff --git a/types/muicss/lib/react/radio.d.ts b/types/muicss/lib/react/radio.d.ts new file mode 100644 index 0000000000..ab8f20cb37 --- /dev/null +++ b/types/muicss/lib/react/radio.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Radio extends React.Component {} diff --git a/types/muicss/lib/react/row.d.ts b/types/muicss/lib/react/row.d.ts new file mode 100644 index 0000000000..6da3037efc --- /dev/null +++ b/types/muicss/lib/react/row.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Row extends React.Component {} diff --git a/types/muicss/lib/react/select.d.ts b/types/muicss/lib/react/select.d.ts new file mode 100644 index 0000000000..4a5cefc75a --- /dev/null +++ b/types/muicss/lib/react/select.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Select extends React.Component {} diff --git a/types/muicss/lib/react/tab.d.ts b/types/muicss/lib/react/tab.d.ts new file mode 100644 index 0000000000..6c93a45b09 --- /dev/null +++ b/types/muicss/lib/react/tab.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Tab extends React.Component {} diff --git a/types/muicss/lib/react/tabs.d.ts b/types/muicss/lib/react/tabs.d.ts new file mode 100644 index 0000000000..e33ca34333 --- /dev/null +++ b/types/muicss/lib/react/tabs.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class Tabs extends React.Component {} diff --git a/types/muicss/lib/react/textarea.d.ts b/types/muicss/lib/react/textarea.d.ts new file mode 100644 index 0000000000..82acb645e0 --- /dev/null +++ b/types/muicss/lib/react/textarea.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; +import * as P from '../../react'; + +export default class TextArea extends React.Component {} diff --git a/types/muicss/muicss-tests.tsx b/types/muicss/muicss-tests.tsx new file mode 100644 index 0000000000..000310918b --- /dev/null +++ b/types/muicss/muicss-tests.tsx @@ -0,0 +1,200 @@ +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; + +import { + Appbar, + Button, + Checkbox, + Col, + Container, + Divider, + Dropdown, + DropdownItem, + Form, + Input, + Option, + Panel, + Radio, + Row, + Select, + Tab, + Tabs, + Textarea +} from 'muicss/react'; + +import Appbar2 from 'muicss/lib/react/appbar'; +import Button2 from 'muicss/lib/react/button'; +import Checkbox2 from 'muicss/lib/react/checkbox'; +import Col2 from 'muicss/lib/react/col'; +import Container2 from 'muicss/lib/react/container'; +import Divider2 from 'muicss/lib/react/divider'; +import Dropdown2 from 'muicss/lib/react/dropdown'; +import DropdownItem2 from 'muicss/lib/react/dropdown-item'; +import Form2 from 'muicss/lib/react/form'; +import Input2 from 'muicss/lib/react/input'; +import Option2 from 'muicss/lib/react/option'; +import Panel2 from 'muicss/lib/react/panel'; +import Radio2 from 'muicss/lib/react/radio'; +import Row2 from 'muicss/lib/react/row'; +import Select2 from 'muicss/lib/react/select'; +import Tab2 from 'muicss/lib/react/tab'; +import Tabs2 from 'muicss/lib/react/tabs'; +import Textarea2 from 'muicss/lib/react/textarea'; + +class Test extends React.Component { + render() { + return ( +
+ Test application + + + + Link + + Link + + + + +
+ Test form + + + +