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/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 cefa92ef5c..f21fab1114 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -43,7 +43,7 @@ declare let marker: Atom.Marker; declare let markers: Atom.Marker[]; declare let markerLayer: Atom.MarkerLayer; declare let notification: Atom.Notification; -declare let notifications: Atom.Notification[]; +declare let notifications: ReadonlyArray; declare let pack: Atom.Package; declare let packs: Atom.Package[]; declare let pane: Atom.Pane; @@ -56,10 +56,12 @@ declare let posArr: Atom.Point[]; declare let project: Atom.Project; declare let range: Atom.Range; declare let ranges: Atom.Range[]; +declare let readonlyStrs: ReadonlyArray; declare let registry: Atom.GrammarRegistry; declare let repository: Atom.GitRepository; declare let repositories: Atom.GitRepository[]; declare let scopeDescriptor: Atom.ScopeDescriptor; +declare let scopes: ReadonlyArray; declare let selection: Atom.Selection; declare let selections: Atom.Selection[]; declare let styleManager: Atom.StyleManager; @@ -188,6 +190,10 @@ function testAtomEnvironment() { // Messaging the User atom.beep(); + atom.confirm({ defaultId: 42 }, (response, checked) => { + num = response; + bool = checked; + }); atom.confirm({ message: "Test" }); atom.confirm({ message: "Test", buttons: [ "a", "b" ], detailedMessage: "Test" }); num = atom.confirm({ message: "Test", detailedMessage: "Test", buttons: { @@ -270,13 +276,19 @@ function testCommandRegistry() { "test-function2": (event) => {}, }); atom.commands.add("test", "test:function", { - didDispatch: (event) => event.stopImmediatePropagation(), + didDispatch: (event) => { + event.stopImmediatePropagation(); + }, description: "A Command Test", displayName: "Command: Test", }); atom.commands.add("atom-text-editor", { - "test-function": (event) => event.currentTarget.getModel(), - "test-function2": (event) => event.currentTarget.getComponent(), + "test-function": (event) => { + event.currentTarget.getModel(); + }, + "test-function2": (event) => { + event.currentTarget.getComponent(); + } }); atom.commands.add("atom-workspace", { "test-command": { @@ -345,7 +357,7 @@ function testConfig() { const allConfigValues = atom.config.getAll("test"); for (const { scopeDescriptor, value } of allConfigValues) { - scopeDescriptor.scopes; + scopes = scopeDescriptor.getScopesArray(); } atom.config.getAll("test", { scope: scopeDescriptor }); atom.config.getAll("test", { excludeSources: ["test"] }); @@ -853,6 +865,7 @@ function testDock() { subscription = dock.onDidDestroyPaneItem(event => { event.index && event.item && event.pane; }); + subscription = dock.onDidChangeHovered(hovered => bool = hovered); // Pane Items objs = dock.getPaneItems(); @@ -1375,6 +1388,7 @@ function testNotification() { function testNotificationManager() { // Events atom.notifications.onDidAddNotification(notification => notification.dismiss()); + atom.notifications.onDidClearNotifications(() => undefined); // Adding Notifications atom.notifications.addSuccess("Test"); @@ -1409,6 +1423,9 @@ function testNotificationManager() { // Getting Notifications notifications = atom.notifications.getNotifications(); + + // Managing Notifications + atom.notifications.clear(); } // Package ==================================================================== @@ -1833,7 +1850,7 @@ function testRange() { } // ScopeDescriptor ============================================================ -strs = scopeDescriptor.getScopesArray(); +readonlyStrs = scopeDescriptor.getScopesArray(); // Selection ================================================================== function testSelection() { @@ -2219,6 +2236,7 @@ function testTextBuffer() { num = buffer.createCheckpoint(); bool = buffer.revertToCheckpoint(42); bool = buffer.groupChangesSinceCheckpoint(42); + bool = buffer.groupLastChanges(); buffer.getChangesSinceCheckpoint(42); // Search And Replace @@ -2306,6 +2324,7 @@ function testTextBuffer() { num = buffer.getLastRow(); pos = buffer.getFirstPosition(); pos = buffer.getEndPosition(); + num = buffer.getLength(); num = buffer.getMaxCharacterIndex(); range = buffer.rangeForRow(42, true); num = buffer.characterIndexForPosition(pos); @@ -2700,6 +2719,8 @@ function testTextEditor() { editor.moveToNextSubwordBoundary(); editor.moveToBeginningOfNextParagraph(); editor.moveToBeginningOfPreviousParagraph(); + editor.selectLargerSyntaxNode(); + editor.selectSmallerSyntaxNode(); cursor = editor.getLastCursor(); str = editor.getWordUnderCursor(); diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index df446d50c3..e673ada530 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Atom 1.24 +// Type definitions for Atom 1.25 // Project: https://github.com/atom/atom // Definitions by: GlenCFL // smhxx @@ -7,7 +7,7 @@ // TypeScript Version: 2.3 // 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 +// https://github.com/atom/atom/blob/v1.25.0/exports/atom.js /// @@ -39,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. */ @@ -204,7 +204,27 @@ export interface AtomEnvironment { beep(): void; /** - * A flexible way to open a dialog akin to an alert dialog. + * A flexible way to open a dialog akin to an alert dialog. If a callback + * is provided, then the confirmation will work asynchronously, which is + * recommended. + * + * If the dialog is closed (via `Esc` key or `X` in the top corner) without + * selecting a button the first button will be clicked unless a "Cancel" or "No" + * button is provided. + * + * Returns the chosen button index number if the buttons option was an array. + * @param response The index of the button that was clicked. + * @param checkboxChecked The checked state of the checkbox if `checkboxLabel` was set. + * Otherwise false. + */ + confirm(options: ConfirmationOptions, callback: (response: number, + checkboxChecked: boolean) => void): void; + + /** + * A flexible way to open a dialog akin to an alert dialog. If a callback + * is provided, then the confirmation will work asynchronously, which is + * recommended. + * * If the dialog is closed (via `Esc` key or `X` in the top corner) without * selecting a button the first button will be clicked unless a "Cancel" or "No" * button is provided. @@ -218,7 +238,10 @@ export interface AtomEnvironment { }): void; /** - * A flexible way to open a dialog akin to an alert dialog. + * A flexible way to open a dialog akin to an alert dialog. If a callback + * is provided, then the confirmation will work asynchronously, which is + * recommended. + * * If the dialog is closed (via `Esc` key or `X` in the top corner) without * selecting a button the first button will be clicked unless a "Cancel" or "No" * button is provided. @@ -264,11 +287,11 @@ export interface CommandRegistryTargetMap extends HTMLElementTagNameMap { } export type CommandRegistryListener = { - didDispatch(event: CommandEvent): void, - displayName?: string, - description?: string, - hiddenInCommandPalette?: boolean, -} | ((event: CommandEvent) => void); + didDispatch(event: CommandEvent): void | Promise, + displayName?: string, + description?: string, + hiddenInCommandPalette?: boolean, +} | ((event: CommandEvent) => void | Promise); /** * Associates listener functions with commands in a context-sensitive way @@ -305,9 +328,10 @@ export interface CommandRegistry { /** * Simulate the dispatch of a command on a DOM node. - * @return Whether or not there was a matching command for the target. + * @return Either a Promise that resolves after all handlers complete or null if + * no handlers were matched. */ - dispatch(target: Node, commandName: string): boolean; + dispatch(target: Node, commandName: string): Promise | null; /** Invoke the given callback before dispatching a command event. */ onWillDispatch(callback: (event: CommandEvent) => void): Disposable; @@ -446,7 +470,7 @@ export interface Config { */ export interface Decoration { /** The identifier for this Decoration. */ - id: number; + readonly id: number; // Construction and Destruction /** @@ -654,7 +678,7 @@ export interface DisplayMarker { */ export interface DisplayMarkerLayer { /** The identifier for the underlying MarkerLayer. */ - id: string; + readonly id: string; // Lifecycle /** Destroy this layer. */ @@ -839,7 +863,7 @@ export interface LayerDecoration { */ export interface Marker { /** The identifier for this Marker. */ - id: number; + readonly id: number; // Lifecycle /** @@ -952,7 +976,7 @@ export interface Marker { /** Experimental: A container for a related set of markers. */ export interface MarkerLayer { /** The identifier for this MarkerLayer. */ - id: string; + readonly id: string; // Lifecycle /** Create a copy of this layer with markers in the same state and locations. */ @@ -1035,13 +1059,13 @@ export class Notification { /** A notification manager used to create Notifications to be shown to the user. */ export interface NotificationManager { - // Properties - notifications: Notification[]; - // Events /** Invoke the given callback after a notification has been added. */ onDidAddNotification(callback: (notification: Notification) => void): Disposable; + /** Invoke the given callback after the notifications have been cleared. */ + onDidClearNotifications(callback: () => void): Disposable; + // Adding Notifications /** Add a success notification. */ addSuccess(message: string, options?: NotificationOptions): Notification; @@ -1060,7 +1084,11 @@ export interface NotificationManager { // Getting Notifications /** Get all the notifications. */ - getNotifications(): Notification[]; + getNotifications(): ReadonlyArray; + + // Managing Notifications + /** Clear all the notifications. */ + clear(): void; } /** Represents a point in a buffer in row/column coordinates. */ @@ -1272,8 +1300,7 @@ export class Range { * including cursor and selection positions, folds, and soft wraps. */ export class TextEditor { - id: number; - buffer: TextBuffer; + readonly id: number; // NOTE: undocumented within the public API. Don't go down the rabbit hole. constructor(options?: object); @@ -2137,6 +2164,12 @@ export class TextEditor { */ selectToBeginningOfPreviousParagraph(): void; + /** For each selection, select the syntax node that contains that selection. */ + selectLargerSyntaxNode(): void; + + /** Undo the effect a preceding call to `::selectLargerSyntaxNode`. */ + selectSmallerSyntaxNode(): void; + /** Select the range of the given marker if it is valid. */ selectMarker(marker: DisplayMarker): Range|undefined; @@ -2347,7 +2380,10 @@ export class TextEditor { /** Unfold all existing folds. */ unfoldAll(): void; - /** Fold all foldable lines at the given indent level. */ + /** + * Fold all foldable lines at the given indent level. + * @param level A zero-indexed number. + */ foldAllAtIndentLevel(level: number): void; /** @@ -2524,10 +2560,6 @@ 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"; @@ -2984,7 +3016,7 @@ export interface WorkspaceCenter { * Node's ChildProcess. */ export class BufferedProcess { - process?: ChildProcess; + readonly process?: ChildProcess; constructor(options: ProcessOptions); @@ -3452,6 +3484,12 @@ export interface Dock { /** Invoke the given callback when a pane item is destroyed. */ onDidDestroyPaneItem(callback: (event: PaneItemObservedEvent) => void): Disposable; + /** + * Invoke the given callback when the hovered state of the dock changes. + * @param hovered Is the dock now hovered? + */ + onDidChangeHovered(callback: (hovered: boolean) => void): Disposable; + // Pane Items /** Get all pane items in the dock. */ getPaneItems(): object[]; @@ -4052,10 +4090,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. */ @@ -4377,7 +4415,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. */ @@ -4498,10 +4536,8 @@ export interface Project { * syntax tree to a token including all scope names for the entire path. */ export interface ScopeDescriptor { - scopes: string[]; - /** Returns all scopes for this descriptor. */ - getScopesArray(): string[]; + getScopesArray(): ReadonlyArray; } /** Represents a selection in the TextEditor. */ @@ -4894,13 +4930,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; @@ -5068,7 +5104,10 @@ export class TextBuffer { /** Get the text of the last line of the buffer, without its line ending. */ getLastLine(): string; - /** Get the text of the line at the given row, without its line ending. */ + /** + * Get the text of the line at the given 0-indexed row, without its line ending. + * @param row A number representing the row. + */ lineForRow(row: number): string|undefined; /** Get the line ending for the given 0-indexed row. */ @@ -5120,10 +5159,18 @@ export class TextBuffer { /** Delete the text in the given range. */ delete(range: RangeCompatible): Range; - /** Delete the line associated with a specified row. */ + /** + * Delete the line associated with a specified 0-indexed row. + * @param row A number representing the row to delete. + */ deleteRow(row: number): Range; - /** Delete the lines associated with the specified row range. */ + /** + * Delete the lines associated with the specified 0-indexed row range. + * + * If the row range is out of bounds, it will be clipped. If the `startRow` + * is greater than the `endRow`, they will be reordered. + */ deleteRows(startRow: number, endRow: number): Range; // Markers @@ -5162,10 +5209,16 @@ export class TextBuffer { getMarkerCount(): number; // History - /** Undo the last operation. If a transaction is in progress, aborts it. */ + /** + * Undo the last operation. If a transaction is in progress, aborts it. + * @return A boolean of whether or not a change was made. + */ undo(): boolean; - /** Redo the last operation. */ + /** + * Redo the last operation. + * @return A boolean of whether or not a change was made. + */ redo(): boolean; /** Batch multiple operations as a single undo/redo step. */ @@ -5173,37 +5226,44 @@ export class TextBuffer { transact(fn: () => T): T; /** - * Call within a transaction to terminate the function's execution and - * revert any changes performed up to the abortion. + * Abort the currently running transaction. + * + * Only intended to be called within the `fn` option to `::transact`. */ abortTransaction(): void; - /** - * Clear the undo stack. When calling this method within a transaction, - * the ::onDidChangeText event will not be triggered because the information - * describing the changes is lost. - */ + /** Clear the undo stack. */ clearUndoStack(): void; /** * Create a pointer to the current state of the buffer for use with - * ::revertToCheckpoint and ::groupChangesSinceCheckpoint. + * `::revertToCheckpoint` and `::groupChangesSinceCheckpoint`. + * @return A checkpoint ID value. */ createCheckpoint(): number; /** * Revert the buffer to the state it was in when the given checkpoint was created. - * Returns a boolean indicating whether the operation succeeded. + * @return A boolean indicating whether the operation succeeded. */ revertToCheckpoint(checkpoint: number): boolean; /** * Group all changes since the given checkpoint into a single transaction for * purposes of undo/redo. - * Returns a boolean indicating whether the operation succeeded. + * @return A boolean indicating whether the operation succeeded. */ groupChangesSinceCheckpoint(checkpoint: number): boolean; + /** + * Group the last two text changes for purposes of undo/redo. + * + * This operation will only succeed if there are two changes on the undo stack. + * It will not group past the beginning of an open transaction. + * @return A boolean indicating whether the operation succeeded. + */ + groupLastChanges(): boolean; + /** * Returns a list of changes since the given checkpoint. * If the given checkpoint is no longer present in the undo history, this method @@ -5293,17 +5353,26 @@ export class TextBuffer { /** Get the maximal position in the buffer, where new text would be appended. */ getEndPosition(): Point; + /** Get the length of the buffer's text. */ + getLength(): number; + /** Get the length of the buffer in characters. */ getMaxCharacterIndex(): number; - /** Get the range for the given row. */ - rangeForRow(row: number, includeNewline: boolean): Range; + /** + * Get the range for the given row. + * @param row A number representing a 0-indexed row. + * @param includeNewline A boolean indicating whether or not to include the + * newline, which results in a range that extends to the start of the next line. + * (default: false) + */ + rangeForRow(row: number, includeNewline?: boolean): Range; /** * Convert a position in the buffer in row/column coordinates to an absolute * character offset, inclusive of line ending characters. */ - characterIndexForPosition(position: Point|[number, number]): number; + characterIndexForPosition(position: PointCompatible): number; /** * Convert an absolute character offset, inclusive of newlines, to a position @@ -5753,7 +5822,7 @@ export interface TextEditorObservedEvent { // information under certain contexts. // NOTE: the config schema with these defaults can be found here: -// https://github.com/atom/atom/blob/v1.24.0/src/config-schema.js +// https://github.com/atom/atom/blob/v1.25.0/src/config-schema.js /** * Allows you to strongly type Atom configuration variables. Additional key:value * pairings merged into this interface will result in configuration values under @@ -6039,6 +6108,59 @@ export interface BuildEnvironmentOptions { enablePersistence?: boolean; } +export interface ConfirmationOptions { + /** The type of the confirmation prompt. */ + type?: "none"|"info"|"error"|"question"|"warning"; + + /** The text for the buttons. */ + buttons?: ReadonlyArray; + + /** The index for the button to be selected by default in the prompt. */ + defaultId?: number; + + /** The title for the prompt. */ + title?: string; + + /** The content of the message box. */ + message?: string; + + /** Additional information regarding the message. */ + detail?: string; + + /** If provided, the message box will include a checkbox with the given label. */ + checkboxLabel?: string; + + /** Initial checked state of the checkbox. false by default. */ + checkboxChecked?: boolean; + + /** An Electron NativeImage to use as the prompt's icon. */ + icon?: object; + + /** + * The index of the button to be used to cancel the dialog, via the `Esc` key. + * By default this is assigned to the first button with "cancel" or "no" as the + * label. If no such labeled buttons exist and this option is not set, 0 will be + * used as the return value or callback response. + * + * This option is ignored on Windows. + */ + cancelId?: number; + + /** + * On Windows, Electron will try to figure out which one of the buttons are + * common buttons (like `Cancel` or `Yes`), and show the others as command links + * in the dialog. This can make the dialog appear in the style of modern Windows + * apps. If you don't like this behavior, you can set noLink to true. + */ + noLink?: boolean; + + /** + * Normalize the keyboard access keys across platforms. + * Atom defaults this to true. + */ + normalizeAccessKeys?: boolean; +} + export interface ContextMenuOptions { /** The menu item's label. */ label?: string; @@ -6506,6 +6628,10 @@ export interface DisposableLike { dispose(): void; } +export interface JQueryCompatible extends Iterable { + jquery: string; +} + /** The types usable when constructing a point via the Point::fromObject method. */ export type PointCompatible = PointLike|[number, number]; @@ -6753,11 +6879,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: HTMLElement; + readonly options: TooltipOptions; + readonly enabled: boolean; + readonly timeout: number; + readonly hoverState: "in"|"out"|null; + readonly element: HTMLElement; getTitle(): string; getTooltipElement(): HTMLElement; @@ -6774,11 +6900,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/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index 119bbb3c37..3ef12e327b 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -117,6 +117,18 @@ const authOptions : Auth0LockConstructorOptions = { new Auth0Lock(CLIENT_ID, DOMAIN, authOptions); +// test "other" properties + +const otherOptions : Auth0LockConstructorOptions = { + clientBaseUrl: "http://www.example.com", + configurationBaseUrl: "https://cdn.auth0.com", + languageBaseUrl: "http://www.example.com", + hashCleanup: false, + leeway: 30 +}; + +new Auth0Lock(CLIENT_ID, DOMAIN, otherOptions); + // test multi-variant example const multiVariantOptions : Auth0LockConstructorOptions = { diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index 352d9c71a9..7dd99af9e6 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -119,17 +119,23 @@ interface Auth0LockConstructorOptions { autoclose?: boolean; autofocus?: boolean; avatar?: Auth0LockAvatarOptions; + clientBaseUrl?: string; closable?: boolean; + configurationBaseUrl?: string; container?: string; defaultADUsernameFromEmailPrefix?: string; defaultDatabaseConnection?: string; defaultEnterpriseConnection?: string; forgotPasswordLink?: string; + hashCleanup?: boolean; initialScreen?: "login" | "signUp" | "forgotPassword"; language?: string; + languageBaseUrl?: string; languageDictionary?: any; + leeway?: number; loginAfterSignUp?: boolean; mustAcceptTerms?: boolean; + oidcConformant?: boolean; popupOptions?: Auth0LockPopupOptions; prefill?: { email?: string, username?: string}; rememberLastLogin?: boolean; @@ -137,7 +143,6 @@ interface Auth0LockConstructorOptions { socialButtonStyle?: "big" | "small"; theme?: Auth0LockThemeOptions; usernameStyle?: string; - oidcConformant?: boolean; } interface Auth0LockFlashMessageOptions { diff --git a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts index 8ac6457975..3ac593a651 100644 --- a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts +++ b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts @@ -20,5 +20,8 @@ namespace BMapTests { map.addOverlay(marker); marker.setAnimation(BMAP_ANIMATION_BOUNCE); } + public create_map(map: BMap.Map, city: string) { + map.centerAndZoom(city); + } } } diff --git a/types/baidumap-web-sdk/baidumap.core.d.ts b/types/baidumap-web-sdk/baidumap.core.d.ts index 24d1aed9f0..a12b78788a 100644 --- a/types/baidumap-web-sdk/baidumap.core.d.ts +++ b/types/baidumap-web-sdk/baidumap.core.d.ts @@ -56,6 +56,7 @@ declare namespace BMap { getZoom(): number getPanorama(): Panorama centerAndZoom(center: Point, zoom: number): void + centerAndZoom(city: string): void panTo(center: Point, opts?: PanOptions): void panBy(x: number, y: number, opts?: PanOptions): void reset(): void 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/bootstrap/bootstrap-tests.ts b/types/bootstrap/bootstrap-tests.ts index 17d6e088cf..21286ad5f4 100755 --- a/types/bootstrap/bootstrap-tests.ts +++ b/types/bootstrap/bootstrap-tests.ts @@ -2,8 +2,10 @@ // Alert // -------------------------------------------------------------------------------------- +// $ExpectType JQuery $("#alert").alert(); +// $ExpectType JQuery $("#alert").alert("close"); $("#alert").on("close.bs.alert", () => {}); @@ -12,20 +14,32 @@ $("#alert").on("close.bs.alert", () => {}); // Button // -------------------------------------------------------------------------------------- -// $("#button").button(); // must fail +// $ExpectError +$("#button").button(); +// $ExpectType JQuery $("#button").button("toggle"); // -------------------------------------------------------------------------------------- // Carousel // -------------------------------------------------------------------------------------- +// $ExpectType JQuery $("#carousel").carousel(); +// $ExpectType JQuery $("#carousel").carousel("pause"); $("#carousel").carousel(100); +$("#carousel").on("slide.bs.carousel", function(ev) { + const that: HTMLElement = this; + const from: number = ev.from; + const to: number = ev.to; + const direction: string = ev.direction; + const data: undefined = ev.data; +}); + $("#carousel").carousel({ interval: 5000, keyboard: true, @@ -37,20 +51,43 @@ $("#carousel").carousel({ pause: false, }); -$("#carousel").on("slide.bs.carousel", function(ev) { - const that: HTMLElement = this; - const from: number = ev.from; - const to: number = ev.to; - const direction: string = ev.direction; - const data: undefined = ev.data; +// -------------------------------------------------------------------------------------- +// Collapse +// -------------------------------------------------------------------------------------- + +// $ExpectType JQuery +$("#collapse").collapse(); + +// $ExpectType JQuery +$("#collapse").collapse("toggle"); + +$("#collapse").on("show.bs.collapse", () => {}); + +$("#collapse").collapse({ + parent: "#parent", + toggle: true, +}); + +$("#collapse").collapse({ + parent: document.body, +}); + +$("#collapse").collapse({ + parent: $("#parent"), +}); + +$("#collapse").collapse({ + toggle: false, }); // -------------------------------------------------------------------------------------- // Dropdown // -------------------------------------------------------------------------------------- +// $ExpectType JQuery $("#dropdown").dropdown(); +// $ExpectType JQuery $("#dropdown").dropdown("update"); $("#dropdown").on("hide.bs.dropdown", () => {}); @@ -66,7 +103,7 @@ $("#dropdown").dropdown({ }); $("#dropdown").dropdown({ - offset(offsets: BootstrapOffsetsExtend) { + offset(offsets: Bootstrap.OffsetsExtend) { if (!this.flip) return { popper: { left: 100 } }; return {}; @@ -81,8 +118,10 @@ $("#dropdown").dropdown({ // Modal // -------------------------------------------------------------------------------------- +// $ExpectType JQuery $("#modal").modal(); +// $ExpectType JQuery $("#modal").modal("show"); $("#modal").on("hide.bs.modal", () => {}); @@ -98,12 +137,90 @@ $("#modal").modal({ backdrop: "static", }); +// -------------------------------------------------------------------------------------- +// Popover +// -------------------------------------------------------------------------------------- + +// $ExpectType JQuery +$("#popover").popover(); + +// $ExpectType JQuery +$("#popover").popover("toggle"); + +$("#popover").on("show.bs.popover", () => {}); + +$("#popover").popover({}); + +$("#popover").popover({ + animation: false, + container: "#container", + delay: {show: 500, hide: 100}, + html: true, + placement: "auto", + selector: "[rel=\"popover\"]", + template: '
', + title: "Hello world", + trigger: "hover focus", + offset: 10, + fallbackPlacement: ["flip", "clockwise"], + boundary: "scrollParent", +}); + +$("#popover").popover({ + placement(this, popover, trigger) { + console.log(this.tip === popover); + console.log(this.element === trigger); + console.log(this.config.content); + return "left"; + }, +}); + +// -------------------------------------------------------------------------------------- +// Scrollspy +// -------------------------------------------------------------------------------------- + +// $ExpectType JQuery +$("#scrollspy").scrollspy(); + +// $ExpectType JQuery +$("#scrollspy").scrollspy("refresh"); + +$("#scrollspy").on("activate.bs.scrollspy", () => {}); + +$("#scrollspy").scrollspy({ + offset: 100, + target: "#navbar-example2", + method: "offset", +}); + +$("#scrollspy").scrollspy({ + target: document.getElementById("navbar-example2") as HTMLElement +}); + +$("#scrollspy").scrollspy({ + method: "position" +}); + +// -------------------------------------------------------------------------------------- +// Tab +// -------------------------------------------------------------------------------------- + +// $ExpectType JQuery +$("#someListItem").tab("show"); + +$("a[data-toggle=\"list\"]").on("shown.bs.tab", (e) => { + e.target; // newly activated tab + e.relatedTarget; // previous active tab +}); + // -------------------------------------------------------------------------------------- // Tooltip // -------------------------------------------------------------------------------------- +// $ExpectType JQuery $("#tooltip").tooltip(); +// $ExpectType JQuery $("#tooltip").tooltip("show"); $("#tooltip").on("hide.bs.tooltip", () => {}); @@ -149,6 +266,14 @@ $("#tooltip").tooltip({ }, }); +$("#tooltip").tooltip({ + placement(this, tooltip, trigger) { + // $ExpectError + console.log(this.config.content); // only for PopoverOption, not TooltipOption + return "left"; + }, +}); + $("#tooltip").tooltip({ selector: "[rel=\"tooltip\"]", }); @@ -176,7 +301,7 @@ $("#tooltip").tooltip({ }); $("#tooltip").tooltip({ - trigger: "focus hover", + trigger: "hover focus", }); $("#tooltip").tooltip({ diff --git a/types/bootstrap/index.d.ts b/types/bootstrap/index.d.ts index c158bbd807..88bcc66af8 100755 --- a/types/bootstrap/index.d.ts +++ b/types/bootstrap/index.d.ts @@ -4,45 +4,43 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// TODO: collapse, tab (list-group, navs), popovers, scrollspy +/// -/// +import * as Popper from "popper.js"; + +export as namespace Bootstrap; // -------------------------------------------------------------------------- // Some Types and Interfaces // -------------------------------------------------------------------------- -type BootstrapPlacement = "auto" | "top" | "bottom" | "left" | "right"; -type PopperBehavior = "flip" | "clockwise" | "counterclockwise"; +export type Placement = "auto" | "top" | "bottom" | "left" | "right"; -interface BootstrapDelay { +export type Trigger = "click" | "hover" | "focus" | "manual" | + "click hover" | "click focus" | "hover focus" | + "click hover focus"; + +export interface Delay { show: number; hide: number; } -interface BootstrapTooltipInstance { - config: BootstrapTooltipOption; +export interface TooltipInstance { + config: T; element: Element; tip: HTMLElement; } -interface BootstrapOffsetExtend { - top?: number; - left?: number; - width?: number; - height?: number; -} - -interface BootstrapOffsetsExtend { - popper?: BootstrapOffsetExtend; - reference?: BootstrapOffsetExtend; +export interface OffsetsExtend { + popper?: Partial; + reference?: Partial; } // -------------------------------------------------------------------------------------- // Options Interfaces // -------------------------------------------------------------------------------------- -interface BootstrapCarouselOption { +export interface CarouselOption { /** * The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. * @@ -75,14 +73,32 @@ interface BootstrapCarouselOption { wrap?: boolean; } -interface BootstrapDropdownOption { +export interface CollapseOption { + /** + * If parent is provided, then all collapsible elements under the specified parent will be closed when + * this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the card class). + * The attribute has to be set on the target collapsible area. + * + * @default "" + */ + parent?: string | JQuery | Element; + + /** + * Toggles the collapsible element on invocation. + * + * @default true + */ + toggle?: boolean; +} + +export interface DropdownOption { /** * Offset of the dropdown relative to its target. * For more information refer to Popper.js's offset docs. * * @default 0 */ - offset?: number | string | ((this: BootstrapDropdownOption, offset: BootstrapOffsetsExtend) => BootstrapOffsetsExtend); + offset?: number | string | ((this: DropdownOption, offset: OffsetsExtend) => OffsetsExtend); /** * Allow Dropdown to flip in case of an overlapping on the reference element. @@ -99,10 +115,10 @@ interface BootstrapDropdownOption { * * @default "scrollParent" */ - boundary?: "viewport" | "window" | "scrollParent" | HTMLElement; + boundary?: Popper.Boundary | HTMLElement; } -interface BootstrapModalOption { +export interface ModalOption { /** * Includes a modal-backdrop element. * Alternatively, specify static for a backdrop which doesn't close the modal on click. @@ -133,36 +149,69 @@ interface BootstrapModalOption { show?: boolean; } -interface BootstrapTooltipOption { +export interface PopoverOption extends TooltipOption { /** - * Apply a CSS fade transition to the tooltip. + * Default content value if data-content attribute isn't present. + * If a function is given, it will be called with its this reference + * set to the element that the popover is attached to. + */ + content?: string | Element | ((this: Element) => string | Element); +} + +export interface ScrollspyOption { + /** + * TODO: https://github.com/twbs/bootstrap/issues/25799 + * + * @default "auto" + */ + method?: "auto" | "offset" | "position"; + + /** + * Pixels to offset from top when calculating position of scroll. + * + * @default 10 + */ + offset?: number; + + /** + * A selector of the parent element or the parent element itself + * of any Bootstrap `.nav` or `.list-group` component. + * + * @default "" + */ + target?: string | Element; +} + +export interface TooltipOption { + /** + * Apply a CSS fade transition to the tooltip or popover. * * @default true */ animation?: boolean; /** - * Appends the tooltip to a specific element. Example: `container: 'body'`. - * This option is particularly useful in that it allows you to position the tooltip + * Appends the tooltip or popover to a specific element. Example: `container: 'body'`. + * This option is particularly useful in that it allows you to position the tooltip or popover * in the flow of the document near the triggering element - which will prevent - * the tooltip from floating away from the triggering element during a window resize. + * it from floating away from the triggering element during a window resize. * * @default false */ container?: string | Element | false; /** - * Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type. + * Delay showing and hiding the tooltip or popover (ms) - does not apply to manual trigger type. * If a number is supplied, delay is applied to both hide/show. * Object structure is: `delay: { "show": 500, "hide": 100 }`. * * @default 0 */ - delay?: number | BootstrapDelay; + delay?: number | Delay; /** - * Allow HTML in the tooltip. - * If true, HTML tags in the tooltip's title will be rendered in the tooltip. + * Allow HTML in the tooltip or popover. + * If true, HTML tags will be rendered in the tooltip or popover. * If false, jQuery's text method will be used to insert content into the DOM. * Use text if you're worried about XSS attacks. * @@ -171,18 +220,18 @@ interface BootstrapTooltipOption { html?: boolean; /** - * How to position the tooltip - auto | top | bottom | left | right. - * When auto is specified, it will dynamically reorient the tooltip. + * How to position the tooltip or popover - auto | top | bottom | left | right. + * When auto is specified, it will dynamically reorient the tooltip or popover. * When a function is used to determine the placement, it is called with - * the tooltip DOM node as its first argument and the triggering element DOM node as its second. - * The this context is set to the tooltip instance. + * the tooltip or popover DOM node as its first argument and the triggering element DOM node as its second. + * The this context is set to the tooltip or popover instance. * * @default "top" */ - placement?: BootstrapPlacement | ((this: BootstrapTooltipInstance, tooltip: HTMLElement, trigger: Element) => BootstrapPlacement); + placement?: Placement | ((this: TooltipInstance, node: HTMLElement, trigger: Element) => Placement); /** - * If a selector is provided, tooltip objects will be delegated to the specified targets. + * If a selector is provided, tooltip or popover objects will be delegated to the specified targets. * In practice, this is used to enable dynamic HTML content to have popovers added. * * @default false @@ -190,41 +239,40 @@ interface BootstrapTooltipOption { selector?: string | false; /** - * Base HTML to use when creating the tooltip. The tooltip's title will be injected into - * the `.tooltip-inner`. The `.arrow` will become the tooltip's arrow. - * The outermost wrapper element should have the `.tooltip` class and `role="tooltip"`. + * Base HTML to use when creating the tooltip or popover. The tooltip's (resp., popover's) title will be injected into + * the `.tooltip-inner` (resp., `.popover-header`). The `.arrow` will become the tooltip's (resp., popover's) arrow. + * The outermost wrapper element should have the `.tooltip` (resp., .popover) class and `role="tooltip"`. * * @default '' + * @default '' */ template?: string; /** * Default title value if title attribute isn't present. * If a function is given, it will be called with its this reference set to the element - * that the tooltip is attached to. + * that the tooltip or popover is attached to. * * @default "" */ - title?: string | Element | ((this: Element) => string); + title?: string | Element | ((this: Element) => string | Element); /** - * How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. - * 'manual' indicates that the tooltip will be triggered programmatically via the .tooltip('show'), .tooltip('hide') and - * .tooltip('toggle') methods; this value cannot be combined with any other trigger. - * 'hover' on its own will result in tooltips that cannot be triggered via the keyboard, and should only be used if - * alternative methods for conveying the same information for keyboard users is present. + * How tooltip or popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. + * 'manual' indicates that the tooltip will be triggered programmatically; this value cannot be combined with any other trigger. + * 'hover' should only be used if alternative methods for conveying the same information for keyboard users is present. * - * @default "hover focus" + * @default tooltip: "hover focus", popover: "click" */ - trigger?: string; + trigger?: Trigger; /** - * Offset of the tooltip relative to its target. + * Offset of the tooltip or popover relative to its target. * For more information refer to Popper.js's offset docs. * * @default 0 */ - offset?: number | string; + offset?: number | string; /** * Allow to specify which position Popper will use on fallback. @@ -232,24 +280,24 @@ interface BootstrapTooltipOption { * * @default "flip" */ - fallbackPlacement?: PopperBehavior | PopperBehavior[]; + fallbackPlacement?: Popper.Behavior | ReadonlyArray; /** - * Overflow constraint boundary of the tooltip. + * Overflow constraint boundary of the tooltip or popover. * Accepts the values of 'viewport', 'window', 'scrollParent', * or an HTMLElement reference (JavaScript only). * For more information refer to Popper.js's preventOverflow docs. * * @default "scrollParent" */ - boundary?: "viewport" | "window" | "scrollParent" | HTMLElement; + boundary?: Popper.Boundary | HTMLElement; } // -------------------------------------------------------------------------------------- // Events // -------------------------------------------------------------------------------------- -interface BootstrapCarouselEventHandler extends JQuery.Event { +export interface CarouselEventHandler extends JQuery.Event { /** * The direction in which the carousel is sliding. */ @@ -266,34 +314,53 @@ interface BootstrapCarouselEventHandler extends JQuery.Event extends Iterable { - alert(action?: "close" | "dispose"): this; +declare global { + interface JQuery extends Iterable { + alert(action?: "close" | "dispose"): this; - button(action: "toggle" | "dispose"): this; + button(action: "toggle" | "dispose"): this; - carousel(action: "cycle" | "pause" | number | "prev" | "next" | "dispose"): this; - carousel(options?: BootstrapCarouselOption): this; + carousel(action: "cycle" | "pause" | number | "prev" | "next" | "dispose"): this; + carousel(options?: CarouselOption): this; - dropdown(action: "toggle" | "update" | "dispose"): this; - dropdown(options?: BootstrapDropdownOption): this; + collapse(action: "toggle" | "show" | "hide" | "dispose"): this; + collapse(options?: CollapseOption): this; - modal(action: "toggle" | "show" | "hide" | "handleUpdate" | "dispose"): this; - modal(options?: BootstrapModalOption): this; + dropdown(action: "toggle" | "update" | "dispose"): this; + dropdown(options?: DropdownOption): this; - tooltip(action: "show" | "hide" | "toggle" | "dispose" | "enable" | "disable" | "toggleEnabled" | "update"): this; - tooltip(options?: BootstrapTooltipOption): this; + modal(action: "toggle" | "show" | "hide" | "handleUpdate" | "dispose"): this; + modal(options?: ModalOption): this; - on(events: BootstrapCarouselEvent, handler: JQuery.EventHandlerBase>): this; - on(events: BootstrapAlertEvent | BootstrapDropdownEvent | BootstrapModalEvent | BootstrapTooltipEvent, - handler: JQuery.EventHandler): this; + popover(action: "show" | "hide" | "toggle" | "dispose" | "enable" | "disable" | "toggleEnabled" | "update"): this; + popover(options?: PopoverOption): this; + + scrollspy(action: "refresh" | "dispose"): this; + scrollspy(options?: ScrollspyOption): this; + + tab(action: "show" | "dispose"): this; + + tooltip(action: "show" | "hide" | "toggle" | "dispose" | "enable" | "disable" | "toggleEnabled" | "update"): this; + tooltip(options?: TooltipOption): this; + + on(events: CarouselEvent, handler: JQuery.EventHandlerBase>): this; + on(events: + AlertEvent | CollapseEvent | DropdownEvent | ModalEvent | + PopoverEvent | ScrollspyEvent | TapEvent | TooltipEvent, + handler: JQuery.EventHandler): this; + } } diff --git a/types/bootstrap/package.json b/types/bootstrap/package.json new file mode 100644 index 0000000000..af84860ef1 --- /dev/null +++ b/types/bootstrap/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "popper.js": "^1.14.1" + } +} \ No newline at end of file diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index 97844cfbbb..c07c938630 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -167,6 +167,11 @@ declare namespace Bull { * End date when the repeat job should stop repeating */ endDate?: Date | string | number; + + /** + * Number of times the job should repeat at max. + */ + limit?: number; } interface JobOptions { @@ -273,18 +278,30 @@ declare namespace Bull { * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path has several advantages: + * - The process is sandboxed so if it crashes it does not affect the worker. + * - You can run blocking code without affecting the queue (jobs will not stall). + * - Much better utilization of multi-core CPUs. + * - Less connections to redis. * * A promise must be returned to signal job completion. * If the promise is rejected, the error will be passed as a second argument to the "failed" event. * If it is resolved, its value will be the "completed" event's second argument. */ - process(callback: (job: Job) => void): Promise; + process(callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue. * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path has several advantages: + * - The process is sandboxed so if it crashes it does not affect the worker. + * - You can run blocking code without affecting the queue (jobs will not stall). + * - Much better utilization of multi-core CPUs. + * - Less connections to redis. * * A promise must be returned to signal job completion. * If the promise is rejected, the error will be passed as a second argument to the "failed" event. @@ -292,7 +309,7 @@ declare namespace Bull { * * @param concurrency Bull will then call you handler in parallel respecting this max number. */ - process(concurrency: number, callback: (job: Job) => void): Promise; + process(concurrency: number, callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue. @@ -314,6 +331,12 @@ declare namespace Bull { * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path has several advantages: + * - The process is sandboxed so if it crashes it does not affect the worker. + * - You can run blocking code without affecting the queue (jobs will not stall). + * - Much better utilization of multi-core CPUs. + * - Less connections to redis. * * A promise must be returned to signal job completion. * If the promise is rejected, the error will be passed as a second argument to the "failed" event. @@ -322,7 +345,7 @@ declare namespace Bull { * @param name Bull will only call the handler if the job name matches */ // tslint:disable-next-line:unified-signatures - process(name: string, callback: (job: Job) => void): Promise; + process(name: string, callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue. @@ -345,6 +368,12 @@ declare namespace Bull { * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path has several advantages: + * - The process is sandboxed so if it crashes it does not affect the worker. + * - You can run blocking code without affecting the queue (jobs will not stall). + * - Much better utilization of multi-core CPUs. + * - Less connections to redis. * * A promise must be returned to signal job completion. * If the promise is rejected, the error will be passed as a second argument to the "failed" event. @@ -353,7 +382,7 @@ declare namespace Bull { * @param name Bull will only call the handler if the job name matches * @param concurrency Bull will then call you handler in parallel respecting this max number. */ - process(name: string, concurrency: number, callback: (job: Job) => void): Promise; + process(name: string, concurrency: number, callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue. 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/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/d3-contour/d3-contour-tests.ts b/types/d3-contour/d3-contour-tests.ts index ce9d50717f..4563521751 100644 --- a/types/d3-contour/d3-contour-tests.ts +++ b/types/d3-contour/d3-contour-tests.ts @@ -113,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 ba9c8e075d..c0b3d70b5e 100644 --- a/types/d3-contour/index.d.ts +++ b/types/d3-contour/index.d.ts @@ -120,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 @@ -238,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/deepmerge/index.d.ts b/types/deepmerge/index.d.ts index 05f5c96d2e..39158354de 100644 --- a/types/deepmerge/index.d.ts +++ b/types/deepmerge/index.d.ts @@ -1,9 +1,10 @@ -// Type definitions for deepmerge 1.3 +// Type definitions for deepmerge 2.1 // Project: https://github.com/KyleAMathews/deepmerge // Definitions by: marvinscharle // syy1125 +// AppLover69 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 export = deepmerge; @@ -14,6 +15,7 @@ declare namespace deepmerge { interface Options { clone?: boolean; arrayMerge?(destination: any[], source: any[], options?: Options): any[]; + isMergeableObject?(value: object): boolean; } function all(objects: Array>, options?: Options): T; 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/dynogels/index.d.ts b/types/dynogels/index.d.ts index 2e4c5acbf4..4742af5a04 100644 --- a/types/dynogels/index.d.ts +++ b/types/dynogels/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for dynogels 8.0 // Project: https://github.com/clarkie/dynogels#readme // Definitions by: Spartan Labs +// Ramon de Klein // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -76,7 +77,7 @@ export interface Model { getItems(items: string[] | Array<{ [key: string]: string }>, options: GetItemOptions, callback: (err: Error, items: any[]) => void): void; batchGetItems(items: string[] | Array<{ [key: string]: string }>, callback: (err: Error, items: any[]) => void): void; batchGetItems(items: string[] | Array<{ [key: string]: string }>, options: GetItemOptions, callback: (err: Error, items: any[]) => void): void; - createTable(options: { [key: string]: CreateTablesOptions } | DynogelsGlobalOptions, callback: (err: Error, data: AWS.DynamoDB.CreateTableOutput) => void): void; + createTable(options: CreateTablesOptions, callback: (err: Error, data: AWS.DynamoDB.CreateTableOutput) => void): void; createTable(callback: (err: Error, data: AWS.DynamoDB.CreateTableOutput) => void): void; updateTable(throughput: Throughput, callback: (err: Error, data: AWS.DynamoDB.UpdateTableOutput) => void): void; updateTable(callback: (err: Error, data: AWS.DynamoDB.UpdateTableOutput) => void): void; 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/event-kit/index.d.ts b/types/event-kit/index.d.ts index 2208ffaae3..aa0275d8a8 100644 --- a/types/event-kit/index.d.ts +++ b/types/event-kit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for event-kit 2.x +// Type definitions for event-kit 2.4 // Project: https://github.com/atom/event-kit // Definitions by: GlenCFL // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -69,7 +69,8 @@ export class CompositeDisposable implements DisposableLike { * for handlers registered via ::on to be invoked with calls to ::emit. */ // tslint:disable-next-line:no-any -export class Emitter implements DisposableLike { +export class Emitter + implements DisposableLike { disposed: boolean; /** Construct an emitter. */ @@ -83,31 +84,58 @@ export class Emitter implements DisposableLi // Event Subscription /** Registers a handler to be invoked whenever the given event is emitted. */ - on(eventName: T, handler: (value?: Emissions[T]) => void): - Disposable; + on(eventName: T, handler: (value?: + OptionalEmissions[T]) => void): Disposable; + /** Registers a handler to be invoked whenever the given event is emitted. */ + on(eventName: T, handler: (value: + RequiredEmissions[T]) => void): Disposable; /** * Register the given handler function to be invoked the next time an event * with the given name is emitted via ::emit. */ - once(eventName: T, handler: (value?: Emissions[T]) => void): - Disposable; + once(eventName: T, handler: (value?: + OptionalEmissions[T]) => void): Disposable; + /** + * Register the given handler function to be invoked the next time an event + * with the given name is emitted via ::emit. + */ + once(eventName: T, handler: (value: + RequiredEmissions[T]) => void): Disposable; /** * Register the given handler function to be invoked before all other * handlers existing at the time of subscription whenever events by the * given name are emitted via ::emit. */ - preempt(eventName: T, handler: (value?: Emissions[T]) => void): - Disposable; + preempt(eventName: T, handler: (value?: + OptionalEmissions[T]) => void): Disposable; + /** + * Register the given handler function to be invoked before all other + * handlers existing at the time of subscription whenever events by the + * given name are emitted via ::emit. + */ + preempt(eventName: T, handler: (value: + RequiredEmissions[T]) => void): Disposable; // Event Emission /** Invoke the handlers registered via ::on for the given event name. */ - emit(eventName: T, value?: Emissions[T]): void; + emit(eventName: T, value?: + OptionalEmissions[T]): void; + /** Invoke the handlers registered via ::on for the given event name. */ + emit(eventName: T, value: + RequiredEmissions[T]): void; /** * Asynchronously invoke the handlers registered via ::on for the given event name. * @return A promise that will be fulfilled once all handlers have been invoked. */ - emitAsync(eventName: T, value?: Emissions[T]): Promise; + emitAsync(eventName: T, value?: + OptionalEmissions[T]): Promise; + /** + * Asynchronously invoke the handlers registered via ::on for the given event name. + * @return A promise that will be fulfilled once all handlers have been invoked. + */ + emitAsync(eventName: T, value: + RequiredEmissions[T]): Promise; } 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 aead720f5b..d1b543c591 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -289,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 8f0463bf0d..8661cac727 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -1418,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); @@ -1434,6 +1438,8 @@ export namespace ImagePicker { allowsEditing?: boolean; aspect?: [number, number]; quality?: number; + base64?: boolean; + exif?: boolean; mediaTypes?: keyof _MediaTypeOptions; } 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/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/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/generic-pool/generic-pool-tests.ts b/types/generic-pool/generic-pool-tests.ts index 970e83d870..9cc8707c86 100644 --- a/types/generic-pool/generic-pool-tests.ts +++ b/types/generic-pool/generic-pool-tests.ts @@ -41,6 +41,9 @@ const opts = { const pool = genericPool.createPool(factory, opts); +pool.use((conn: Connection) => 'test') + .then((result: string) => { }); + pool.acquire() .then((conn: Connection) => { return pool.release(conn); diff --git a/types/generic-pool/index.d.ts b/types/generic-pool/index.d.ts index 00f8852823..bcfbb907e1 100644 --- a/types/generic-pool/index.d.ts +++ b/types/generic-pool/index.d.ts @@ -22,6 +22,7 @@ export class Pool extends EventEmitter { destroy(resource: T): void; drain(): PromiseLike; clear(): PromiseLike; + use(cb: (resource: T) => U): PromiseLike; } export interface Factory { diff --git a/types/gijgo/index.d.ts b/types/gijgo/index.d.ts index 19d17deb22..188d8753b1 100644 --- a/types/gijgo/index.d.ts +++ b/types/gijgo/index.d.ts @@ -4,7 +4,11 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -declare module Gijgo { +declare module 'gijgo' { + export = Types; +} + +declare module Types { //Grid interface GridPager { @@ -151,8 +155,8 @@ declare module Gijgo { count(): number; destroy(keepTableTag?: boolean, keepWrapperTag?: boolean): void; downloadCSV(filename?: string, includeAllRecords?: boolean): Grid; - edit(id: string): Grid; - expandAll(): 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; @@ -263,7 +267,7 @@ declare module Gijgo { close(): DatePicker; destroy(): void; open(): DatePicker; - value(value: string): string | DatePicker; + value(value?: string): string | DatePicker; } // DropDown @@ -306,7 +310,7 @@ declare module Gijgo { } interface Editor extends JQuery { - content(html: string): string | Editor; + content(html?: string): string | Editor; destroy(): void; } @@ -332,7 +336,7 @@ declare module Gijgo { close(): TimePicker; destroy(): void; open(): TimePicker; - value(value: string): string | TimePicker; + value(value?: string): string | TimePicker; } // Tree @@ -368,7 +372,7 @@ declare module Gijgo { checkedField?: string; cascadeCheck?: boolean; dragAndDrop?: boolean; - paramNames: TreeParamNames; + paramNames?: TreeParamNames; lazyLoading?: boolean; @@ -408,9 +412,9 @@ declare module Gijgo { selectAll() : Tree; unselectAll() : Tree; getSelections() : Array; - getChildren(node: any, cascade: boolean) : Array; - enable(node: any, cascade: boolean) : Tree; - disable(node: any, cascade: boolean) : Tree; + getChildren(node: any, cascade?: boolean) : Array; + enable(node: any, cascade?: boolean) : Tree; + disable(node: any, cascade?: boolean) : Tree; enableAll() : Tree; disableAll() : Tree; @@ -424,21 +428,21 @@ declare module Gijgo { interface JQuery { - grid(settings: Gijgo.GridSettings): Gijgo.Grid; - grid(settings: Gijgo.GridSettings): Gijgo.Grid; - grid(settings: Gijgo.GridSettings): Gijgo.Grid; + grid(settings: Types.GridSettings): Types.Grid; + grid(settings: Types.GridSettings): Types.Grid; + grid(settings: Types.GridSettings): Types.Grid; - dialog(settings: Gijgo.DialogSettings): Gijgo.Dialog; + dialog(settings: Types.DialogSettings): Types.Dialog; - checkbox(settings: Gijgo.CheckboxSettings): Gijgo.Checkbox; + checkbox(settings: Types.CheckboxSettings): Types.Checkbox; - datepicker(settings: Gijgo.DatePickerSettings): Gijgo.DatePicker; + datepicker(settings: Types.DatePickerSettings): Types.DatePicker; - dropdown(settings: Gijgo.DropDownSettings): Gijgo.DropDown; + dropdown(settings: Types.DropDownSettings): Types.DropDown; - editor(settings: Gijgo.EditorSettings): Gijgo.Editor; + editor(settings: Types.EditorSettings): Types.Editor; - timepicker(settings: Gijgo.TimePickerSettings): Gijgo.TimePicker; + timepicker(settings: Types.TimePickerSettings): Types.TimePicker; - tree(settings: Gijgo.TreeSettings): Gijgo.Tree; + tree(settings: Types.TreeSettings): Types.Tree; } diff --git a/types/google-apps-script-oauth2/google-apps-script-oauth2-tests.ts b/types/google-apps-script-oauth2/google-apps-script-oauth2-tests.ts index ca6d874fa4..4bad3291ff 100644 --- a/types/google-apps-script-oauth2/google-apps-script-oauth2-tests.ts +++ b/types/google-apps-script-oauth2/google-apps-script-oauth2-tests.ts @@ -14,8 +14,7 @@ function getDriveService() { .setScope('https://www.googleapis.com/auth/drive') .setParam('login_hint', Session.getActiveUser().getEmail()) .setParam('access_type', 'offline') - .setParam('approval_prompt', 'force') - ; + .setParam('approval_prompt', 'force'); } /** @@ -24,9 +23,5 @@ function getDriveService() { function authCallback(request: any) { const driveService = getDriveService(); const isAuthorized = driveService.handleCallback(request); - if (isAuthorized) { - Logger.log('success'); - } else { - Logger.log('denied'); - } + Logger.log(isAuthorized ? 'success' : 'denied'); } diff --git a/types/googlemaps/index.d.ts b/types/googlemaps/index.d.ts index 526f5b7e06..5c4cca2eb3 100644 --- a/types/googlemaps/index.d.ts +++ b/types/googlemaps/index.d.ts @@ -392,8 +392,8 @@ declare namespace google.maps { export module Data { export interface DataOptions { controlPosition?: ControlPosition; - controls?: string[]; - drawingMode?: string; + controls?: DrawingMode[] | null; + drawingMode?: DrawingMode | null; featureFactory?: (geometry: Data.Geometry) => Data.Feature; map?: Map; style?: Data.StylingFunction|Data.StyleOptions; @@ -1863,7 +1863,8 @@ declare namespace google.maps { getZIndex(): number; setMap(map: Map | null): void; setUrl(url: string): void; - setZIndez(zIndex: number): void; + setZIndex(zIndex: number): void; + setOptions(options: KmlLayerOptions): void; } export interface KmlLayerOptions { 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-relay/index.d.ts b/types/graphql-relay/index.d.ts index 50ed0c3b7d..fc1eb3aa1e 100644 --- a/types/graphql-relay/index.d.ts +++ b/types/graphql-relay/index.d.ts @@ -21,6 +21,9 @@ import { GraphQLOutputType, GraphQLFieldResolver, GraphQLTypeResolver, + GraphQLUnionType, + GraphQLEnumType, + GraphQLScalarType, Thunk } from "graphql"; @@ -58,9 +61,20 @@ export const backwardConnectionArgs: GraphQLFieldConfigArgumentMap & { */ export const connectionArgs: GraphQLFieldConfigArgumentMap & ForwardConnectionArgs & BackwardConnectionArgs; +export type ConnectionConfigNodeTypeNullable = + | GraphQLScalarType + | GraphQLObjectType + | GraphQLInterfaceType + | GraphQLUnionType + | GraphQLEnumType; + +export type ConnectionConfigNodeType = + | ConnectionConfigNodeTypeNullable + | GraphQLNonNull; + export interface ConnectionConfig { name?: string | null; - nodeType: GraphQLObjectType; + nodeType: ConnectionConfigNodeType; resolveNode?: GraphQLFieldResolver | null; resolveCursor?: GraphQLFieldResolver | null; edgeFields?: Thunk> | null; diff --git a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts index 519a3a4088..9043cdaf0e 100644 --- a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts +++ b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts @@ -16,6 +16,14 @@ interface SomeTestResult { someTestResultProp: string; } +const batchFunction = (sources: ReadonlyArray) => { + const someTestResult: SomeTestResult = { + someTestResultProp: "Hello" + }; + + return sources.map(source => someTestResult); +}; + const asyncBatchFunction = async (sources: ReadonlyArray) => { return new Promise(resolve => { const res = [ @@ -27,19 +35,35 @@ const asyncBatchFunction = async (sources: ReadonlyArray) => { }); }; +const asyncBatchFunctionWhenTReturnIsArray = async ( + sources: ReadonlyArray +) => { + const sourceBatches = sources.map(() => { + return new Promise(resolve => { + const res = [ + { + someTestResultProp: "" + } + ]; + resolve(res); + }); + }); + + return Promise.all(sourceBatches); +}; + +// $ExpectType ResolverFunction const withSourceAndResultTyped = createBatchResolver< SomeTestSource, SomeTestResult >((sources, _, __) => { - return sources.map(source => { - const res: SomeTestResult = { - someTestResultProp: "" - }; + // $ExpectType ReadonlyArray + const verifySources = sources; - return res; - }); + return batchFunction(sources); }); +// $ExpectType ResolverFunction const withSourceAndResultTypedAsPromise = createBatchResolver< SomeTestSource, SomeTestResult @@ -50,6 +74,7 @@ const withSourceAndResultTypedAsPromise = createBatchResolver< return result; }); +// $ExpectType ResolverFunction const withSourceAndArgsAndResultTyped = createBatchResolver< SomeTestSource, SomeTestResult, @@ -64,6 +89,7 @@ const withSourceAndArgsAndResultTyped = createBatchResolver< return result; }); +// $ExpectType ResolverFunction const withSourceAndArgsAndContextTyped = createBatchResolver< SomeTestSource, SomeTestResult, @@ -80,3 +106,13 @@ const withSourceAndArgsAndContextTyped = createBatchResolver< const result = await asyncBatchFunction(sources); return result; }); + +// $ExpectType ResolverFunction +const withResultIsArray = createBatchResolver( + (sources, _, __) => { + // $ExpectType ReadonlyArray + const verifySources = sources; + + return asyncBatchFunctionWhenTReturnIsArray(sources); + } +); diff --git a/types/graphql-resolve-batch/index.d.ts b/types/graphql-resolve-batch/index.d.ts index e78ddafb37..ea90a83555 100644 --- a/types/graphql-resolve-batch/index.d.ts +++ b/types/graphql-resolve-batch/index.d.ts @@ -4,6 +4,22 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +/** + * Creates a GraphQL.js field resolver that batches together multiple resolves + * together that share the *exact* same GraphQL field selection. + * + * Note: + * The batchResolveFunction you supply always expects you to return an array of TReturn (or a promise with this array). + * This is because you will have to return a TReturn for every source given to you by the batch function. + * For an example of this please see the examples in the original project repository: + * https://github.com/calebmer/graphql-resolve-batch/tree/master/examples + * + * @template TSource The original type of a single source. + * @template TReturn The return type of the field resolver. + * @template TArgs The type of supplied arguments. + * @template TContext The type of the current resolver context. + * @param batchResolveFn A batch function to resolve all fields for the given sources in a single batch. + */ export function createBatchResolver< TSource, TReturn, @@ -13,12 +29,19 @@ export function createBatchResolver< batchResolveFn: BatchResolveFunction ): ResolverFunction; +/** + * The resulting field resolver that batches together multiple resolves. + * Graphql-resolve-batch will always return a promise for this resulting resolver. + */ export type ResolverFunction = ( source: TSource, args: TArgs, context: TContext -) => Promise | Promise; +) => Promise; +/** + * A batch function to resolve all fields for the given sources in a single batch. + */ export type BatchResolveFunction = ( sources: ReadonlyArray, args: TArgs, 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/index.d.ts b/types/hapi/index.d.ts index 210e1cc332..3628a7a931 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; @@ -1706,7 +1706,7 @@ export interface RouteOptions { * * credentials - if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscors) */ - cors?: false | RouteOptionsCors; + cors?: boolean | RouteOptionsCors; /** * Default value: none. @@ -2586,7 +2586,7 @@ export interface ServerInjectOptions extends Shot.RequestOptions { /** * sets the initial value of request.app, defaults to {}. */ - app?: ApplicationState; + app: ApplicationState; /** * sets the initial value of request.plugins, defaults to {}. */ @@ -3257,7 +3257,7 @@ export class Server extends Podium { * Initialized with an empty object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp) */ - app?: ApplicationState; + app: ApplicationState; /** * Server Auth: properties and methods diff --git a/types/hapi/test/server/server-app.ts b/types/hapi/test/server/server-app.ts index 8e9cff88b0..69bac86e2f 100644 --- a/types/hapi/test/server/server-app.ts +++ b/types/hapi/test/server/server-app.ts @@ -6,20 +6,20 @@ const options: ServerOptions = { }; declare module "hapi" { - // Demonstrate augmenting the application state. - interface ApplicationState { - key?: string; - } + // Demonstrate augmenting the application state. + interface ApplicationState { + key?: string; + } } const server = new Server(options); -server.app!.key = 'value2'; +server.app.key = 'value2'; const serverRoute: ServerRoute = { path: '/', method: 'GET', handler(request, h) { - return 'key: ' + request.server.app!.key; + return 'key: ' + request.server.app.key; } }; 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/hapi/test/server/server-table.ts b/types/hapi/test/server/server-table.ts index 9237a2be28..ab14938be4 100644 --- a/types/hapi/test/server/server-table.ts +++ b/types/hapi/test/server/server-table.ts @@ -6,7 +6,7 @@ const options: ServerOptions = { }; const server = new Server(options); -server.app!.key = 'value2'; +server.app.key = 'value2'; server.route({ path: '/', 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/html-void-elements/html-void-elements-tests.ts b/types/html-void-elements/html-void-elements-tests.ts new file mode 100644 index 0000000000..584c353455 --- /dev/null +++ b/types/html-void-elements/html-void-elements-tests.ts @@ -0,0 +1,3 @@ +import voidElements = require('html-void-elements'); + +voidElements.indexOf('br'); diff --git a/types/html-void-elements/index.d.ts b/types/html-void-elements/index.d.ts new file mode 100644 index 0000000000..47f903aad0 --- /dev/null +++ b/types/html-void-elements/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for html-void-elements 1.0 +// Project: https://github.com/wooorm/html-void-elements +// Definitions by: rhysd +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare const TagNames: string[]; +export = TagNames; diff --git a/types/html-void-elements/tsconfig.json b/types/html-void-elements/tsconfig.json new file mode 100644 index 0000000000..964e5ebdd2 --- /dev/null +++ b/types/html-void-elements/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", + "html-void-elements-tests.ts" + ] +} diff --git a/types/html-void-elements/tslint.json b/types/html-void-elements/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/html-void-elements/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } 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 37141876a7..7c4e9a1f2e 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -4,20 +4,21 @@ // Parvez // Jouderian // Qibang +// Jason Dreyzehner // Synarque // 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[] + | ReadonlyArray> | Rx.Observable>; interface Inquirer { @@ -97,7 +98,10 @@ declare namespace inquirer { * 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: T) => ChoiceType[]) | ((answers: T) => Promise); + choices?: + | ReadonlyArray + | ((answers: T) => ReadonlyArray); + | ((answers: T) => Promise>); /** * 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. @@ -254,11 +258,11 @@ declare namespace inquirer { */ interface Choices { new ( - choices: (string | Separator | ChoiceOption)[], + choices: ReadonlyArray, answers?: T ): Choices; - choices: Choice[]; - realChoices: Choice[]; + choices: ReadonlyArray; + realChoices: ReadonlyArray; length: number; realLength: number; /** diff --git a/types/inquirer/inquirer-tests.ts b/types/inquirer/inquirer-tests.ts index bd1d6a5ac4..7cc0fddd2a 100644 --- a/types/inquirer/inquirer-tests.ts +++ b/types/inquirer/inquirer-tests.ts @@ -563,3 +563,24 @@ function likesFood(aFood: string) { inquirer.prompt(questions, function(answers) { console.log(JSON.stringify(answers, null, " ")); }); + +// immutable usage +const immutableChoices: ReadonlyArray = [ + 'Order a pizza', + 'Make a reservation', + 'Ask opening hours', + 'Talk to the receptionist' +]; +inquirer.prompt( + [ + { + type: 'rawlist', + name: 'theme', + message: 'What do you want to do?', + choices: immutableChoices + } + ], + function(answers: inquirer.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/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/json-schema/index.d.ts b/types/json-schema/index.d.ts index 7f02b671a0..4c483dd42d 100644 --- a/types/json-schema/index.d.ts +++ b/types/json-schema/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for json-schema 4.0 and 6.0 // Project: https://www.npmjs.com/package/json-schema -// Definitions by: Boris Cherny , Cyrille Tuzi +// Definitions by: Boris Cherny +// Cyrille Tuzi +// Lucian Buzzo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -197,6 +199,8 @@ export interface JSONSchema4 { * @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-5.6 */ [k: string]: any + + format?: string } /* JSON Schema 6 */ @@ -470,4 +474,9 @@ export interface JSONSchema6 { * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4 */ examples?: JSONSchema6Type[] + + /** + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-8 + */ + format?: string } diff --git a/types/json-schema/json-schema-tests.ts b/types/json-schema/json-schema-tests.ts index 0fd15f5de9..fdfe4d0435 100644 --- a/types/json-schema/json-schema-tests.ts +++ b/types/json-schema/json-schema-tests.ts @@ -64,7 +64,8 @@ import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSch oneOf: [{}], not: {}, extends: 'foo', - bar: 4 + bar: 4, + format: 'date-time' } } @@ -134,6 +135,7 @@ import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSch const: 'foo', contains: {}, examples: [{}], - propertyNames: {} + propertyNames: {}, + format: 'date-time' } } diff --git a/types/json2csv/JSON2CSVBase.d.ts b/types/json2csv/JSON2CSVBase.d.ts index 165497b4c8..d65a3cc297 100644 --- a/types/json2csv/JSON2CSVBase.d.ts +++ b/types/json2csv/JSON2CSVBase.d.ts @@ -10,9 +10,9 @@ export declare namespace json2csv { } export interface Options { - fields?: (string | FieldInfo); + fields?: Array>; ndjson?: boolean; - unwind?: string | string[]; + unwind?: string | Array; flatten?: boolean; defaultValue?: string; quote?: string; diff --git a/types/json2csv/json2csv-tests.ts b/types/json2csv/json2csv-tests.ts index 566cc06cee..67c46cd1c3 100644 --- a/types/json2csv/json2csv-tests.ts +++ b/types/json2csv/json2csv-tests.ts @@ -17,9 +17,27 @@ parse({}); parse([]); parse({}, {}); +interface Car { + car: string; + price: number; +} + new Parser(); const parser: Parser = new Parser({}); s = parser.parse({ str: '', num: 1, obj: {} }); + +const opts: json2csv.Options = { + fields: [{ + label: 'Car Name', + value: 'car' + }, { + label: 'Price USD', + value: 'price' + }] +}; + +const json2csvParser = new Parser(opts); + parser.parse([]); const transform: Transform = new Transform({ quote: '' }); const nodeTransform: NodeTransform = transform; diff --git a/types/jsonwebtoken/index.d.ts b/types/jsonwebtoken/index.d.ts index 26e223df53..ddb2a3f6c3 100644 --- a/types/jsonwebtoken/index.d.ts +++ b/types/jsonwebtoken/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jsonwebtoken 7.2.1 +// Type definitions for jsonwebtoken 7.2.2 // Project: https://github.com/auth0/node-jsonwebtoken // Definitions by: Maxime LUCE , // Daniel Heim , @@ -167,4 +167,4 @@ declare function verify( declare function decode( token: string, options?: DecodeOptions, -): null | object | string; +): null | { [key: string]: any } | string; diff --git a/types/jsonwebtoken/jsonwebtoken-tests.ts b/types/jsonwebtoken/jsonwebtoken-tests.ts index 0b04c23e63..f20fbba5cc 100644 --- a/types/jsonwebtoken/jsonwebtoken-tests.ts +++ b/types/jsonwebtoken/jsonwebtoken-tests.ts @@ -11,39 +11,44 @@ var token: string; var cert: Buffer; interface ITestObject { - 'foo': string + foo: string; } -const testObject = { foo: 'bar' } +const testObject = { foo: "bar" }; /** * jwt.sign * https://github.com/auth0/node-jsonwebtoken#usage */ // sign with default (HMAC SHA256) -token = jwt.sign(testObject, 'shhhhh'); +token = jwt.sign(testObject, "shhhhh"); // sign with default (HMAC SHA256) and single audience -token = jwt.sign(testObject, 'shhhhh', { audience: "theAudience"}); +token = jwt.sign(testObject, "shhhhh", { audience: "theAudience" }); // sign with default (HMAC SHA256) and multiple audiences -token = jwt.sign(testObject, 'shhhhh', { audience: ["audience1", "audience2"]}); +token = jwt.sign(testObject, "shhhhh", { + audience: ["audience1", "audience2"], +}); // sign with default (HMAC SHA256) and a keyid -token = jwt.sign(testObject, 'shhhhh', { keyid: "theKeyId"}); +token = jwt.sign(testObject, "shhhhh", { keyid: "theKeyId" }); // sign with RSA SHA256 -cert = fs.readFileSync('private.key'); // get private key -token = jwt.sign(testObject, cert, { algorithm: 'RS256'}); +cert = fs.readFileSync("private.key"); // get private key +token = jwt.sign(testObject, cert, { algorithm: "RS256" }); // sign with encrypted RSA SHA256 private key (only PEM encoding is supported) -const privKey: Buffer = fs.readFileSync('encrypted_private.key'); // get private key -const secret = {key: privKey.toString(), passphrase: 'keypwd'} -token = jwt.sign(testObject, secret, { algorithm: 'RS256' }); // the algorithm option is mandatory in this case +const privKey: Buffer = fs.readFileSync("encrypted_private.key"); // get private key +const secret = { key: privKey.toString(), passphrase: "keypwd" }; +token = jwt.sign(testObject, secret, { algorithm: "RS256" }); // the algorithm option is mandatory in this case // sign asynchronously -jwt.sign(testObject, cert, { algorithm: 'RS256' }, function(err: Error, token: string) { - console.log(token); +jwt.sign(testObject, cert, { algorithm: "RS256" }, function( + err: Error, + token: string, +) { + console.log(token); }); /** @@ -51,10 +56,10 @@ jwt.sign(testObject, cert, { algorithm: 'RS256' }, function(err: Error, token: s * https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback */ // verify a token symmetric -jwt.verify(token, 'shhhhh', function(err, decoded) { - const result = decoded as ITestObject +jwt.verify(token, "shhhhh", function(err, decoded) { + const result = decoded as ITestObject; - console.log(result.foo) // bar + console.log(result.foo); // bar }); // use external time for verifying @@ -65,41 +70,44 @@ jwt.verify(token, 'shhhhh', { clockTimestamp: 1 }, function(err, decoded) { }); // invalid token -jwt.verify(token, 'wrong-secret', function(err, decoded) { - // err - // decoded undefined +jwt.verify(token, "wrong-secret", function(err, decoded) { + // err + // decoded undefined }); // verify a token asymmetric -cert = fs.readFileSync('public.pem'); // get public key -jwt.verify(token, cert, function (err, decoded) { - const result = decoded as ITestObject +cert = fs.readFileSync("public.pem"); // get public key +jwt.verify(token, cert, function(err, decoded) { + const result = decoded as ITestObject; - console.log(result.foo) // bar + console.log(result.foo); // bar }); // verify audience -cert = fs.readFileSync('public.pem'); // get public key -jwt.verify(token, cert, { audience: 'urn:foo' }, function(err, decoded) { - // if audience mismatch, err == invalid audience +cert = fs.readFileSync("public.pem"); // get public key +jwt.verify(token, cert, { audience: "urn:foo" }, function(err, decoded) { + // if audience mismatch, err == invalid audience }); // verify issuer -cert = fs.readFileSync('public.pem'); // get public key -jwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer' }, function(err, decoded) { - // if issuer mismatch, err == invalid issuer +cert = fs.readFileSync("public.pem"); // get public key +jwt.verify(token, cert, { audience: "urn:foo", issuer: "urn:issuer" }, function( + err, + decoded, +) { + // if issuer mismatch, err == invalid issuer }); // verify algorithm -cert = fs.readFileSync('public.pem'); // get public key -jwt.verify(token, cert, { algorithms: ['RS256'] }, function(err, decoded) { - // if algorithm mismatch, err == invalid algorithm +cert = fs.readFileSync("public.pem"); // get public key +jwt.verify(token, cert, { algorithms: ["RS256"] }, function(err, decoded) { + // if algorithm mismatch, err == invalid algorithm }); // verify without expiration check -cert = fs.readFileSync('public.pem'); // get public key +cert = fs.readFileSync("public.pem"); // get public key jwt.verify(token, cert, { ignoreExpiration: true }, function(err, decoded) { - // if ignoreExpration == false and token is expired, err == expired token + // if ignoreExpration == false and token is expired, err == expired token }); /** @@ -110,6 +118,10 @@ var decoded = jwt.decode(token); decoded = jwt.decode(token, { complete: false }); +if (decoded !== null && typeof decoded === "object") { + console.log(decoded.foo); +} + decoded = jwt.decode(token, { json: false }); decoded = jwt.decode(token, { complete: false, json: false }); diff --git a/types/jss/index.d.ts b/types/jss/index.d.ts index d0136216ed..0f77605b2c 100644 --- a/types/jss/index.d.ts +++ b/types/jss/index.d.ts @@ -5,6 +5,10 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 +export interface ToCssOptions { + indent?: number; +} + export interface Rule { className: string; selector: string; @@ -62,7 +66,7 @@ export interface StyleSheet { /** * Convert rules to a CSS string. */ - toString(options?: { indent?: number }): string; + toString(options?: ToCssOptions): string; } export type GenerateClassName = (rule: Rule, sheet?: StyleSheet) => string; export interface Style { @@ -96,6 +100,15 @@ export interface RuleOptions { index: number; className: string; } +export declare class SheetsRegistry { + constructor(); + registry: ReadonlyArray>; + readonly index: number; + add(sheet: StyleSheet): void; + reset(): void; + remove(sheet: StyleSheet): void; + toString(options?: ToCssOptions): string; +} declare class JSS { constructor(options?: Partial); createStyleSheet( diff --git a/types/jss/jss-tests.ts b/types/jss/jss-tests.ts index 0cf3f51350..a5c6f34126 100644 --- a/types/jss/jss-tests.ts +++ b/types/jss/jss-tests.ts @@ -2,7 +2,8 @@ import { create as createJSS, - default as sharedInstance + SheetsRegistry, + default as sharedInstance, } from 'jss'; const jss = createJSS().setup({}); @@ -21,28 +22,30 @@ const styleSheet = jss.createStyleSheet( { link: true, } -).attach(); +); -styleSheet.classes.container; // $ExpectType string -styleSheet.classes.ruleWithMockObservable; // $ExpectType string +const attachedStyleSheet = styleSheet.attach(); -const rule = styleSheet.addRule('dynamicRule', { color: 'indigo' }); +attachedStyleSheet.classes.container; // $ExpectType string +attachedStyleSheet.classes.ruleWithMockObservable; // $ExpectType string + +const rule = attachedStyleSheet.addRule('dynamicRule', { color: 'indigo' }); rule.prop('border-radius', 5).prop('color'); // $ExpectType string -styleSheet.classes.dynamicRule; // $ExpectType string +attachedStyleSheet.classes.dynamicRule; // $ExpectType string -styleSheet.deleteRule('dynamicRule'); +attachedStyleSheet.deleteRule('dynamicRule'); // test that `addRule` supports the shorthand signature -const dynamicRule = styleSheet.addRule({ color: 'red' }); +const dynamicRule = attachedStyleSheet.addRule({ color: 'red' }); const div = document.createElement('div'); dynamicRule.applyTo(div); -const containerRule = styleSheet.getRule('container'); +const containerRule = attachedStyleSheet.getRule('container'); const containerJSON = containerRule.toJSON(); -const css = styleSheet.toString(); +const css = attachedStyleSheet.toString(); -styleSheet.addRules({ +attachedStyleSheet.addRules({ rule1: { fontFamily: 'Roboto', color: '#FFFFFF', @@ -53,10 +56,42 @@ styleSheet.addRules({ }, }); -styleSheet.detach(); +attachedStyleSheet.detach(); sharedInstance.createStyleSheet({ container: { background: '#000099', } }); + +/* SheetsRegistry test */ +const sheetsRegistry = new SheetsRegistry(); +sheetsRegistry.add(styleSheet); + +const secondStyleSheet = jss.createStyleSheet( + { + ruleWithMockObservable: { + subscribe() {} + }, + container2: { + display: 'flex', + width: 150, + opacity: .8, + }, + }, + { + link: true, + } +); + +sheetsRegistry.add(secondStyleSheet); +sheetsRegistry.registry.length; // $ExpectType number +sheetsRegistry.remove(secondStyleSheet); + +sheetsRegistry.index; // $ExpectType number +sheetsRegistry.index = 5; // $ExpectError +sheetsRegistry.toString(); // $ExpectType string +// With css options +sheetsRegistry.toString({indent: 5}); // $ExpectType string + +sheetsRegistry.reset(); 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/knex/index.d.ts b/types/knex/index.d.ts index eecfde8774..1d405f54b0 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -153,6 +153,7 @@ declare namespace Knex { pluck(column: string): QueryBuilder; insert(data: any, returning?: string | string[]): QueryBuilder; + modify(callback: QueryCallback, ...args: any[]): QueryBuilder; update(data: any, returning?: string | string[]): QueryBuilder; update(columnName: string, value: Value, returning?: string | string[]): QueryBuilder; returning(column: string | string[]): QueryBuilder; @@ -403,6 +404,7 @@ declare namespace Knex { interface SchemaBuilder extends Bluebird { createTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): SchemaBuilder; createTableIfNotExists(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): SchemaBuilder; + alterTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): SchemaBuilder; renameTable(oldTableName: string, newTableName: string): Bluebird; dropTable(tableName: string): SchemaBuilder; hasTable(tableName: string): Bluebird; diff --git a/types/knex/knex-tests.ts b/types/knex/knex-tests.ts index 3e8e798212..1afd65ef6d 100644 --- a/types/knex/knex-tests.ts +++ b/types/knex/knex-tests.ts @@ -763,6 +763,10 @@ knex.schema.createTable('users', function (table) { table.timestamps(true, true); }); +knex.schema.alterTable('users', function (table) { + table.string('role').nullable(); +}); + knex.schema.renameTable('users', 'old_users'); knex.schema.dropTable('users'); @@ -1026,6 +1030,9 @@ knex('users') }).unionAll(function(builder) { let self: Knex.QueryBuilder = this; self = builder; + }).modify(function(builder) { + let self: Knex.QueryBuilder = this; + self = builder; }); // 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/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/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/ndarray/index.d.ts b/types/ndarray/index.d.ts index eb889d31af..039401b6e2 100644 --- a/types/ndarray/index.d.ts +++ b/types/ndarray/index.d.ts @@ -24,7 +24,7 @@ interface ndarray { hi(...args: number[]): ndarray; step(...args: number[]): ndarray; transpose(...args: number[]): ndarray; - pick(...args: number[]): ndarray; + pick(...args: Array): ndarray; reshape(...shapes: number[]): ndarray; T: ndarray; } diff --git a/types/ndarray/ndarray-tests.ts b/types/ndarray/ndarray-tests.ts index aa4f4fcefb..09bd7b2f00 100644 --- a/types/ndarray/ndarray-tests.ts +++ b/types/ndarray/ndarray-tests.ts @@ -22,3 +22,5 @@ console.log(a.get(0, 0, 0) === 1); console.log(a.index(1, 1, 1) === 12); const b = a.lo(0, 0, 0).hi(1, 1, 1); + +a.pick(null, null, 1); diff --git a/types/openlayers/index.d.ts b/types/openlayers/index.d.ts index 3c87320827..9dc5461f5e 100644 --- a/types/openlayers/index.d.ts +++ b/types/openlayers/index.d.ts @@ -11,34 +11,56 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions partially generated using tsd-jsdoc (https://github.com/englercj/tsd-jsdoc) -interface GlobalObject { [key: string]: any; } +export as namespace ol; -declare namespace ol { +export interface GlobalObject { [key: string]: any; } + +/** + * Error object thrown when an assertion failed. This is an ECMA-262 Error, + * extended with a `code` property. + * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error} + * @param code Error code. + */ +export class AssertionError extends Error { /** * Error object thrown when an assertion failed. This is an ECMA-262 Error, * extended with a `code` property. * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error} * @param code Error code. */ - class AssertionError extends Error { - /** - * Error object thrown when an assertion failed. This is an ECMA-262 Error, - * extended with a `code` property. - * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error} - * @param code Error code. - */ - constructor(code: number); + constructor(code: number); - /** - * Error code. The meaning of the code can be found on - * {@link http://openlayers.org/en/latest/errors.html} (replace `latest` with - * the version found in the OpenLayers script's header comment if a version - * other than the latest is used). - * @api - */ - code: number; - } + /** + * Error code. The meaning of the code can be found on + * {@link http://openlayers.org/en/latest/errors.html} (replace `latest` with + * the version found in the OpenLayers script's header comment if a version + * other than the latest is used). + * @api + */ + code: number; +} +/** + * @classdesc + * An attribution for a layer source. + * + * Example: + * + * source: new ol.source.OSM({ + * attributions: [ + * new ol.Attribution({ + * html: 'All maps © ' + + * 'OpenCycleMap' + * }), + * ol.source.OSM.ATTRIBUTION + * ], + * .. + * + * @param options Attribution options. + * @struct + * @api stable + */ +export class Attribution { /** * @classdesc * An attribution for a layer source. @@ -59,37 +81,30 @@ declare namespace ol { * @struct * @api stable */ - class Attribution { - /** - * @classdesc - * An attribution for a layer source. - * - * Example: - * - * source: new ol.source.OSM({ - * attributions: [ - * new ol.Attribution({ - * html: 'All maps © ' + - * 'OpenCycleMap' - * }), - * ol.source.OSM.ATTRIBUTION - * ], - * .. - * - * @param options Attribution options. - * @struct - * @api stable - */ - constructor(options: olx.AttributionOptions); + constructor(options: olx.AttributionOptions); - /** - * Get the attribution markup. - * @return The attribution HTML. - * @api stable - */ - getHTML(): string; - } + /** + * Get the attribution markup. + * @return The attribution HTML. + * @api stable + */ + getHTML(): string; +} +/** + * @classdesc + * An expanded version of standard JS Array, adding convenience methods for + * manipulation. Add and remove changes to the Collection trigger a Collection + * event. Note that this does not cover changes to the objects _within_ the + * Collection; they trigger events on the appropriate object, not on the + * Collection as a whole. + * + * @fires ol.Collection.Event + * @param opt_array Array. + * @template T + * @api stable + */ +export class Collection extends Object { /** * @classdesc * An expanded version of standard JS Array, adding convenience methods for @@ -103,127 +118,122 @@ declare namespace ol { * @template T * @api stable */ - class Collection extends ol.Object { - /** - * @classdesc - * An expanded version of standard JS Array, adding convenience methods for - * manipulation. Add and remove changes to the Collection trigger a Collection - * event. Note that this does not cover changes to the objects _within_ the - * Collection; they trigger events on the appropriate object, not on the - * Collection as a whole. - * - * @fires ol.Collection.Event - * @param opt_array Array. - * @template T - * @api stable - */ - constructor(opt_array?: T[]); + constructor(opt_array?: T[]); - /** - * Remove all elements from the collection. - * @api stable - */ - clear(): void; + /** + * Remove all elements from the collection. + * @api stable + */ + clear(): void; - /** - * Add elements to the collection. This pushes each item in the provided array - * to the end of the collection. - * @param arr Array. - * @return This collection. - * @api stable - */ - extend(arr: T[]): ol.Collection; + /** + * Add elements to the collection. This pushes each item in the provided array + * to the end of the collection. + * @param arr Array. + * @return This collection. + * @api stable + */ + extend(arr: T[]): ol.Collection; - /** - * Iterate over each element, calling the provided callback. - * @param f The function to call - * for every element. This function takes 3 arguments (the element, the - * index and the array). The return value is ignored. - * @param opt_this The object to use as `this` in `f`. - * @template S - * @api stable - */ - forEach(f: ((item: T, index: number, array: T[]) => any), opt_this?: S): void; + /** + * Iterate over each element, calling the provided callback. + * @param f The function to call + * for every element. This function takes 3 arguments (the element, the + * index and the array). The return value is ignored. + * @param opt_this The object to use as `this` in `f`. + * @template S + * @api stable + */ + forEach(f: ((item: T, index: number, array: T[]) => any), opt_this?: any): void; - /** - * Get a reference to the underlying Array object. Warning: if the array - * is mutated, no events will be dispatched by the collection, and the - * collection's "length" property won't be in sync with the actual length - * of the array. - * @return Array. - * @api stable - */ - getArray(): T[]; + /** + * Get a reference to the underlying Array object. Warning: if the array + * is mutated, no events will be dispatched by the collection, and the + * collection's "length" property won't be in sync with the actual length + * of the array. + * @return Array. + * @api stable + */ + getArray(): T[]; - /** - * Get the element at the provided index. - * @param index Index. - * @return Element. - * @api stable - */ - item(index: number): T; + /** + * Get the element at the provided index. + * @param index Index. + * @return Element. + * @api stable + */ + item(index: number): T; - /** - * Get the length of this collection. - * @return The length of the array. - * @observable - * @api stable - */ - getLength(): number; + /** + * Get the length of this collection. + * @return The length of the array. + * @observable + * @api stable + */ + getLength(): number; - /** - * Insert an element at the provided index. - * @param index Index. - * @param elem Element. - * @api stable - */ - insertAt(index: number, elem: T): void; + /** + * Insert an element at the provided index. + * @param index Index. + * @param elem Element. + * @api stable + */ + insertAt(index: number, elem: T): void; - /** - * Remove the last element of the collection and return it. - * Return `undefined` if the collection is empty. - * @return Element. - * @api stable - */ - pop(): (T); + /** + * Remove the last element of the collection and return it. + * Return `undefined` if the collection is empty. + * @return Element. + * @api stable + */ + pop(): (T); - /** - * Insert the provided element at the end of the collection. - * @param elem Element. - * @return Length. - * @api stable - */ - push(elem: T): number; + /** + * Insert the provided element at the end of the collection. + * @param elem Element. + * @return Length. + * @api stable + */ + push(elem: T): number; - /** - * Remove the first occurrence of an element from the collection. - * @param elem Element. - * @return The removed element or undefined if none found. - * @api stable - */ - remove(elem: T): (T); + /** + * Remove the first occurrence of an element from the collection. + * @param elem Element. + * @return The removed element or undefined if none found. + * @api stable + */ + remove(elem: T): (T); - /** - * Remove the element at the provided index and return it. - * Return `undefined` if the collection does not contain this index. - * @param index Index. - * @return Value. - * @api stable - */ - removeAt(index: number): (T); + /** + * Remove the element at the provided index and return it. + * Return `undefined` if the collection does not contain this index. + * @param index Index. + * @return Value. + * @api stable + */ + removeAt(index: number): (T); - /** - * Set the element at the provided index. - * @param index Index. - * @param elem Element. - * @api stable - */ - setAt(index: number, elem: T): void; - } + /** + * Set the element at the provided index. + * @param index Index. + * @param elem Element. + * @api stable + */ + setAt(index: number, elem: T): void; +} - namespace Collection { - type EventType = string; +export namespace Collection { + type EventType = string; + /** + * @classdesc + * Events emitted by {@link ol.Collection} instances are instances of this + * type. + * + * @param type Type. + * @param opt_element Element. + */ + class Event extends events.Event { /** * @classdesc * Events emitted by {@link ol.Collection} instances are instances of this @@ -232,65 +242,67 @@ declare namespace ol { * @param type Type. * @param opt_element Element. */ - class Event extends ol.events.Event { - /** - * @classdesc - * Events emitted by {@link ol.Collection} instances are instances of this - * type. - * - * @param type Type. - * @param opt_element Element. - */ - constructor(type: ol.Collection.EventType, opt_element?: any); + constructor(type: EventType, opt_element?: any); - /** - * The element that is added to or removed from the collection. - * @api stable - */ - element: any; - } + /** + * The element that is added to or removed from the collection. + * @api stable + */ + element: any; } +} + +/** + * Colors can be defined as a {@link ol.Color} array, or as strings in + * `rgb(r,g,b)` or `rgba(r,g,b,a)` format, or in hex `#rrggbb` or `#rgb` format. + * Color names, like 'red', 'blue' or 'green', may also be used with the + * Canvas renderer. + * + */ +export namespace color { + /** + * Return the color as an array. This function maintains a cache of calculated + * arrays which means the result should not be modified. + * @param color Color. + * @return Color. + * @api + */ + function asArray(color: (ol.Color | string)): ol.Color; /** - * Colors can be defined as a {@link ol.Color} array, or as strings in - * `rgb(r,g,b)` or `rgba(r,g,b,a)` format, or in hex `#rrggbb` or `#rgb` format. - * Color names, like 'red', 'blue' or 'green', may also be used with the - * Canvas renderer. + * Return the color as an rgba string. + * @param color Color. + * @return Rgba string. + * @api + */ + function asString(color: (ol.Color | string)): string; +} + +/** + * An {@link ol.ColorLike} can be a color, gradient or pattern accepted by + * [CanvasRenderingContext2D.fillStyle](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle). + */ +export namespace colorlike { + /** + * @param color Color. + * @return The color as an ol.ColorLike + * @api + */ + function asColorLike(color: (ol.Color | ol.ColorLike)): ol.ColorLike; +} + +export namespace control { + /** + * @classdesc + * Control to show all the attributions associated with the layer sources + * in the map. This control is one of the default controls included in maps. + * By default it will show in the bottom right portion of the map, but this can + * be changed by using a css selector for `.ol-attribution`. * + * @param opt_options Attribution options. + * @api stable */ - namespace color { - /** - * Return the color as an array. This function maintains a cache of calculated - * arrays which means the result should not be modified. - * @param color Color. - * @return Color. - * @api - */ - function asArray(color: (ol.Color | string)): ol.Color; - - /** - * Return the color as an rgba string. - * @param color Color. - * @return Rgba string. - * @api - */ - function asString(color: (ol.Color | string)): string; - } - - /** - * An {@link ol.ColorLike} can be a color, gradient or pattern accepted by - * [CanvasRenderingContext2D.fillStyle](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle). - */ - namespace colorlike { - /** - * @param color Color. - * @return The color as an ol.ColorLike - * @api - */ - function asColorLike(color: (ol.Color | ol.ColorLike)): ol.ColorLike; - } - - namespace control { + class Attribution extends Control { /** * @classdesc * Control to show all the attributions associated with the layer sources @@ -301,58 +313,74 @@ declare namespace ol { * @param opt_options Attribution options. * @api stable */ - class Attribution extends ol.control.Control { - /** - * @classdesc - * Control to show all the attributions associated with the layer sources - * in the map. This control is one of the default controls included in maps. - * By default it will show in the bottom right portion of the map, but this can - * be changed by using a css selector for `.ol-attribution`. - * - * @param opt_options Attribution options. - * @api stable - */ - constructor(opt_options?: olx.control.AttributionOptions); + constructor(opt_options?: olx.control.AttributionOptions); - /** - * Update the attribution element. - * @param mapEvent Map event. - * @api - */ - static render(mapEvent: ol.MapEvent): void; + /** + * Update the attribution element. + * @param mapEvent Map event. + * @api + */ + static render(mapEvent: ol.MapEvent): void; - /** - * Return `true` if the attribution is collapsible, `false` otherwise. - * @return True if the widget is collapsible. - * @api stable - */ - getCollapsible(): boolean; + /** + * Return `true` if the attribution is collapsible, `false` otherwise. + * @return True if the widget is collapsible. + * @api stable + */ + getCollapsible(): boolean; - /** - * Set whether the attribution should be collapsible. - * @param collapsible True if the widget is collapsible. - * @api stable - */ - setCollapsible(collapsible: boolean): void; + /** + * Set whether the attribution should be collapsible. + * @param collapsible True if the widget is collapsible. + * @api stable + */ + setCollapsible(collapsible: boolean): void; - /** - * Collapse or expand the attribution according to the passed parameter. Will - * not do anything if the attribution isn't collapsible or if the current - * collapsed state is already the one requested. - * @param collapsed True if the widget is collapsed. - * @api stable - */ - setCollapsed(collapsed: boolean): void; + /** + * Collapse or expand the attribution according to the passed parameter. Will + * not do anything if the attribution isn't collapsible or if the current + * collapsed state is already the one requested. + * @param collapsed True if the widget is collapsed. + * @api stable + */ + setCollapsed(collapsed: boolean): void; - /** - * Return `true` when the attribution is currently collapsed or `false` - * otherwise. - * @return True if the widget is collapsed. - * @api stable - */ - getCollapsed(): boolean; - } + /** + * Return `true` when the attribution is currently collapsed or `false` + * otherwise. + * @return True if the widget is collapsed. + * @api stable + */ + getCollapsed(): boolean; + } + /** + * @classdesc + * A control is a visible widget with a DOM element in a fixed position on the + * screen. They can involve user input (buttons), or be informational only; + * the position is determined using CSS. By default these are placed in the + * container with CSS class name `ol-overlaycontainer-stopevent`, but can use + * any outside DOM element. + * + * This is the base class for controls. You can use it for simple custom + * controls by creating the element with listeners, creating an instance: + * ```js + * var myControl = new ol.control.Control({element: myElement}); + * ``` + * and then adding this to the map. + * + * The main advantage of having this as a control rather than a simple separate + * DOM element is that preventing propagation is handled for you. Controls + * will also be `ol.Object`s in a `ol.Collection`, so you can use their + * methods. + * + * You can also extend this base for your own control class. See + * examples/custom-controls for an example of how to do this. + * + * @param options Control options. + * @api stable + */ + class Control extends Object { /** * @classdesc * A control is a visible widget with a DOM element in a fixed position on the @@ -379,63 +407,52 @@ declare namespace ol { * @param options Control options. * @api stable */ - class Control extends ol.Object { - /** - * @classdesc - * A control is a visible widget with a DOM element in a fixed position on the - * screen. They can involve user input (buttons), or be informational only; - * the position is determined using CSS. By default these are placed in the - * container with CSS class name `ol-overlaycontainer-stopevent`, but can use - * any outside DOM element. - * - * This is the base class for controls. You can use it for simple custom - * controls by creating the element with listeners, creating an instance: - * ```js - * var myControl = new ol.control.Control({element: myElement}); - * ``` - * and then adding this to the map. - * - * The main advantage of having this as a control rather than a simple separate - * DOM element is that preventing propagation is handled for you. Controls - * will also be `ol.Object`s in a `ol.Collection`, so you can use their - * methods. - * - * You can also extend this base for your own control class. See - * examples/custom-controls for an example of how to do this. - * - * @param options Control options. - * @api stable - */ - constructor(options: olx.control.ControlOptions); + constructor(options: olx.control.ControlOptions); - /** - * Get the map associated with this control. - * @return Map. - * @api stable - */ - getMap(): ol.Map; + /** + * Get the map associated with this control. + * @return Map. + * @api stable + */ + getMap(): ol.Map; - /** - * Remove the control from its current map and attach it to the new map. - * Subclasses may set up event handlers to get notified about changes to - * the map here. - * @param map Map. - * @api stable - */ - setMap(map: ol.Map): void; + /** + * Remove the control from its current map and attach it to the new map. + * Subclasses may set up event handlers to get notified about changes to + * the map here. + * @param map Map. + * @api stable + */ + setMap(map: ol.Map): void; - /** - * This function is used to set a target element for the control. It has no - * effect if it is called after the control has been added to the map (i.e. - * after `setMap` is called on the control). If no `target` is set in the - * options passed to the control constructor and if `setTarget` is not called - * then the control is added to the map's overlay container. - * @param target Target. - * @api - */ - setTarget(target: (Element | string)): void; - } + /** + * This function is used to set a target element for the control. It has no + * effect if it is called after the control has been added to the map (i.e. + * after `setMap` is called on the control). If no `target` is set in the + * options passed to the control constructor and if `setTarget` is not called + * then the control is added to the map's overlay container. + * @param target Target. + * @api + */ + setTarget(target: (Element | string)): void; + } + /** + * @classdesc + * Provides a button that when clicked fills up the full screen with the map. + * The full screen source element is by default the element containing the map viewport unless + * overriden by providing the `source` option. In which case, the dom + * element introduced using this parameter will be displayed in full screen. + * + * When in full screen mode, a close button is shown to exit full screen mode. + * The [Fullscreen API](http://www.w3.org/TR/fullscreen/) is used to + * toggle the map in full screen mode. + * + * + * @param opt_options Options. + * @api stable + */ + class FullScreen extends Control { /** * @classdesc * Provides a button that when clicked fills up the full screen with the map. @@ -451,39 +468,35 @@ declare namespace ol { * @param opt_options Options. * @api stable */ - class FullScreen extends ol.control.Control { - /** - * @classdesc - * Provides a button that when clicked fills up the full screen with the map. - * The full screen source element is by default the element containing the map viewport unless - * overriden by providing the `source` option. In which case, the dom - * element introduced using this parameter will be displayed in full screen. - * - * When in full screen mode, a close button is shown to exit full screen mode. - * The [Fullscreen API](http://www.w3.org/TR/fullscreen/) is used to - * toggle the map in full screen mode. - * - * - * @param opt_options Options. - * @api stable - */ - constructor(opt_options?: olx.control.FullScreenOptions); - } + constructor(opt_options?: olx.control.FullScreenOptions); + } - /** - * Set of controls included in maps by default. Unless configured otherwise, - * this returns a collection containing an instance of each of the following - * controls: - * * {@link ol.control.Zoom} - * * {@link ol.control.Rotate} - * * {@link ol.control.Attribution} - * - * @param opt_options Defaults options. - * @return Controls. - * @api stable - */ - function defaults(opt_options?: olx.control.DefaultsOptions): ol.Collection; + /** + * Set of controls included in maps by default. Unless configured otherwise, + * this returns a collection containing an instance of each of the following + * controls: + * * {@link ol.control.Zoom} + * * {@link ol.control.Rotate} + * * {@link ol.control.Attribution} + * + * @param opt_options Defaults options. + * @return Controls. + * @api stable + */ + function defaults(opt_options?: olx.control.DefaultsOptions): ol.Collection; + /** + * @classdesc + * A control to show the 2D coordinates of the mouse cursor. By default, these + * are in the view projection, but can be in any supported projection. + * By default the control is shown in the top right corner of the map, but this + * can be changed by using the css selector `.ol-mouse-position`. + * + * @param opt_options Mouse position + * options. + * @api stable + */ + class MousePosition extends Control { /** * @classdesc * A control to show the 2D coordinates of the mouse cursor. By default, these @@ -495,125 +508,123 @@ declare namespace ol { * options. * @api stable */ - class MousePosition extends ol.control.Control { - /** - * @classdesc - * A control to show the 2D coordinates of the mouse cursor. By default, these - * are in the view projection, but can be in any supported projection. - * By default the control is shown in the top right corner of the map, but this - * can be changed by using the css selector `.ol-mouse-position`. - * - * @param opt_options Mouse position - * options. - * @api stable - */ - constructor(opt_options?: olx.control.MousePositionOptions); + constructor(opt_options?: olx.control.MousePositionOptions); - /** - * Update the mouseposition element. - * @param mapEvent Map event. - * @api - */ - static render(mapEvent: ol.MapEvent): void; + /** + * Update the mouseposition element. + * @param mapEvent Map event. + * @api + */ + static render(mapEvent: ol.MapEvent): void; - /** - * Return the coordinate format type used to render the current position or - * undefined. - * @return The format to render the current - * position in. - * @observable - * @api stable - */ - getCoordinateFormat(): (ol.CoordinateFormatType); + /** + * Return the coordinate format type used to render the current position or + * undefined. + * @return The format to render the current + * position in. + * @observable + * @api stable + */ + getCoordinateFormat(): (ol.CoordinateFormatType); - /** - * Return the projection that is used to report the mouse position. - * @return The projection to report mouse - * position in. - * @observable - * @api stable - */ - getProjection(): (ol.proj.Projection); + /** + * Return the projection that is used to report the mouse position. + * @return The projection to report mouse + * position in. + * @observable + * @api stable + */ + getProjection(): (ol.proj.Projection); - /** - * Set the coordinate format type used to render the current position. - * @param format The format to render the current - * position in. - * @observable - * @api stable - */ - setCoordinateFormat(format: ol.CoordinateFormatType): void; + /** + * Set the coordinate format type used to render the current position. + * @param format The format to render the current + * position in. + * @observable + * @api stable + */ + setCoordinateFormat(format: ol.CoordinateFormatType): void; - /** - * Set the projection that is used to report the mouse position. - * @param projection The projection to report mouse - * position in. - * @observable - * @api stable - */ - setProjection(projection: ol.proj.Projection): void; - } + /** + * Set the projection that is used to report the mouse position. + * @param projection The projection to report mouse + * position in. + * @observable + * @api stable + */ + setProjection(projection: ol.proj.Projection): void; + } + /** + * Create a new control with a map acting as an overview map for an other + * defined map. + * @param opt_options OverviewMap options. + * @api + */ + class OverviewMap extends Control { /** * Create a new control with a map acting as an overview map for an other * defined map. * @param opt_options OverviewMap options. * @api */ - class OverviewMap extends ol.control.Control { - /** - * Create a new control with a map acting as an overview map for an other - * defined map. - * @param opt_options OverviewMap options. - * @api - */ - constructor(opt_options?: olx.control.OverviewMapOptions); + constructor(opt_options?: olx.control.OverviewMapOptions); - /** - * Update the overview map element. - * @param mapEvent Map event. - * @api - */ - static render(mapEvent: ol.MapEvent): void; + /** + * Update the overview map element. + * @param mapEvent Map event. + * @api + */ + static render(mapEvent: ol.MapEvent): void; - /** - * Return `true` if the overview map is collapsible, `false` otherwise. - * @return True if the widget is collapsible. - * @api stable - */ - getCollapsible(): boolean; + /** + * Return `true` if the overview map is collapsible, `false` otherwise. + * @return True if the widget is collapsible. + * @api stable + */ + getCollapsible(): boolean; - /** - * Set whether the overview map should be collapsible. - * @param collapsible True if the widget is collapsible. - * @api stable - */ - setCollapsible(collapsible: boolean): void; + /** + * Set whether the overview map should be collapsible. + * @param collapsible True if the widget is collapsible. + * @api stable + */ + setCollapsible(collapsible: boolean): void; - /** - * Collapse or expand the overview map according to the passed parameter. Will - * not do anything if the overview map isn't collapsible or if the current - * collapsed state is already the one requested. - * @param collapsed True if the widget is collapsed. - * @api stable - */ - setCollapsed(collapsed: boolean): void; + /** + * Collapse or expand the overview map according to the passed parameter. Will + * not do anything if the overview map isn't collapsible or if the current + * collapsed state is already the one requested. + * @param collapsed True if the widget is collapsed. + * @api stable + */ + setCollapsed(collapsed: boolean): void; - /** - * Determine if the overview map is collapsed. - * @return The overview map is collapsed. - * @api stable - */ - getCollapsed(): boolean; + /** + * Determine if the overview map is collapsed. + * @return The overview map is collapsed. + * @api stable + */ + getCollapsed(): boolean; - /** - * Return the overview map. - * @return Overview map. - * @api - */ - getOverviewMap(): ol.Map; - } + /** + * Return the overview map. + * @return Overview map. + * @api + */ + getOverviewMap(): ol.Map; + } + /** + * @classdesc + * A button control to reset rotation to 0. + * To style this control use css selector `.ol-rotate`. A `.ol-hidden` css + * selector is added to the button when the rotation is 0. + * + * @param opt_options Rotate options. + * @api stable + */ + class Rotate extends Control { /** * @classdesc * A button control to reset rotation to 0. @@ -623,26 +634,30 @@ declare namespace ol { * @param opt_options Rotate options. * @api stable */ - class Rotate extends ol.control.Control { - /** - * @classdesc - * A button control to reset rotation to 0. - * To style this control use css selector `.ol-rotate`. A `.ol-hidden` css - * selector is added to the button when the rotation is 0. - * - * @param opt_options Rotate options. - * @api stable - */ - constructor(opt_options?: olx.control.RotateOptions); + constructor(opt_options?: olx.control.RotateOptions); - /** - * Update the rotate control element. - * @param mapEvent Map event. - * @api - */ - static render(mapEvent: ol.MapEvent): void; - } + /** + * Update the rotate control element. + * @param mapEvent Map event. + * @api + */ + static render(mapEvent: ol.MapEvent): void; + } + /** + * @classdesc + * A control displaying rough y-axis distances, calculated for the center of the + * viewport. For conformal projections (e.g. EPSG:3857, the default view + * projection in OpenLayers), the scale is valid for all directions. + * No scale line will be shown when the y-axis distance of a pixel at the + * viewport center cannot be calculated in the view projection. + * By default the scale line will show in the bottom left portion of the map, + * but this can be changed by using the css selector `.ol-scale-line`. + * + * @param opt_options Scale line options. + * @api stable + */ + class ScaleLine extends Control { /** * @classdesc * A control displaying rough y-axis distances, calculated for the center of the @@ -656,60 +671,56 @@ declare namespace ol { * @param opt_options Scale line options. * @api stable */ - class ScaleLine extends ol.control.Control { - /** - * @classdesc - * A control displaying rough y-axis distances, calculated for the center of the - * viewport. For conformal projections (e.g. EPSG:3857, the default view - * projection in OpenLayers), the scale is valid for all directions. - * No scale line will be shown when the y-axis distance of a pixel at the - * viewport center cannot be calculated in the view projection. - * By default the scale line will show in the bottom left portion of the map, - * but this can be changed by using the css selector `.ol-scale-line`. - * - * @param opt_options Scale line options. - * @api stable - */ - constructor(opt_options?: olx.control.ScaleLineOptions); + constructor(opt_options?: olx.control.ScaleLineOptions); - /** - * Return the units to use in the scale line. - * @return The units to use in the scale - * line. - * @observable - * @api stable - */ - getUnits(): (ol.control.ScaleLine.Units); + /** + * Return the units to use in the scale line. + * @return The units to use in the scale + * line. + * @observable + * @api stable + */ + getUnits(): (ScaleLine.Units); - /** - * Update the scale line element. - * @param mapEvent Map event. - * @api - */ - static render(mapEvent: ol.MapEvent): void; + /** + * Update the scale line element. + * @param mapEvent Map event. + * @api + */ + static render(mapEvent: ol.MapEvent): void; - /** - * Set the units to use in the scale line. - * @param units The units to use in the scale line. - * @observable - * @api stable - */ - setUnits(units: ol.control.ScaleLine.Units): void; - } + /** + * Set the units to use in the scale line. + * @param units The units to use in the scale line. + * @observable + * @api stable + */ + setUnits(units: ScaleLine.Units): void; + } - namespace ScaleLine { - /** - * @api - */ - type Property = string; + namespace ScaleLine { + /** + * @api + */ + type Property = string; - /** - * Units for the scale line. Supported values are `'degrees'`, `'imperial'`, - * `'nautical'`, `'metric'`, `'us'`. - */ - type Units = "degrees" | "imperial" | "nautical" | "metric" | "us"; - } + /** + * Units for the scale line. Supported values are `'degrees'`, `'imperial'`, + * `'nautical'`, `'metric'`, `'us'`. + */ + type Units = "degrees" | "imperial" | "nautical" | "metric" | "us"; + } + /** + * @classdesc + * A control with 2 buttons, one for zoom in and one for zoom out. + * This control is one of the default controls of a map. To style this control + * use css selectors `.ol-zoom-in` and `.ol-zoom-out`. + * + * @param opt_options Zoom options. + * @api stable + */ + class Zoom extends Control { /** * @classdesc * A control with 2 buttons, one for zoom in and one for zoom out. @@ -719,19 +730,21 @@ declare namespace ol { * @param opt_options Zoom options. * @api stable */ - class Zoom extends ol.control.Control { - /** - * @classdesc - * A control with 2 buttons, one for zoom in and one for zoom out. - * This control is one of the default controls of a map. To style this control - * use css selectors `.ol-zoom-in` and `.ol-zoom-out`. - * - * @param opt_options Zoom options. - * @api stable - */ - constructor(opt_options?: olx.control.ZoomOptions); - } + constructor(opt_options?: olx.control.ZoomOptions); + } + /** + * @classdesc + * A slider type of control for zooming. + * + * Example: + * + * map.addControl(new ol.control.ZoomSlider()); + * + * @param opt_options Zoom slider options. + * @api stable + */ + class ZoomSlider extends Control { /** * @classdesc * A slider type of control for zooming. @@ -743,28 +756,25 @@ declare namespace ol { * @param opt_options Zoom slider options. * @api stable */ - class ZoomSlider extends ol.control.Control { - /** - * @classdesc - * A slider type of control for zooming. - * - * Example: - * - * map.addControl(new ol.control.ZoomSlider()); - * - * @param opt_options Zoom slider options. - * @api stable - */ - constructor(opt_options?: olx.control.ZoomSliderOptions); + constructor(opt_options?: olx.control.ZoomSliderOptions); - /** - * Update the zoomslider element. - * @param mapEvent Map event. - * @api - */ - static render(mapEvent: ol.MapEvent): void; - } + /** + * Update the zoomslider element. + * @param mapEvent Map event. + * @api + */ + static render(mapEvent: ol.MapEvent): void; + } + /** + * @classdesc + * A button control which, when pressed, changes the map view to a specific + * extent. To style this control use the css selector `.ol-zoom-extent`. + * + * @param opt_options Options. + * @api stable + */ + class ZoomToExtent extends Control { /** * @classdesc * A button control which, when pressed, changes the map view to a specific @@ -773,157 +783,202 @@ declare namespace ol { * @param opt_options Options. * @api stable */ - class ZoomToExtent extends ol.control.Control { - /** - * @classdesc - * A button control which, when pressed, changes the map view to a specific - * extent. To style this control use the css selector `.ol-zoom-extent`. - * - * @param opt_options Options. - * @api stable - */ - constructor(opt_options?: olx.control.ZoomToExtentOptions); - } + constructor(opt_options?: olx.control.ZoomToExtentOptions); } +} - namespace coordinate { - /** - * Add `delta` to `coordinate`. `coordinate` is modified in place and returned - * by the function. - * - * Example: - * - * var coord = [7.85, 47.983333]; - * ol.coordinate.add(coord, [-2, 4]); - * // coord is now [5.85, 51.983333] - * - * @param coordinate Coordinate. - * @param delta Delta. - * @return The input coordinate adjusted by the given delta. - * @api stable - */ - function add(coordinate: ol.Coordinate, delta: ol.Coordinate): ol.Coordinate; +export namespace coordinate { + /** + * Add `delta` to `coordinate`. `coordinate` is modified in place and returned + * by the function. + * + * Example: + * + * var coord = [7.85, 47.983333]; + * ol.coordinate.add(coord, [-2, 4]); + * // coord is now [5.85, 51.983333] + * + * @param coordinate Coordinate. + * @param delta Delta. + * @return The input coordinate adjusted by the given delta. + * @api stable + */ + function add(coordinate: ol.Coordinate, delta: ol.Coordinate): ol.Coordinate; - /** - * Returns a {@link ol.CoordinateFormatType} function that can be used to format - * a {ol.Coordinate} to a string. - * - * Example without specifying the fractional digits: - * - * var coord = [7.85, 47.983333]; - * var stringifyFunc = ol.coordinate.createStringXY(); - * var out = stringifyFunc(coord); - * // out is now '8, 48' - * - * Example with explicitly specifying 2 fractional digits: - * - * var coord = [7.85, 47.983333]; - * var stringifyFunc = ol.coordinate.createStringXY(2); - * var out = stringifyFunc(coord); - * // out is now '7.85, 47.98' - * - * @param opt_fractionDigits The number of digits to include - * after the decimal point. Default is `0`. - * @return Coordinate format. - * @api stable - */ - function createStringXY(opt_fractionDigits?: number): ol.CoordinateFormatType; + /** + * Returns a {@link ol.CoordinateFormatType} function that can be used to format + * a {ol.Coordinate} to a string. + * + * Example without specifying the fractional digits: + * + * var coord = [7.85, 47.983333]; + * var stringifyFunc = ol.coordinate.createStringXY(); + * var out = stringifyFunc(coord); + * // out is now '8, 48' + * + * Example with explicitly specifying 2 fractional digits: + * + * var coord = [7.85, 47.983333]; + * var stringifyFunc = ol.coordinate.createStringXY(2); + * var out = stringifyFunc(coord); + * // out is now '7.85, 47.98' + * + * @param opt_fractionDigits The number of digits to include + * after the decimal point. Default is `0`. + * @return Coordinate format. + * @api stable + */ + function createStringXY(opt_fractionDigits?: number): ol.CoordinateFormatType; - /** - * Transforms the given {@link ol.Coordinate} to a string using the given string - * template. The strings `{x}` and `{y}` in the template will be replaced with - * the first and second coordinate values respectively. - * - * Example without specifying the fractional digits: - * - * var coord = [7.85, 47.983333]; - * var template = 'Coordinate is ({x}|{y}).'; - * var out = ol.coordinate.format(coord, template); - * // out is now 'Coordinate is (8|48).' - * - * Example explicitly specifying the fractional digits: - * - * var coord = [7.85, 47.983333]; - * var template = 'Coordinate is ({x}|{y}).'; - * var out = ol.coordinate.format(coord, template, 2); - * // out is now 'Coordinate is (7.85|47.98).' - * - * @param coordinate Coordinate. - * @param template A template string with `{x}` and `{y}` placeholders - * that will be replaced by first and second coordinate values. - * @param opt_fractionDigits The number of digits to include - * after the decimal point. Default is `0`. - * @return Formatted coordinate. - * @api stable - */ - function format(coordinate: (ol.Coordinate), template: string, opt_fractionDigits?: number): string; + /** + * Transforms the given {@link ol.Coordinate} to a string using the given string + * template. The strings `{x}` and `{y}` in the template will be replaced with + * the first and second coordinate values respectively. + * + * Example without specifying the fractional digits: + * + * var coord = [7.85, 47.983333]; + * var template = 'Coordinate is ({x}|{y}).'; + * var out = ol.coordinate.format(coord, template); + * // out is now 'Coordinate is (8|48).' + * + * Example explicitly specifying the fractional digits: + * + * var coord = [7.85, 47.983333]; + * var template = 'Coordinate is ({x}|{y}).'; + * var out = ol.coordinate.format(coord, template, 2); + * // out is now 'Coordinate is (7.85|47.98).' + * + * @param coordinate Coordinate. + * @param template A template string with `{x}` and `{y}` placeholders + * that will be replaced by first and second coordinate values. + * @param opt_fractionDigits The number of digits to include + * after the decimal point. Default is `0`. + * @return Formatted coordinate. + * @api stable + */ + function format(coordinate: (ol.Coordinate), template: string, opt_fractionDigits?: number): string; - /** - * Rotate `coordinate` by `angle`. `coordinate` is modified in place and - * returned by the function. - * - * Example: - * - * var coord = [7.85, 47.983333]; - * var rotateRadians = Math.PI / 2; // 90 degrees - * ol.coordinate.rotate(coord, rotateRadians); - * // coord is now [-47.983333, 7.85] - * - * @param coordinate Coordinate. - * @param angle Angle in radian. - * @return Coordinate. - * @api stable - */ - function rotate(coordinate: ol.Coordinate, angle: number): ol.Coordinate; + /** + * Rotate `coordinate` by `angle`. `coordinate` is modified in place and + * returned by the function. + * + * Example: + * + * var coord = [7.85, 47.983333]; + * var rotateRadians = Math.PI / 2; // 90 degrees + * ol.coordinate.rotate(coord, rotateRadians); + * // coord is now [-47.983333, 7.85] + * + * @param coordinate Coordinate. + * @param angle Angle in radian. + * @return Coordinate. + * @api stable + */ + function rotate(coordinate: ol.Coordinate, angle: number): ol.Coordinate; - /** - * Format a geographic coordinate with the hemisphere, degrees, minutes, and - * seconds. - * - * Example without specifying fractional digits: - * - * var coord = [7.85, 47.983333]; - * var out = ol.coordinate.toStringHDMS(coord); - * // out is now '47° 58′ 60″ N 7° 50′ 60″ E' - * - * Example explicitly specifying 1 fractional digit: - * - * var coord = [7.85, 47.983333]; - * var out = ol.coordinate.toStringHDMS(coord, 1); - * // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E' - * - * @param coordinate Coordinate. - * @param opt_fractionDigits The number of digits to include - * after the decimal point. Default is `0`. - * @return Hemisphere, degrees, minutes and seconds. - * @api stable - */ - function toStringHDMS(coordinate?: ol.Coordinate, opt_fractionDigits?: number): string; + /** + * Format a geographic coordinate with the hemisphere, degrees, minutes, and + * seconds. + * + * Example without specifying fractional digits: + * + * var coord = [7.85, 47.983333]; + * var out = ol.coordinate.toStringHDMS(coord); + * // out is now '47° 58′ 60″ N 7° 50′ 60″ E' + * + * Example explicitly specifying 1 fractional digit: + * + * var coord = [7.85, 47.983333]; + * var out = ol.coordinate.toStringHDMS(coord, 1); + * // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E' + * + * @param coordinate Coordinate. + * @param opt_fractionDigits The number of digits to include + * after the decimal point. Default is `0`. + * @return Hemisphere, degrees, minutes and seconds. + * @api stable + */ + function toStringHDMS(coordinate?: ol.Coordinate, opt_fractionDigits?: number): string; - /** - * Format a coordinate as a comma delimited string. - * - * Example without specifying fractional digits: - * - * var coord = [7.85, 47.983333]; - * var out = ol.coordinate.toStringXY(coord); - * // out is now '8, 48' - * - * Example explicitly specifying 1 fractional digit: - * - * var coord = [7.85, 47.983333]; - * var out = ol.coordinate.toStringXY(coord, 1); - * // out is now '7.8, 48.0' - * - * @param coordinate Coordinate. - * @param opt_fractionDigits The number of digits to include - * after the decimal point. Default is `0`. - * @return XY. - * @api stable - */ - function toStringXY(coordinate?: ol.Coordinate, opt_fractionDigits?: number): string; - } + /** + * Format a coordinate as a comma delimited string. + * + * Example without specifying fractional digits: + * + * var coord = [7.85, 47.983333]; + * var out = ol.coordinate.toStringXY(coord); + * // out is now '8, 48' + * + * Example explicitly specifying 1 fractional digit: + * + * var coord = [7.85, 47.983333]; + * var out = ol.coordinate.toStringXY(coord, 1); + * // out is now '7.8, 48.0' + * + * @param coordinate Coordinate. + * @param opt_fractionDigits The number of digits to include + * after the decimal point. Default is `0`. + * @return XY. + * @api stable + */ + function toStringXY(coordinate?: ol.Coordinate, opt_fractionDigits?: number): string; +} +/** + * @classdesc + * The ol.DeviceOrientation class provides access to information from + * DeviceOrientation events. See the [HTML 5 DeviceOrientation Specification]( + * http://www.w3.org/TR/orientation-event/) for more details. + * + * Many new computers, and especially mobile phones + * and tablets, provide hardware support for device orientation. Web + * developers targeting mobile devices will be especially interested in this + * class. + * + * Device orientation data are relative to a common starting point. For mobile + * devices, the starting point is to lay your phone face up on a table with the + * top of the phone pointing north. This represents the zero state. All + * angles are then relative to this state. For computers, it is the same except + * the screen is open at 90 degrees. + * + * Device orientation is reported as three angles - `alpha`, `beta`, and + * `gamma` - relative to the starting position along the three planar axes X, Y + * and Z. The X axis runs from the left edge to the right edge through the + * middle of the device. Similarly, the Y axis runs from the bottom to the top + * of the device through the middle. The Z axis runs from the back to the front + * through the middle. In the starting position, the X axis points to the + * right, the Y axis points away from you and the Z axis points straight up + * from the device lying flat. + * + * The three angles representing the device orientation are relative to the + * three axes. `alpha` indicates how much the device has been rotated around the + * Z axis, which is commonly interpreted as the compass heading (see note + * below). `beta` indicates how much the device has been rotated around the X + * axis, or how much it is tilted from front to back. `gamma` indicates how + * much the device has been rotated around the Y axis, or how much it is tilted + * from left to right. + * + * For most browsers, the `alpha` value returns the compass heading so if the + * device points north, it will be 0. With Safari on iOS, the 0 value of + * `alpha` is calculated from when device orientation was first requested. + * ol.DeviceOrientation provides the `heading` property which normalizes this + * behavior across all browsers for you. + * + * It is important to note that the HTML 5 DeviceOrientation specification + * indicates that `alpha`, `beta` and `gamma` are in degrees while the + * equivalent properties in ol.DeviceOrientation are in radians for consistency + * with all other uses of angles throughout OpenLayers. + * + * To get notified of device orientation changes, register a listener for the + * generic `change` event on your `ol.DeviceOrientation` instance. + * + * @see {@link http://www.w3.org/TR/orientation-event/} + * + * @param opt_options Options. + * @api + */ +export class DeviceOrientation extends Object { /** * @classdesc * The ol.DeviceOrientation class provides access to information from @@ -977,325 +1032,285 @@ declare namespace ol { * @param opt_options Options. * @api */ - class DeviceOrientation extends ol.Object { - /** - * @classdesc - * The ol.DeviceOrientation class provides access to information from - * DeviceOrientation events. See the [HTML 5 DeviceOrientation Specification]( - * http://www.w3.org/TR/orientation-event/) for more details. - * - * Many new computers, and especially mobile phones - * and tablets, provide hardware support for device orientation. Web - * developers targeting mobile devices will be especially interested in this - * class. - * - * Device orientation data are relative to a common starting point. For mobile - * devices, the starting point is to lay your phone face up on a table with the - * top of the phone pointing north. This represents the zero state. All - * angles are then relative to this state. For computers, it is the same except - * the screen is open at 90 degrees. - * - * Device orientation is reported as three angles - `alpha`, `beta`, and - * `gamma` - relative to the starting position along the three planar axes X, Y - * and Z. The X axis runs from the left edge to the right edge through the - * middle of the device. Similarly, the Y axis runs from the bottom to the top - * of the device through the middle. The Z axis runs from the back to the front - * through the middle. In the starting position, the X axis points to the - * right, the Y axis points away from you and the Z axis points straight up - * from the device lying flat. - * - * The three angles representing the device orientation are relative to the - * three axes. `alpha` indicates how much the device has been rotated around the - * Z axis, which is commonly interpreted as the compass heading (see note - * below). `beta` indicates how much the device has been rotated around the X - * axis, or how much it is tilted from front to back. `gamma` indicates how - * much the device has been rotated around the Y axis, or how much it is tilted - * from left to right. - * - * For most browsers, the `alpha` value returns the compass heading so if the - * device points north, it will be 0. With Safari on iOS, the 0 value of - * `alpha` is calculated from when device orientation was first requested. - * ol.DeviceOrientation provides the `heading` property which normalizes this - * behavior across all browsers for you. - * - * It is important to note that the HTML 5 DeviceOrientation specification - * indicates that `alpha`, `beta` and `gamma` are in degrees while the - * equivalent properties in ol.DeviceOrientation are in radians for consistency - * with all other uses of angles throughout OpenLayers. - * - * To get notified of device orientation changes, register a listener for the - * generic `change` event on your `ol.DeviceOrientation` instance. - * - * @see {@link http://www.w3.org/TR/orientation-event/} - * - * @param opt_options Options. - * @api - */ - constructor(opt_options?: olx.DeviceOrientationOptions); + constructor(opt_options?: olx.DeviceOrientationOptions); - /** - * Rotation around the device z-axis (in radians). - * @return The euler angle in radians of the device from the - * standard Z axis. - * @observable - * @api - */ - getAlpha(): (number); + /** + * Rotation around the device z-axis (in radians). + * @return The euler angle in radians of the device from the + * standard Z axis. + * @observable + * @api + */ + getAlpha(): (number); - /** - * Rotation around the device x-axis (in radians). - * @return The euler angle in radians of the device from the - * planar X axis. - * @observable - * @api - */ - getBeta(): (number); + /** + * Rotation around the device x-axis (in radians). + * @return The euler angle in radians of the device from the + * planar X axis. + * @observable + * @api + */ + getBeta(): (number); - /** - * Rotation around the device y-axis (in radians). - * @return The euler angle in radians of the device from the - * planar Y axis. - * @observable - * @api - */ - getGamma(): (number); + /** + * Rotation around the device y-axis (in radians). + * @return The euler angle in radians of the device from the + * planar Y axis. + * @observable + * @api + */ + getGamma(): (number); - /** - * The heading of the device relative to north (in radians). - * @return The heading of the device relative to north, in - * radians, normalizing for different browser behavior. - * @observable - * @api - */ - getHeading(): (number); + /** + * The heading of the device relative to north (in radians). + * @return The heading of the device relative to north, in + * radians, normalizing for different browser behavior. + * @observable + * @api + */ + getHeading(): (number); - /** - * Determine if orientation is being tracked. - * @return Changes in device orientation are being tracked. - * @observable - * @api - */ - getTracking(): boolean; + /** + * Determine if orientation is being tracked. + * @return Changes in device orientation are being tracked. + * @observable + * @api + */ + getTracking(): boolean; - /** - * Enable or disable tracking of device orientation events. - * @param tracking The status of tracking changes to alpha, beta and - * gamma. If true, changes are tracked and reported immediately. - * @observable - * @api - */ - setTracking(tracking: boolean): void; - } + /** + * Enable or disable tracking of device orientation events. + * @param tracking The status of tracking changes to alpha, beta and + * gamma. If true, changes are tracked and reported immediately. + * @observable + * @api + */ + setTracking(tracking: boolean): void; +} +/** + * Objects that need to clean up after themselves. + */ +/* tslint:disable-next-line:no-unnecessary-class */ +export class Disposable { /** * Objects that need to clean up after themselves. */ - class Disposable { - /** - * Objects that need to clean up after themselves. - */ - constructor(); - } + constructor(); +} +/** + * Easing functions for {@link ol.animation}. + */ +export namespace easing { /** - * Easing functions for {@link ol.animation}. + * Start slow and speed up. + * @param t Input between 0 and 1. + * @return Output between 0 and 1. + * @api */ - namespace easing { + function easeIn(t: number): number; + + /** + * Start fast and slow down. + * @param t Input between 0 and 1. + * @return Output between 0 and 1. + * @api + */ + function easeOut(t: number): number; + + /** + * Start slow, speed up, and then slow down again. + * @param t Input between 0 and 1. + * @return Output between 0 and 1. + * @api + */ + function inAndOut(t: number): number; + + /** + * Maintain a constant speed over time. + * @param t Input between 0 and 1. + * @return Output between 0 and 1. + * @api + */ + function linear(t: number): number; + + /** + * Start slow, speed up, and at the very end slow down again. This has the + * same general behavior as {@link ol.easing.inAndOut}, but the final slowdown + * is delayed. + * @param t Input between 0 and 1. + * @return Output between 0 and 1. + * @api + */ + function upAndDown(t: number): number; +} + +/** + * Applications do not normally create event instances. They register (and + * unregister) event listener functions, which, when called by the library as + * the result of an event being dispatched, are passed event instances as their + * first argument. Listeners can be registered and unregistered on all objects + * descending from {@link ol.Observable}. All event instances have a `target` + * property, which corresponds to the object on which the event was dispatched. + * By default, `this` within the listener also refers to the target, though + * this can be configured in the listener registration function. + * Some classes have their own event type, which return additional + * properties; see the specific event class page for details. + * + */ +export namespace events { + namespace condition { /** - * Start slow and speed up. - * @param t Input between 0 and 1. - * @return Output between 0 and 1. - * @api + * Return `true` if only the alt-key is pressed, `false` otherwise (e.g. when + * additionally the shift-key is pressed). + * + * @param mapBrowserEvent Map browser event. + * @return True if only the alt key is pressed. + * @api stable */ - function easeIn(t: number): number; + function altKeyOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean; /** - * Start fast and slow down. - * @param t Input between 0 and 1. - * @return Output between 0 and 1. - * @api + * Return `true` if only the alt-key and shift-key is pressed, `false` otherwise + * (e.g. when additionally the platform-modifier-key is pressed). + * + * @param mapBrowserEvent Map browser event. + * @return True if only the alt and shift keys are pressed. + * @api stable */ - function easeOut(t: number): number; + function altShiftKeysOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean; /** - * Start slow, speed up, and then slow down again. - * @param t Input between 0 and 1. - * @return Output between 0 and 1. - * @api + * Return always true. + * + * @param mapBrowserEvent Map browser event. + * @return True. + * @api stable */ - function inAndOut(t: number): number; + function always(mapBrowserEvent: ol.MapBrowserEvent): boolean; /** - * Maintain a constant speed over time. - * @param t Input between 0 and 1. - * @return Output between 0 and 1. - * @api + * Return `true` if the event is a `click` event, `false` otherwise. + * + * @param mapBrowserEvent Map browser event. + * @return True if the event is a map `click` event. + * @api stable */ - function linear(t: number): number; + function click(mapBrowserEvent: ol.MapBrowserEvent): boolean; /** - * Start slow, speed up, and at the very end slow down again. This has the - * same general behavior as {@link ol.easing.inAndOut}, but the final slowdown - * is delayed. - * @param t Input between 0 and 1. - * @return Output between 0 and 1. + * Return always false. + * + * @param mapBrowserEvent Map browser event. + * @return False. + * @api stable + */ + function never(mapBrowserEvent: ol.MapBrowserEvent): boolean; + + /** + * Return `true` if the browser event is a `pointermove` event, `false` + * otherwise. + * + * @param mapBrowserEvent Map browser event. + * @return True if the browser event is a `pointermove` event. * @api */ - function upAndDown(t: number): number; + function pointerMove(mapBrowserEvent: ol.MapBrowserEvent): boolean; + + /** + * Return `true` if the event is a map `singleclick` event, `false` otherwise. + * + * @param mapBrowserEvent Map browser event. + * @return True if the event is a map `singleclick` event. + * @api stable + */ + function singleClick(mapBrowserEvent: ol.MapBrowserEvent): boolean; + + /** + * Return `true` if the event is a map `dblclick` event, `false` otherwise. + * + * @param mapBrowserEvent Map browser event. + * @return True if the event is a map `dblclick` event. + * @api stable + */ + function doubleClick(mapBrowserEvent: ol.MapBrowserEvent): boolean; + + /** + * Return `true` if no modifier key (alt-, shift- or platform-modifier-key) is + * pressed. + * + * @param mapBrowserEvent Map browser event. + * @return True only if there no modifier keys are pressed. + * @api stable + */ + function noModifierKeys(mapBrowserEvent: ol.MapBrowserEvent): boolean; + + /** + * Return `true` if only the platform-modifier-key (the meta-key on Mac, + * ctrl-key otherwise) is pressed, `false` otherwise (e.g. when additionally + * the shift-key is pressed). + * + * @param mapBrowserEvent Map browser event. + * @return True if only the platform modifier key is pressed. + * @api stable + */ + function platformModifierKeyOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean; + + /** + * Return `true` if only the shift-key is pressed, `false` otherwise (e.g. when + * additionally the alt-key is pressed). + * + * @param mapBrowserEvent Map browser event. + * @return True if only the shift key is pressed. + * @api stable + */ + function shiftKeyOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean; + + /** + * Return `true` if the target element is not editable, i.e. not a ``-, + * `