From d819ae8dcf971b19995ea312817d895c59d72bf1 Mon Sep 17 00:00:00 2001 From: Naor Torgeman Date: Mon, 12 Jun 2017 16:46:57 +0300 Subject: [PATCH 01/90] Create index.d.ts ReactInputMask should be exported as default to be proper used. --- types/react-input-mask/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-input-mask/index.d.ts b/types/react-input-mask/index.d.ts index 560dc8cc2b..28095b4104 100644 --- a/types/react-input-mask/index.d.ts +++ b/types/react-input-mask/index.d.ts @@ -41,4 +41,4 @@ declare namespace reactInputMask { } } declare var ReactInputMask: typeof reactInputMask.ReactInputMask; -export = ReactInputMask; +export default ReactInputMask; From 15e315003c58e29e2920222884dadca27e4cc245 Mon Sep 17 00:00:00 2001 From: Flarna Date: Tue, 13 Jun 2017 13:05:18 +0200 Subject: [PATCH 02/90] * Add missing OS signals * add missing process APIs --- types/node/index.d.ts | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 178a8920e1..5ed6beb44c 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -382,7 +382,7 @@ declare namespace NodeJS { "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" | "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" | "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" | - "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ"; + "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO"; export interface Socket extends ReadWriteStream { isTTY?: true; @@ -467,7 +467,9 @@ declare namespace NodeJS { * 6. uncaughtException * 7. unhandledRejection * 8. warning - * 9. + * 9. message + * 10. + * 11. anything else */ addListener(event: "beforeExit", listener: (code: number) => void): this; @@ -477,16 +479,20 @@ declare namespace NodeJS { addListener(event: "uncaughtException", listener: (error: Error) => void): this; addListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; addListener(event: "warning", listener: (warning: Error) => void): this; + addListener(event: "message", listener: (message: any, sendHandle: any) => void): this; addListener(event: Signals, listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; - emit(event: "beforeExit", listener: (code: number) => void): boolean; - emit(event: "disconnect", listener: () => void): boolean; - emit(event: "exit", listener: (code: number) => void): boolean; - emit(event: "rejectionHandled", listener: (promise: Promise) => void): boolean; - emit(event: "uncaughtException", listener: (error: Error) => void): boolean; - emit(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): boolean; - emit(event: "warning", listener: (warning: Error) => void): boolean; - emit(event: Signals, listener: () => void): boolean; + emit(event: "beforeExit", code: number): boolean; + emit(event: "disconnect"): boolean; + emit(event: "exit", code: number): boolean; + emit(event: "rejectionHandled", promise: Promise): boolean; + emit(event: "uncaughtException", error: Error): boolean; + emit(event: "unhandledRejection", reason: any, promise: Promise): boolean; + emit(event: "warning", warning: Error): boolean; + emit(event: "message", message: any, sendHandle: any): this; + emit(event: Signals): boolean; + emit(event: string | symbol, ...args: any[]): boolean; on(event: "beforeExit", listener: (code: number) => void): this; on(event: "disconnect", listener: () => void): this; @@ -497,6 +503,7 @@ declare namespace NodeJS { on(event: "warning", listener: (warning: Error) => void): this; on(event: "message", listener: (message: any, sendHandle: any) => void): this; on(event: Signals, listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; once(event: "beforeExit", listener: (code: number) => void): this; once(event: "disconnect", listener: () => void): this; @@ -505,7 +512,9 @@ declare namespace NodeJS { once(event: "uncaughtException", listener: (error: Error) => void): this; once(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; once(event: "warning", listener: (warning: Error) => void): this; + once(event: "message", listener: (message: any, sendHandle: any) => void): this; once(event: Signals, listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; prependListener(event: "beforeExit", listener: (code: number) => void): this; prependListener(event: "disconnect", listener: () => void): this; @@ -514,7 +523,9 @@ declare namespace NodeJS { prependListener(event: "uncaughtException", listener: (error: Error) => void): this; prependListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; prependListener(event: "warning", listener: (warning: Error) => void): this; + prependListener(event: "message", listener: (message: any, sendHandle: any) => void): this; prependListener(event: Signals, listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; prependOnceListener(event: "beforeExit", listener: (code: number) => void): this; prependOnceListener(event: "disconnect", listener: () => void): this; @@ -523,7 +534,9 @@ declare namespace NodeJS { prependOnceListener(event: "uncaughtException", listener: (error: Error) => void): this; prependOnceListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; prependOnceListener(event: "warning", listener: (warning: Error) => void): this; + prependOnceListener(event: "message", listener: (message: any, sendHandle: any) => void): this; prependOnceListener(event: Signals, listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; } export interface Global { From 76260f6cf3f4fff04c402f70784e749f4550dc38 Mon Sep 17 00:00:00 2001 From: Sebastien PUECH Date: Tue, 13 Jun 2017 16:24:43 +0200 Subject: [PATCH 03/90] Fix "connect" method for node typings. --- types/node/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 178a8920e1..9ec5eff946 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2338,7 +2338,7 @@ declare module "net" { } export function createServer(connectionListener?: (socket: Socket) => void): Server; export function createServer(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void): Server; - export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: number, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; export function connect(port: number, host?: string, connectionListener?: Function): Socket; export function connect(path: string, connectionListener?: Function): Socket; export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; From 56866537591b4d78d0904ceb9cd7ea2cc4a12267 Mon Sep 17 00:00:00 2001 From: Flarna Date: Tue, 13 Jun 2017 22:08:10 +0200 Subject: [PATCH 04/90] * remove catch-all variants for on/once/... in Process * add "newListener" | "removeListener" variants * correct emit() functions for "cluster" * add some tests --- types/node/index.d.ts | 55 ++++++++++++++++++++-------------------- types/node/node-tests.ts | 11 ++++++++ 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 5ed6beb44c..4498b49210 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -469,9 +469,8 @@ declare namespace NodeJS { * 8. warning * 9. message * 10. - * 11. anything else + * 11. newListener/removeListener inherited from EventEmitter */ - addListener(event: "beforeExit", listener: (code: number) => void): this; addListener(event: "disconnect", listener: () => void): this; addListener(event: "exit", listener: (code: number) => void): this; @@ -481,7 +480,7 @@ declare namespace NodeJS { addListener(event: "warning", listener: (warning: Error) => void): this; addListener(event: "message", listener: (message: any, sendHandle: any) => void): this; addListener(event: Signals, listener: () => void): this; - addListener(event: string | symbol, listener: (...args: any[]) => void): this; + addListener(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; emit(event: "beforeExit", code: number): boolean; emit(event: "disconnect"): boolean; @@ -492,7 +491,7 @@ declare namespace NodeJS { emit(event: "warning", warning: Error): boolean; emit(event: "message", message: any, sendHandle: any): this; emit(event: Signals): boolean; - emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "newListener" | "removeListener", eventName: string, listener: Function): this; on(event: "beforeExit", listener: (code: number) => void): this; on(event: "disconnect", listener: () => void): this; @@ -503,7 +502,7 @@ declare namespace NodeJS { on(event: "warning", listener: (warning: Error) => void): this; on(event: "message", listener: (message: any, sendHandle: any) => void): this; on(event: Signals, listener: () => void): this; - on(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; once(event: "beforeExit", listener: (code: number) => void): this; once(event: "disconnect", listener: () => void): this; @@ -514,7 +513,7 @@ declare namespace NodeJS { once(event: "warning", listener: (warning: Error) => void): this; once(event: "message", listener: (message: any, sendHandle: any) => void): this; once(event: Signals, listener: () => void): this; - once(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; prependListener(event: "beforeExit", listener: (code: number) => void): this; prependListener(event: "disconnect", listener: () => void): this; @@ -525,7 +524,7 @@ declare namespace NodeJS { prependListener(event: "warning", listener: (warning: Error) => void): this; prependListener(event: "message", listener: (message: any, sendHandle: any) => void): this; prependListener(event: Signals, listener: () => void): this; - prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; prependOnceListener(event: "beforeExit", listener: (code: number) => void): this; prependOnceListener(event: "disconnect", listener: () => void): this; @@ -536,7 +535,7 @@ declare namespace NodeJS { prependOnceListener(event: "warning", listener: (warning: Error) => void): this; prependOnceListener(event: "message", listener: (message: any, sendHandle: any) => void): this; prependOnceListener(event: Signals, listener: () => void): this; - prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; } export interface Global { @@ -959,12 +958,12 @@ declare module "cluster" { addListener(event: "online", listener: () => void): this; emit(event: string, listener: Function): boolean - emit(event: "disconnect", listener: () => void): boolean - emit(event: "error", listener: (code: number, signal: string) => void): boolean - emit(event: "exit", listener: (code: number, signal: string) => void): boolean - emit(event: "listening", listener: (address: Address) => void): boolean - emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean - emit(event: "online", listener: () => void): boolean + emit(event: "disconnect"): boolean + emit(event: "error", code: number, signal: string): boolean + emit(event: "exit", code: number, signal: string): boolean + emit(event: "listening", address: Address): boolean + emit(event: "message", message: any, handle: net.Socket | net.Server): boolean + emit(event: "online"): boolean on(event: string, listener: Function): this; on(event: "disconnect", listener: () => void): this; @@ -1033,13 +1032,13 @@ declare module "cluster" { addListener(event: "setup", listener: (settings: any) => void): this; emit(event: string, listener: Function): boolean; - emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - emit(event: "fork", listener: (worker: Worker) => void): boolean; - emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - emit(event: "online", listener: (worker: Worker) => void): boolean; - emit(event: "setup", listener: (settings: any) => void): boolean; + emit(event: "disconnect", worker: Worker): boolean; + emit(event: "exit", worker: Worker, code: number, signal: string): boolean; + emit(event: "fork", worker: Worker): boolean; + emit(event: "listening", worker: Worker, address: Address): boolean; + emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean; + emit(event: "online", worker: Worker): boolean; + emit(event: "setup", settings: any): boolean; on(event: string, listener: Function): this; on(event: "disconnect", listener: (worker: Worker) => void): this; @@ -1111,13 +1110,13 @@ declare module "cluster" { export function addListener(event: "setup", listener: (settings: any) => void): Cluster; export function emit(event: string, listener: Function): boolean; - export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - export function emit(event: "fork", listener: (worker: Worker) => void): boolean; - export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - export function emit(event: "online", listener: (worker: Worker) => void): boolean; - export function emit(event: "setup", listener: (settings: any) => void): boolean; + export function emit(event: "disconnect", worker: Worker): boolean; + export function emit(event: "exit", worker: Worker, code: number, signal: string): boolean; + export function emit(event: "fork", worker: Worker): boolean; + export function emit(event: "listening", worker: Worker, address: Address): boolean; + export function emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean; + export function emit(event: "online", worker: Worker): boolean; + export function emit(event: "setup", settings: any): boolean; export function on(event: string, listener: Function): Cluster; export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 35260b138b..251ef2d7eb 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1892,6 +1892,17 @@ namespace process_tests { } { process.on("message", (req: any) => { }); + process.addListener("beforeExit", (code: number) => { }); + process.once("disconnect", () => { }); + process.prependListener("exit", (code: number) => { }); + process.prependOnceListener("rejectionHandled", (promise: Promise) => { }); + process.on("uncaughtException", (error: Error) => { }); + process.addListener("unhandledRejection", (reason: any, promise: Promise) => { }); + process.once("warning", (warning: Error) => { }); + process.prependListener("message", (message: any, sendHandle: any) => { }); + process.prependOnceListener("SIGBREAK", () => { }); + process.on("newListener", (event: string, listener: Function) => { }); + process.once("removeListener", (event: string, listener: Function) => { }); } } From c6eb2e6f077407495082353c6547241fd5e1ae73 Mon Sep 17 00:00:00 2001 From: Flarna Date: Wed, 14 Jun 2017 09:14:02 +0200 Subject: [PATCH 05/90] split events newListener/removeListener for Process --- types/node/index.d.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 4498b49210..369b786f17 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -480,7 +480,8 @@ declare namespace NodeJS { addListener(event: "warning", listener: (warning: Error) => void): this; addListener(event: "message", listener: (message: any, sendHandle: any) => void): this; addListener(event: Signals, listener: () => void): this; - addListener(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; + addListener(event: "newListener", listener: (event: string, listener: Function) => void): this; + addListener(event: "removeListener", listener: (event: string, listener: Function) => void): this; emit(event: "beforeExit", code: number): boolean; emit(event: "disconnect"): boolean; @@ -491,7 +492,8 @@ declare namespace NodeJS { emit(event: "warning", warning: Error): boolean; emit(event: "message", message: any, sendHandle: any): this; emit(event: Signals): boolean; - emit(event: "newListener" | "removeListener", eventName: string, listener: Function): this; + emit(event: "newListener", eventName: string, listener: Function): this; + emit(event: "removeListener", eventName: string, listener: Function): this; on(event: "beforeExit", listener: (code: number) => void): this; on(event: "disconnect", listener: () => void): this; @@ -502,7 +504,8 @@ declare namespace NodeJS { on(event: "warning", listener: (warning: Error) => void): this; on(event: "message", listener: (message: any, sendHandle: any) => void): this; on(event: Signals, listener: () => void): this; - on(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; + on(event: "newListener", listener: (event: string, listener: Function) => void): this; + on(event: "removeListener", listener: (event: string, listener: Function) => void): this; once(event: "beforeExit", listener: (code: number) => void): this; once(event: "disconnect", listener: () => void): this; @@ -513,7 +516,8 @@ declare namespace NodeJS { once(event: "warning", listener: (warning: Error) => void): this; once(event: "message", listener: (message: any, sendHandle: any) => void): this; once(event: Signals, listener: () => void): this; - once(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; + once(event: "newListener", listener: (event: string, listener: Function) => void): this; + once(event: "removeListener", listener: (event: string, listener: Function) => void): this; prependListener(event: "beforeExit", listener: (code: number) => void): this; prependListener(event: "disconnect", listener: () => void): this; @@ -524,7 +528,8 @@ declare namespace NodeJS { prependListener(event: "warning", listener: (warning: Error) => void): this; prependListener(event: "message", listener: (message: any, sendHandle: any) => void): this; prependListener(event: Signals, listener: () => void): this; - prependListener(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; + prependListener(event: "newListener", listener: (event: string, listener: Function) => void): this; + prependListener(event: "removeListener", listener: (event: string, listener: Function) => void): this; prependOnceListener(event: "beforeExit", listener: (code: number) => void): this; prependOnceListener(event: "disconnect", listener: () => void): this; @@ -535,7 +540,8 @@ declare namespace NodeJS { prependOnceListener(event: "warning", listener: (warning: Error) => void): this; prependOnceListener(event: "message", listener: (message: any, sendHandle: any) => void): this; prependOnceListener(event: Signals, listener: () => void): this; - prependOnceListener(event: "newListener" | "removeListener", listener: (event: string, listener: Function) => void): this; + prependOnceListener(event: "newListener", listener: (event: string, listener: Function) => void): this; + prependOnceListener(event: "removeListener", listener: (event: string, listener: Function) => void): this; } export interface Global { From 779dcecfa79543f0ee3e1d566613a30cb1859d69 Mon Sep 17 00:00:00 2001 From: amiram Date: Wed, 14 Jun 2017 16:55:16 +0300 Subject: [PATCH 06/90] add option to call process with type and callback only --- types/kue/index.d.ts | 2 +- types/kue/kue-tests.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/types/kue/index.d.ts b/types/kue/index.d.ts index 4fc964b118..4c391328a5 100644 --- a/types/kue/index.d.ts +++ b/types/kue/index.d.ts @@ -29,7 +29,7 @@ export declare class Queue extends events.EventEmitter { checkActiveJobTtl(ttlOptions: Object): void; watchStuckJobs(ms: number): void; setting(name: string, fn: Function): Queue; - process(type: string, n?: number, fn?: Function): void; + process(type: string, n?: number | Function, fn?: Function): void; shutdown(timeout: number, type: string, fn: Function): Queue; types(fn: Function): Queue; state(string: string, fn: Function): Queue; diff --git a/types/kue/kue-tests.ts b/types/kue/kue-tests.ts index d69f6eaead..bcd2c26a60 100644 --- a/types/kue/kue-tests.ts +++ b/types/kue/kue-tests.ts @@ -46,7 +46,7 @@ create(); // process video conversion jobs, 1 at a time. -jobs.process('video conversion', 1, function(job: kue.Job, done: Function) { +var processCb = function(job: kue.Job, done: Function) { var frames: number = job.data.frames; function next(i: number) { @@ -61,7 +61,10 @@ jobs.process('video conversion', 1, function(job: kue.Job, done: Function) { } next(0); -} ); +} + +jobs.process('video conversion', 1, processCb); +jobs.process('video conversion', processCb); function convertFrame(i: number, fn: Function) { setTimeout(fn, Math.random() * 50); @@ -102,4 +105,4 @@ jobs.process('email', 10, function(job: kue.Job, done: Function) { // start the UI kue.app.listen(3000); -console.log('UI started on port 3000'); \ No newline at end of file +console.log('UI started on port 3000'); From 61a9bd3f85e1a7610f8c97f0f09f4ed681aacd36 Mon Sep 17 00:00:00 2001 From: amiram Date: Wed, 14 Jun 2017 16:58:53 +0300 Subject: [PATCH 07/90] add author --- types/kue/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/kue/index.d.ts b/types/kue/index.d.ts index 4c391328a5..45fd6cfa83 100644 --- a/types/kue/index.d.ts +++ b/types/kue/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for kue 0.11.x // Project: https://github.com/Automattic/kue // Definitions by: Nicholas Penree +// Amiram Korach // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 12741d93926dfe28e5b77a91ce74e3b82e7a2ce0 Mon Sep 17 00:00:00 2001 From: Michael Haan Date: Wed, 14 Jun 2017 13:35:08 -0700 Subject: [PATCH 08/90] add sendOffsetCommitV2Request to Client --- types/kafka-node/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/kafka-node/index.d.ts b/types/kafka-node/index.d.ts index 46de85286d..a2740fcc0f 100644 --- a/types/kafka-node/index.d.ts +++ b/types/kafka-node/index.d.ts @@ -11,6 +11,7 @@ export declare class Client { topicExists(topics: Array, callback: Function): void; refreshMetadata(topics: Array, cb?: (error: any, data: any) => any): void; close(cb: (error: any) => any): void; + sendOffsetCommitV2Request(group: string, generationId: number, memberId: string, commits: Array, cb: (error: any, data: any) => any): void; } export declare class Producer { @@ -70,6 +71,8 @@ export declare class ConsumerGroup extends HighLevelConsumer { on(eventName: string, cb: (message: string) => any): void; on(eventName: string, cb: (error: any) => any): void; close(force: boolean, cb: (error: any) => any): void; + generationId: number; + memberId: string; } export declare class Offset { From 5e13d26ae191c85428d00518b68af83118ac2c6b Mon Sep 17 00:00:00 2001 From: Jeffrey Young Date: Thu, 15 Jun 2017 11:13:10 -0400 Subject: [PATCH 09/90] redux-mock-store export MockStore Rename mockStore to MockStoreCreator and export MockStore --- types/redux-mock-store/index.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/types/redux-mock-store/index.d.ts b/types/redux-mock-store/index.d.ts index e8d4cced5e..c92bb6bcb8 100644 --- a/types/redux-mock-store/index.d.ts +++ b/types/redux-mock-store/index.d.ts @@ -8,14 +8,16 @@ declare module 'redux-mock-store' { import * as Redux from 'redux'; - function createMockStore(middlewares?: Redux.Middleware[]): mockStore; - - interface MockStore extends Redux.Store { + export interface MockStore extends Redux.Store { getActions(): any[]; clearActions(): void; } - export type mockStore = (state?: T) => MockStore; + export interface MockStoreCreator { + (state?: T): MockStore; + } + + function createMockStore(middlewares?: Redux.Middleware[]): MockStoreCreator; export default createMockStore; } From be0f70fbf2a9f9fcfd5f889bae408c7c408dbea6 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Thu, 15 Jun 2017 12:21:49 -0400 Subject: [PATCH 10/90] [electron-settings/v2] Expose types. --- .../v2/electron-settings-tests.ts | 16 +- types/electron-settings/v2/index.d.ts | 337 +++++++++--------- 2 files changed, 189 insertions(+), 164 deletions(-) diff --git a/types/electron-settings/v2/electron-settings-tests.ts b/types/electron-settings/v2/electron-settings-tests.ts index 38e37e6ba0..0eb746559e 100644 --- a/types/electron-settings/v2/electron-settings-tests.ts +++ b/types/electron-settings/v2/electron-settings-tests.ts @@ -1,4 +1,5 @@ -import * as settings from 'electron-settings'; +import settings = require('electron-settings'); +import Observer = require('electron-settings/lib/observer'); function test_configure() { settings.configure({ @@ -59,6 +60,7 @@ async function test_clear() { function test_clearSync() { settings.clearSync() === undefined; } + async function test_applyDefaults() { await settings.applyDefaults({ overwrite: true }) === undefined; } @@ -100,3 +102,15 @@ function test_on_write() { console.log(); }) === settings; } + +function test_settings_type_annotation(s: typeof settings) { + s.getSettingsFilePath(); +} + +function test_observer_type_annotation(observer: Observer) { + observer.dispose(); +} + +function test_options_type_annotation(options: ElectronSettings.Options) { + options.atomicSaving; +} diff --git a/types/electron-settings/v2/index.d.ts b/types/electron-settings/v2/index.d.ts index ead5250015..5d932bbcf3 100644 --- a/types/electron-settings/v2/index.d.ts +++ b/types/electron-settings/v2/index.d.ts @@ -6,191 +6,194 @@ /// -import * as EventEmitter from 'events'; - -/** - * The Settings class. - */ -declare class Settings extends EventEmitter { - /** - * Globally configures default options. - * - * @throws if options is not an object. - */ - configure(options: ElectronSettings.Options | object): void; +declare module 'electron-settings' { + import { EventEmitter } from 'events'; + import Observer = require('electron-settings/lib/observer'); /** - * Globally configures default settings. - * - * If the settings file has not been created yet, these defaults will be applied, - * but only if settings.defaults is called before making any other calls that - * interact with the file system, such as has(), get(), or set(). - * - * @param defaults The defaults object. - * @throws if defaults is not an object. + * The Settings class. */ - defaults(defaults: any): void; + class Settings extends EventEmitter { + /** + * Globally configures default options. + * + * @throws if options is not an object. + */ + configure(options: ElectronSettings.Options.Param): void; - /** - * Returns a promise whose first argument is a boolean indicating if the key path exists within the settings object. - * For synchronous operation, use hasSync(). - * - * @param keyPath The path to the key that we wish to check exists within the settings object. - * @throws if key path is not a string. - * @see hasSync - */ - has(keyPath: string): Promise; + /** + * Globally configures default settings. + * + * If the settings file has not been created yet, these defaults will be applied, + * but only if settings.defaults is called before making any other calls that + * interact with the file system, such as has(), get(), or set(). + * + * @param defaults The defaults object. + * @throws if defaults is not an object. + */ + defaults(defaults: any): void; - /** - * The synchronous version of has(). - * - * @see has - */ - hasSync(keyPath: string): boolean; + /** + * Returns a promise whose first argument is a boolean indicating if the key path exists within the settings object. + * For synchronous operation, use hasSync(). + * + * @param keyPath The path to the key that we wish to check exists within the settings object. + * @throws if key path is not a string. + * @see hasSync + */ + has(keyPath: string): Promise; - /** - * Returns a promise whose first argument is the value at the chosen key path. - * If no key path is chosen, the entire settings object will be returned instead. - * For synchronous operation, use getSync(). - * - * @param keyPath The path to the key that we wish to get the value of. - * @see getSync - */ - get(keyPath?: string): Promise; + /** + * The synchronous version of has(). + * + * @see has + */ + hasSync(keyPath: string): boolean; - /** - * The synchronous version of get(). - * - * @see get - */ - getSync(keyPath?: string): any; + /** + * Returns a promise whose first argument is the value at the chosen key path. + * If no key path is chosen, the entire settings object will be returned instead. + * For synchronous operation, use getSync(). + * + * @param keyPath The path to the key that we wish to get the value of. + * @see getSync + */ + get(keyPath?: string): Promise; - /** - * Sets the value of the key at the chosen key path. - * For synchronous operation, use setSync(). - * - * @param keyPath The path to the key whose value we wish to set. This key need not already exist. - * @param value The value to set the key at the chosen key path to. This must be a data type supported by JSON: object, array, string, number, boolean, or null. - * @param options - * @throws if key path is not a string. - * @throws if options is not an object. - * @see setSync - */ - set(keyPath: string, value: any, options?: ElectronSettings.Options | object): Promise; + /** + * The synchronous version of get(). + * + * @see get + */ + getSync(keyPath?: string): any; - /** - * The synchronous version of set(). - * - * @see set - */ - setSync(keyPath: string, value: any, options?: ElectronSettings.Options | object): void; + /** + * Sets the value of the key at the chosen key path. + * For synchronous operation, use setSync(). + * + * @param keyPath The path to the key whose value we wish to set. This key need not already exist. + * @param value The value to set the key at the chosen key path to. This must be a data type supported by JSON: object, array, string, number, boolean, or null. + * @param options + * @throws if key path is not a string. + * @throws if options is not an object. + * @see setSync + */ + set(keyPath: string, value: any, options?: ElectronSettings.Options.Param): Promise; - /** - * Deletes the key and value at the chosen key path. - * - * @param keyPath The path to the key we wish to unset. - * @param options - * @throws if keyPath is not a string. - * @throws if options is not an object. - * @see deleteSync - */ - delete(keyPath: string, options?: ElectronSettings.Options | object): Promise; + /** + * The synchronous version of set(). + * + * @see set + */ + setSync(keyPath: string, value: any, options?: ElectronSettings.Options.Param): void; - /** - * The synchronous version of delete(). - * - * @see delete - */ - deleteSync(keyPath: string, options?: ElectronSettings.Options | object): void; + /** + * Deletes the key and value at the chosen key path. + * + * @param keyPath The path to the key we wish to unset. + * @param options + * @throws if keyPath is not a string. + * @throws if options is not an object. + * @see deleteSync + */ + delete(keyPath: string, options?: ElectronSettings.Options.Param): Promise; - /** - * Clears the entire settings object. - * For synchronous operation, use clearSync(). - * - * @throws if options is not an object. - * @see clearSync - */ - clear(options?: ElectronSettings.Options | object): Promise; + /** + * The synchronous version of delete(). + * + * @see delete + */ + deleteSync(keyPath: string, options?: ElectronSettings.Options.Param): void; - /** - * The synchronous version of clear(). - * - * @see clear - */ - clearSync(options?: ElectronSettings.Options | object): void; + /** + * Clears the entire settings object. + * For synchronous operation, use clearSync(). + * + * @throws if options is not an object. + * @see clearSync + */ + clear(options?: ElectronSettings.Options.Param): Promise; - /** - * Applies defaults to the current settings object (deep). - * Settings that already exist will not be overwritten, but keys that exist within the defaults - * that don't exist within the setting object will be added. - * To configure defaults, use defaults(). - * For synchronous operation, use applyDefaultsSync(). - * - * @throws if options is not an object. - * @see defaults - * @see applyDefaultsSync - */ - applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions | object): Promise; + /** + * The synchronous version of clear(). + * + * @see clear + */ + clearSync(options?: ElectronSettings.Options.Param): void; - /** - * The synchronous version of applyDefaults(). - * - * @see applyDefaults - */ - applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions | object): void; + /** + * Applies defaults to the current settings object (deep). + * Settings that already exist will not be overwritten, but keys that exist within the defaults + * that don't exist within the setting object will be added. + * To configure defaults, use defaults(). + * For synchronous operation, use applyDefaultsSync(). + * + * @throws if options is not an object. + * @see defaults + * @see applyDefaultsSync + */ + applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions.Param): Promise; - /** - * Resets all settings to defaults. - * To configure defaults, use defaults(). - * For synchronous operation, use resetToDefaultsSync(). - * - * @throws if options is not an object. - * @see defaults - * @see resetToDefaultsSync - */ - resetToDefaults(options?: ElectronSettings.Options | object): Promise; + /** + * The synchronous version of applyDefaults(). + * + * @see applyDefaults + */ + applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions.Param): void; - /** - * The synchronous version of resetToDefaults(). - * - * @see resetToDefaults - */ - resetToDefaultsSync(options?: ElectronSettings.Options | object): void; + /** + * Resets all settings to defaults. + * To configure defaults, use defaults(). + * For synchronous operation, use resetToDefaultsSync(). + * + * @throws if options is not an object. + * @see defaults + * @see resetToDefaultsSync + */ + resetToDefaults(options?: ElectronSettings.Options.Param): Promise; - /** - * Observes the chosen key path for changes and calls the handler if the value changes. - * Returns an Observer instance which has a dispose method. - * To unsubscribe, simply call dispose() on the returned key path observer. - * - * @param keyPath The path to the key that we wish to observe. - * @param handler The callback that will be invoked if the value at the chosen key path changes. - * @throws if key path is not a string. - * @throws if handler is not a function. - */ - observe(keyPath: string, handler: (evt: ElectronSettings.ChangeEvent) => void): ElectronSettings.Observer; + /** + * The synchronous version of resetToDefaults(). + * + * @see resetToDefaults + */ + resetToDefaultsSync(options?: ElectronSettings.Options.Param): void; - /** - * Returns the path to the config file. Typically found in your application's user data directory: - * ~/Library/Application Support/YourApp on MacOS. - * %APPDATA%/YourApp on Windows. - * $XDG_CONFIG_HOME/YourApp or ~/.config/YourApp on Linux. - */ - getSettingsFilePath(): string; + /** + * Observes the chosen key path for changes and calls the handler if the value changes. + * Returns an Observer instance which has a dispose method. + * To unsubscribe, simply call dispose() on the returned key path observer. + * + * @param keyPath The path to the key that we wish to observe. + * @param handler The callback that will be invoked if the value at the chosen key path changes. + * @throws if key path is not a string. + * @throws if handler is not a function. + */ + observe(keyPath: string, handler: (evt: ElectronSettings.ChangeEvent) => void): Observer; - /** - * Emitted when the settings file has been created. - */ - on(event: 'create', listener: (pathToSettings: string) => void): this; - /** - * Emitted when the settings have been written to disk. - */ - on(event: 'write', listener: () => void): this; + /** + * Returns the path to the config file. Typically found in your application's user data directory: + * ~/Library/Application Support/YourApp on MacOS. + * %APPDATA%/YourApp on Windows. + * $XDG_CONFIG_HOME/YourApp or ~/.config/YourApp on Linux. + */ + getSettingsFilePath(): string; + + /** + * Emitted when the settings file has been created. + */ + on(event: 'create', listener: (pathToSettings: string) => void): this; + /** + * Emitted when the settings have been written to disk. + */ + on(event: 'write', listener: () => void): this; + } + + const SettingsInstance: Settings; + export = SettingsInstance; } -declare const SettingsInstance: Settings; -export = SettingsInstance; - -declare namespace ElectronSettings { +declare module 'electron-settings/lib/observer' { /** * The Observer class. */ @@ -202,9 +205,15 @@ declare namespace ElectronSettings { dispose(): void; } + export = Observer; +} + +declare namespace ElectronSettings { interface Options extends Pick { } namespace Options { + type Param = Options | object; + interface _Impl { /** * Whether electron-settings should create a tmp file during save to ensure data-write consistency. @@ -224,6 +233,8 @@ declare namespace ElectronSettings { interface ApplyDefaultsOptions extends Pick { } namespace ApplyDefaultsOptions { + type Param = ApplyDefaultsOptions | object; + interface _Impl extends Options._Impl { /** * Overwrite pre-existing settings with their respective default values. From 98bc49403070408c030edede89c0b9449170d0b5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 15 Jun 2017 14:32:33 -0700 Subject: [PATCH 11/90] node-getopt: Fix type of `create` --- types/node-getopt/index.d.ts | 2 +- types/node-getopt/node-getopt-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/node-getopt/index.d.ts b/types/node-getopt/index.d.ts index afd0a89adf..cb08791fc3 100644 --- a/types/node-getopt/index.d.ts +++ b/types/node-getopt/index.d.ts @@ -122,7 +122,7 @@ declare class Getopt { * equals new Getopt(options) * @param options */ - static create(options: string[]): Getopt; + static create(options: string[][]): Getopt; } export = Getopt; diff --git a/types/node-getopt/node-getopt-tests.ts b/types/node-getopt/node-getopt-tests.ts index 7427731ca8..2ba3afd01d 100644 --- a/types/node-getopt/node-getopt-tests.ts +++ b/types/node-getopt/node-getopt-tests.ts @@ -34,7 +34,7 @@ function help() { function onedragon() { // examples/onedragon.js - var opt = require('node-getopt').create([ + var opt = Getopt.create([ ['s' , '' , 'short option.'], ['' , 'long' , 'long option.'], ['S' , 'short-with-arg=ARG' , 'option with argument'], @@ -52,7 +52,7 @@ function onedragon() { function online(){ // node-getopt oneline example. - var opt = require('..').create([ + var opt = Getopt.create([ ['s' , '' , 'short option.'], ['' , 'long' , 'long option.'], ['S' , 'short-with-arg=ARG' , 'option with argument'], From 1e6172179eb6ca8e90449d22d155d312605e177b Mon Sep 17 00:00:00 2001 From: Kevin Lowe Date: Thu, 15 Jun 2017 18:06:38 -0700 Subject: [PATCH 12/90] Add module declaration for pdfjs-dist library --- types/pdf/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/pdf/index.d.ts b/types/pdf/index.d.ts index c3d7bc8788..31c9ed7800 100644 --- a/types/pdf/index.d.ts +++ b/types/pdf/index.d.ts @@ -474,3 +474,8 @@ interface PDFJSStatic { } declare var PDFJS: PDFJSStatic; + +declare module "pdfjs-dist" { + export = PDFJS; +} + From 2d9acea80aae1fe59914e706d045072e14cd442f Mon Sep 17 00:00:00 2001 From: Andrew Linfoot Date: Thu, 15 Jun 2017 18:30:20 -0700 Subject: [PATCH 13/90] Allow null values to be passed to navigation.goBack() --- types/react-navigation/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index d4ec6dc2d4..7d26058ad3 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -360,7 +360,7 @@ export interface NavigationProp { } export type NavigationScreenProp = NavigationProp & { - goBack: (routeKey?: string) => boolean, + goBack: (routeKey?: string | null) => boolean, navigate: (routeName: string, params?: NavigationParams, action?: NavigationAction) => boolean, setParams: (newParams: NavigationParams) => boolean, } From 05ce66f5df31e1689725acefe03d7a6de60529e6 Mon Sep 17 00:00:00 2001 From: Sebastien PUECH Date: Fri, 16 Jun 2017 11:03:35 +0200 Subject: [PATCH 14/90] Created a typings for the collections.js library. Only the SortedSet is made. --- types/collections/collections-tests.ts | 32 ++++++ types/collections/index.d.ts | 133 +++++++++++++++++++++++++ types/collections/tsconfig.json | 13 +++ 3 files changed, 178 insertions(+) create mode 100644 types/collections/collections-tests.ts create mode 100755 types/collections/index.d.ts create mode 100644 types/collections/tsconfig.json diff --git a/types/collections/collections-tests.ts b/types/collections/collections-tests.ts new file mode 100644 index 0000000000..b7feef3c05 --- /dev/null +++ b/types/collections/collections-tests.ts @@ -0,0 +1,32 @@ +import SortedSet = require('collections/sorted-set'); + +interface Person { + name: string; +} + +let set = new SortedSet( + [{name: 'John'}, {name: 'Jack'}, {name: 'Linda'}], + (a: Person, b: Person) => a.name === b.name, + (a: Person, b: Person) => { + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } + return 0; + } +); + +let p1: Person | undefined = set.max(); +let p2: Person | undefined = set.min(); + + +set.push({name: 'Laurie'}, {name: 'Max'}); +set.pop(); + +set.get({name: 'Laurie'}); +set.has({name: 'John'}); + +let a = 1; +set.forEach((p: Person) => a++); \ No newline at end of file diff --git a/types/collections/index.d.ts b/types/collections/index.d.ts new file mode 100755 index 0000000000..f423eb458d --- /dev/null +++ b/types/collections/index.d.ts @@ -0,0 +1,133 @@ +// Type definitions for collections v5.0.6 +// Project: http://www.collectionsjs.com/ +// Definitions by: Scarabe Dore <> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'collections/sorted-set' { + namespace internal { + // TODO: These methods can be similar in others collection. One's should make some + // class model. + abstract class AbstractSet { + union(...plus: any[]): any; + intersection(...plus: any[]): any; + difference(...plus: any[]): any; + symmetricDifference(...plus: any[]): any; + remove(...plus: any[]): any; + contains(...plus: any[]): any; + toggle(...plus: any[]): any; + addEach(...plus: any[]): any; + deleteEach(...plus: any[]): any; + deleteAll(...plus: any[]): any; + findValue(...plus: any[]): any; + iterator(...plus: any[]): any; + forEach(...plus: any[]): any; + map(...plus: any[]): any; + + filter(...plus: any[]): any; + group(...plus: any[]): any; + some(...plus: any[]): any; + every(...plus: any[]): any; + any(...plus: any[]): any; + all(...plus: any[]): any; + only(...plus: any[]): any; + sorted(...plus: any[]): any; + reversed(...plus: any[]): any; + join(...plus: any[]): any; + sum(...plus: any[]): any; + average(...plus: any[]): any; + zip(...plus: any[]): any; + enumerate(...plus: any[]): any; + concat(...plus: any[]): any; + flatten(...plus: any[]): any; + toArray(...plus: any[]): any; + toObject(...plus: any[]): any; + toJSON(...plus: any[]): any; + equals(...plus: any[]): any; + clone(...plus: any[]): any; + contentCompare(...plus: any[]): any; + contentEquals(...plus: any[]): any; + sortedSetLog(...plus: any[]): any; + addRangeChangeListener(...plus: any[]): any; + removeRangeChangeListener(...plus: any[]): any; + dispatchRangeChange(...plus: any[]): any; + addBeforeRangeChangeListener(...plus: any[]): any; + removeBeforeRangeChangeListener(...plus: any[]): any; + dispatchBeforeRangeChange(...plus: any[]): any; + addOwnPropertyChangeListener(...plus: any[]): any; + addBeforeOwnPropertyChangeListener(...plus: any[]): any; + removeOwnPropertyChangeListener(...plus: any[]): any; + removeBeforeOwnPropertyChangeListener(...plus: any[]): any; + dispatchOwnPropertyChange(...plus: any[]): any; + dispatchBeforeOwnPropertyChange(...plus: any[]): any; + makePropertyObservable(...plus: any[]): any; + } + + class Node { + reduce(cb: (result?: any, val?: any, key?: any, collection?: any) => any, + basis: any, index: number, thisp: any, tree: any, depth: number): any; + touch(...plus: any[]): void; + checkIntegrity(...plus: any[]): number; + getNext(...plus: any[]): Node | undefined; + getPrevious(...plus: any[]): Node | undefined; + summary(...plus: any[]): string; + log(charmap: any, logNode: any, log: any, logAbove: any): any; + } + + class Iterator { + next(): {done: true, value: T | null | undefined}; + } + + export class SortedSet extends AbstractSet { + constructor( + values?: T[], + equals?: (a: T, b: T) => boolean, + compare?: (a: T, b: T) => number, + getDefault?: any + ); + constructClone(values?: T[]): SortedSet; + + add(value: T): boolean; + clear(): void; + ['delete'](value: T): boolean; + + find(value: T): Node | undefined; + findGreatest(n?: Node | undefined): Node | undefined; + findGreatestLessThan(value: T): Node | undefined; + findGreatestLessThanOrEqual(value: T): Node | undefined; + findLeast(n?: Node | undefined): Node | undefined; + findLeastGreaterThan(value: T): Node | undefined; + findLeastGreaterThanOrEqual(value: T): Node | undefined; + max(n?: Node): T | undefined; + min(n?: Node): T | undefined; + one(): T | undefined; + + get(elt: T): T | undefined; + has(elt: T): boolean; + indexOf(value: T): number; + + pop(): T | undefined; + push(...rest: T[]): void; + + shift(): T | undefined; + unshift(...rest: T[]): void; + + slice(start?: number, end?: number): T[]; + splice(start: Node, length: number, ...values: T[]): T[]; + swap(start: number, length: number, values?: T[]): T[]; + + splay(value: T): void; + splayIndex(index: number): boolean; + + reduce(callback: (result?: any, val?: any, key?: any, collection?: any) => any, + basis?: any, thisp?: any): any; + reduceRight( + callback: (result?: any, val?: any, key?: any, collection?: any) => any, + basis?: any, thisp?: any + ): any; + + iterate(start: number, stop: number): Iterator; + } + } + + export = internal.SortedSet; +} \ No newline at end of file diff --git a/types/collections/tsconfig.json b/types/collections/tsconfig.json new file mode 100644 index 0000000000..c90cfab20d --- /dev/null +++ b/types/collections/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": ["es2015"], + "sourceMap": true, + "strict": true, + "typeRoots": ["."] + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file From 3aabbf999d4e508b6d30d969b78292206e1c7b21 Mon Sep 17 00:00:00 2001 From: shinhwagk Date: Fri, 16 Jun 2017 17:53:57 +0800 Subject: [PATCH 15/90] [kafka-node] modify property Client.clientId to Client.clientId? Client clientId have default value 'kafka-node-client'. --- types/kafka-node/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/kafka-node/index.d.ts b/types/kafka-node/index.d.ts index 46de85286d..f1d1922769 100644 --- a/types/kafka-node/index.d.ts +++ b/types/kafka-node/index.d.ts @@ -6,7 +6,7 @@ // # Classes export declare class Client { - constructor(connectionString: string, clientId: string, options?: ZKOptions); + constructor(connectionString: string, clientId?: string, options?: ZKOptions); close(callback?: Function): void; topicExists(topics: Array, callback: Function): void; refreshMetadata(topics: Array, cb?: (error: any, data: any) => any): void; From 284892954bc041839cca3184d159395282377d3b Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 07:14:37 -0700 Subject: [PATCH 16/90] core-js: Fix tests that fail due to callback covariance --- types/core-js/core-js-tests.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/types/core-js/core-js-tests.ts b/types/core-js/core-js-tests.ts index 3f585db33e..325ff56fc1 100644 --- a/types/core-js/core-js-tests.ts +++ b/types/core-js/core-js-tests.ts @@ -243,15 +243,15 @@ promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint); promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => point); promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => point); promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => promiseLikeOfPoint); -promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => { }); -promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => { }); +promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => { throw e; }); +promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => { throw e; }); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => point3d); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => point3d); promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => promiseLikeOfPoint3D); -promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => { }); -promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => { }); +promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => { throw e; }); +promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => { throw e; }); promiseOfPoint.then((point: Point) => { }); promiseOfPoint = promiseOfPoint.then(); promiseOfPoint = promiseOfPoint.then(p => point); @@ -262,9 +262,9 @@ promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => point); promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => point); promiseOfPoint = promiseOfPoint.then(p => point, e => promiseOfPoint); promiseOfPoint = promiseOfPoint.then(p => point, e => promiseLikeOfPoint); -promiseOfPoint = promiseOfPoint.then(p => point, e => { }); -promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => { }); -promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => { }); +promiseOfPoint = promiseOfPoint.then(p => point, e => { throw e; }); +promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => { throw e; }); +promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => { throw e; }); promiseOfPoint3D = promiseOfPoint.then(p => point3d); promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D); promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D); @@ -273,16 +273,16 @@ promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => point3d); promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => point3d); promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => promiseOfPoint3D); promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => promiseLikeOfPoint3D); -promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => { }); -promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => { }); -promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => { }); +promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => { throw e; }); +promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => { throw e; }); +promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => { throw e; }); promiseOfPoint = promiseOfPoint.catch(e => point); promiseOfPoint = promiseOfPoint.catch(e => promiseOfPoint); promiseOfPoint = promiseOfPoint.catch(e => promiseLikeOfPoint); -promiseOfPoint = promiseOfPoint.catch(e => { }); -promiseOfPoint3D = promiseOfPoint.catch(e => point3d); -promiseOfPoint3D = promiseOfPoint.catch(e => promiseOfPoint3D); -promiseOfPoint3D = promiseOfPoint.catch(e => promiseLikeOfPoint3D); +promiseOfPoint = promiseOfPoint.catch(e => { throw e; }); +promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => point3d); +promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => promiseOfPoint3D); +promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => promiseLikeOfPoint3D); promiseOfPoint = new Promise((resolve, reject) => resolve(point)); promiseOfPoint = new Promise((resolve, reject) => resolve(promiseOfPoint)); promiseOfPoint = new Promise((resolve, reject) => resolve(promiseLikeOfPoint)); From c15e214e5a77e2e158e0e3e61b4fe3d49e0cc48d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 07:08:11 -0700 Subject: [PATCH 17/90] bluebird: Make `Thenable` an alias to the builtin `PromiseLike`. --- types/amqplib/index.d.ts | 1 + types/anydb-sql-migrations/index.d.ts | 1 + types/asana/index.d.ts | 1 + types/auth0/index.d.ts | 1 + types/blue-tape/index.d.ts | 1 + types/bluebird-global/index.d.ts | 1 + types/bluebird-retry/index.d.ts | 1 + types/bluebird/index.d.ts | 13 +- types/bookshelf/index.d.ts | 2 +- types/consolidate/index.d.ts | 1 + types/db-migrate-base/index.d.ts | 1 + types/db-migrate-pg/index.d.ts | 1 + types/fs-extra-promise/index.d.ts | 4 +- types/inline-css/index.d.ts | 1 + types/java/index.d.ts | 1 + types/java/java-tests.ts | 4 +- types/karma-coverage/index.d.ts | 1 + types/karma/index.d.ts | 4 +- types/knex/index.d.ts | 3 +- types/node-mysql-wrapper/index.d.ts | 49 ++-- types/nodemailer-smtp-transport/index.d.ts | 8 +- types/nodemailer/index.d.ts | 6 +- types/orientjs/index.d.ts | 2 + types/pg/pg-tests.ts | 4 +- types/pify/pify-tests.ts | 6 +- types/project-oxford/index.d.ts | 1 + types/redlock/index.d.ts | 1 + types/request-promise/index.d.ts | 1 + types/sequelize-fixtures/index.d.ts | 4 +- types/sequelize/index.d.ts | 3 +- types/sequelize/v3/index.d.ts | 1 - types/simple-mock/simple-mock-tests.ts | 11 +- types/simple-oauth2/index.d.ts | 1 + types/stripe-node/index.d.ts | 1 - types/umzug/index.d.ts | 3 - types/waterline/index.d.ts | 1 + types/webgme/tsconfig.json | 1 + types/webgme/webgme-tests.ts | 258 +++++++++------------ 38 files changed, 186 insertions(+), 219 deletions(-) diff --git a/types/amqplib/index.d.ts b/types/amqplib/index.d.ts index a6e5aec204..45b5e6e3ca 100644 --- a/types/amqplib/index.d.ts +++ b/types/amqplib/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/squaremo/amqp.node // Definitions by: Michael Nahkies , Ab Reitsma , Nicolás Fantone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/anydb-sql-migrations/index.d.ts b/types/anydb-sql-migrations/index.d.ts index 5db740c70f..ae922c37ae 100644 --- a/types/anydb-sql-migrations/index.d.ts +++ b/types/anydb-sql-migrations/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/spion/anydb-sql-migrations // Definitions by: Gorgi Kosev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import Promise = require('bluebird'); import { Column, Table, Transaction, AnydbSql } from 'anydb-sql'; diff --git a/types/asana/index.d.ts b/types/asana/index.d.ts index 364980b66c..ede3bc99f9 100644 --- a/types/asana/index.d.ts +++ b/types/asana/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Asana/node-asana // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index a8a6242bb4..0e810f8ae5 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/auth0/node-auth0 // Definitions by: Wilson Hobbs , Seth Westphal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as Promise from 'bluebird'; diff --git a/types/blue-tape/index.d.ts b/types/blue-tape/index.d.ts index 133968a165..c2d2d50ab5 100644 --- a/types/blue-tape/index.d.ts +++ b/types/blue-tape/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/spion/blue-tape // Definitions by: Haoqun Jiang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/bluebird-global/index.d.ts b/types/bluebird-global/index.d.ts index 835bc59c31..20e38ed7bb 100644 --- a/types/bluebird-global/index.d.ts +++ b/types/bluebird-global/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/petkaantonov/bluebird // Definitions by: d-ph // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /* * 1. Why use `bluebird-global` instead of `bluebird`? diff --git a/types/bluebird-retry/index.d.ts b/types/bluebird-retry/index.d.ts index 63adc1476d..97d756524b 100644 --- a/types/bluebird-retry/index.d.ts +++ b/types/bluebird-retry/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jut-io/bluebird-retry // Definitions by: Pascal Vomhoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 5d1d5cfc81..3dc4aad0a4 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/petkaantonov/bluebird // Definitions by: Leonard Hecker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /*! * The code following this comment originates from: @@ -44,10 +45,8 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(onFulfill: (value: R) => U1 | Bluebird.Thenable, onReject: (error: any) => U2 | Bluebird.Thenable): Bluebird; - then(onFulfill: (value: R) => U | Bluebird.Thenable, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - then(onFulfill: (value: R) => U | Bluebird.Thenable): Bluebird; - then(): Bluebird; + // Based on PromiseLike.then, but returns a Bluebird instance. + then(onfulfilled?: ((value: R) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Bluebird; /** * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. @@ -951,10 +950,8 @@ declare namespace Bluebird { export class Disposer { } - export interface Thenable { - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => void | Thenable): Thenable; - } + /** @deprecated Use PromiseLike directly. */ + export type Thenable = PromiseLike; export interface Resolver { /** diff --git a/types/bookshelf/index.d.ts b/types/bookshelf/index.d.ts index a7c0a90536..55be61ba9e 100644 --- a/types/bookshelf/index.d.ts +++ b/types/bookshelf/index.d.ts @@ -2,7 +2,7 @@ // Project: http://bookshelfjs.org/ // Definitions by: Andrew Schurman , Vesa Poikajärvi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import Knex = require('knex'); import knex = require('knex'); diff --git a/types/consolidate/index.d.ts b/types/consolidate/index.d.ts index 2a0adb1db9..bfe432214f 100644 --- a/types/consolidate/index.d.ts +++ b/types/consolidate/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/visionmedia/consolidate.js // Definitions by: Carlos Ballesteros Velasco , Theo Sherry , Nicolas Henry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 // Imported from: https://github.com/soywiz/typescript-node-definitions/consolidate.d.ts diff --git a/types/db-migrate-base/index.d.ts b/types/db-migrate-base/index.d.ts index de3a4c0812..a881fa6a06 100644 --- a/types/db-migrate-base/index.d.ts +++ b/types/db-migrate-base/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/db-migrate/db-migrate-base // Definitions by: nickiannone // Definitions: https://github.com/nickiannone/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/db-migrate-pg/index.d.ts b/types/db-migrate-pg/index.d.ts index 7804f4ddad..6a72fd1109 100644 --- a/types/db-migrate-pg/index.d.ts +++ b/types/db-migrate-pg/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/db-migrate/pg // Definitions by: nickiannone // Definitions: https://github.com/nickiannone/DefinitelyTyped +// TypeScript Version: 2.3 import * as pg from "pg"; import * as DbMigrateBase from "db-migrate-base"; diff --git a/types/fs-extra-promise/index.d.ts b/types/fs-extra-promise/index.d.ts index b4c9a648ac..a962746944 100644 --- a/types/fs-extra-promise/index.d.ts +++ b/types/fs-extra-promise/index.d.ts @@ -2,11 +2,9 @@ // Project: https://github.com/overlookmotel/fs-extra-promise // Definitions by: midknight41 , Jason Swearingen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 /// -/// -/// import * as stream from 'stream'; import { Stats } from 'fs'; diff --git a/types/inline-css/index.d.ts b/types/inline-css/index.d.ts index a6db3ef67b..6d43b7975d 100644 --- a/types/inline-css/index.d.ts +++ b/types/inline-css/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jonkemp/inline-css // Definitions by: Philip Spain // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/java/index.d.ts b/types/java/index.d.ts index 46dc577e35..cf770a8807 100644 --- a/types/java/index.d.ts +++ b/types/java/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/joeferner/node-java // Definitions by: Jim Lloyd , Kentaro Teramoto // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/java/java-tests.ts b/types/java/java-tests.ts index 6d464b36e1..4c79640733 100644 --- a/types/java/java-tests.ts +++ b/types/java/java-tests.ts @@ -1,5 +1,3 @@ -/// - import java = require('java'); import BluePromise = require('bluebird'); @@ -9,7 +7,7 @@ java.asyncOptions = { promiseSuffix: 'P', promisify: BluePromise.promisify }; -// todo: figure out why promise doesn't work here +// todo: figure out why promise doesn't work here /* java.registerClientP((): Promise => { return BluePromise.resolve(); }); */ diff --git a/types/karma-coverage/index.d.ts b/types/karma-coverage/index.d.ts index 20ee56f43c..03ca857449 100644 --- a/types/karma-coverage/index.d.ts +++ b/types/karma-coverage/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/karma-runner/karma-coverage // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as karma from 'karma'; import * as istanbul from 'istanbul'; diff --git a/types/karma/index.d.ts b/types/karma/index.d.ts index 59590b0a6d..ab4dc9b31f 100644 --- a/types/karma/index.d.ts +++ b/types/karma/index.d.ts @@ -2,8 +2,8 @@ // Project: https://github.com/karma-runner/karma // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -/// /// // See Karma public API https://karma-runner.github.io/0.13/dev/public-api.html @@ -54,7 +54,7 @@ declare namespace karma { }; EXIT_CODE: string; } - + interface LauncherStatic { generateId(): string; //TODO: injector should be of type `di.Injector` diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index fa84243b76..2e301af850 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -2,9 +2,8 @@ // Project: https://github.com/tgriesser/knex // Definitions by: Qubo , Baronfel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 -/// /// import events = require("events"); diff --git a/types/node-mysql-wrapper/index.d.ts b/types/node-mysql-wrapper/index.d.ts index 7785d8a7b4..c887da3368 100644 --- a/types/node-mysql-wrapper/index.d.ts +++ b/types/node-mysql-wrapper/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/nodets/node-mysql-wrapper // Definitions by: Makis Maropoulos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// @@ -49,20 +50,20 @@ interface IQueryConstructor { declare class Helper { - /** + /** * Callback like forEach * @name valueCallback * @function - * @param {T} the value of the object's key + * @param {T} the value of the object's key * @returnTye {U} * @return {U} */ - + /** * CallbaforEach * @name keyCallback * @function - * @param {string} the name of the object's key + * @param {string} the name of the object's key * @returnTye {U} * @return {U} */ @@ -158,7 +159,7 @@ declare class CriteriaParts implements ICriteriaParts { noDatabaseProperties: string[]; /** - * The converted/exported where clause. + * The converted/exported where clause. */ whereClause: string; @@ -472,7 +473,7 @@ declare class Connection extends EventEmitter { eventTypes: string[]; /** - * Force to fetch ONLY these Database table names {array of string}. + * Force to fetch ONLY these Database table names {array of string}. */ tableNamesToUseOnly: any[]; @@ -495,7 +496,7 @@ declare class Connection extends EventEmitter { * Attach a real connection. * @param {Mysql.IConnection} connection the real connection object. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ attach(connection: Mysql.IConnection): void; @@ -503,13 +504,13 @@ declare class Connection extends EventEmitter { * Close the entire real connection and remove all event's listeners (if exist). * @param {function} callback If error occurs when closing the connection, this callback has the responsibility to catch it. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ end(callback?: (error: any) => void): void; /** * Close the entire real connection and remove all event's listeners (if exist). - * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. + * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. */ destroy(): void; @@ -545,7 +546,7 @@ declare class Connection extends EventEmitter { /** * Escape the query column's value and return it. - * @param {string} val the value which will be escaped. + * @param {string} val the value which will be escaped. * @returnType {string} * @return {string} */ @@ -565,7 +566,7 @@ declare class Connection extends EventEmitter { * Adds an event listener/watcher on a table for a 'database event'. * @param {string} tableName the table name which you want to add the event listener. * @param {string or string[]} evtType the event(s) type you want to watch, one of these(string) or an array of them(string[]): ["INSERT", "UPDATE", "REMOVE", "SAVE"]. - * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawRows (results after query executed and before parsed to object(s)). + * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawRows (results after query executed and before parsed to object(s)). * @returnType {nothing} * @return {nothing} */ @@ -573,7 +574,7 @@ declare class Connection extends EventEmitter { /** * Removes an event listener/watcher from a table for a specific event type. - * @param {string} tableName the table name which you want to remove the event listener. + * @param {string} tableName the table name which you want to remove the event listener. * @param {string} evtType the Event type you want to remove, one of these: "INSERT", "UPDATE", "REMOVE", "SAVE". * @param {function} callbackToRemove the callback that you were used for watch this event type. * @returnType {nothing} @@ -587,13 +588,13 @@ declare class Connection extends EventEmitter { * @param {function} callback the function will be called and fill the one and only parameter when an errors occurs. * @param {any[]} queryArguments (optional) the query arguments you want to pass into query. ['arg1','arg2']... * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ query(queryStr: string, callback: (err: Mysql.IError, results: any) => any, queryArguments?: any[]): void; /** * Returns a MysqlTable object from the database factory. (Note: this method doesn't create anything, just finds and returns the correct table, you don't have to create anything at all. Tables are fetched by the library itself.) - * If you are using typescript you can pass a class (generic) in order to use the auto completion assistance on table's results methods(find,findById,findAll,save,remove,safeRemove). + * If you are using typescript you can pass a class (generic) in order to use the auto completion assistance on table's results methods(find,findById,findAll,save,remove,safeRemove). * @param {string} tableName the table name which you want to get, on the form of: 'anyDatabaseTable' OR 'any_database_table' (possible your real table name into your database). * @returnType {MysqlTable} * @return {MysqlTable} @@ -602,7 +603,7 @@ declare class Connection extends EventEmitter { } declare class Table { - /** Private keywords here are useless but I put them. + /** Private keywords here are useless but I put them. * If the developer wants to see the properties of the Table class, he/she just comes here. */ @@ -630,17 +631,17 @@ declare class Table { primaryKey: string; /** - * The MysqlConnection object which this MysqlTable belongs. + * The MysqlConnection object which this MysqlTable belongs. */ connection: Connection; /** - * The real database name of the table. Autofilled by library. + * The real database name of the table. Autofilled by library. */ name: string; /** - * Set of the query rules that will be applied after the 'where clause' on each select query executed by this table. + * Set of the query rules that will be applied after the 'where clause' on each select query executed by this table. * @return {SelectQueryRules} */ rules: SelectQueryRules; @@ -661,7 +662,7 @@ declare class Table { /** * Adds or turn on an event listener/watcher on a table for a 'database event'. * @param {string} evtType the event type you want to watch, one of these: ["INSERT", "UPDATE", "REMOVE", "SAVE"]. - * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawResults (results after query executed and before exports to object(s)). + * @param {function} callback Callback which has one parameter(typeof any[]) which filled by the rawResults (results after query executed and before exports to object(s)). * @returnType {nothing} * @return {nothing} */ @@ -689,7 +690,7 @@ declare class Table { * @param {string} functionName the function name you want to use, this is used when you want to call this function later. * @param {function} theFunction the function with any optional parameters you want to pass along. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ extend(functionName: string, theFunction: (...args: any[]) => any): void; @@ -726,9 +727,9 @@ declare class Table { getPrimaryKeyValue(jsObject: any): number | string; /** - * + * */ - find(criteriaRawJsObject: any): Promise; // only criteria + find(criteriaRawJsObject: any): Promise; // only criteria find(criteriaRawJsObject: any, callback: ((_results: T[]) => any)): Promise; // criteria and callback find(criteriaRawJsObject: any, callback?: (_results: T[]) => any): Promise; @@ -792,7 +793,7 @@ declare class Database { /** * Close the entire real connection and remove all event's listeners (if exist). - * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. + * the difference from the 'end' is that this method doesn't care about errors so no callback passing here. */ destroy(): void; @@ -800,7 +801,7 @@ declare class Database { * Close the entire real connection and remove all event's listeners (if exist). * @param {function} maybeAcallbackError If error occurs when closing the connection, this callback has the responsibility to catch it. * @returnType {nothing} - * @return {nothing} + * @return {nothing} */ end(maybeAcallbackError: (err: any) => void): void; diff --git a/types/nodemailer-smtp-transport/index.d.ts b/types/nodemailer-smtp-transport/index.d.ts index 7f0f8d7cca..4e4e11afe0 100644 --- a/types/nodemailer-smtp-transport/index.d.ts +++ b/types/nodemailer-smtp-transport/index.d.ts @@ -24,16 +24,16 @@ declare namespace smtpTransport { /** is the registered client secret of the application */ clientSecret?: string; - + /** is an optional refresh token. If it is provided then Nodemailer tries to generate a new access token if existing one expires or fails */ refreshToken?: string; - + /** is the access token for the user. Required only if refreshToken is not available and there is no token refresh callback specified */ accessToken?: string; - + /** is an optional expiration time for the current accessToken */ expires?: number; - + /** is an optional HTTP endpoint for requesting new access tokens. This value defaults to Gmail */ accessUrl?: string; diff --git a/types/nodemailer/index.d.ts b/types/nodemailer/index.d.ts index 88a82f073a..833873c45e 100644 --- a/types/nodemailer/index.d.ts +++ b/types/nodemailer/index.d.ts @@ -4,11 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import directTransport = require("nodemailer-direct-transport"); import smtpTransport = require("nodemailer-smtp-transport"); -import * as Promise from 'bluebird'; /** * Transporter plugin @@ -36,7 +34,7 @@ export interface Transporter { * Send mail using a template. */ templateSender(template?: any, defaults?: any): (mailData: any, context: any) => Promise; - + /** * Send mail using a template with a callback. */ @@ -50,7 +48,7 @@ export interface Transporter { * @param pluginFunc is a function that takes two arguments: the mail object and a callback function */ use(step: string, plugin: Plugin): void; - + /** * Verifies connection with server */ diff --git a/types/orientjs/index.d.ts b/types/orientjs/index.d.ts index 571aeebe7c..679fc7c70a 100644 --- a/types/orientjs/index.d.ts +++ b/types/orientjs/index.d.ts @@ -2,6 +2,8 @@ // Project: https://github.com/orientechnologies/orientjs // Definitions by: Saeed Tabrizi // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.3 + // Developed with love in www.nowcando.com /// diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index 2fe301935a..73c18ac1b7 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -1,6 +1,4 @@ - import * as pg from "pg"; -import * as bluebird from "bluebird"; var conString = "postgres://username:password@localhost/database"; @@ -55,7 +53,7 @@ var config = { port: 5432, //env var: PGPORT max: 10, // max number of clients in the pool idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed - Promise: bluebird + Promise, }; var pool = new pg.Pool(config); diff --git a/types/pify/pify-tests.ts b/types/pify/pify-tests.ts index 2252005b85..87e1ba28ae 100644 --- a/types/pify/pify-tests.ts +++ b/types/pify/pify-tests.ts @@ -1,8 +1,4 @@ - -/// - import * as pify from 'pify'; -import * as Bluebird from 'bluebird'; function assert(actual: string, expected: string): void { if (actual !== expected) { @@ -28,4 +24,4 @@ const fsP = pify(fs); fsP.readFile('foo.txt').then((result: string) => assert(result, 'foo')); pify(fs.readFile)('foo.txt').then((result: string) => assert(result, 'foo')); -pify(fs.readFile, Bluebird)('bar.txt').then((result: string) => assert(result, 'bar')); \ No newline at end of file +pify(fs.readFile, Promise)('bar.txt').then((result: string) => assert(result, 'bar')); \ No newline at end of file diff --git a/types/project-oxford/index.d.ts b/types/project-oxford/index.d.ts index db322e3fa8..5a85f26ad6 100644 --- a/types/project-oxford/index.d.ts +++ b/types/project-oxford/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/felixrieseberg/project-oxford // Definitions by: Scott Southwood // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/redlock/index.d.ts b/types/redlock/index.d.ts index 85e5882639..1e00de6ed1 100644 --- a/types/redlock/index.d.ts +++ b/types/redlock/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/mike-marcacci/node-redlock // Definitions by: Ilya Mochalov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as redis from 'redis'; import * as Promise from 'bluebird'; diff --git a/types/request-promise/index.d.ts b/types/request-promise/index.d.ts index 06d4947579..393abacbe7 100644 --- a/types/request-promise/index.d.ts +++ b/types/request-promise/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/request/request-promise // Definitions by: Christopher Glantschnig , Joe Skeen , Aya Morisawa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import request = require('request'); import http = require('http'); diff --git a/types/sequelize-fixtures/index.d.ts b/types/sequelize-fixtures/index.d.ts index 6114ed84e2..5a54317668 100644 --- a/types/sequelize-fixtures/index.d.ts +++ b/types/sequelize-fixtures/index.d.ts @@ -2,9 +2,7 @@ // Project: https://github.com/domasx2/sequelize-fixtures // Definitions by: Christian Schwarz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - -/// +// TypeScript Version: 2.3 import * as Sequelize from "sequelize"; diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 47e6039f89..a427c30eb8 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -2,12 +2,11 @@ // Project: http://sequelizejs.com // Definitions by: samuelneff , Peter Harris , Ivan Drinchev , Brendan Abolivier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 // Based on original work by: samuelneff /// -/// /// diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index 1a3ce50d0c..50e428f47b 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -7,7 +7,6 @@ // Based on original work by: samuelneff /// -/// /// diff --git a/types/simple-mock/simple-mock-tests.ts b/types/simple-mock/simple-mock-tests.ts index 16d8b89a93..05c900ee99 100644 --- a/types/simple-mock/simple-mock-tests.ts +++ b/types/simple-mock/simple-mock-tests.ts @@ -1,7 +1,7 @@ -/// - import Simple = require('simple-mock'); -import Bluebird = require('bluebird'); +declare function describe(desc: string, action: () => void): void; +declare function beforeEach(action: () => void): void; +declare function it(desc: string, action: (done: () => void) => void): void; declare var assert: { (cond: any, message?: string): void; equal(a: T, b: T): void; @@ -908,9 +908,6 @@ describe('Simple', function() { let obj: any - before(function() { - }) - beforeEach(function() { obj = new ProtoKlass() }) @@ -1019,5 +1016,5 @@ describe('Simple', function() { }) }) -Simple.Promise = Bluebird; +Simple.Promise = Promise; diff --git a/types/simple-oauth2/index.d.ts b/types/simple-oauth2/index.d.ts index a192e6879b..37add22766 100644 --- a/types/simple-oauth2/index.d.ts +++ b/types/simple-oauth2/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/lelylan/simple-oauth2 // Definitions by: [Michael Müller] // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import Bluebird = require("bluebird"); diff --git a/types/stripe-node/index.d.ts b/types/stripe-node/index.d.ts index b299f5c2a1..a6193cb45d 100644 --- a/types/stripe-node/index.d.ts +++ b/types/stripe-node/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: William Johnston , Peter Harris // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// declare module 'stripe' { diff --git a/types/umzug/index.d.ts b/types/umzug/index.d.ts index 85659e246b..31e2b569aa 100644 --- a/types/umzug/index.d.ts +++ b/types/umzug/index.d.ts @@ -4,9 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -/// -/// - import Sequelize = require("sequelize"); declare namespace umzug { diff --git a/types/waterline/index.d.ts b/types/waterline/index.d.ts index 6525e699b6..a3aa7c04ee 100644 --- a/types/waterline/index.d.ts +++ b/types/waterline/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/balderdashy/waterline // Definitions by: Alexandro Libertino // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// diff --git a/types/webgme/tsconfig.json b/types/webgme/tsconfig.json index 2d5184486f..d1ae63d85c 100644 --- a/types/webgme/tsconfig.json +++ b/types/webgme/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "module": "commonjs", + "target": "es6", "lib": [ "es6", "dom" diff --git a/types/webgme/webgme-tests.ts b/types/webgme/webgme-tests.ts index e6f315a3ef..61cd76bef0 100644 --- a/types/webgme/webgme-tests.ts +++ b/types/webgme/webgme-tests.ts @@ -15,7 +15,6 @@ */ const MetaDataStr = ""; -import Promise = require("bluebird"); import PluginBase = require("plugin/PluginBase"); import * as fs from "fs"; @@ -286,36 +285,29 @@ function test_client_using_a_blob() { return { stateMachine: { name: "dm", initialState: null, finalStates: [], states: [] } }; } - public main(mainHandler: Core.ResultCallback): void { + async main(mainHandler: Core.ResultCallback): Promise { let artifact: Core.Artifact; - Promise - .try(() => { - return this.extractDataModel(); - }) - .then((dataModel) => { - var dataModelStr = JSON.stringify(dataModel, null, 4); - this.dataModel = dataModel; + const dataModel = this.extractDataModel(); + var dataModelStr = JSON.stringify(dataModel, null, 4); + this.dataModel = dataModel; - this.logger.info('Extracted dataModel', dataModelStr); + this.logger.info('Extracted dataModel', dataModelStr); - return self.blobClient.putFile('dataModel.json', dataModelStr); - }) - .then((jsonFileHash) => { - // Add link from result to this file. - self.result.addArtifact(jsonFileHash); + const jsonFileHash = await self.blobClient.putFile('dataModel.json', dataModelStr); + // Add link from result to this file. + self.result.addArtifact(jsonFileHash); - // Create a complex artifact, with links to multiple files. - artifact = self.blobClient.createArtifact('simulator'); + // Create a complex artifact, with links to multiple files. + artifact = self.blobClient.createArtifact('simulator'); - let programJS = "some javascript file"; - self.logger.info('program.js', programJS); + let programJS = "some javascript file"; + self.logger.info('program.js', programJS); - return artifact.addFilesAsSoftLinks({ - 'program.js': programJS, - 'index.html': this.pluginMetadata - }); - }) + return artifact.addFilesAsSoftLinks({ + 'program.js': programJS, + 'index.html': this.pluginMetadata + }); } } } @@ -336,7 +328,7 @@ type DictionaryAny = { [key: string]: any }; * Related example using traverse. * https://github.com/webgme/xmi-tools/blob/master/src/plugins/XMIExporter/XMIExporter.js#L430 */ -function test_core_containment_traversal_complete() { +async function test_core_containment_traversal_complete() { const BLANK = ""; const NULL_OBJECT = "_OBJECT" const NULL_GUID = "00000000-0000-0000-0000-000000000000"; @@ -389,7 +381,7 @@ function test_core_containment_traversal_complete() { * The traverse function follows the containment tree. * @type {[type]} */ - let visitFn = (node: Node, done: Common.VoidFn): void => { + let visitFn = async (node: Node, done: Common.VoidFn): Promise => { try { let core = sponsor.core; let nodePath: string = core.getPath(node); @@ -486,133 +478,113 @@ function test_core_containment_traversal_complete() { }); // get pointers & inv_pointers - Promise - .try(() => { - return core.getPointerNames(node); - }) - .map((ptrName: string) => { - let targetPathRaw = core.getPointerPath(node, ptrName); - if (typeof targetPathRaw !== "string") { return; } + const ptrNames = await core.getPointerNames(node); + Promise.all(ptrNames.map(async ptrName => { + let targetPathRaw = core.getPointerPath(node, ptrName); + if (typeof targetPathRaw !== "string") { return; } - let targetPath: string = targetPathRaw; - Promise - .try(() => { - return core.loadByPath(sponsor.rootNode, targetPath); - }) - .then((targetNode: Node) => { - let targetGuid = core.getGuid(targetNode); - if (ptrName === "base") { + let targetPath: string = targetPathRaw; + const targetNode = core.loadByPath(sponsor.rootNode, targetPath); + let targetGuid = core.getGuid(targetNode); + if (ptrName === "base") { - } else { - let pointers: DictionaryAny = sourceEntry.pointers; - let targetMetaNode = core.getBaseType(targetNode); - let targetMetaName = core.getAttribute(targetMetaNode, "name"); - if (typeof targetMetaName === "string") { - pointers[ptrName] = { - name: targetMetaName, - guid: targetGuid - }; - } - let targetEntry = nodeGuidMap[targetGuid]; - if (targetEntry === undefined) { - targetEntry = { - "name": {}, - "guid": targetGuid, - "pointers": {}, "inv_pointers": {}, - "sets": {}, "inv_sets": {} - }; - nodeGuidMap[targetGuid] = targetEntry; - } - targetEntry.inv_pointers[ptrName] = { - name: targetMetaName, - guid: sourceGuid - }; - } - }); - }); + } else { + let pointers: DictionaryAny = sourceEntry.pointers; + let targetMetaNode = core.getBaseType(targetNode); + let targetMetaName = core.getAttribute(targetMetaNode, "name"); + if (typeof targetMetaName === "string") { + pointers[ptrName] = { + name: targetMetaName, + guid: targetGuid + }; + } + let targetEntry = nodeGuidMap[targetGuid]; + if (targetEntry === undefined) { + targetEntry = { + "name": {}, + "guid": targetGuid, + "pointers": {}, "inv_pointers": {}, + "sets": {}, "inv_sets": {} + }; + nodeGuidMap[targetGuid] = targetEntry; + } + targetEntry.inv_pointers[ptrName] = { + name: targetMetaName, + guid: sourceGuid + }; + } + })); // get sets & inv_set - Promise - .try(() => { - return core.getValidSetNames(node); - }) - .map((setName: string) => { - let targetMemberPathsRaw = core.getMemberPaths(node, setName); - for (let targetMemberPath of targetMemberPathsRaw) { - if (typeof targetMemberPath !== "string") { return; } - let targetPath: string = targetMemberPath; + const setNames = await core.getValidSetNames(node); + Promise.all(setNames.map(setName => { + let targetMemberPathsRaw = core.getMemberPaths(node, setName); + for (let targetMemberPath of targetMemberPathsRaw) { + if (typeof targetMemberPath !== "string") { return; } + let targetPath: string = targetMemberPath; - Promise - .try(() => { - return core.loadByPath(sponsor.rootNode, targetPath); - }) - .then((targetNode: Node) => { - let targetGuid = core.getGuid(targetNode); - let sets: DictionaryAny = sourceEntry.sets; - let targetMetaNode = core.getBaseType(targetNode); - let targetMetaName = core.getAttribute(targetMetaNode, "name"); - if (typeof targetMetaName === "string") { - let load = { - name: targetMetaName, - guid: targetGuid - }; - let sourceSet = sets[setName]; - if (sourceSet === undefined) { - sets[setName] = [load]; - } else { - sourceSet.push(load); - } - } - let targetEntry = nodeGuidMap[targetGuid]; - if (targetEntry === undefined) { - targetEntry = { - "name": {}, - "guid": targetGuid, - "pointers": {}, "inv_pointers": {}, - "sets": {}, "inv_sets": {} - }; - nodeGuidMap[targetGuid] = targetEntry; - } - let invSets = targetEntry.inv_sets; - let targetSet = invSets[setName]; - let invLoad = { - name: targetMetaName, - guid: sourceGuid - }; - if (targetSet === undefined) { - invSets[setName] = [invLoad]; - } else { - targetSet.push(invLoad); - }; - }) - .catch((err: Error) => { - console.log(`difficulty loading target path: ${targetPath} with err: ${err.message}`); - let load = { - "fault": `could not load member path: ${targetPath}` - }; - let sets: DictionaryAny = sourceEntry.sets; - let sourceSet = sets[setName]; - if (sourceSet === undefined) { - sets[setName] = [load]; - } else { - sourceSet.push(load); - } - }); + try { + const targetNode = core.loadByPath(sponsor.rootNode, targetPath); + let targetGuid = core.getGuid(targetNode); + let sets: DictionaryAny = sourceEntry.sets; + let targetMetaNode = core.getBaseType(targetNode); + let targetMetaName = core.getAttribute(targetMetaNode, "name"); + if (typeof targetMetaName === "string") { + let load = { + name: targetMetaName, + guid: targetGuid + }; + let sourceSet = sets[setName]; + if (sourceSet === undefined) { + sets[setName] = [load]; + } else { + sourceSet.push(load); + } + } + let targetEntry = nodeGuidMap[targetGuid]; + if (targetEntry === undefined) { + targetEntry = { + "name": {}, + "guid": targetGuid, + "pointers": {}, "inv_pointers": {}, + "sets": {}, "inv_sets": {} + }; + nodeGuidMap[targetGuid] = targetEntry; + } + let invSets = targetEntry.inv_sets; + let targetSet = invSets[setName]; + let invLoad = { + name: targetMetaName, + guid: sourceGuid + }; + if (targetSet === undefined) { + invSets[setName] = [invLoad]; + } else { + targetSet.push(invLoad); + }; } - }); + catch (err) { + console.log(`difficulty loading target path: ${targetPath} with err: ${err.message}`); + let load = { + "fault": `could not load member path: ${targetPath}` + }; + let sets: DictionaryAny = sourceEntry.sets; + let sourceSet = sets[setName]; + if (sourceSet === undefined) { + sets[setName] = [load]; + } else { + sourceSet.push(load); + } + } + } + })); } finally { done(); } }; - return Promise - .try(() => { - return core.traverse(sponsor.rootNode, - { excludeRoot: false }, - visitFn); - }) - .then(() => { - return nodeGuidMap; - }); + + await core.traverse(sponsor.rootNode, { excludeRoot: false }, visitFn); + return nodeGuidMap; } } From 4b2fabbdff1ec79fec7e2c3798e1f4af86360fa0 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 08:55:53 -0700 Subject: [PATCH 18/90] Fix webgme --- types/webgme/webgme-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webgme/webgme-tests.ts b/types/webgme/webgme-tests.ts index 61cd76bef0..d8fbc390e3 100644 --- a/types/webgme/webgme-tests.ts +++ b/types/webgme/webgme-tests.ts @@ -333,7 +333,7 @@ async function test_core_containment_traversal_complete() { const NULL_OBJECT = "_OBJECT" const NULL_GUID = "00000000-0000-0000-0000-000000000000"; - function getEdgesModel(sponsor: PluginBase, core: Core.Core, + async function getEdgesModel(sponsor: PluginBase, core: Core.Core, _rootNode: Common.Node, _metaNode: Common.Node): Core.Dictionary { let fcoName = core.getAttribute(core.getFCO(sponsor.rootNode), "name"); From 74c978a9a984b1eef4aaea9b50409964a1e4e11c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 09:01:33 -0700 Subject: [PATCH 19/90] Replace Bluebird.Thenable with PromiseLike --- types/bluebird-global/index.d.ts | 14 +-- types/bluebird/index.d.ts | 172 +++++++++++++++---------------- 2 files changed, 93 insertions(+), 93 deletions(-) diff --git a/types/bluebird-global/index.d.ts b/types/bluebird-global/index.d.ts index 20e38ed7bb..c0e220ce07 100644 --- a/types/bluebird-global/index.d.ts +++ b/types/bluebird-global/index.d.ts @@ -118,19 +118,19 @@ declare global { * * @todo Duplication of code is never ideal. See whether there's a better way of achieving this. */ - catch(predicate: (error: any) => boolean, onReject: (error: any) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable): Bluebird; - catch(predicate: Object, onReject: (error: any) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; + catch(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Bluebird; + catch(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike): Bluebird; + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => T | PromiseLike | void | PromiseLike): Bluebird; + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | PromiseLike): Bluebird; + catch(predicate: Object, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Bluebird; + catch(predicate: Object, onReject: (error: any) => U | PromiseLike): Bluebird; } /* * Patch all static methods and the constructor */ interface PromiseConstructor { - new (callback: (resolve: (thenableOrResult?: T | Bluebird.Thenable) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Promise; + new (callback: (resolve: (thenableOrResult?: T | PromiseLike) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Promise; // all: typeof Bluebird.all; any: typeof Bluebird.any; diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 3dc4aad0a4..f08cdb964b 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -35,12 +35,12 @@ * THE SOFTWARE. */ -declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection { +declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. * If promise cancellation is enabled, passed in function will receive one more function argument `onCancel` that allows to register an optional cancellation callback. */ - constructor(callback: (resolve: (thenableOrResult?: R | Bluebird.Thenable) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void); + constructor(callback: (resolve: (thenableOrResult?: R | PromiseLike) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void); /** * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. @@ -53,10 +53,10 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - caught(onReject?: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; - caught(onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; + catch(onReject?: (error: any) => R | PromiseLike | void | PromiseLike): Bluebird; + caught(onReject?: (error: any) => R | PromiseLike | void | PromiseLike): Bluebird; + catch(onReject?: (error: any) => U | PromiseLike): Bluebird; + caught(onReject?: (error: any) => U | PromiseLike): Bluebird; /** * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. @@ -73,7 +73,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -81,7 +81,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -89,7 +89,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -97,7 +97,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, ): Bluebird; catch( @@ -105,106 +105,106 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => U | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1 | E2) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => U | Bluebird.Thenable, + onReject: (error: E1 | E2) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => U | Bluebird.Thenable, + onReject: (error: E1 | E2) => U | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1) => R | PromiseLike | void | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => R | Bluebird.Thenable | void | Bluebird.Thenable, + onReject: (error: E1) => R | PromiseLike | void | PromiseLike, ): Bluebird; catch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => U | Bluebird.Thenable, + onReject: (error: E1) => U | PromiseLike, ): Bluebird; caught( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => U | Bluebird.Thenable, + onReject: (error: E1) => U | PromiseLike, ): Bluebird; /** * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. */ - error(onReject: (reason: any) => U | Bluebird.Thenable): Bluebird; + error(onReject: (reason: any) => U | PromiseLike): Bluebird; /** * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. * * Alias `.lastly();` for compatibility with earlier ECMAScript version. */ - finally(handler: () => U | Bluebird.Thenable): Bluebird; + finally(handler: () => U | PromiseLike): Bluebird; - lastly(handler: () => U | Bluebird.Thenable): Bluebird; + lastly(handler: () => U | PromiseLike): Bluebird; /** * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. @@ -214,19 +214,19 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(onFulfilled?: (value: R) => U | Bluebird.Thenable, onRejected?: (error: any) => U | Bluebird.Thenable): void; + done(onFulfilled?: (value: R) => U | PromiseLike, onRejected?: (error: any) => U | PromiseLike): void; /** * Like `.finally()`, but not called for rejections. */ - tap(onFulFill: (value: R) => Bluebird.Thenable): Bluebird; + tap(onFulFill: (value: R) => PromiseLike): Bluebird; tap(onFulfill: (value: R) => U): Bluebird; /** * Like `.catch()` but rethrows the error * TODO: disallow non-objects */ - tapCatch(onReject: (error?: any) => U | Bluebird.Thenable): Bluebird; + tapCatch(onReject: (error?: any) => U | PromiseLike): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, @@ -234,29 +234,29 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable, + onReject: (error: E1 | E2 | E3) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object, - onReject: (error: E1 | E2) => U | Bluebird.Thenable, + onReject: (error: E1 | E2) => U | PromiseLike, ): Bluebird; tapCatch( filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object, - onReject: (error: E1) => U | Bluebird.Thenable, + onReject: (error: E1) => U | PromiseLike, ): Bluebird; /** @@ -487,7 +487,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(fulfilledHandler: (...values: W[]) => U | Bluebird.Thenable): Bluebird; + spread(fulfilledHandler: (...values: W[]) => U | PromiseLike): Bluebird; spread(fulfilledHandler: Function): Bluebird; /** @@ -524,29 +524,29 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(mapper: (item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + map(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; /** * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - filter(filterer: (item: U, index: number, arrayLength: number) => boolean | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + filter(filterer: (item: U, index: number, arrayLength: number) => boolean | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Same as calling ``Bluebird.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - each(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + each(iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * Same as calling ``Bluebird.mapSeries(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - mapSeries(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + mapSeries(iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * Cancel this `promise`. Will not do anything if this promise is already settled or if the cancellation feature has not been enabled @@ -567,8 +567,8 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(fn: () => R | Bluebird.Thenable): Bluebird; - static attempt(fn: () => R | Bluebird.Thenable): Bluebird; + static try(fn: () => R | PromiseLike): Bluebird; + static attempt(fn: () => R | PromiseLike): Bluebird; /** * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. @@ -580,7 +580,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection; - static resolve(value: R | Bluebird.Thenable): Bluebird; + static resolve(value: R | PromiseLike): Bluebird; /** * Create a promise that is rejected with the given `reason`. @@ -596,7 +596,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(value: R | Bluebird.Thenable): Bluebird; + static cast(value: R | PromiseLike): Bluebird; /** * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. @@ -618,7 +618,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(ms: number, value: R | Bluebird.Thenable): Bluebird; + static delay(ms: number, value: R | PromiseLike): Bluebird; static delay(ms: number): Bluebird; /** @@ -670,13 +670,13 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4, Bluebird.Thenable | T5]): Bluebird<[T1, T2, T3, T4, T5]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4]): Bluebird<[T1, T2, T3, T4]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3]): Bluebird<[T1, T2, T3]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2]): Bluebird<[T1, T2]>; - static all(values: [Bluebird.Thenable | T1]): Bluebird<[T1]>; + static all(values: [PromiseLike | T1, PromiseLike | T2, PromiseLike | T3, PromiseLike | T4, PromiseLike | T5]): Bluebird<[T1, T2, T3, T4, T5]>; + static all(values: [PromiseLike | T1, PromiseLike | T2, PromiseLike | T3, PromiseLike | T4]): Bluebird<[T1, T2, T3, T4]>; + static all(values: [PromiseLike | T1, PromiseLike | T2, PromiseLike | T3]): Bluebird<[T1, T2, T3]>; + static all(values: [PromiseLike | T1, PromiseLike | T2]): Bluebird<[T1, T2]>; + static all(values: [PromiseLike | T1]): Bluebird<[T1]>; // array with values - static all(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; + static all(values: PromiseLike<(PromiseLike | R)[]> | (PromiseLike | R)[]): Bluebird; /** * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. @@ -694,14 +694,14 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; + static any(values: PromiseLike<(PromiseLike | R)[]> | (PromiseLike | R)[]): Bluebird; /** * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. * * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. */ - static race(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; + static race(values: PromiseLike<(PromiseLike | R)[]> | (PromiseLike | R)[]): Bluebird; /** * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. @@ -711,11 +711,11 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, count: number): Bluebird; + static some(values: PromiseLike[]>, count: number): Bluebird; // promise of array with values - static some(values: Bluebird.Thenable, count: number): Bluebird; + static some(values: PromiseLike, count: number): Bluebird; // array with promises of value - static some(values: Bluebird.Thenable[], count: number): Bluebird; + static some(values: PromiseLike[], count: number): Bluebird; // array with values static some(values: R[], count: number): Bluebird; @@ -728,15 +728,15 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(arg1: A1 | Bluebird.Thenable, handler: (arg1: A1) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2, arg3: A3) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, arg5: A5 | Bluebird.Thenable, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | Bluebird.Thenable): Bluebird; + static join(arg1: A1 | PromiseLike, handler: (arg1: A1) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, handler: (arg1: A1, arg2: A2) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, arg4: A4 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike): Bluebird; + static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, arg4: A4 | PromiseLike, arg5: A5 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike): Bluebird; // variadic array /** @deprecated use .all instead */ - static join(...values: (R | Bluebird.Thenable)[]): Bluebird; + static join(...values: (R | PromiseLike)[]): Bluebird; /** * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. @@ -746,16 +746,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: PromiseLike[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; // promise of array with values - static map(values: Bluebird.Thenable, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: PromiseLike, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; // array with promises of value - static map(values: Bluebird.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: PromiseLike[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; // array with values - static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; + static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. @@ -765,16 +765,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: PromiseLike[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; // promise of array with values - static reduce(values: Bluebird.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: PromiseLike, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; // array with promises of value - static reduce(values: Bluebird.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: PromiseLike[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; // array with values - static reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; + static reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; /** * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. @@ -784,16 +784,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: PromiseLike[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; // promise of array with values - static filter(values: Bluebird.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: PromiseLike, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; // array with promises of value - static filter(values: Bluebird.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: PromiseLike[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; // array with values - static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; /** * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. @@ -801,11 +801,11 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: Bluebird.Thenable[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static each(values: PromiseLike[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; // array with promises of value - static each(values: Bluebird.Thenable[], iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static each(values: PromiseLike[], iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; // array with values OR promise of array with values - static each(values: R[] | Bluebird.Thenable, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static each(values: R[] | PromiseLike, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order. @@ -814,7 +814,7 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection(values: (R | Bluebird.Thenable)[] | Bluebird.Thenable<(R | Bluebird.Thenable)[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; + static mapSeries(values: (R | PromiseLike)[] | PromiseLike<(R | PromiseLike)[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; /** * A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`. @@ -826,16 +826,16 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection) => void | Bluebird.Thenable): Bluebird.Disposer; + disposer(disposeFn: (arg: R, promise: Bluebird) => void | PromiseLike): Bluebird.Disposer; /** * In conjunction with `.disposer`, using will make sure that no matter what, the specified disposer * will be called when the promise returned by the callback passed to using has settled. The disposer is * necessary because there is no standard interface in node for disposing resources. */ - static using(disposer: Bluebird.Disposer, executor: (transaction: R) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, disposer3: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => Bluebird.Thenable): Bluebird; + static using(disposer: Bluebird.Disposer, executor: (transaction: R) => PromiseLike): Bluebird; + static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2) => PromiseLike): Bluebird; + static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, disposer3: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike): Bluebird; /** * Add handler as the handler to call when there is a possibly unhandled rejection. @@ -890,7 +890,7 @@ declare namespace Bluebird { suffix?: string; filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean; // The promisifier gets a reference to the original method and should return a function which returns a promise - promisifier?: (originalMethod: Function) => () => Thenable; + promisifier?: (originalMethod: Function) => () => PromiseLike; } /** From a3f2dc5786cc88d63c3dce915dc9be07319981b5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 09:11:29 -0700 Subject: [PATCH 20/90] More fixes --- types/umzug/index.d.ts | 2 +- types/webgme/webgme-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/umzug/index.d.ts b/types/umzug/index.d.ts index 31e2b569aa..0c58ef40ff 100644 --- a/types/umzug/index.d.ts +++ b/types/umzug/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/sequelize/umzug // Definitions by: Ivan Drinchev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import Sequelize = require("sequelize"); diff --git a/types/webgme/webgme-tests.ts b/types/webgme/webgme-tests.ts index d8fbc390e3..1cb2c78814 100644 --- a/types/webgme/webgme-tests.ts +++ b/types/webgme/webgme-tests.ts @@ -334,7 +334,7 @@ async function test_core_containment_traversal_complete() { const NULL_GUID = "00000000-0000-0000-0000-000000000000"; async function getEdgesModel(sponsor: PluginBase, core: Core.Core, - _rootNode: Common.Node, _metaNode: Common.Node): Core.Dictionary { + _rootNode: Common.Node, _metaNode: Common.Node): Promise { let fcoName = core.getAttribute(core.getFCO(sponsor.rootNode), "name"); let languageName = core.getAttribute(sponsor.rootNode, "name"); From c9f6b78761b630a7151ee78100b23d51c558a42f Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 10:29:06 -0700 Subject: [PATCH 21/90] Add another `then` overload for simpler signature help --- types/bluebird/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index f08cdb964b..c6d4c4d215 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -46,6 +46,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. */ // Based on PromiseLike.then, but returns a Bluebird instance. + then(onFulfill: (value: R) => U | PromiseLike): Bluebird; // For simpler signature help. then(onfulfilled?: ((value: R) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Bluebird; /** From 4e63c30269f925a9f53b883ae0ebaf8061f208e8 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 10:43:54 -0700 Subject: [PATCH 22/90] mime: lookup fallback parameter should be optional --- types/mime/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mime/index.d.ts b/types/mime/index.d.ts index 71b4677ac6..7debcca6f3 100644 --- a/types/mime/index.d.ts +++ b/types/mime/index.d.ts @@ -7,7 +7,7 @@ export as namespace mime; -export function lookup(path: string, fallback: string): string; +export function lookup(path: string, fallback?: string): string; export function extension(mime: string): string; export function load(filepath: string): void; export function define(mimes: { [key: string]: any }): void; From 18e5e1b05d470010a5309f320aae1c7932f51526 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 16 Jun 2017 10:53:33 -0700 Subject: [PATCH 23/90] Fix angular tests for 2.4's improved generic checking --- types/angular/angular-tests.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index d77c18fa37..4936f02e6e 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -367,8 +367,8 @@ namespace TestQ { let result: angular.IPromise; result = $q.resolve(tResult); result = $q.resolve(promiseTResult); - result = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); - result = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); + let result2: angular.IPromise = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); + let result3: angular.IPromise> = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); } // $q.when @@ -378,7 +378,8 @@ namespace TestQ { } { let result: angular.IPromise; - let resultOther: angular.IPromise; + let other: angular.IPromise; + let resultOther: angular.IPromise; result = $q.when(tResult); result = $q.when(promiseTResult); @@ -388,20 +389,21 @@ namespace TestQ { result = $q.when(tValue, (result: TValue) => tResult, (any) => any, (any) => any); result = $q.when(promiseTValue, (result: TValue) => tResult); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther); + resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (any) => any); result = $q.when(tValue, (result: TValue) => promiseTResult); result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any); result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any, (any) => any); result = $q.when(promiseTValue, (result: TValue) => promiseTResult); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther); - result = resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther); + resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any); } } @@ -547,7 +549,7 @@ namespace TestPromise { assertPromiseType(promise.then((result) => result, (any) => any, (any) => any)); assertPromiseType(promise.then((result) => result, (any) => reject, (any) => any)); - assertPromiseType(promise.then((result) => anyOf2(reject, result))); + assertPromiseType | TResult>(promise.then((result) => anyOf2(reject, result))); assertPromiseType(promise.then((result) => anyOf3(result, tresultPromise, reject))); assertPromiseType(promise.then( (result) => anyOf3(reject, result, tresultPromise), @@ -557,7 +559,7 @@ namespace TestPromise { assertPromiseType>(promise.then((result) => tresultHttpPromise)); assertPromiseType(promise.then((result) => result, (any) => tother)); - assertPromiseType(promise.then( + assertPromiseType | angular.IPromise | TOther | angular.IPromise>(promise.then( (result) => anyOf3(reject, result, totherPromise), (reason) => anyOf3(reject, tother, tresultPromise) )); @@ -588,7 +590,7 @@ namespace TestPromise { assertPromiseType(promise.catch((err) => err)); assertPromiseType(promise.catch((err) => any)); assertPromiseType(promise.catch((err) => tresult)); - assertPromiseType(promise.catch((err) => anyOf2(tresult, reject))); + assertPromiseType>(promise.catch((err) => anyOf2(tresult, reject))); assertPromiseType(promise.catch((err) => anyOf3(tresult, tresultPromise, reject))); assertPromiseType(promise.catch((err) => tresultPromise)); assertPromiseType>(promise.catch((err) => tresultHttpPromise)); From 3994968d322058cbe35f10c4d5bc0aed2bc65bff Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Fri, 16 Jun 2017 22:08:28 +0300 Subject: [PATCH 24/90] Fixed contributor link. --- types/jwt-decode/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/jwt-decode/index.d.ts b/types/jwt-decode/index.d.ts index d27cdf91e9..13e4506eac 100644 --- a/types/jwt-decode/index.d.ts +++ b/types/jwt-decode/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for jwt-decode v2.2.0 // Project: https://github.com/auth0/jwt-decode -// Definitions by: Giedrius Grabauskas , Mads Madsen +// Definitions by: Giedrius Grabauskas , Mads Madsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -12,4 +12,4 @@ declare namespace JwtDecode { declare var jwtDecode: JwtDecode.JwtDecodeStatic; export = jwtDecode; -export as namespace jwt_decode; \ No newline at end of file +export as namespace jwt_decode; From 0295224ee62387859974ef2c201d64ab7282dfc2 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Fri, 16 Jun 2017 22:21:03 +0300 Subject: [PATCH 25/90] Added tslint. --- types/jwt-decode/tslint.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 types/jwt-decode/tslint.json diff --git a/types/jwt-decode/tslint.json b/types/jwt-decode/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/jwt-decode/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 59eec563dec544b5b8d1b8137d151535c9e93f51 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Fri, 16 Jun 2017 22:21:24 +0300 Subject: [PATCH 26/90] Enabled strictNullCheck. --- types/jwt-decode/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/jwt-decode/tsconfig.json b/types/jwt-decode/tsconfig.json index 34ce87d118..8d87ddb618 100644 --- a/types/jwt-decode/tsconfig.json +++ b/types/jwt-decode/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "jwt-decode-tests.ts" ] -} \ No newline at end of file +} From 5bfe51cdce5f156c0559133e780c7566af270bf4 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Fri, 16 Jun 2017 22:23:10 +0300 Subject: [PATCH 27/90] Added generic type for JwtDecode function. Fixed tslint errors. --- types/jwt-decode/index.d.ts | 12 ++++++------ types/jwt-decode/jwt-decode-tests.ts | 13 +++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/types/jwt-decode/index.d.ts b/types/jwt-decode/index.d.ts index 13e4506eac..73dacb3c00 100644 --- a/types/jwt-decode/index.d.ts +++ b/types/jwt-decode/index.d.ts @@ -1,15 +1,15 @@ -// Type definitions for jwt-decode v2.2.0 +// Type definitions for jwt-decode 2.2 // Project: https://github.com/auth0/jwt-decode // Definitions by: Giedrius Grabauskas , Mads Madsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare namespace JwtDecode { - interface JwtDecodeStatic { - (token: string, options?: { header: boolean }): any; + interface Options { + header: boolean; } } -declare var jwtDecode: JwtDecode.JwtDecodeStatic; -export = jwtDecode; +declare function JwtDecode(token: string, options?: JwtDecode.Options): TTokenDto; + +export = JwtDecode; export as namespace jwt_decode; diff --git a/types/jwt-decode/jwt-decode-tests.ts b/types/jwt-decode/jwt-decode-tests.ts index 7e65c2a5a4..22bb5cf6cc 100644 --- a/types/jwt-decode/jwt-decode-tests.ts +++ b/types/jwt-decode/jwt-decode-tests.ts @@ -1,7 +1,6 @@ - -import jwtDecode = require('jwt-decode'); - -let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; +import * as jwtDecode from "jwt-decode"; + +const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; interface TokenDto { foo: string; @@ -14,5 +13,7 @@ interface TokenHeaderDto { alg: string; } -let decodedTokenPayload = jwtDecode(token) as TokenDto; -let decodedTokenHeader = jwtDecode(token, { header: true }) as TokenHeaderDto; \ No newline at end of file +const decodedTokenPayloadOld = jwtDecode(token) as TokenDto; +const decodedTokenPayload = jwtDecode(token); +const decodedTokenHeaderOld = jwtDecode(token, { header: true }) as TokenHeaderDto; +const decodedTokenHeader = jwtDecode(token, { header: true }); From d279dd93272ac4f32c6f0abd4565b3bd4dd811c6 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Fri, 16 Jun 2017 22:31:26 +0300 Subject: [PATCH 28/90] Added missing V1 version. --- types/jwt-decode/v1/index.d.ts | 11 ++++++++++ types/jwt-decode/v1/jwt-decode-tests.ts | 12 +++++++++++ types/jwt-decode/v1/tsconfig.json | 27 +++++++++++++++++++++++++ types/jwt-decode/v1/tslint.json | 3 +++ 4 files changed, 53 insertions(+) create mode 100644 types/jwt-decode/v1/index.d.ts create mode 100644 types/jwt-decode/v1/jwt-decode-tests.ts create mode 100644 types/jwt-decode/v1/tsconfig.json create mode 100644 types/jwt-decode/v1/tslint.json diff --git a/types/jwt-decode/v1/index.d.ts b/types/jwt-decode/v1/index.d.ts new file mode 100644 index 0000000000..10ec01f10f --- /dev/null +++ b/types/jwt-decode/v1/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for jwt-decode 1.4 +// Project: https://github.com/auth0/jwt-decode +// Definitions by: Giedrius Grabauskas +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace JwtDecode { } + +declare function JwtDecode(token: string): TTokenDto; + +export = JwtDecode; +export as namespace jwt_decode; diff --git a/types/jwt-decode/v1/jwt-decode-tests.ts b/types/jwt-decode/v1/jwt-decode-tests.ts new file mode 100644 index 0000000000..f1db120261 --- /dev/null +++ b/types/jwt-decode/v1/jwt-decode-tests.ts @@ -0,0 +1,12 @@ +import jwtDecode = require('jwt-decode'); + +const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; + +interface TokenDto { + foo: string; + exp: number; + iat: number; +} + +const decodedTokenOld = jwtDecode(token) as TokenDto; +const decodedToken = jwtDecode(token); diff --git a/types/jwt-decode/v1/tsconfig.json b/types/jwt-decode/v1/tsconfig.json new file mode 100644 index 0000000000..a0d0dd4f39 --- /dev/null +++ b/types/jwt-decode/v1/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "jwt-decode": [ + "jwt-decode/v1" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jwt-decode-tests.ts" + ] +} diff --git a/types/jwt-decode/v1/tslint.json b/types/jwt-decode/v1/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/jwt-decode/v1/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From b5c94b002020ce800d04cf96af40893d95c68e87 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 12:50:03 -0700 Subject: [PATCH 29/90] Add onReject parameter to the simpler overload --- types/bluebird/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index c6d4c4d215..451b23fa02 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -46,7 +46,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. */ // Based on PromiseLike.then, but returns a Bluebird instance. - then(onFulfill: (value: R) => U | PromiseLike): Bluebird; // For simpler signature help. + then(onFulfill?: (value: R) => U | Bluebird.Thenable, onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; // For simpler signature help. then(onfulfilled?: ((value: R) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Bluebird; /** From be63f892806b9ebb349ae0f771003bc17ea5f7cc Mon Sep 17 00:00:00 2001 From: Louis De Bevere Date: Fri, 16 Jun 2017 22:51:32 +0200 Subject: [PATCH 30/90] gulp-sourcemaps - Adds the clone write option --- .../gulp-sourcemaps/gulp-sourcemaps-tests.ts | 22 +++++++++++++++++++ types/gulp-sourcemaps/index.d.ts | 6 +++++ 2 files changed, 28 insertions(+) diff --git a/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts b/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts index 9ea2849f1e..f41612c4a5 100644 --- a/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts +++ b/types/gulp-sourcemaps/gulp-sourcemaps-tests.ts @@ -94,4 +94,26 @@ gulp.task('javascript', function() { } })) .pipe(gulp.dest('public/scripts')); +}); + +gulp.task('javascript', function() { + var stream = gulp.src('src/**/*.js') + .pipe(sourcemaps.init()) + .pipe(plugin1()) + .pipe(plugin2()) + .pipe(sourcemaps.write('../maps', { + clone: true + })) + .pipe(gulp.dest('public/scripts')); +}); + +gulp.task('javascript', function() { + var stream = gulp.src('src/**/*.js') + .pipe(sourcemaps.init()) + .pipe(plugin1()) + .pipe(plugin2()) + .pipe(sourcemaps.write('../maps', { + clone: { contents: false } + })) + .pipe(gulp.dest('public/scripts')); }); \ No newline at end of file diff --git a/types/gulp-sourcemaps/index.d.ts b/types/gulp-sourcemaps/index.d.ts index 107c6560c1..3b805e8fd8 100644 --- a/types/gulp-sourcemaps/index.d.ts +++ b/types/gulp-sourcemaps/index.d.ts @@ -15,11 +15,17 @@ interface WriteMapper { (file: string): string; } +interface CloneOptions { + contents?: boolean; + deep?: boolean; +} + interface WriteOptions { addComment?: boolean; includeContent?: boolean; sourceRoot?: string | WriteMapper; sourceMappingURLPrefix?: string | WriteMapper; + clone?: boolean | CloneOptions; } export declare function init(opts?: InitOptions): NodeJS.ReadWriteStream; From 1cc7d17eae4ef2d570b62d3ac5c4e42b43509b5a Mon Sep 17 00:00:00 2001 From: Louis De Bevere Date: Fri, 16 Jun 2017 23:11:13 +0200 Subject: [PATCH 31/90] gulp-watch - Extend options with vinyl-fs src options --- types/gulp-watch/gulp-watch-tests.ts | 12 ++++++++++++ types/gulp-watch/index.d.ts | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/types/gulp-watch/gulp-watch-tests.ts b/types/gulp-watch/gulp-watch-tests.ts index 56a676bc65..0260a24bb6 100644 --- a/types/gulp-watch/gulp-watch-tests.ts +++ b/types/gulp-watch/gulp-watch-tests.ts @@ -25,3 +25,15 @@ gulp.task('build', () => { gulp.src(files, { base: '..' }) .pipe(watch(files, { base: '..' })); }); + +gulp.task('build', () => { + var files = [ + 'app/**/*.ts', + 'lib/**/*.ts', + 'components/**/*.ts', + ]; + + gulp.src(files, { cwd: '..' }) + .pipe(watch(files, { base: '..' })); +}); + diff --git a/types/gulp-watch/index.d.ts b/types/gulp-watch/index.d.ts index de56633491..f9855f09a6 100644 --- a/types/gulp-watch/index.d.ts +++ b/types/gulp-watch/index.d.ts @@ -5,8 +5,9 @@ /// +import {SrcOptions} from "vinyl-fs"; -interface IOptions { +interface IOptions extends SrcOptions { ignoreInitial?: boolean; events?: Array; base?: string; From f10aa9bbdc8a1f33d6f9b37592ae20ff12182b05 Mon Sep 17 00:00:00 2001 From: Oden Date: Fri, 16 Jun 2017 19:47:49 -0700 Subject: [PATCH 32/90] Update react-loadable types for v4. Changes: https://github.com/thejameskyle/react-loadable/pull/46 --- types/react-loadable/babel.d.ts | 3 - types/react-loadable/index.d.ts | 105 +++++++++--------- types/react-loadable/react-loadable-tests.tsx | 61 +++++++--- types/react-loadable/tsconfig.json | 1 - 4 files changed, 100 insertions(+), 70 deletions(-) delete mode 100644 types/react-loadable/babel.d.ts diff --git a/types/react-loadable/babel.d.ts b/types/react-loadable/babel.d.ts deleted file mode 100644 index a9f18c2e00..0000000000 --- a/types/react-loadable/babel.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as babel from 'babel-core'; - -export default function(context: Pick): { visitor: any }; diff --git a/types/react-loadable/index.d.ts b/types/react-loadable/index.d.ts index bbe7d1aac4..1a77aa543c 100644 --- a/types/react-loadable/index.d.ts +++ b/types/react-loadable/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for react-loadable 3.3 +// Type definitions for react-loadable 4.0 // Project: https://github.com/thejameskyle/react-loadable#readme -// Definitions by: Diogo Franco +// Definitions by: Diogo Franco , Oden S. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import * as React from 'react'; @@ -11,10 +11,11 @@ export type LoadedComponent = React.ComponentClass | React.SFC = OptionsWithoutResolve | OptionsWithResolve; +export type Options = OptionsWithoutRender | OptionsWithRender; export interface CommonOptions { /** @@ -24,64 +25,76 @@ export interface CommonOptions { * (this is considered a valid React component). */ // NOTE: () => null is only needed until React.SFC supports components returning null - LoadingComponent: React.ComponentClass | React.SFC | (() => null); + loading: React.ComponentClass | React.SFC | (() => null); /** - * Defaults to 200, in milliseconds + * Defaults to 200, in milliseconds. * * Only show the LoadingComponent if the loader() has taken this long to succeed or error. */ - delay?: number; + delay?: number | false | null; /** - * When rendering server-side, require() this path to load the component instead, this way it happens - * synchronously. If you are rendering server-side you should use this option. + * Disabled by default. * - * If you are using Babel, you might want to use the Babel plugin to add this option automatically. + * After the specified time in milliseconds passes, the component's `timedOut` prop will be set to true. */ - serverSideRequirePath?: string; + timeout?: number | false | null; +} + +export interface OptionsWithoutRender extends CommonOptions { /** - * In order for Loadable to require() a component synchronously (when possible) instead of waiting for - * the promise returned by import() to resolve. If you are using Webpack you should use this option. + * Function returning a promise which returns a React component displayed on success. + * + * Resulting React component receives all the props passed to the generated component. + */ + loader(): Promise | { [key: string]: LoadedComponent }>; +} + +export interface OptionsWithRender extends CommonOptions { + /** + * Function returning a promise which returns an object to be passed to `render` on success. + */ + loader(): Promise; + /** + * If you want to customize what gets rendered from your loader you can also pass `render`. + * + * Note: If you want to load multiple resources at once, you can also use `Loadable.Map`. * * ```ts * Loadable({ * // ... - * webpackRequireWeakId: () => require.resolveWeak('./MyComponent') + * render(loaded, props) { + * const Component = loaded.default; + * return + * } * }); * ``` - * - * If you are using Babel, you might want to use the Babel plugin to add this option automatically. */ - webpackRequireWeakId?(): number|string; + render(loaded: Exports, props: Props): React.ReactNode; } -export interface OptionsWithoutResolve extends CommonOptions { +export interface OptionsWithMap extends CommonOptions { /** - * Function returning promise returning a React component displayed on success. - * - * Resulting React component receives all the props passed to the generated component. + * Function returning a promise which returns an object to be passed to `render` on success. */ - loader(): Promise | { default: LoadedComponent }>; -} - -export interface OptionsWithResolve extends CommonOptions { + loader: { + [P in keyof Exports]: () => Promise + }; /** - * Function returning promise returning a React component displayed on success. + * If you want to customize what gets rendered from your loader you can also pass `render`. * - * Resulting React component receives all the props passed to the generated component. - */ - loader(): Promise; - /** - * If the component that you want to load is not the default exported from a module you can use this - * function to resolve it. + * Note: If you want to load multiple resources at once, you can also use `Loadable.Map`. * * ```ts * Loadable({ * // ... - * resolveModule: module => module.MyComponent + * render(loaded, props) { + * const Component = loaded.default; + * return + * } * }); * ``` */ - resolveModule(obj: T): LoadedComponent; + render(loaded: Exports, props: Props): React.ReactNode; } export interface LoadableComponent { @@ -96,22 +109,10 @@ export interface LoadableComponent { preload(): void; } -export default function Loadable(options: Options): LoadedComponent & LoadableComponent; +export interface Loadable { + (options: Options): LoadedComponent & LoadableComponent; + Map(options: OptionsWithMap): LoadedComponent & LoadableComponent; +} -/** - * In case you are rendering server-side and want to find out after a render cycle which - * serverSideRequirePath's and webpackRequireWeakId's were actually rendered, you can use - * flushServerSideRequirePaths or flushWebpackRequireWeakIds to get an array of them. - * - * Note: These are flushed individually, one does not affect the other. - */ -export function flushServerSideRequirePaths(): string[]; - -/** - * In case you are rendering server-side and want to find out after a render cycle which - * serverSideRequirePath's and webpackRequireWeakId's were actually rendered, you can use - * flushServerSideRequirePaths or flushWebpackRequireWeakIds to get an array of them. - * - * Note: These are flushed individually, one does not affect the other. - */ -export function flushWebpackRequireWeakIds(): string[]|number[]; +declare const LoadableExport: Loadable; +export default LoadableExport; diff --git a/types/react-loadable/react-loadable-tests.tsx b/types/react-loadable/react-loadable-tests.tsx index 3455a7b23a..981508292c 100644 --- a/types/react-loadable/react-loadable-tests.tsx +++ b/types/react-loadable/react-loadable-tests.tsx @@ -3,7 +3,14 @@ import Loadable, { LoadingComponentProps } from 'react-loadable'; class LoadingComponent extends React.Component { render() { - return
{this.props.isLoading}
; + return ( +
+ {this.props.error} + {this.props.isLoading} + {this.props.pastDelay} + {this.props.timedOut} +
+ ); } } @@ -16,36 +23,62 @@ const Component: React.SFC = ({ text }) =>
{text}
; const Loadable100 = Loadable({ // a module shape with 'export = Component' / 'module.exports = Component' loader: () => Promise.resolve(Component), - LoadingComponent, - delay: 100 + loading: LoadingComponent, + delay: 100, + timeout: 10000 }); const Loadable200 = Loadable({ // a module shape with 'export default Component' loader: () => Promise.resolve({ default: Component }), - LoadingComponent, - delay: 200 + loading: LoadingComponent, + delay: null, + timeout: null }); const Loadable300 = Loadable({ // a module shape with 'export { Component }' loader: () => Promise.resolve({ Component }), - LoadingComponent, - delay: 300, - resolveModule: shape => shape.Component + loading: LoadingComponent, + delay: false, + timeout: false, + render(loaded, props) { + const { Component } = loaded; + return ; + } }); const Loadable400 = Loadable({ // a module shape with both 'export default Component' and 'export { Component }' loader: () => Promise.resolve({ default: Component, Component }), - LoadingComponent: () => null, + loading: () => null, delay: 300, - resolveModule: shape => shape.Component + render(loaded, props) { + const Component = loaded.default; + const NamedComponent = loaded.Component; + return ( + + + + ); + } }); -const used100 = ; -const used200 = ; -const used300 = ; -const used400 = ; +const LoadableMap = Loadable.Map({ + loading: () => null, + loader: { + Component: () => Promise.resolve({ default: Component }), + text: () => Promise.resolve("test text") + }, + render(loaded, props) { + let Component = loaded.Component.default; + return ; + } +}); + +const used100 = ; +const used200 = ; +const used300 = ; +const used400 = ; Loadable100.preload(); diff --git a/types/react-loadable/tsconfig.json b/types/react-loadable/tsconfig.json index bf26cfdbc5..4f1cf2c0f0 100644 --- a/types/react-loadable/tsconfig.json +++ b/types/react-loadable/tsconfig.json @@ -18,7 +18,6 @@ }, "files": [ "index.d.ts", - "babel.d.ts", "react-loadable-tests.tsx" ] } From 641b8d3110ad62b39f9f07f327bcc2e6b514006e Mon Sep 17 00:00:00 2001 From: icosahebron Date: Fri, 16 Jun 2017 17:59:23 -0700 Subject: [PATCH 33/90] Turn on strictNullChecks --- types/quill/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/quill/tsconfig.json b/types/quill/tsconfig.json index 5c353f17a3..cfef2d65ab 100644 --- a/types/quill/tsconfig.json +++ b/types/quill/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From f264917e017909698e44f2ec0e3d75216f97d154 Mon Sep 17 00:00:00 2001 From: icosahebron Date: Fri, 16 Jun 2017 16:46:02 -0700 Subject: [PATCH 34/90] Update Delta declarations --- types/quill/index.d.ts | 57 ++++++++------- types/quill/quill-tests.ts | 137 +++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+), 24 deletions(-) diff --git a/types/quill/index.d.ts b/types/quill/index.d.ts index cf7440f428..f8ee7c5d1f 100644 --- a/types/quill/index.d.ts +++ b/types/quill/index.d.ts @@ -7,7 +7,16 @@ declare namespace Quill { type Key = { key: string, shortKey?: boolean }; type Sources = "api" | "user" | "silent"; - type Formats = { [key: string]: any }; + type StringMap = { [key: string]: any }; + type OptionalAttributes = { attributes?: StringMap }; + /** + * A stricter type definition would be: + * + * type DeltaOperation ({ insert: any } | { delete: number } | { retain: number }) & OptionalAttributes; + * + * But this would break a lot of existing code as it would require manual discrimination of the union types. + */ + type DeltaOperation = StringMap & OptionalAttributes; export interface KeyboardStatic { addBinding(key: Key, callback: (range: RangeStatic, context: any) => void): void; @@ -23,7 +32,7 @@ declare namespace Quill { export interface QuillOptionsStatic { debug?: string, - modules?: Formats, + modules?: StringMap, placeholder?: string, readOnly?: boolean, theme?: string, @@ -38,26 +47,26 @@ declare namespace Quill { } export interface DeltaStatic { - new (ops: Array) : DeltaStatic; - new (ops: any) : DeltaStatic; - ops?: Array; - retain(length: number, attributes: any) : DeltaStatic; + new (ops?: DeltaOperation[] | { ops: DeltaOperation[] }) : DeltaStatic; + ops?: DeltaOperation[]; + retain(length: number, attributes?: StringMap) : DeltaStatic; delete(length: number) : DeltaStatic; - filter(predicate: any) : DeltaStatic; - forEach(predicate: any) : DeltaStatic; - insert(text: any, attributes: any): DeltaStatic; - map(predicate: any) : DeltaStatic; - partition(predicate: any) : DeltaStatic; - reduce(predicate: any, initial: number): DeltaStatic; + filter(predicate: (op: DeltaOperation) => boolean) : DeltaOperation[]; + forEach(predicate: (op: DeltaOperation) => void) : void; + insert(text: any, attributes?: StringMap): DeltaStatic; + map(predicate: (op: DeltaOperation) => T) : T[]; + partition(predicate: (op: DeltaOperation) => boolean) : [DeltaOperation[], DeltaOperation[]]; + reduce(predicate: (acc: T, curr: DeltaOperation, idx: number, arr: DeltaOperation[]) => T, initial: T): T; chop() : DeltaStatic; length(): number; - slice(start: number, end: number): DeltaStatic; - compose(other: any): DeltaStatic; + slice(start?: number, end?: number): DeltaStatic; + compose(other: DeltaStatic): DeltaStatic; concat(other: DeltaStatic): DeltaStatic; - diff(other: DeltaStatic, index: number) : DeltaStatic; - eachLine(predicate: any, newline: any) : DeltaStatic; - transform(other: any, priority: any) : DeltaStatic; - transformPosition(index: number, priority: any) : DeltaStatic; + diff(other: DeltaStatic, index?: number) : DeltaStatic; + eachLine(predicate: (line: DeltaStatic, attributes: StringMap, idx: number) => any, newline?: string) : DeltaStatic; + transform(index: number) : DeltaStatic; + transform(other: DeltaStatic, priority: boolean) : DeltaStatic; + transformPosition(index: number) : DeltaStatic; } export interface RangeStatic { @@ -77,7 +86,7 @@ declare namespace Quill { insertEmbed(index: number, type: string, value: any, source?: Sources): void; insertText(index: number, text: string, source?: Sources): DeltaStatic; insertText(index: number, text: string, format: string, value: any, source?: Sources): DeltaStatic; - insertText(index: number, text: string, formats: Formats, source?: Sources): DeltaStatic; + insertText(index: number, text: string, formats: StringMap, source?: Sources): DeltaStatic; /** * @deprecated Use clipboard.dangerouslyPasteHTML(index: number, html: string, source: Sources) */ @@ -94,12 +103,12 @@ declare namespace Quill { format(name: string, value: any, source?: Sources): DeltaStatic; formatLine(index: number, length: number, source?: Sources): DeltaStatic; formatLine(index: number, length: number, format: string, value: any, source?: Sources): DeltaStatic; - formatLine(index: number, length: number, formats: Formats, source?: Sources): DeltaStatic; + formatLine(index: number, length: number, formats: StringMap, source?: Sources): DeltaStatic; formatText(index: number, length: number, source?: Sources): DeltaStatic; formatText(index: number, length: number, format: string, value: any, source?: Sources): DeltaStatic; - formatText(index: number, length: number, formats: Formats, source?: Sources): DeltaStatic; - getFormat(range?: RangeStatic): Formats; - getFormat(index: number, length?: number): Formats; + formatText(index: number, length: number, formats: StringMap, source?: Sources): DeltaStatic; + getFormat(range?: RangeStatic): StringMap; + getFormat(index: number, length?: number): StringMap; removeFormat(index: number, length: number, source?: Sources): void; blur(): void; @@ -118,7 +127,7 @@ declare namespace Quill { debug(level: string): void; import(path: string): any; register(path: string, def: any, suppressWarning?: boolean): void; - register(defs: Formats, suppressWarning?: boolean): void; + register(defs: StringMap, suppressWarning?: boolean): void; addContainer(className: string, refNode?: any): any; addContainer(domNode: any, refNode?: any): any; getModule(name: string): any diff --git a/types/quill/quill-tests.ts b/types/quill/quill-tests.ts index eba77f8b68..dc7800d444 100644 --- a/types/quill/quill-tests.ts +++ b/types/quill/quill-tests.ts @@ -187,3 +187,140 @@ function test_PasteHTML2() var quillEditor = new Quill('#editor'); quillEditor.pasteHTML(5, '

Quill Rocks

'); } + +function test_DeltaChaining() { + var delta = new Delta() + .insert('Hello', { bold: true }) + .insert('World') + .delete(5) + .retain(5) + .retain(5, { color: '#0c6' }); + +} + +function test_DeltaFilter() { + var delta = new Delta().insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var text = delta.filter(function(op) { + return typeof op.insert === 'string'; + }).map(function(op) { + return op.insert; + }).join(''); +} + +function test_DeltaForEach() { + var delta = new Delta(); + delta.forEach(function(op) { + console.log(op); + }); +} + +function test_DeltaMap() { + var delta = new Delta() + .insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var text = delta.map(function(op) { + if (typeof op.insert === 'string') { + return op.insert; + } else { + return ''; + } + }).join(''); +} + +function test_DeltaPartition() { + var delta = new Delta().insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var results = delta.partition(function(op) { + return typeof op.insert === 'string'; + }); + var passed = results[0]; // [{ insert: 'Hello', attributes: { bold: true }}, { insert: 'World'}] + var failed = results[1]; // [{ insert: { image: 'https://octodex.github.com/images/labtocat.png' }}] +} + +function test_DeltaReduce() { + var delta = new Delta().insert('Hello', { bold: true }) + .insert({ image: 'https://octodex.github.com/images/labtocat.png' }) + .insert('World!'); + + var length = delta.reduce(function(length, op) { + return length + (op.insert.length || 1); + }, 0); +} + +function test_DeltaSlice() { + var delta = new Delta().insert('Hello', { bold: true }).insert(' World'); + + // { + // ops: [ + // { insert: 'Hello', attributes: { bold: true } }, + // { insert: ' World' } + // ] + // } + var copy = delta.slice(); + console.log(copy.ops); + + // { ops: [{ insert: 'World' }] } + var world = delta.slice(6); + console.log(world.ops); + + // { ops: [{ insert: ' ' }] } + var space = delta.slice(5, 6); + console.log(space.ops); +} + +function test_DeltaCompose() { + var a = new Delta().insert('abc'); + var b = new Delta().retain(1).delete(1); + + var composed = a.compose(b); // composed == new Delta().insert('ac'); +} + +function test_DeltaDiff() { + var a = new Delta().insert('Hello'); + var b = new Delta().insert('Hello!'); + + var diff = a.diff(b); // { ops: [{ retain: 5 }, { insert: '!' }] } + // a.compose(diff) == b + var diff2 = a.diff(b, 0); // { ops: [{ retain: 5 }, { insert: '!' }] } + // a.compose(diff) == b +} + +function test_DeltaEachLine() { + var delta = new Delta().insert('Hello\n\n') + .insert('World') + .insert({ image: 'octocat.png' }) + .insert('\n', { align: 'right' }) + .insert('!'); + + delta.eachLine(function(line, attributes, i) { + console.log(line, attributes, i); + // Can return false to exit loop early + }); + // Should log: + // { ops: [{ insert: 'Hello' }] }, {}, 0 + // { ops: [] }, {}, 1 + // { ops: [{ insert: 'World' }, { insert: { image: 'octocat.png' } }] }, { align: 'right' }, 2 + // { ops: [{ insert: '!' }] }, {}, 3 +} + +function test_DeltaTransform() { + var a = new Delta().insert('a'); + var b = new Delta().insert('b').retain(5).insert('c'); + + a.transform(b, true); // new Delta().retain(1).insert('b').retain(5).insert('c'); + a.transform(b, false); // new Delta().insert('b').retain(6).insert('c'); + a.transform(5); +} + +function test_DeltatransformPosition() { + var delta = new Delta().retain(5).insert('a'); + delta.transformPosition(4); // 4 + delta.transformPosition(5); // 6 +} From 174f07f38374a9b3547e028ad8b23e70f273fdd0 Mon Sep 17 00:00:00 2001 From: icosahebron Date: Fri, 16 Jun 2017 17:45:06 -0700 Subject: [PATCH 35/90] Update event-related declarations --- types/quill/index.d.ts | 24 ++++++++++++++++++------ types/quill/quill-tests.ts | 20 +++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/types/quill/index.d.ts b/types/quill/index.d.ts index f8ee7c5d1f..afa72a5290 100644 --- a/types/quill/index.d.ts +++ b/types/quill/index.d.ts @@ -18,6 +18,11 @@ declare namespace Quill { */ type DeltaOperation = StringMap & OptionalAttributes; + type TextChangeHandler = (delta: DeltaStatic, oldContents: DeltaStatic, source: Sources) => any; + type SelectionChangeHandler = (range: RangeStatic, oldRange: RangeStatic, source: Sources) => any; + type EditorChangeHandler = ((name: "text-change", delta: DeltaStatic, oldContents: DeltaStatic, source: Sources) => any) + | ((name: "selection-change", range: RangeStatic, oldRange: RangeStatic, source: Sources) => any); + export interface KeyboardStatic { addBinding(key: Key, callback: (range: RangeStatic, context: any) => void): void; addBinding(key: Key, context: any, callback: (range: RangeStatic, context: any) => void) : void; @@ -75,7 +80,19 @@ declare namespace Quill { length: number; } - export interface Quill { + export interface EventEmitter { + on(eventName: "text-change", handler: TextChangeHandler): EventEmitter; + on(eventName: "selection-change", handler: SelectionChangeHandler): EventEmitter; + on(eventName: "editor-change", handler: EditorChangeHandler): EventEmitter; + once(eventName: "text-change", handler: TextChangeHandler): EventEmitter; + once(eventName: "selection-change", handler: SelectionChangeHandler): EventEmitter; + once(eventName: "editor-change", handler: EditorChangeHandler): EventEmitter; + off(eventName: "text-change", handler: TextChangeHandler): EventEmitter; + off(eventName: "selection-change", handler: SelectionChangeHandler): EventEmitter; + off(eventName: "editor-change", handler: EditorChangeHandler): EventEmitter; + } + + export interface Quill extends EventEmitter { new (container: string | Element, options?: QuillOptionsStatic): Quill; deleteText(index: number, length: number, source?: Sources): void; disable(): void; @@ -119,11 +136,6 @@ declare namespace Quill { setSelection(index: number, length: number, source?: Sources): void; setSelection(range: RangeStatic, source?: Sources): void; - on(eventName: string, callback: ((delta: T, oldContents: T, source: string) => void) | - ((name: string, ...args: any[]) => void)): Quill; - once(eventName: string, callback: (delta: DeltaStatic, source: string) => void): Quill; - off(eventName: string, callback: (delta: DeltaStatic, source: string) => void): Quill; - debug(level: string): void; import(path: string): any; register(path: string, def: any, suppressWarning?: boolean): void; diff --git a/types/quill/quill-tests.ts b/types/quill/quill-tests.ts index dc7800d444..fe2af00afc 100644 --- a/types/quill/quill-tests.ts +++ b/types/quill/quill-tests.ts @@ -168,12 +168,22 @@ function test_addContainer() quillEditor.addContainer('ql-custom'); } -function test_on_EventType1(){ - var quillEditor = new Quill('#editor'); - quillEditor.on('text-change', (newDelta: T, oldDelta: T, source: string)=>{ - // happened - }); +function test_on_Events(){ + var textChangeHandler = function(newDelta: Quill.DeltaStatic, oldDelta: Quill.DeltaStatic, source: string) { }; + var selectionChangeHandler = function(newRange: Quill.RangeStatic, oldRange: Quill.RangeStatic, source: string) { }; + var editorChangeHandler = function(name: string, ...args: any[]) { }; + var quillEditor = new Quill('#editor'); + quillEditor + .on('text-change', textChangeHandler) + .off('text-change', textChangeHandler) + .once('text-change', textChangeHandler) + .on('selection-change', selectionChangeHandler) + .off('selection-change', selectionChangeHandler) + .once('selection-change', selectionChangeHandler) + .on('editor-change', editorChangeHandler) + .off('editor-change', editorChangeHandler) + .once('editor-change', editorChangeHandler); } function test_PasteHTML() From e9c2d11fb2e88d103f9528a2a18db9c0fe954aa8 Mon Sep 17 00:00:00 2001 From: icosahebron Date: Fri, 16 Jun 2017 22:12:41 -0700 Subject: [PATCH 36/90] Allow dot notation access of known DeltaOperation properties --- types/quill/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/quill/index.d.ts b/types/quill/index.d.ts index afa72a5290..650408c67c 100644 --- a/types/quill/index.d.ts +++ b/types/quill/index.d.ts @@ -16,7 +16,7 @@ declare namespace Quill { * * But this would break a lot of existing code as it would require manual discrimination of the union types. */ - type DeltaOperation = StringMap & OptionalAttributes; + type DeltaOperation = { insert?: any, delete?: number, retain?: number } & OptionalAttributes; type TextChangeHandler = (delta: DeltaStatic, oldContents: DeltaStatic, source: Sources) => any; type SelectionChangeHandler = (range: RangeStatic, oldRange: RangeStatic, source: Sources) => any; From 02a294dfd613e5255a663a959700bcd84d908cf2 Mon Sep 17 00:00:00 2001 From: Kevin Lowe Date: Fri, 16 Jun 2017 22:29:44 -0700 Subject: [PATCH 37/90] Rename pdf package to npm name (pdfjs-dist) --- types/{pdf => pdfjs-dist}/index.d.ts | 0 types/{pdf => pdfjs-dist}/pdf-tests.ts | 0 types/{pdf => pdfjs-dist}/tsconfig.json | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename types/{pdf => pdfjs-dist}/index.d.ts (100%) rename types/{pdf => pdfjs-dist}/pdf-tests.ts (100%) rename types/{pdf => pdfjs-dist}/tsconfig.json (100%) diff --git a/types/pdf/index.d.ts b/types/pdfjs-dist/index.d.ts similarity index 100% rename from types/pdf/index.d.ts rename to types/pdfjs-dist/index.d.ts diff --git a/types/pdf/pdf-tests.ts b/types/pdfjs-dist/pdf-tests.ts similarity index 100% rename from types/pdf/pdf-tests.ts rename to types/pdfjs-dist/pdf-tests.ts diff --git a/types/pdf/tsconfig.json b/types/pdfjs-dist/tsconfig.json similarity index 100% rename from types/pdf/tsconfig.json rename to types/pdfjs-dist/tsconfig.json From 5fa9d85818117a6e12b8016d8cd48abf7c7cca3f Mon Sep 17 00:00:00 2001 From: Kevin Lowe Date: Fri, 16 Jun 2017 22:35:07 -0700 Subject: [PATCH 38/90] Rename test file to new package --- types/pdfjs-dist/{pdf-tests.ts => pdfjs-dist-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename types/pdfjs-dist/{pdf-tests.ts => pdfjs-dist-tests.ts} (100%) diff --git a/types/pdfjs-dist/pdf-tests.ts b/types/pdfjs-dist/pdfjs-dist-tests.ts similarity index 100% rename from types/pdfjs-dist/pdf-tests.ts rename to types/pdfjs-dist/pdfjs-dist-tests.ts From 5580239cfec21de62d98cc40aad679a781423e92 Mon Sep 17 00:00:00 2001 From: Kevin Lowe Date: Fri, 16 Jun 2017 22:45:30 -0700 Subject: [PATCH 39/90] Fix tsconfig --- types/pdfjs-dist/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/pdfjs-dist/tsconfig.json b/types/pdfjs-dist/tsconfig.json index ad7d35deb6..110e5b444a 100644 --- a/types/pdfjs-dist/tsconfig.json +++ b/types/pdfjs-dist/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "pdf-tests.ts" + "pdfjs-dist-tests.ts" ] -} \ No newline at end of file +} From 0ffd1233437f56d2c97be69456801f0003b24977 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sat, 17 Jun 2017 09:20:44 -0400 Subject: [PATCH 40/90] [electron-settings] Remove internal module declaration. --- .../v2/electron-settings-tests.ts | 13 +- types/electron-settings/v2/index.d.ts | 340 +++++++++--------- 2 files changed, 180 insertions(+), 173 deletions(-) diff --git a/types/electron-settings/v2/electron-settings-tests.ts b/types/electron-settings/v2/electron-settings-tests.ts index 0eb746559e..25404c90b3 100644 --- a/types/electron-settings/v2/electron-settings-tests.ts +++ b/types/electron-settings/v2/electron-settings-tests.ts @@ -1,5 +1,4 @@ import settings = require('electron-settings'); -import Observer = require('electron-settings/lib/observer'); function test_configure() { settings.configure({ @@ -107,10 +106,18 @@ function test_settings_type_annotation(s: typeof settings) { s.getSettingsFilePath(); } -function test_observer_type_annotation(observer: Observer) { +function test_observer_type_annotation(observer: settings.Observer) { observer.dispose(); } -function test_options_type_annotation(options: ElectronSettings.Options) { +function test_options_type_annotation(options: settings.Options) { options.atomicSaving; } + +function test_applyDefaultOptions_type_annotation(options: settings.ApplyDefaultsOptions) { + options.overwrite; +} + +function test_changeEvent_type_annotation(e: settings.ChangeEvent) { + e.oldValue === e.newValue; +} diff --git a/types/electron-settings/v2/index.d.ts b/types/electron-settings/v2/index.d.ts index 5d932bbcf3..71677cb0df 100644 --- a/types/electron-settings/v2/index.d.ts +++ b/types/electron-settings/v2/index.d.ts @@ -6,194 +6,198 @@ /// -declare module 'electron-settings' { - import { EventEmitter } from 'events'; - import Observer = require('electron-settings/lib/observer'); +import { EventEmitter } from 'events'; + +declare const SettingsInstance: Settings; +export = SettingsInstance; + +/** + * The Settings class. + */ +declare class Settings extends EventEmitter { + /** + * Globally configures default options. + * + * @throws if options is not an object. + */ + configure(options: ElectronSettings.Options.Param): void; /** - * The Settings class. + * Globally configures default settings. + * + * If the settings file has not been created yet, these defaults will be applied, + * but only if settings.defaults is called before making any other calls that + * interact with the file system, such as has(), get(), or set(). + * + * @param defaults The defaults object. + * @throws if defaults is not an object. */ - class Settings extends EventEmitter { - /** - * Globally configures default options. - * - * @throws if options is not an object. - */ - configure(options: ElectronSettings.Options.Param): void; + defaults(defaults: any): void; - /** - * Globally configures default settings. - * - * If the settings file has not been created yet, these defaults will be applied, - * but only if settings.defaults is called before making any other calls that - * interact with the file system, such as has(), get(), or set(). - * - * @param defaults The defaults object. - * @throws if defaults is not an object. - */ - defaults(defaults: any): void; + /** + * Returns a promise whose first argument is a boolean indicating if the key path exists within the settings object. + * For synchronous operation, use hasSync(). + * + * @param keyPath The path to the key that we wish to check exists within the settings object. + * @throws if key path is not a string. + * @see hasSync + */ + has(keyPath: string): Promise; - /** - * Returns a promise whose first argument is a boolean indicating if the key path exists within the settings object. - * For synchronous operation, use hasSync(). - * - * @param keyPath The path to the key that we wish to check exists within the settings object. - * @throws if key path is not a string. - * @see hasSync - */ - has(keyPath: string): Promise; + /** + * The synchronous version of has(). + * + * @see has + */ + hasSync(keyPath: string): boolean; - /** - * The synchronous version of has(). - * - * @see has - */ - hasSync(keyPath: string): boolean; + /** + * Returns a promise whose first argument is the value at the chosen key path. + * If no key path is chosen, the entire settings object will be returned instead. + * For synchronous operation, use getSync(). + * + * @param keyPath The path to the key that we wish to get the value of. + * @see getSync + */ + get(keyPath?: string): Promise; - /** - * Returns a promise whose first argument is the value at the chosen key path. - * If no key path is chosen, the entire settings object will be returned instead. - * For synchronous operation, use getSync(). - * - * @param keyPath The path to the key that we wish to get the value of. - * @see getSync - */ - get(keyPath?: string): Promise; + /** + * The synchronous version of get(). + * + * @see get + */ + getSync(keyPath?: string): any; - /** - * The synchronous version of get(). - * - * @see get - */ - getSync(keyPath?: string): any; + /** + * Sets the value of the key at the chosen key path. + * For synchronous operation, use setSync(). + * + * @param keyPath The path to the key whose value we wish to set. This key need not already exist. + * @param value The value to set the key at the chosen key path to. This must be a data type supported by JSON: object, array, string, number, boolean, or null. + * @param options + * @throws if key path is not a string. + * @throws if options is not an object. + * @see setSync + */ + set(keyPath: string, value: any, options?: ElectronSettings.Options.Param): Promise; - /** - * Sets the value of the key at the chosen key path. - * For synchronous operation, use setSync(). - * - * @param keyPath The path to the key whose value we wish to set. This key need not already exist. - * @param value The value to set the key at the chosen key path to. This must be a data type supported by JSON: object, array, string, number, boolean, or null. - * @param options - * @throws if key path is not a string. - * @throws if options is not an object. - * @see setSync - */ - set(keyPath: string, value: any, options?: ElectronSettings.Options.Param): Promise; + /** + * The synchronous version of set(). + * + * @see set + */ + setSync(keyPath: string, value: any, options?: ElectronSettings.Options.Param): void; - /** - * The synchronous version of set(). - * - * @see set - */ - setSync(keyPath: string, value: any, options?: ElectronSettings.Options.Param): void; + /** + * Deletes the key and value at the chosen key path. + * + * @param keyPath The path to the key we wish to unset. + * @param options + * @throws if keyPath is not a string. + * @throws if options is not an object. + * @see deleteSync + */ + delete(keyPath: string, options?: ElectronSettings.Options.Param): Promise; - /** - * Deletes the key and value at the chosen key path. - * - * @param keyPath The path to the key we wish to unset. - * @param options - * @throws if keyPath is not a string. - * @throws if options is not an object. - * @see deleteSync - */ - delete(keyPath: string, options?: ElectronSettings.Options.Param): Promise; + /** + * The synchronous version of delete(). + * + * @see delete + */ + deleteSync(keyPath: string, options?: ElectronSettings.Options.Param): void; - /** - * The synchronous version of delete(). - * - * @see delete - */ - deleteSync(keyPath: string, options?: ElectronSettings.Options.Param): void; + /** + * Clears the entire settings object. + * For synchronous operation, use clearSync(). + * + * @throws if options is not an object. + * @see clearSync + */ + clear(options?: ElectronSettings.Options.Param): Promise; - /** - * Clears the entire settings object. - * For synchronous operation, use clearSync(). - * - * @throws if options is not an object. - * @see clearSync - */ - clear(options?: ElectronSettings.Options.Param): Promise; + /** + * The synchronous version of clear(). + * + * @see clear + */ + clearSync(options?: ElectronSettings.Options.Param): void; - /** - * The synchronous version of clear(). - * - * @see clear - */ - clearSync(options?: ElectronSettings.Options.Param): void; + /** + * Applies defaults to the current settings object (deep). + * Settings that already exist will not be overwritten, but keys that exist within the defaults + * that don't exist within the setting object will be added. + * To configure defaults, use defaults(). + * For synchronous operation, use applyDefaultsSync(). + * + * @throws if options is not an object. + * @see defaults + * @see applyDefaultsSync + */ + applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions.Param): Promise; - /** - * Applies defaults to the current settings object (deep). - * Settings that already exist will not be overwritten, but keys that exist within the defaults - * that don't exist within the setting object will be added. - * To configure defaults, use defaults(). - * For synchronous operation, use applyDefaultsSync(). - * - * @throws if options is not an object. - * @see defaults - * @see applyDefaultsSync - */ - applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions.Param): Promise; + /** + * The synchronous version of applyDefaults(). + * + * @see applyDefaults + */ + applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions.Param): void; - /** - * The synchronous version of applyDefaults(). - * - * @see applyDefaults - */ - applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions.Param): void; + /** + * Resets all settings to defaults. + * To configure defaults, use defaults(). + * For synchronous operation, use resetToDefaultsSync(). + * + * @throws if options is not an object. + * @see defaults + * @see resetToDefaultsSync + */ + resetToDefaults(options?: ElectronSettings.Options.Param): Promise; - /** - * Resets all settings to defaults. - * To configure defaults, use defaults(). - * For synchronous operation, use resetToDefaultsSync(). - * - * @throws if options is not an object. - * @see defaults - * @see resetToDefaultsSync - */ - resetToDefaults(options?: ElectronSettings.Options.Param): Promise; + /** + * The synchronous version of resetToDefaults(). + * + * @see resetToDefaults + */ + resetToDefaultsSync(options?: ElectronSettings.Options.Param): void; - /** - * The synchronous version of resetToDefaults(). - * - * @see resetToDefaults - */ - resetToDefaultsSync(options?: ElectronSettings.Options.Param): void; + /** + * Observes the chosen key path for changes and calls the handler if the value changes. + * Returns an Observer instance which has a dispose method. + * To unsubscribe, simply call dispose() on the returned key path observer. + * + * @param keyPath The path to the key that we wish to observe. + * @param handler The callback that will be invoked if the value at the chosen key path changes. + * @throws if key path is not a string. + * @throws if handler is not a function. + */ + observe(keyPath: string, handler: (evt: ElectronSettings.ChangeEvent) => void): ElectronSettings.Observer; - /** - * Observes the chosen key path for changes and calls the handler if the value changes. - * Returns an Observer instance which has a dispose method. - * To unsubscribe, simply call dispose() on the returned key path observer. - * - * @param keyPath The path to the key that we wish to observe. - * @param handler The callback that will be invoked if the value at the chosen key path changes. - * @throws if key path is not a string. - * @throws if handler is not a function. - */ - observe(keyPath: string, handler: (evt: ElectronSettings.ChangeEvent) => void): Observer; + /** + * Returns the path to the config file. Typically found in your application's user data directory: + * ~/Library/Application Support/YourApp on MacOS. + * %APPDATA%/YourApp on Windows. + * $XDG_CONFIG_HOME/YourApp or ~/.config/YourApp on Linux. + */ + getSettingsFilePath(): string; - /** - * Returns the path to the config file. Typically found in your application's user data directory: - * ~/Library/Application Support/YourApp on MacOS. - * %APPDATA%/YourApp on Windows. - * $XDG_CONFIG_HOME/YourApp or ~/.config/YourApp on Linux. - */ - getSettingsFilePath(): string; - - /** - * Emitted when the settings file has been created. - */ - on(event: 'create', listener: (pathToSettings: string) => void): this; - /** - * Emitted when the settings have been written to disk. - */ - on(event: 'write', listener: () => void): this; - } - - const SettingsInstance: Settings; - export = SettingsInstance; + /** + * Emitted when the settings file has been created. + */ + on(event: 'create', listener: (pathToSettings: string) => void): this; + /** + * Emitted when the settings have been written to disk. + */ + on(event: 'write', listener: () => void): this; } -declare module 'electron-settings/lib/observer' { +declare namespace SettingsInstance { + type Observer = ElectronSettings.Observer; + type Options = ElectronSettings.Options; + type ApplyDefaultsOptions = ElectronSettings.ApplyDefaultsOptions; + type ChangeEvent = ElectronSettings.ChangeEvent; +} + +declare namespace ElectronSettings { /** * The Observer class. */ @@ -205,10 +209,6 @@ declare module 'electron-settings/lib/observer' { dispose(): void; } - export = Observer; -} - -declare namespace ElectronSettings { interface Options extends Pick { } namespace Options { From 07a1a1a59a7673b13615ac638cab5de3937ff0e4 Mon Sep 17 00:00:00 2001 From: Naor Torgeman Date: Sat, 17 Jun 2017 17:09:14 +0300 Subject: [PATCH 41/90] update test to work with default export --- types/react-input-mask/react-input-mask-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-input-mask/react-input-mask-tests.tsx b/types/react-input-mask/react-input-mask-tests.tsx index 0a4f2cd74e..d116b2b27a 100644 --- a/types/react-input-mask/react-input-mask-tests.tsx +++ b/types/react-input-mask/react-input-mask-tests.tsx @@ -1,4 +1,4 @@ -import * as ReactInputMask from 'react-input-mask'; +import ReactInputMask from 'react-input-mask'; import * as React from 'react';
From b56761f148ed35c0faf42af642ddbde033b3cccf Mon Sep 17 00:00:00 2001 From: Ludovic L'Hours Date: Sat, 17 Jun 2017 22:44:01 +0200 Subject: [PATCH 42/90] [codemirror] Linter function can either be sync or async --- types/codemirror/index.d.ts | 13 ++++++++++--- types/codemirror/test/index.ts | 10 +++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 9a74dc1e53..b42ebabae3 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -1097,7 +1097,7 @@ declare namespace CodeMirror { * Both modes get to parse all of the text, but when both assign a non-null style to a piece of code, the overlay wins, unless * the combine argument was true and not overridden, or state.overlay.combineTokens was true, in which case the styles are combined. */ - function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode + function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode; /** * async specifies that the lint process runs asynchronously. hasGutters specifies that lint errors should be displayed in the CodeMirror @@ -1114,13 +1114,20 @@ declare namespace CodeMirror { * linter. */ interface LintOptions extends LintStateOptions { - getAnnotations: AnnotationsCallback; + getAnnotations: Linter | AsyncLinter; + } + + /** + * A function that return errors found during the linting process. + */ + interface Linter { + (content: string, options: LintStateOptions, codeMirror: Editor): Annotation[] | PromiseLike; } /** * A function that calls the updateLintingCallback with any errors found during the linting process. */ - interface AnnotationsCallback { + interface AsyncLinter { (content: string, updateLintingCallback: UpdateLintingCallback, options: LintStateOptions, codeMirror: Editor): void; } diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index 41b7170fd1..e283abe974 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -28,7 +28,7 @@ var lintStateOptions: CodeMirror.LintStateOptions = { hasGutters: true }; -var lintOptions: CodeMirror.LintOptions = { +var asyncLintOptions: CodeMirror.LintOptions = { async: true, hasGutters: true, getAnnotations: (content: string, @@ -37,6 +37,14 @@ var lintOptions: CodeMirror.LintOptions = { codeMirror: CodeMirror.Editor) => {} }; +var syncLintOptions: CodeMirror.LintOptions = { + async: false, + hasGutters: true, + getAnnotations: (content: string, + options: CodeMirror.LintStateOptions, + codeMirror: CodeMirror.Editor): CodeMirror.Annotation[] => { return []; } +}; + var updateLintingCallback: CodeMirror.UpdateLintingCallback = (codeMirror: CodeMirror.Editor, annotations: CodeMirror.Annotation[]) => {}; From faa1999428ba475de700ff952e656a148edfa56a Mon Sep 17 00:00:00 2001 From: icosahebron Date: Sat, 17 Jun 2017 21:33:49 -0700 Subject: [PATCH 43/90] Update Delta#transform and Delta#transformPosition --- types/quill/index.d.ts | 4 ++-- types/quill/quill-tests.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/types/quill/index.d.ts b/types/quill/index.d.ts index 650408c67c..73a877815f 100644 --- a/types/quill/index.d.ts +++ b/types/quill/index.d.ts @@ -69,9 +69,9 @@ declare namespace Quill { concat(other: DeltaStatic): DeltaStatic; diff(other: DeltaStatic, index?: number) : DeltaStatic; eachLine(predicate: (line: DeltaStatic, attributes: StringMap, idx: number) => any, newline?: string) : DeltaStatic; - transform(index: number) : DeltaStatic; + transform(index: number) : number; transform(other: DeltaStatic, priority: boolean) : DeltaStatic; - transformPosition(index: number) : DeltaStatic; + transformPosition(index: number) : number; } export interface RangeStatic { diff --git a/types/quill/quill-tests.ts b/types/quill/quill-tests.ts index fe2af00afc..f45781a685 100644 --- a/types/quill/quill-tests.ts +++ b/types/quill/quill-tests.ts @@ -324,13 +324,14 @@ function test_DeltaTransform() { var a = new Delta().insert('a'); var b = new Delta().insert('b').retain(5).insert('c'); - a.transform(b, true); // new Delta().retain(1).insert('b').retain(5).insert('c'); - a.transform(b, false); // new Delta().insert('b').retain(6).insert('c'); - a.transform(5); + var d1: Quill.DeltaStatic = a.transform(b, true); // new Delta().retain(1).insert('b').retain(5).insert('c'); + var d2: Quill.DeltaStatic = a.transform(b, false); // new Delta().insert('b').retain(6).insert('c'); + var n1: number = a.transform(5); + } function test_DeltatransformPosition() { var delta = new Delta().retain(5).insert('a'); - delta.transformPosition(4); // 4 - delta.transformPosition(5); // 6 + var n1: number = delta.transformPosition(4); // 4 + var n2: number = delta.transformPosition(5); // 6 } From 3db1d4c9b47ea86b18f3e4a7f2f6192b5f3190f2 Mon Sep 17 00:00:00 2001 From: amiram Date: Sun, 18 Jun 2017 09:57:00 +0300 Subject: [PATCH 44/90] add result to job and process done callback. https://github.com/Automattic/kue/blob/master/lib/queue/job.js#L205 https://github.com/Automattic/kue/blob/master/lib/queue/worker.js#L181 --- types/kue/index.d.ts | 6 +++++- types/kue/kue-tests.ts | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/kue/index.d.ts b/types/kue/index.d.ts index 45fd6cfa83..035d83ce15 100644 --- a/types/kue/index.d.ts +++ b/types/kue/index.d.ts @@ -30,7 +30,7 @@ export declare class Queue extends events.EventEmitter { checkActiveJobTtl(ttlOptions: Object): void; watchStuckJobs(ms: number): void; setting(name: string, fn: Function): Queue; - process(type: string, n?: number | Function, fn?: Function): void; + process(type: string, n?: number | DoneCallback, fn?: DoneCallback): void; shutdown(timeout: number, type: string, fn: Function): Queue; types(fn: Function): Queue; state(string: string, fn: Function): Queue; @@ -57,10 +57,13 @@ interface Priorities { critical: number; } +export type DoneCallback = (err?: any, result?: any) => void; + export declare class Job extends events.EventEmitter { public id: number; public type: string; public data: any; + public result: any; public client: redisClientFactory.RedisClient; private _max_attempts; @@ -80,6 +83,7 @@ export declare class Job extends events.EventEmitter { log(str: string): Job; set(key: string, val: string, fn?: Function): Job; get(key: string, fn?: Function): Job; + get(key: string, jobType: string, fn?: Function): Job; progress(complete: number, total: number, data?: any): Job; delay(ms: number | Date): Job; removeOnComplete(param: any): Job; diff --git a/types/kue/kue-tests.ts b/types/kue/kue-tests.ts index bcd2c26a60..e20ec3e331 100644 --- a/types/kue/kue-tests.ts +++ b/types/kue/kue-tests.ts @@ -46,16 +46,16 @@ create(); // process video conversion jobs, 1 at a time. -var processCb = function(job: kue.Job, done: Function) { +var processCb = function(job: kue.Job, done: kue.DoneCallback) { var frames: number = job.data.frames; function next(i: number) { // pretend we are doing some work - convertFrame(i, function(err: Error) { + convertFrame(i, function(err: Error, result: any) { if (err) return done(err); // report progress, i/frames complete job.progress(i, frames); - if (i >= frames) done(); + if (i >= frames) done(null, result); else next(i + Math.random() * 10); } ); } @@ -67,7 +67,7 @@ jobs.process('video conversion', 1, processCb); jobs.process('video conversion', processCb); function convertFrame(i: number, fn: Function) { - setTimeout(fn, Math.random() * 50); + setTimeout(() => fn(null, Math.random()), Math.random() * 50); } // one minute From ccdd34441dbb357a436c2ab3e8df3144ece9fca7 Mon Sep 17 00:00:00 2001 From: amiram Date: Sun, 18 Jun 2017 10:38:46 +0300 Subject: [PATCH 45/90] add created_at --- types/kue/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/kue/index.d.ts b/types/kue/index.d.ts index 035d83ce15..039ab1fcee 100644 --- a/types/kue/index.d.ts +++ b/types/kue/index.d.ts @@ -64,6 +64,9 @@ export declare class Job extends events.EventEmitter { public type: string; public data: any; public result: any; + // Should always be a number however currently it is a number when creating and a string when loading + // https://github.com/Automattic/kue/issues/1081 + public created_at: string | number; public client: redisClientFactory.RedisClient; private _max_attempts; From 7b23bb554f677a83ac096b1bfa6c9c2e2a330b5a Mon Sep 17 00:00:00 2001 From: amiram Date: Sun, 18 Jun 2017 12:24:40 +0300 Subject: [PATCH 46/90] add get job callback definition https://github.com/Automattic/kue/blob/master/lib/queue/job.js#L161 --- types/kue/index.d.ts | 3 ++- types/kue/kue-tests.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/types/kue/index.d.ts b/types/kue/index.d.ts index 039ab1fcee..8c778a8693 100644 --- a/types/kue/index.d.ts +++ b/types/kue/index.d.ts @@ -58,6 +58,7 @@ interface Priorities { } export type DoneCallback = (err?: any, result?: any) => void; +export type JobCallback = (err?: any, job?: Job) => void; export declare class Job extends events.EventEmitter { public id: number; @@ -73,7 +74,7 @@ export declare class Job extends events.EventEmitter { static priorities: Priorities; static disableSearch: boolean; static jobEvents: boolean; - static get(id: number, fn: Function): void; + static get(id: number, type: string | JobCallback, fn?: JobCallback): void; static remove(id: number, fn?: Function): void; static removeBadJob(id: number): void; static log(id: number, fn: Function): void; diff --git a/types/kue/kue-tests.ts b/types/kue/kue-tests.ts index e20ec3e331..fd929d7aeb 100644 --- a/types/kue/kue-tests.ts +++ b/types/kue/kue-tests.ts @@ -39,6 +39,13 @@ function create() { job.save(); + kue.Job.get(job.id, function (err: any, _job: kue.Job) { + console.log('get job', _job); + }); + kue.Job.get(job.id, 'video conversion', function (err: any, _job: kue.Job) { + console.log('get job', _job); + }); + setTimeout( create, Math.random() * 2000 | 0 ); } From cb2189e1848c72edfd7862f67e6e97939e963e02 Mon Sep 17 00:00:00 2001 From: HiromiShikata Date: Thu, 15 Jun 2017 19:59:51 +0900 Subject: [PATCH 47/90] feat(fs-extra-promise): add missing interfaces --- types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts | 9 +++++++++ types/fs-extra-promise-es6/index.d.ts | 6 +++++- types/fs-extra-promise/fs-extra-promise-tests.ts | 9 +++++++++ types/fs-extra-promise/index.d.ts | 6 +++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts index 46e623207a..e789c5627f 100644 --- a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts +++ b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts @@ -42,6 +42,7 @@ var openOpts: fs.OpenOptions; var watcher: fs.FSWatcher; var readStreeam: stream.Readable; var writeStream: stream.Writable; +var isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -222,3 +223,11 @@ writeStream = fs.createWriteStream(path, { flags: str, encoding: str }); + +var isDirectoryCallback = (err: Error, isDirectory: boolean) => { +}; +fs.isDirectory(path, isDirectoryCallback); +fs.isDirectory(path); +isDirectory = fs.isDirectorySync(path); +fs.isDirectoryAsync(path); + diff --git a/types/fs-extra-promise-es6/index.d.ts b/types/fs-extra-promise-es6/index.d.ts index 85055636dc..82ab2da35b 100644 --- a/types/fs-extra-promise-es6/index.d.ts +++ b/types/fs-extra-promise-es6/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for fs-extra-promise-es6 // Project: https://github.com/vinsonchuong/fs-extra-promise-es6 -// Definitions by: midknight41 , Jason Swearingen , Joshua DeVinney +// Definitions by: midknight41 , Jason Swearingen , Joshua DeVinney , Hiromi Shikata // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: fs-extra-promise typings (minus Bluebird) @@ -239,3 +239,7 @@ export declare function appendFileAsync(filename: string, data: any, option?: Op export declare function existsAsync(path: string): Promise; export declare function ensureDirAsync(path: string): Promise; + +export declare function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export declare function isDirectorySync(path: string): boolean; +export declare function isDirectoryAsync(path: string): Promise; diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index ef8de43ad3..592f61ca87 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -43,6 +43,7 @@ var writeOpts: fs.WriteOptions; var watcher: fs.FSWatcher; var readStream: stream.Readable; var writeStream: stream.Writable; +var isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -219,3 +220,11 @@ writeStream = fs.createWriteStream(path, { flags: str, encoding: str }); + +var isDirectoryCallback = (err: Error, isDirectory: boolean) => { +}; +fs.isDirectory(path, isDirectoryCallback); +fs.isDirectory(path); +isDirectory = fs.isDirectorySync(path); +fs.isDirectoryAsync(path); + diff --git a/types/fs-extra-promise/index.d.ts b/types/fs-extra-promise/index.d.ts index b4c9a648ac..36de7fdf19 100644 --- a/types/fs-extra-promise/index.d.ts +++ b/types/fs-extra-promise/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for fs-extra-promise 1.0 // Project: https://github.com/overlookmotel/fs-extra-promise -// Definitions by: midknight41 , Jason Swearingen +// Definitions by: midknight41 , Jason Swearingen , Hiromi Shikata // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -90,3 +90,7 @@ export declare function appendFileAsync(filename: string, data: any, option?: Wr export declare function existsAsync(path: string): Promise; export declare function ensureDirAsync(path: string): Promise; + +export declare function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export declare function isDirectorySync(path: string): boolean; +export declare function isDirectoryAsync(path: string): Promise; From 4692264abaf4302186a863dd3d6f7d84b9ce4015 Mon Sep 17 00:00:00 2001 From: Steve Tran Date: Sun, 18 Jun 2017 18:15:39 +0700 Subject: [PATCH 48/90] Create types for ffmpeg-static and ffprobe-static --- types/ffmpeg-static/ffmpeg-static-tests.ts | 3 +++ types/ffmpeg-static/index.d.ts | 10 +++++++++ types/ffmpeg-static/tsconfig.json | 22 ++++++++++++++++++++ types/ffmpeg-static/tslint.json | 1 + types/ffprobe-static/ffprobe-static-tests.ts | 3 +++ types/ffprobe-static/index.d.ts | 10 +++++++++ types/ffprobe-static/tsconfig.json | 22 ++++++++++++++++++++ types/ffprobe-static/tslint.json | 1 + 8 files changed, 72 insertions(+) create mode 100644 types/ffmpeg-static/ffmpeg-static-tests.ts create mode 100644 types/ffmpeg-static/index.d.ts create mode 100644 types/ffmpeg-static/tsconfig.json create mode 100644 types/ffmpeg-static/tslint.json create mode 100644 types/ffprobe-static/ffprobe-static-tests.ts create mode 100644 types/ffprobe-static/index.d.ts create mode 100644 types/ffprobe-static/tsconfig.json create mode 100644 types/ffprobe-static/tslint.json diff --git a/types/ffmpeg-static/ffmpeg-static-tests.ts b/types/ffmpeg-static/ffmpeg-static-tests.ts new file mode 100644 index 0000000000..319a5e27f8 --- /dev/null +++ b/types/ffmpeg-static/ffmpeg-static-tests.ts @@ -0,0 +1,3 @@ +import * as ffmpegStatic from 'ffmpeg-static'; + +ffmpegStatic.path; diff --git a/types/ffmpeg-static/index.d.ts b/types/ffmpeg-static/index.d.ts new file mode 100644 index 0000000000..dfd9ce0906 --- /dev/null +++ b/types/ffmpeg-static/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ffmpeg-static 2.0 +// Project: https://github.com/eugeneware/ffmpeg-static#readme +// Definitions by: Steve Tran +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ You can declare properties of the module using const, let, or var */ +/** + * Binary location + */ +export const path: string; diff --git a/types/ffmpeg-static/tsconfig.json b/types/ffmpeg-static/tsconfig.json new file mode 100644 index 0000000000..94c7a336b8 --- /dev/null +++ b/types/ffmpeg-static/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ffmpeg-static-tests.ts" + ] +} diff --git a/types/ffmpeg-static/tslint.json b/types/ffmpeg-static/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ffmpeg-static/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ffprobe-static/ffprobe-static-tests.ts b/types/ffprobe-static/ffprobe-static-tests.ts new file mode 100644 index 0000000000..6565fd2ae1 --- /dev/null +++ b/types/ffprobe-static/ffprobe-static-tests.ts @@ -0,0 +1,3 @@ +import * as ffprobeStatic from 'ffmpeg-static'; + +ffprobeStatic.path; diff --git a/types/ffprobe-static/index.d.ts b/types/ffprobe-static/index.d.ts new file mode 100644 index 0000000000..b337d85e38 --- /dev/null +++ b/types/ffprobe-static/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ffprobe-static 2.0 +// Project: https://github.com/joshwnj/ffprobe-static +// Definitions by: Steve Tran +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ You can declare properties of the module using const, let, or var */ +/** + * Binary location + */ +export const path: string; diff --git a/types/ffprobe-static/tsconfig.json b/types/ffprobe-static/tsconfig.json new file mode 100644 index 0000000000..726a8e0feb --- /dev/null +++ b/types/ffprobe-static/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ffprobe-static-tests.ts" + ] +} diff --git a/types/ffprobe-static/tslint.json b/types/ffprobe-static/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ffprobe-static/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 4636d3ed83956ac60854127cb518d7f1263b016a Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 13:31:35 -0400 Subject: [PATCH 49/90] [jquery] Fix JSDoc failing to associate with type member when TSLint rule flag is in between. --- types/jquery/index.d.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 598d71bc60..e7f1229b65 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -516,8 +516,7 @@ interface JQuery { * @see {@link https://api.jquery.com/data/} * @since 1.2.3 */ - // tslint:disable-next-line:unified-signatures - data(key: string, undefined: undefined): any; + data(key: string, undefined: undefined): any; // tslint:disable-line:unified-signatures /** * Store arbitrary data associated with the matched elements. * @@ -1695,8 +1694,7 @@ interface JQuery { * @see {@link https://api.jquery.com/prop/} * @since 1.6 */ - // tslint:disable-next-line:unified-signatures - prop(propertyName: string, value: any): this; + prop(propertyName: string, value: any): this; // tslint:disable-line:unified-signatures /** * Set one or more properties for the set of matched elements. * @@ -2553,8 +2551,7 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.data/} * @since 1.2.3 */ - // tslint:disable-next-line:unified-signatures - data(element: Element, key: string, undefined: undefined): any; + data(element: Element, key: string, undefined: undefined): any; // tslint:disable-line:unified-signatures /** * Store arbitrary data associated with the specified element. Returns the value that was set. * From 77ad71917d918416aaeddcf1e92b9ecfcd4192ec Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 14:55:54 -0400 Subject: [PATCH 50/90] [jquery] Use 'SuccessTextStatus' instead of 'string'. --- types/jquery/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index e7f1229b65..65e87ea37a 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -1147,7 +1147,7 @@ interface JQuery { */ load(url: string, data: string | JQuery.PlainObject, - complete: (this: TElement, responseText: string, textStatus: string, jqXHR: JQuery.jqXHR) => void): this; + complete: (this: TElement, responseText: string, textStatus: JQuery.Ajax.SuccessTextStatus, jqXHR: JQuery.jqXHR) => void): this; /** * Load data from the server and place the returned HTML into the matched element. * @@ -1158,7 +1158,7 @@ interface JQuery { * @since 1.0 */ load(url: string, - complete_data?: ((this: TElement, responseText: string, textStatus: string, jqXHR: JQuery.jqXHR) => void) | string | JQuery.PlainObject): this; + complete_data?: ((this: TElement, responseText: string, textStatus: JQuery.Ajax.SuccessTextStatus, jqXHR: JQuery.jqXHR) => void) | string | JQuery.PlainObject): this; /** * Pass each element in the current matched set through a function, producing a new jQuery object * containing the return values. From 821e7ce3879e2668769dfd15a4c01f356e4478bc Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 15:58:04 -0400 Subject: [PATCH 51/90] [jquery] Consistency pass. --- types/jquery/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 65e87ea37a..c1e7a6bac7 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -1609,7 +1609,7 @@ interface JQuery { * @see {@link https://api.jquery.com/prepend/} * @since 1.4 */ - prepend(fn: (this: TElement, elementOfArray: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; + prepend(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; /** * Insert every element in the set of matched elements to the beginning of the target. * @@ -1618,7 +1618,7 @@ interface JQuery { * @see {@link https://api.jquery.com/prependTo/} * @since 1.0 */ - prependTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; + prependTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; /** * Get the immediately preceding sibling of each element in the set of matched elements. If a selector * is provided, it retrieves the previous sibling only if it matches that selector. @@ -2354,7 +2354,7 @@ interface JQuery { * @since 1.2 * @since 1.4 */ - wrapInner(wrappingElement: JQuery.htmlString | JQuery.Selector | JQuery | Element | ((this: TElement, index: number) => string)): this; + wrapInner(wrappingElement: JQuery.Selector | JQuery.htmlString | Element | JQuery | ((this: TElement, index: number) => string | Element | JQuery)): this; } interface JQuery extends ArrayLike, Iterable { } From a3ef3077dd0861734b18f1dc08f9feeae43b267a Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 16:26:05 -0400 Subject: [PATCH 52/90] [jquery] Fixed signatures on Ajax-related methods on JQuery. Added tests for Ajax-related methods on JQuery. --- types/jquery/index.d.ts | 12 +-- types/jquery/jquery-tests.ts | 138 ++++++++++++++++++++++++++++++++++- 2 files changed, 143 insertions(+), 7 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index c1e7a6bac7..2d5543cb3a 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -129,7 +129,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxComplete/} * @since 1.0 */ - ajaxComplete(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; + ajaxComplete(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; /** * Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. * @@ -137,7 +137,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxError/} * @since 1.0 */ - ajaxError(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxSettings: JQuery.AjaxSettings, thrownError: string) => void | false): this; + ajaxError(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxSettings: JQuery.AjaxSettings, thrownError: string) => void | false): this; /** * Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. * @@ -145,7 +145,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxSend/} * @since 1.0 */ - ajaxSend(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; + ajaxSend(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings) => void | false): this; /** * Register a handler to be called when the first Ajax request begins. This is an Ajax Event. * @@ -169,7 +169,7 @@ interface JQuery { * @see {@link https://api.jquery.com/ajaxSuccess/} * @since 1.0 */ - ajaxSuccess(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings, data: JQuery.PlainObject) => void | false): this; + ajaxSuccess(handler: (this: Document, event: JQuery.Event, jqXHR: JQuery.jqXHR, ajaxOptions: JQuery.AjaxSettings, data: JQuery.PlainObject) => void | false): this; /** * Perform a custom animation of a set of CSS properties. * @@ -1147,7 +1147,7 @@ interface JQuery { */ load(url: string, data: string | JQuery.PlainObject, - complete: (this: TElement, responseText: string, textStatus: JQuery.Ajax.SuccessTextStatus, jqXHR: JQuery.jqXHR) => void): this; + complete: (this: TElement, responseText: string, textStatus: JQuery.Ajax.TextStatus, jqXHR: JQuery.jqXHR) => void): this; /** * Load data from the server and place the returned HTML into the matched element. * @@ -1158,7 +1158,7 @@ interface JQuery { * @since 1.0 */ load(url: string, - complete_data?: ((this: TElement, responseText: string, textStatus: JQuery.Ajax.SuccessTextStatus, jqXHR: JQuery.jqXHR) => void) | string | JQuery.PlainObject): this; + complete_data?: ((this: TElement, responseText: string, textStatus: JQuery.Ajax.TextStatus, jqXHR: JQuery.jqXHR) => void) | string | JQuery.PlainObject): this; /** * Pass each element in the current matched set through a function, producing a new jQuery object * containing the return values. diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 09468a1c55..c76d26ad8e 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -9,6 +9,140 @@ function JQuery() { $('div')[0] === new HTMLElement(); } + function ajax() { + function ajaxComplete() { + // $ExpectType JQuery + $(document).ajaxComplete(function(event, jqXHR, ajaxOptions) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxOptions; + + return false; + }); + } + + function ajaxError() { + // $ExpectType JQuery + $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxSettings; + // $ExpectType string + thrownError; + + return false; + }); + } + + function ajaxSend() { + // $ExpectType JQuery + $(document).ajaxSend(function(event, jqXHR, ajaxOptions) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxOptions; + + return false; + }); + } + + function ajaxStart() { + // $ExpectType JQuery + $(document).ajaxStart(function() { + // $ExpectType Document + this; + + return false; + }); + } + + function ajaxStop() { + // $ExpectType JQuery + $(document).ajaxStop(function() { + // $ExpectType Document + this; + + return false; + }); + } + + function ajaxSuccess() { + // $ExpectType JQuery + $(document).ajaxSuccess(function(event, jqXHR, ajaxOptions, data) { + // $ExpectType Document + this; + // $ExpectType Event + event; + // $ExpectType jqXHR + jqXHR; + // $ExpectType AjaxSettings + ajaxOptions; + // $ExpectType PlainObject + data; + + return false; + }); + } + + function load() { + // $ExpectType JQuery + $('#result').load('/echo/html/', 'data', function(responseText, textStatus, jqXHR) { + // $ExpectType HTMLElement + this; + // $ExpectType string + responseText; + // $ExpectType TextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType JQuery + $('#result').load('/echo/html/', { data: 'data' }, function(responseText, textStatus, jqXHR) { + // $ExpectType HTMLElement + this; + // $ExpectType string + responseText; + // $ExpectType TextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType JQuery + $('#result').load('/echo/html/', function(responseText, textStatus, jqXHR) { + // $ExpectType HTMLElement + this; + // $ExpectType string + responseText; + // $ExpectType TextStatus + textStatus; + // $ExpectType jqXHR + jqXHR; + }); + + // $ExpectType JQuery + $('#result').load('/echo/html/', 'data'); + + // $ExpectType JQuery + $('#result').load('/echo/html/', { data: 'data' }); + } + } + function on() { function false_handler_shorthand() { $().on('events', false); @@ -184,7 +318,9 @@ function jqXHR() { $.ajax('/echo').fail((jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; - // $ExpectType "abort" | "timeout" | "error" | "parsererror" | null + // This test is flaky + // Should be 'ErrorTextStatus | null' and should be able to handle it out of order + // $ExpectType "timeout" | "error" | "abort" | "parsererror" | null textStatus; // $ExpectType string errorThrown; From cb59acb8171abd55680678371521a07154036462 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 17:01:10 -0400 Subject: [PATCH 53/90] [jquery] Added tests for attribute-related and property-related methods on JQuery. --- types/jquery/jquery-tests.ts | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index c76d26ad8e..02eb9f0695 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -143,6 +143,112 @@ function JQuery() { } } + function attributes() { + function attr() { + // $ExpectType JQuery + $('#greatphoto').attr('alt', 'Beijing Brush Seller'); + + // $ExpectType JQuery + $('#greatphoto').attr('width', 200); + + // $ExpectType JQuery + $('#greatphoto').attr('title', null); + + // $ExpectType JQuery + $('#greatphoto').attr('alt', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return 'Beijing Brush Seller'; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('width', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return 200; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('title', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + }); + + // $ExpectType JQuery + $('#greatphoto').attr('title', function(index, attr) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + attr; + + return undefined; + }); + + // $ExpectType JQuery + $('img').attr({ + src: '/resources/hat.gif', + title: 'jQuery', + alt: 'jQuery Logo' + }); + + // $ExpectType string | undefined + $('img').attr('src'); + } + + function removeAttr() { + // $ExpectType JQuery + $('#greatphoto').removeAttr('alt'); + } + } + + function properties() { + function prop() { + // $ExpectType JQuery + $('p').prop('myProp', function(index, oldPropertyValue) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType any + oldPropertyValue; + + return {}; + }); + + // $ExpectType JQuery + $('p').prop('myProp', {}); + + // $ExpectType JQuery + $('input[type=\'checkbox\']').prop({ + myProp: true + }); + + // $ExpectType any + $('input[type=\'checkbox\']').prop('myProp'); + } + + function removeProp() { + // $ExpectType JQuery + $('p').removeProp('luggageCode'); + } + } + function on() { function false_handler_shorthand() { $().on('events', false); From 89b331e304fed1d38f82032aa6b23c1ff9b316eb Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 18:19:18 -0400 Subject: [PATCH 54/90] [jquery] width and height methods on JQuery can return undefined on empty sets. Add tests for CSS-related methods on JQuery. --- types/jquery/index.d.ts | 19 +- types/jquery/jquery-tests.ts | 457 +++++++++++++++++++++++++++++ types/jquery/test/example-tests.ts | 16 +- 3 files changed, 475 insertions(+), 17 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 2d5543cb3a..d497b698ac 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -932,7 +932,7 @@ interface JQuery { * @see {@link https://api.jquery.com/height/} * @since 1.0 */ - height(): number; + height(): number | undefined; /** * Hide the matched elements. * @@ -1024,7 +1024,7 @@ interface JQuery { * @see {@link https://api.jquery.com/innerHeight/} * @since 1.2.6 */ - innerHeight(): number; + innerHeight(): number | undefined; /** * Set the CSS inner width of each element in the set of matched elements. * @@ -1044,7 +1044,7 @@ interface JQuery { * @see {@link https://api.jquery.com/innerWidth/} * @since 1.2.6 */ - innerWidth(): number; + innerWidth(): number | undefined; /** * Insert every element in the set of matched elements after the target. * @@ -1534,7 +1534,7 @@ interface JQuery { * @see {@link https://api.jquery.com/outerHeight/} * @since 1.2.6 */ - outerHeight(includeMargin?: boolean): number; + outerHeight(includeMargin?: boolean): number | undefined; /** * Set the CSS outer width of each element in the set of matched elements. * @@ -1554,7 +1554,7 @@ interface JQuery { * @see {@link https://api.jquery.com/outerWidth/} * @since 1.2.6 */ - outerWidth(includeMargin?: boolean): number; + outerWidth(includeMargin?: boolean): number | undefined; /** * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. * @@ -2177,10 +2177,11 @@ interface JQuery { * @since 1.3 * @since 1.4 */ - toggleClass(className: string | ((this: TElement, index: number, className: string, state: boolean) => string), - state?: boolean): this; + toggleClass(className: string | ((this: TElement, index: number, className: string, state: TState) => string), + state?: TState): this; /** - * + * Add or remove one or more classes from each element in the set of matched elements, depending on + * either the class's presence or the value of the state argument. * * @param state A boolean value to determine whether the class should be added or removed. * @see {@link https://api.jquery.com/toggleClass/} @@ -2314,7 +2315,7 @@ interface JQuery { * @see {@link https://api.jquery.com/width/} * @since 1.0 */ - width(): number; + width(): number | undefined; /** * Wrap an HTML structure around each element in the set of matched elements. * diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 02eb9f0695..03c8d18360 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -249,6 +249,463 @@ function JQuery() { } } + function css() { + // TODO: .css() getters can return 'undefined' for properties that don't exist. Consider changing the return types to reflect this after adding specialized signatures. + function css() { + // $ExpectType JQuery + $('p').css('cssProp', 'value'); + + // $ExpectType JQuery + $('p').css('cssProp', 20); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 'value'; + }); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 20; + }); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + }); + + // $ExpectType JQuery + $('p').css('cssProp', function(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return undefined; + }); + + // $ExpectType JQuery + $('p').css({ + myProp1: 'value', + myProp2: 20, + myProp3(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 'value'; + }, + myProp4(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return 20; + }, + myProp5(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + }, + myProp6(index, value) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + value; + + return undefined; + } + }); + + // $ExpectType string + $('p').css('myProp'); + + // $ExpectType PlainObject + $('p').css([ + 'myProp1', + 'myProp2' + ]); + } + + function height() { + // $ExpectType JQuery + $('p').height('200px'); + + // $ExpectType JQuery + $('p').height(400); + + // $ExpectType JQuery + $('p').height(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').height(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return 400; + }); + + // $ExpectType number | undefined + $('p').height(); + } + + function innerHeight() { + // $ExpectType JQuery + $('p').innerHeight('200px'); + + // $ExpectType JQuery + $('p').innerHeight(400); + + // $ExpectType JQuery + $('p').innerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').innerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return 400; + }); + + // $ExpectType number | undefined + $('p').innerHeight(); + } + + function outerHeight() { + // $ExpectType JQuery + $('p').outerHeight('200px'); + + // $ExpectType JQuery + $('p').outerHeight(400); + + // $ExpectType JQuery + $('p').outerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').outerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return 400; + }); + + // $ExpectType number | undefined + $('p').outerHeight(); + + // $ExpectType number | undefined + $('p').outerHeight(true); + } + + function width() { + // $ExpectType JQuery + $('p').width('200px'); + + // $ExpectType JQuery + $('p').width(400); + + // $ExpectType JQuery + $('p').width(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').width(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return 400; + }); + + // $ExpectType number | undefined + $('p').width(); + } + + function innerWidth() { + // $ExpectType JQuery + $('p').innerWidth('200px'); + + // $ExpectType JQuery + $('p').innerWidth(400); + + // $ExpectType JQuery + $('p').innerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').innerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return 400; + }); + + // $ExpectType number | undefined + $('p').innerWidth(); + } + + function outerWidth() { + // $ExpectType JQuery + $('p').outerWidth('200px'); + + // $ExpectType JQuery + $('p').outerWidth(400); + + // $ExpectType JQuery + $('p').outerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return '200px'; + }); + + // $ExpectType JQuery + $('p').outerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return 400; + }); + + // $ExpectType number | undefined + $('p').outerWidth(); + + // $ExpectType number | undefined + $('p').outerWidth(true); + } + + function offset() { + // $ExpectType JQuery + $('p').offset({ + left: 20, + top: 50 + }); + + // $ExpectType JQuery + $('p').offset(function(index, coords) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType Coordinates + coords; + + return { + left: 20, + top: 50 + }; + }); + + // $ExpectType Coordinates + $('p').offset(); + } + + function position() { + // $ExpectType Coordinates + $('p').position(); + } + + function scrollLeft() { + // $ExpectType JQuery + $('p').scrollLeft(200); + + // $ExpectType number + $('p').scrollLeft(); + } + + function scrollTop() { + // $ExpectType JQuery + $('p').scrollTop(200); + + // $ExpectType number + $('p').scrollTop(); + } + + function addClass() { + // $ExpectType JQuery + $('p').addClass('className'); + + // $ExpectType JQuery + $('p').addClass(function(index, currentClassName) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + currentClassName; + + return 'className'; + }); + } + + function hasClass() { + // $ExpectType boolean + $('p').hasClass('className'); + } + + function removeClass() { + // $ExpectType JQuery + $('p').removeClass('className'); + + // $ExpectType JQuery + $('p').removeClass(function(index, currentClassName) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + currentClassName; + + return 'className'; + }); + + // $ExpectType JQuery + $('p').removeClass(); + } + + function toggleClass() { + // $ExpectType JQuery + $('p').toggleClass('className', true); + + // $ExpectType JQuery + $('p').toggleClass(function(index, className, state) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + className; + // $ExpectType true + state; + + return 'className'; + }, true); + + // $ExpectType JQuery + $('p').toggleClass('className'); + + // $ExpectType JQuery + $('p').toggleClass(function(index, className, state) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType string + className; + // $ExpectType boolean + state; + + return 'className'; + }); + + // $ExpectType JQuery + $('p').toggleClass(false); + + // $ExpectType JQuery + $('p').toggleClass(); + } + } + function on() { function false_handler_shorthand() { $().on('events', false); diff --git a/types/jquery/test/example-tests.ts b/types/jquery/test/example-tests.ts index d2c0a8464d..961e239192 100644 --- a/types/jquery/test/example-tests.ts +++ b/types/jquery/test/example-tests.ts @@ -1822,8 +1822,8 @@ function examples() { } function finish_0() { - var horiz = $('#path').width() - 20, - vert = $('#path').height() - 20; + var horiz = $('#path').width()! - 20, + vert = $('#path').height()! - 20; var btns: { [key: string]: () => void; } = { bstt: function() { @@ -1992,13 +1992,13 @@ function examples() { } $('#getp').click(function() { - showHeight('paragraph', $('p').height()); + showHeight('paragraph', $('p').height()!); }); $('#getd').click(function() { - showHeight('document', $(document).height()); + showHeight('document', $(document).height()!); }); $('#getw').click(function() { - showHeight('window', $(window).height()); + showHeight('window', $(window).height()!); }); } @@ -4935,13 +4935,13 @@ function examples() { } $('#getp').click(function() { - showWidth('paragraph', $('p').width()); + showWidth('paragraph', $('p').width()!); }); $('#getd').click(function() { - showWidth('document', $(document).width()); + showWidth('document', $(document).width()!); }); $('#getw').click(function() { - showWidth('window', $(window).width()); + showWidth('window', $(window).width()!); }); } From 2ab5b3991528d7290a99b8935bdc7a0d76355bad Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 18:29:01 -0400 Subject: [PATCH 55/90] [jquery] Add tests for data-related methods on JQuery. --- types/jquery/jquery-tests.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 03c8d18360..f55232e43e 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -706,6 +706,42 @@ function JQuery() { } } + function data() { + function data() { + // $ExpectType any + $('p').data('myData', undefined); + + // $ExpectType JQuery + $('p').data('myData', {}); + + // $ExpectType JQuery + $('p').data({ + myData1: {}, + myData2: false + }); + + // $ExpectType any + $('p').data('myData'); + + // $ExpectType PlainObject + $('p').data(); + } + + function removeData() { + // $ExpectType JQuery + $('p').removeData('myData'); + + // $ExpectType JQuery + $('p').removeData([ + 'myData1', + 'myData2' + ]); + + // $ExpectType JQuery + $('p').removeData(); + } + } + function on() { function false_handler_shorthand() { $().on('events', false); From 66517493eff283a6239502dc160877790086a630 Mon Sep 17 00:00:00 2001 From: newraina Date: Mon, 19 Jun 2017 10:38:45 +0800 Subject: [PATCH 56/90] fix fetch.io append param --- types/fetch.io/fetch.io-tests.ts | 5 +++++ types/fetch.io/index.d.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/fetch.io/fetch.io-tests.ts b/types/fetch.io/fetch.io-tests.ts index 538da8e74b..67c2612fdc 100644 --- a/types/fetch.io/fetch.io-tests.ts +++ b/types/fetch.io/fetch.io-tests.ts @@ -57,3 +57,8 @@ request .post('') .send({}) .json(); + +request + .post('') + .append('key', 'value') + .append({key: 'value'}); diff --git a/types/fetch.io/index.d.ts b/types/fetch.io/index.d.ts index 8258cbf8da..fabbbc4b52 100644 --- a/types/fetch.io/index.d.ts +++ b/types/fetch.io/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for fetch.io 3.1 +// Type definitions for fetch.io 4.0 // Project: https://github.com/haoxins/fetch.io // Definitions by: newraina // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -95,7 +95,9 @@ export class Request { /** * ppend formData */ - append(key: string, value: string): this; + append(key: string, value: any): this; + + append(object: {[key: string]: any}): this; /** * Get Response directly From 294e98d261920f5cf33c2f737c25aa6ede6a87b8 Mon Sep 17 00:00:00 2001 From: Oden Date: Mon, 19 Jun 2017 00:24:18 -0700 Subject: [PATCH 57/90] Use React.ComponentType --- types/react-loadable/index.d.ts | 10 ++++------ types/react-loadable/react-loadable-tests.tsx | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/types/react-loadable/index.d.ts b/types/react-loadable/index.d.ts index 1a77aa543c..f6c0cf5fde 100644 --- a/types/react-loadable/index.d.ts +++ b/types/react-loadable/index.d.ts @@ -6,8 +6,6 @@ import * as React from 'react'; -export type LoadedComponent = React.ComponentClass | React.SFC; - export interface LoadingComponentProps { isLoading: boolean; pastDelay: boolean; @@ -29,7 +27,7 @@ export interface CommonOptions { /** * Defaults to 200, in milliseconds. * - * Only show the LoadingComponent if the loader() has taken this long to succeed or error. + * Only show the loading component if the loader() has taken this long to succeed or error. */ delay?: number | false | null; /** @@ -46,7 +44,7 @@ export interface OptionsWithoutRender extends CommonOptions { * * Resulting React component receives all the props passed to the generated component. */ - loader(): Promise | { [key: string]: LoadedComponent }>; + loader(): Promise | { [key: string]: React.ComponentType }>; } export interface OptionsWithRender extends CommonOptions { @@ -110,8 +108,8 @@ export interface LoadableComponent { } export interface Loadable { - (options: Options): LoadedComponent & LoadableComponent; - Map(options: OptionsWithMap): LoadedComponent & LoadableComponent; + (options: Options): React.ComponentType & LoadableComponent; + Map(options: OptionsWithMap): React.ComponentType & LoadableComponent; } declare const LoadableExport: Loadable; diff --git a/types/react-loadable/react-loadable-tests.tsx b/types/react-loadable/react-loadable-tests.tsx index 981508292c..9ae6c499df 100644 --- a/types/react-loadable/react-loadable-tests.tsx +++ b/types/react-loadable/react-loadable-tests.tsx @@ -70,7 +70,7 @@ const LoadableMap = Loadable.Map({ Component: () => Promise.resolve({ default: Component }), text: () => Promise.resolve("test text") }, - render(loaded, props) { + render(loaded, props: ComponentProps) { let Component = loaded.Component.default; return ; } From 081c004d033a1a111f6ff2cf8f9b0993358d6f26 Mon Sep 17 00:00:00 2001 From: Oden Date: Mon, 19 Jun 2017 00:28:21 -0700 Subject: [PATCH 58/90] Fix Map loader docs. --- types/react-loadable/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-loadable/index.d.ts b/types/react-loadable/index.d.ts index f6c0cf5fde..d456f4e085 100644 --- a/types/react-loadable/index.d.ts +++ b/types/react-loadable/index.d.ts @@ -72,7 +72,7 @@ export interface OptionsWithRender extends Common export interface OptionsWithMap extends CommonOptions { /** - * Function returning a promise which returns an object to be passed to `render` on success. + * An object containing functions which return promises, which resolve to an object to be passed to `render` on success. */ loader: { [P in keyof Exports]: () => Promise From c83b614b4225943d81a9ff81951042b124fc47bb Mon Sep 17 00:00:00 2001 From: Tim Brust Date: Wed, 14 Jun 2017 20:23:07 +0200 Subject: [PATCH 59/90] fix(cordova-plugin-inappbrowser): add missing entry of InAppBrowser to Cordova interface --- .../cordova-plugin-inappbrowser-tests.ts | 8 +- types/cordova-plugin-inappbrowser/index.d.ts | 73 +++++-------------- types/cordova-plugin-inappbrowser/tslint.json | 1 + 3 files changed, 23 insertions(+), 59 deletions(-) create mode 100644 types/cordova-plugin-inappbrowser/tslint.json diff --git a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts index d717e85ea4..1497eec386 100644 --- a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts +++ b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts @@ -1,10 +1,10 @@ // InAppBrowser plugin -//---------------------------------------------------------------------- +// ---------------------------------------------------------------------- // signature of window.open() added by InAppBrowser plugin // is similar to native window.open signature, so the compiler can's // select proper overload, but we cast result to InAppBrowser manually. -var iab = window.open('google.com', '_self'); +const iab = window.open('google.com', '_self'); iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); }); iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); }); @@ -30,5 +30,5 @@ iab.removeEventListener('exit', inAppBrowserCallBack); iab.show(); iab.executeScript( { code: "console.log('Injected script in action')" }, - ()=> { console.log('Script is executed'); } -); \ No newline at end of file + () => { console.log('Script is executed'); } +); diff --git a/types/cordova-plugin-inappbrowser/index.d.ts b/types/cordova-plugin-inappbrowser/index.d.ts index 91dc61314f..cd1af63c79 100644 --- a/types/cordova-plugin-inappbrowser/index.d.ts +++ b/types/cordova-plugin-inappbrowser/index.d.ts @@ -1,11 +1,13 @@ -// Type definitions for Apache Cordova InAppBrowser plugin +// Type definitions for Apache Cordova InAppBrowser plugin 1.7 // Project: https://github.com/apache/cordova-plugin-inappbrowser // Definitions by: Microsoft Open Technologies Inc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// +// // Copyright (c) Microsoft Open Technologies Inc // Licensed under the MIT license. // TypeScript Version: 2.3 +type target = "_self" | "_blank" | "_system"; +type channel = "loadstart" | "loadstop" | "loaderror" | "exit"; interface Window { /** @@ -16,34 +18,7 @@ interface Window { * The options string must not contain any blank space, and each feature's * name/value pairs must be separated by a comma. Feature names are case insensitive. */ - open(url: string, target?: "_self", options?: string): InAppBrowser; - /** - * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. - * @param url The URL to load. - * @param target The target in which to load the URL, an optional parameter that defaults to _self. - * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. - * The options string must not contain any blank space, and each feature's - * name/value pairs must be separated by a comma. Feature names are case insensitive. - */ - open(url: string, target?: "_blank", options?: string): InAppBrowser; - /** - * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. - * @param url The URL to load. - * @param target The target in which to load the URL, an optional parameter that defaults to _self. - * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. - * The options string must not contain any blank space, and each feature's - * name/value pairs must be separated by a comma. Feature names are case insensitive. - */ - open(url: string, target?: "_system", options?: string): InAppBrowser; - /** - * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. - * @param url The URL to load. - * @param target The target in which to load the URL, an optional parameter that defaults to _self. - * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. - * The options string must not contain any blank space, and each feature's - * name/value pairs must be separated by a comma. Feature names are case insensitive. - */ - open(url: string, target?: string, options?: string, replace?: boolean): InAppBrowser; + open(url: string, target?: target | string, options?: string, replace?: boolean): InAppBrowser; } /** @@ -51,10 +26,10 @@ interface Window { * NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs. */ interface InAppBrowser extends Window { - onloadstart: (type: InAppBrowserEvent) => void; - onloadstop: (type: InAppBrowserEvent) => void; - onloaderror: (type: InAppBrowserEvent) => void; - onexit: (type: InAppBrowserEvent) => void; + onloadstart(type: InAppBrowserEvent): void; + onloadstop(type: InAppBrowserEvent): void; + onloaderror(type: InAppBrowserEvent): void; + onexit(type: InAppBrowserEvent): void; // addEventListener overloads /** * Adds a listener for an event from the InAppBrowser. @@ -65,7 +40,7 @@ interface InAppBrowser extends Window { * @param callback the function that executes when the event fires. The function is * passed an InAppBrowserEvent object as a parameter. */ - addEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void; + addEventListener(type: channel, callback: (event: InAppBrowserEvent) => void): void; // removeEventListener overloads /** * Removes a listener for an event from the InAppBrowser. @@ -77,7 +52,7 @@ interface InAppBrowser extends Window { * @param callback the function that executes when the event fires. The function is * passed an InAppBrowserEvent object as a parameter. */ - removeEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void; + removeEventListener(type: channel, callback: (event: InAppBrowserEvent) => void): void; /** Closes the InAppBrowser window. */ close(): void; /** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */ @@ -96,29 +71,13 @@ interface InAppBrowser extends Window { * For multi-line scripts, this is the return value of the last statement, * or the last expression evaluated. */ - executeScript(script: { code: string }, callback: (result: any) => void): void; - /** - * Injects JavaScript code into the InAppBrowser window. - * @param script Details of the script to run, specifying either a file or code key. - * @param callback The function that executes after the JavaScript code is injected. - * If the injected script is of type code, the callback executes with - * a single parameter, which is the return value of the script, wrapped in an Array. - * For multi-line scripts, this is the return value of the last statement, - * or the last expression evaluated. - */ - executeScript(script: { file: string }, callback: (result: any) => void): void; + executeScript(script: { code: string } | { file: string }, callback: (result: any) => void): void; /** * Injects CSS into the InAppBrowser window. * @param css Details of the script to run, specifying either a file or code key. * @param callback The function that executes after the CSS is injected. */ - insertCSS(css: { code: string }, callback: () => void): void; - /** - * Injects CSS into the InAppBrowser window. - * @param css Details of the script to run, specifying either a file or code key. - * @param callback The function that executes after the CSS is injected. - */ - insertCSS(css: { file: string }, callback: () => void): void; + insertCSS(css: { code: string } | { file: string }, callback: () => void): void; } interface InAppBrowserEvent extends Event { @@ -130,4 +89,8 @@ interface InAppBrowserEvent extends Event { code: number; /** the error message, only in the case of loaderror. */ message: string; -} \ No newline at end of file +} + +interface Cordova { + InAppBrowser: InAppBrowser; +} diff --git a/types/cordova-plugin-inappbrowser/tslint.json b/types/cordova-plugin-inappbrowser/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cordova-plugin-inappbrowser/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 7b1d4d2dd3ddea157d071e0614874f5fca6d0878 Mon Sep 17 00:00:00 2001 From: Tim Brust Date: Mon, 19 Jun 2017 09:53:27 +0200 Subject: [PATCH 60/90] fix(cordova-plugin-inappbrowser): remove not needed type --- types/cordova-plugin-inappbrowser/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/cordova-plugin-inappbrowser/index.d.ts b/types/cordova-plugin-inappbrowser/index.d.ts index cd1af63c79..b266fbab44 100644 --- a/types/cordova-plugin-inappbrowser/index.d.ts +++ b/types/cordova-plugin-inappbrowser/index.d.ts @@ -6,7 +6,6 @@ // Copyright (c) Microsoft Open Technologies Inc // Licensed under the MIT license. // TypeScript Version: 2.3 -type target = "_self" | "_blank" | "_system"; type channel = "loadstart" | "loadstop" | "loaderror" | "exit"; interface Window { @@ -18,7 +17,7 @@ interface Window { * The options string must not contain any blank space, and each feature's * name/value pairs must be separated by a comma. Feature names are case insensitive. */ - open(url: string, target?: target | string, options?: string, replace?: boolean): InAppBrowser; + open(url: string, target?: string, options?: string, replace?: boolean): InAppBrowser; } /** From 0554c5aa259e508a6c02a4fb5ff9f95b0245a459 Mon Sep 17 00:00:00 2001 From: Oden Date: Mon, 19 Jun 2017 01:11:35 -0700 Subject: [PATCH 61/90] Fix missed replacement. --- types/react-loadable/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-loadable/index.d.ts b/types/react-loadable/index.d.ts index d456f4e085..cd10924682 100644 --- a/types/react-loadable/index.d.ts +++ b/types/react-loadable/index.d.ts @@ -23,7 +23,7 @@ export interface CommonOptions { * (this is considered a valid React component). */ // NOTE: () => null is only needed until React.SFC supports components returning null - loading: React.ComponentClass | React.SFC | (() => null); + loading: React.ComponentType | (() => null); /** * Defaults to 200, in milliseconds. * From 84d9be6f91f89f9bf5206b7ec5a3eaa368f09596 Mon Sep 17 00:00:00 2001 From: HiromiShikata Date: Mon, 19 Jun 2017 17:34:04 +0900 Subject: [PATCH 62/90] Fix lint warnings --- .../fs-extra-promise-es6-tests.ts | 100 ++--- types/fs-extra-promise-es6/index.d.ts | 413 ++++++++++-------- types/fs-extra-promise-es6/tslint.json | 3 + .../fs-extra-promise-tests.ts | 102 ++--- types/fs-extra-promise/index.d.ts | 145 +++--- types/fs-extra-promise/tslint.json | 3 + 6 files changed, 400 insertions(+), 366 deletions(-) create mode 100644 types/fs-extra-promise-es6/tslint.json create mode 100644 types/fs-extra-promise/tslint.json diff --git a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts index e789c5627f..b17cb07e32 100644 --- a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts +++ b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts @@ -1,48 +1,48 @@ import fs = require('fs-extra-promise-es6'); import stream = require('stream'); -var stats: fs.Stats; -var str: string; -var strArr: string[]; -var bool: boolean; -var num: number; -var src: string; -var dest: string; -var file: string; -var filename: string; -var dir: string; -var path: string; -var data: any; -var object: Object; -var buffer: NodeBuffer; -var modeNum: number; -var modeStr: string; -var encoding: string; -var type: string; -var flags: string; -var srcpath: string; -var dstpath: string; -var oldPath: string; -var newPath: string; -var cache: string; -var offset: number; -var length: number; -var position: number; -var cacheBool: boolean; -var cacheStr: string; -var fd: number; -var len: number; -var uid: number; -var gid: number; -var atime: number; -var mtime: number; -var statsCallback: (err: Error, stats: fs.Stats) => void; -var errorCallback: (err: Error) => void; -var openOpts: fs.OpenOptions; -var watcher: fs.FSWatcher; -var readStreeam: stream.Readable; -var writeStream: stream.Writable; -var isDirectory: boolean; +let stats: fs.Stats; +let str: string; +let strArr: string[]; +let bool: boolean; +let num: number; +let src: string; +let dest: string; +let file: string; +let filename: string; +let dir: string; +let path: string; +let data: any; +let object: any; +let buffer: NodeBuffer; +let modeNum: number; +let modeStr: string; +let encoding: string; +let type: string; +let flags: string; +let srcpath: string; +let dstpath: string; +let oldPath: string; +let newPath: string; +let cache: string; +let offset: number; +let length: number; +let position: number; +let cacheBool: boolean; +let cacheStr: string; +let fd: number; +let len: number; +let uid: number; +let gid: number; +let atime: number; +let mtime: number; +let statsCallback: (err: Error, stats: fs.Stats) => void; +let errorCallback: (err: Error) => void; +let openOpts: fs.OpenOptions; +let watcher: fs.FSWatcher; +let readStreeam: stream.Readable; +let writeStream: stream.Writable; +let isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -120,13 +120,10 @@ fs.linkSync(srcpath, dstpath); fs.symlink(srcpath, dstpath, type, errorCallback); fs.symlinkSync(srcpath, dstpath, type); fs.readlink(path, (err: Error, linkString: string) => { - }); fs.realpath(path, (err: Error, resolvedPath: string) => { - }); fs.realpath(path, cache, (err: Error, resolvedPath: string) => { - }); str = fs.realpathSync(path, cacheBool); fs.unlink(path, errorCallback); @@ -138,13 +135,11 @@ fs.mkdir(path, modeStr, errorCallback); fs.mkdirSync(path, modeNum); fs.mkdirSync(path, modeStr); fs.readdir(path, (err: Error, files: string[]) => { - }); strArr = fs.readdirSync(path); fs.close(fd, errorCallback); fs.closeSync(fd); fs.open(path, flags, modeStr, (err: Error, fd: number) => { - }); num = fs.openSync(path, flags, modeStr); fs.utimes(path, atime, mtime, errorCallback); @@ -154,24 +149,18 @@ fs.futimesSync(fd, atime, mtime); fs.fsync(fd, errorCallback); fs.fsyncSync(fd); fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { - }); num = fs.writeSync(fd, buffer, offset, length, position); fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { - }); num = fs.readSync(fd, buffer, offset, length, position); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); fs.readFile(filename, encoding, (err: Error, data: string) => { - }); fs.readFile(filename, openOpts, (err: Error, data: string) => { - }); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); buffer = fs.readFileSync(filename); str = fs.readFileSync(filename, encoding); @@ -204,10 +193,8 @@ fs.watchFile(filename, { }); fs.unwatchFile(filename); watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { - }); fs.exists(path, (exists: boolean) => { - }); bool = fs.existsSync(path); @@ -224,10 +211,9 @@ writeStream = fs.createWriteStream(path, { encoding: str }); -var isDirectoryCallback = (err: Error, isDirectory: boolean) => { +let isDirectoryCallback = (err: Error, isDirectory: boolean) => { }; fs.isDirectory(path, isDirectoryCallback); fs.isDirectory(path); isDirectory = fs.isDirectorySync(path); fs.isDirectoryAsync(path); - diff --git a/types/fs-extra-promise-es6/index.d.ts b/types/fs-extra-promise-es6/index.d.ts index 82ab2da35b..db262c1460 100644 --- a/types/fs-extra-promise-es6/index.d.ts +++ b/types/fs-extra-promise-es6/index.d.ts @@ -1,158 +1,194 @@ -// Type definitions for fs-extra-promise-es6 +// Type definitions for fs-extra-promise-es6 0.1 // Project: https://github.com/vinsonchuong/fs-extra-promise-es6 -// Definitions by: midknight41 , Jason Swearingen , Joshua DeVinney , Hiromi Shikata +// Definitions by: midknight41 +// Jason Swearingen +// Joshua DeVinney +// Hiromi Shikata // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: fs-extra-promise typings (minus Bluebird) -/// - +/// import stream = require("stream"); import fs = require("fs"); -export type Stats = fs.Stats +export type Stats = fs.Stats; export interface FSWatcher { close(): void; } -export declare class ReadStream extends stream.Readable { } -export declare class WriteStream extends stream.Writable { } +export class ReadStream extends stream.Readable { } +export class WriteStream extends stream.Writable { } -//extended methods -export declare function copy(src: string, dest: string, callback?: (err: Error) => void): void; -export declare function copy(src: string, dest: string, filter: (src: string) => boolean, callback?: (err: Error) => void): void; +// extended methods +export function copy(src: string, dest: string, callback?: (err: Error) => void): void; +export function copy(src: string, dest: string, filter: (src: string) => boolean, callback?: (err: Error) => void): void; -export declare function copySync(src: string, dest: string): void; -export declare function copySync(src: string, dest: string, filter: (src: string) => boolean): void; +export function copySync(src: string, dest: string, filter?: (src: string) => boolean): void; -export declare function createFile(file: string, callback?: (err: Error) => void): void; -export declare function createFileSync(file: string): void; +export function createFile(file: string, callback?: (err: Error) => void): void; +export function createFileSync(file: string): void; -export declare function mkdirs(dir: string, callback?: (err: Error) => void): void; -export declare function mkdirp(dir: string, callback?: (err: Error) => void): void; -export declare function mkdirsSync(dir: string): void; -export declare function mkdirpSync(dir: string): void; +export function mkdirs(dir: string, callback?: (err: Error) => void): void; +export function mkdirp(dir: string, callback?: (err: Error) => void): void; +export function mkdirsSync(dir: string): void; +export function mkdirpSync(dir: string): void; -export declare function outputFile(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputFileSync(file: string, data: any): void; +export function outputFile(file: string, data: any, callback?: (err: Error) => void): void; +export function outputFileSync(file: string, data: any): void; -export declare function outputJson(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputJSON(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputJsonSync(file: string, data: any): void; -export declare function outputJSONSync(file: string, data: any): void; +export function outputJson(file: string, data: any, callback?: (err: Error) => void): void; +export function outputJSON(file: string, data: any, callback?: (err: Error) => void): void; +export function outputJsonSync(file: string, data: any): void; +export function outputJSONSync(file: string, data: any): void; -export declare function readJson(file: string, callback?: (err: Error) => void): void; -export declare function readJson(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function readJSON(file: string, callback?: (err: Error) => void): void; -export declare function readJSON(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; +export function readJson(file: string, callback?: (err: Error) => void): void; +export function readJson(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; +export function readJSON(file: string, callback?: (err: Error) => void): void; +export function readJSON(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function readJsonSync(file: string, options?: OpenOptions): void; -export declare function readJSONSync(file: string, options?: OpenOptions): void; +export function readJsonSync(file: string, options?: OpenOptions): void; +export function readJSONSync(file: string, options?: OpenOptions): void; -export declare function remove(dir: string, callback?: (err: Error) => void): void; -export declare function removeSync(dir: string): void; +export function remove(dir: string, callback?: (err: Error) => void): void; +export function removeSync(dir: string): void; // export function delete(dir: string, callback?: (err: Error) => void): void; // export function deleteSync(dir: string): void; -export declare function writeJson(file: string, object: any, callback?: (err: Error) => void): void; -export declare function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeJSON(file: string, object: any, callback?: (err: Error) => void): void; -export declare function writeJSON(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; +export function writeJson(file: string, object: any, callback?: (err: Error) => void): void; +export function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; +export function writeJSON(file: string, object: any, callback?: (err: Error) => void): void; +export function writeJSON(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeJsonSync(file: string, object: any, options?: OpenOptions): void; -export declare function writeJSONSync(file: string, object: any, options?: OpenOptions): void; +export function writeJsonSync(file: string, object: any, options?: OpenOptions): void; +export function writeJSONSync(file: string, object: any, options?: OpenOptions): void; -export declare function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; -export declare function renameSync(oldPath: string, newPath: string): void; -export declare function truncate(fd: number, len: number, callback?: (err: Error) => void): void; -export declare function truncateSync(fd: number, len: number): void; -export declare function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function chownSync(path: string, uid: number, gid: number): void; -export declare function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function fchownSync(fd: number, uid: number, gid: number): void; -export declare function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function lchownSync(path: string, uid: number, gid: number): void; -export declare function chmod(path: string, mode: number, callback?: (err: Error) => void): void; -export declare function chmod(path: string, mode: string, callback?: (err: Error) => void): void; -export declare function chmodSync(path: string, mode: number): void; -export declare function chmodSync(path: string, mode: string): void; -export declare function fchmod(fd: number, mode: number, callback?: (err: Error) => void): void; -export declare function fchmod(fd: number, mode: string, callback?: (err: Error) => void): void; -export declare function fchmodSync(fd: number, mode: number): void; -export declare function fchmodSync(fd: number, mode: string): void; -export declare function lchmod(path: string, mode: string, callback?: (err: Error) => void): void; -export declare function lchmod(path: string, mode: number, callback?: (err: Error) => void): void; -export declare function lchmodSync(path: string, mode: number): void; -export declare function lchmodSync(path: string, mode: string): void; -export declare function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; -export declare function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; -export declare function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): void; -export declare function statSync(path: string): Stats; -export declare function lstatSync(path: string): Stats; -export declare function fstatSync(fd: number): Stats; -export declare function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; -export declare function linkSync(srcpath: string, dstpath: string): void; -export declare function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; -export declare function symlinkSync(srcpath: string, dstpath: string, type?: string): void; -export declare function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; -export declare function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; -export declare function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; -export declare function realpathSync(path: string, cache?: boolean): string; -export declare function unlink(path: string, callback?: (err: Error) => void): void; -export declare function unlinkSync(path: string): void; -export declare function rmdir(path: string, callback?: (err: Error) => void): void; -export declare function rmdirSync(path: string): void; -export declare function mkdir(path: string, mode?: number, callback?: (err: Error) => void): void; -export declare function mkdir(path: string, mode?: string, callback?: (err: Error) => void): void; -export declare function mkdirSync(path: string, mode?: number): void; -export declare function mkdirSync(path: string, mode?: string): void; -export declare function readdir(path: string, callback?: (err: Error, files: string[]) => void): void; -export declare function readdirSync(path: string): string[]; -export declare function close(fd: number, callback?: (err: Error) => void): void; -export declare function closeSync(fd: number): void; -export declare function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; -export declare function openSync(path: string, flags: string, mode?: string): number; -export declare function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; -export declare function utimesSync(path: string, atime: number, mtime: number): void; -export declare function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; -export declare function futimesSync(fd: number, atime: number, mtime: number): void; -export declare function fsync(fd: number, callback?: (err: Error) => void): void; -export declare function fsyncSync(fd: number): void; -export declare function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; -export declare function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; -export declare function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; -export declare function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; -export declare function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void): void; -export declare function readFile(filename: string, options: OpenOptions, callback: (err: Error, data: string) => void): void; -export declare function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void): void; -export declare function readFileSync(filename: string): NodeBuffer; -export declare function readFileSync(filename: string, encoding: string): string; -export declare function readFileSync(filename: string, options: OpenOptions): string; -export declare function writeFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; -export declare function writeFile(filename: string, data: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeFileSync(filename: string, data: any, encoding?: string): void; -export declare function writeFileSync(filename: string, data: any, option?: OpenOptions): void; -export declare function appendFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; -export declare function appendFile(filename: string, data: any, option?: OpenOptions, callback?: (err: Error) => void): void; -export declare function appendFileSync(filename: string, data: any, encoding?: string): void; -export declare function appendFileSync(filename: string, data: any, option?: OpenOptions): void; -export declare function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; -export declare function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; -export declare function unwatchFile(filename: string, listener?: Stats): void; -export declare function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; -export declare function exists(path: string, callback?: (exists: boolean) => void): void; -export declare function existsSync(path: string): boolean; -export declare function ensureDir(path: string, cb: (err: Error) => void): void; -export declare function ensureDirSync(path: string): void; +export function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; +export function renameSync(oldPath: string, newPath: string): void; +export function truncate(fd: number, len: number, callback?: (err: Error) => void): void; +export function truncateSync(fd: number, len: number): void; +export function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; +export function chownSync(path: string, uid: number, gid: number): void; +export function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; +export function fchownSync(fd: number, uid: number, gid: number): void; +export function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; +export function lchownSync(path: string, uid: number, gid: number): void; +export function chmod(path: string, mode: number | string, callback?: (err: Error) => void): void; +export function chmodSync(path: string, mode: number | string): void; +export function fchmod(fd: number, mode: number | string, callback?: (err: Error) => void): void; +export function fchmodSync(fd: number, mode: number | string): void; +export function lchmod(path: string, mode: number | string, callback?: (err: Error) => void): void; +export function lchmodSync(path: string, mode: number | string): void; +export function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; +export function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; +export function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): void; +export function statSync(path: string): Stats; +export function lstatSync(path: string): Stats; +export function fstatSync(fd: number): Stats; +export function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; +export function linkSync(srcpath: string, dstpath: string): void; +export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; +export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; +export function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; +export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; +export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; +export function realpathSync(path: string, cache?: boolean): string; +export function unlink(path: string, callback?: (err: Error) => void): void; +export function unlinkSync(path: string): void; +export function rmdir(path: string, callback?: (err: Error) => void): void; +export function rmdirSync(path: string): void; +export function mkdir(path: string, mode?: number | string, callback?: (err: Error) => void): void; +export function mkdirSync(path: string, mode?: number | string): void; +export function readdir(path: string, callback?: (err: Error, files: string[]) => void): void; +export function readdirSync(path: string): string[]; +export function close(fd: number, callback?: (err: Error) => void): void; +export function closeSync(fd: number): void; +export function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; +export function openSync(path: string, flags: string, mode?: string): number; +export function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; +export function utimesSync(path: string, atime: number, mtime: number): void; +export function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; +export function futimesSync(fd: number, atime: number, mtime: number): void; +export function fsync(fd: number, callback?: (err: Error) => void): void; +export function fsyncSync(fd: number): void; +export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; +export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; +export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; +export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; +/** + * readFile + * @param filename + * @param options + * string: encoding + * OpenOptions: options + * @param callback + */ +export function readFile(filename: string, options: OpenOptions | string, callback: (err: Error, data: string) => void): void; +export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void): void; +export function readFileSync(filename: string): NodeBuffer; +/** + * readFileSync + * @param filename + * @param options + * string: encoding + * OpenOptions: options + */ +export function readFileSync(filename: string, options: OpenOptions | string): string; +/** + * writeFile + * @param filename + * @param data + * @param options + * string: encoding + * OpenOptions: options + * @param callback + */ +export function writeFile(filename: string, data: any, options?: OpenOptions | string, callback?: (err: Error) => void): void; +/** + * writeFileSync + * @param filename + * @param data + * @param option + * string: encoding + * OpenOptions: options + */ +export function writeFileSync(filename: string, data: any, option?: OpenOptions | string): void; +/** + * appendFile + * @param filename + * @param data + * @param option: + * string: encoding + * OpenOptions: options + * @param callback + */ +export function appendFile(filename: string, data: any, option?: OpenOptions | string, callback?: (err: Error) => void): void; +/** + * appendFileSync + * @param filename + * @param data + * @param option + * string: encoding + * OpenOptions: options + */ +export function appendFileSync(filename: string, data: any, option?: OpenOptions | string): void; +export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; +export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; +export function unwatchFile(filename: string, listener?: Stats): void; +export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; +export function exists(path: string, callback?: (exists: boolean) => void): void; +export function existsSync(path: string): boolean; +export function ensureDir(path: string, cb: (err: Error) => void): void; +export function ensureDirSync(path: string): void; export interface OpenOptions { encoding?: string; flag?: string; } -export declare function createReadStream(path: string | Buffer, options?: { +export function createReadStream(path: string | Buffer, options?: { flags?: string; encoding?: string; fd?: number; @@ -161,85 +197,90 @@ export declare function createReadStream(path: string | Buffer, options?: { start?: number; end?: number; }): ReadStream; -export declare function createWriteStream(path: string | Buffer, options?: { +export function createWriteStream(path: string | Buffer, options?: { flags?: string; encoding?: string; fd?: number; mode?: number; }): WriteStream; +// promisified versions +export function copyAsync(src: string, dest: string, filter?: (src: string) => boolean): Promise; +export function createFileAsync(file: string): Promise; -//promisified versions -export declare function copyAsync(src: string, dest: string): Promise; -export declare function copyAsync(src: string, dest: string, filter: (src: string) => boolean): Promise; +export function mkdirsAsync(dir: string): Promise; +export function mkdirpAsync(dir: string): Promise; -export declare function createFileAsync(file: string): Promise; +export function outputFileAsync(file: string, data: any): Promise; -export declare function mkdirsAsync(dir: string): Promise; -export declare function mkdirpAsync(dir: string): Promise; +export function outputJSONAsync(file: string, data: any): Promise; -export declare function outputFileAsync(file: string, data: any): Promise; +export function readJSONAsync(file: string, options?: OpenOptions): Promise; -export declare function outputJsonAsync(file: string, data: any): Promise; -export declare function outputJSONAsync(file: string, data: any): Promise; - -export declare function readJsonAsync(file: string): Promise; -export declare function readJsonAsync(file: string, options?: OpenOptions): Promise; -export declare function readJSONAsync(file: string): Promise; -export declare function readJSONAsync(file: string, options?: OpenOptions): Promise; - - -export declare function removeAsync(dir: string): Promise; +export function removeAsync(dir: string): Promise; // export function deleteAsync(dir: string):Promise; -export declare function writeJsonAsync(file: string, object: any): Promise; -export declare function writeJsonAsync(file: string, object: any, options?: OpenOptions): Promise; -export declare function writeJSONAsync(file: string, object: any): Promise; -export declare function writeJSONAsync(file: string, object: any, options?: OpenOptions): Promise; +export function writeJsonAsync(file: string, object: any, options?: OpenOptions): Promise; +export function writeJSONAsync(file: string, object: any, options?: OpenOptions): Promise; -export declare function renameAsync(oldPath: string, newPath: string): Promise; -export declare function truncateAsync(fd: number, len: number): Promise; -export declare function chownAsync(path: string, uid: number, gid: number): Promise; -export declare function fchownAsync(fd: number, uid: number, gid: number): Promise; -export declare function lchownAsync(path: string, uid: number, gid: number): Promise; -export declare function chmodAsync(path: string, mode: number): Promise; -export declare function chmodAsync(path: string, mode: string): Promise; -export declare function fchmodAsync(fd: number, mode: number): Promise; -export declare function fchmodAsync(fd: number, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: number): Promise; -export declare function statAsync(path: string): Promise; -export declare function lstatAsync(path: string): Promise; -export declare function fstatAsync(fd: number): Promise; -export declare function linkAsync(srcpath: string, dstpath: string): Promise; -export declare function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; -export declare function readlinkAsync(path: string): Promise; -export declare function realpathAsync(path: string): Promise; -export declare function realpathAsync(path: string, cache: string): Promise; -export declare function unlinkAsync(path: string): Promise; -export declare function rmdirAsync(path: string): Promise; -export declare function mkdirAsync(path: string, mode?: number): Promise; -export declare function mkdirAsync(path: string, mode?: string): Promise; -export declare function readdirAsync(path: string): Promise; -export declare function closeAsync(fd: number): Promise; -export declare function openAsync(path: string, flags: string, mode?: string): Promise; -export declare function utimesAsync(path: string, atime: number, mtime: number): Promise; -export declare function futimesAsync(fd: number, atime: number, mtime: number): Promise; -export declare function fsyncAsync(fd: number): Promise; -export declare function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readFileAsync(filename: string, encoding: string): Promise; -export declare function readFileAsync(filename: string, options: OpenOptions): Promise; -export declare function readFileAsync(filename: string): Promise; -export declare function writeFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function writeFileAsync(filename: string, data: any, options?: OpenOptions): Promise; -export declare function appendFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function appendFileAsync(filename: string, data: any, option?: OpenOptions): Promise; +export function renameAsync(oldPath: string, newPath: string): Promise; +export function truncateAsync(fd: number, len: number): Promise; +export function chownAsync(path: string, uid: number, gid: number): Promise; +export function fchownAsync(fd: number, uid: number, gid: number): Promise; +export function lchownAsync(path: string, uid: number, gid: number): Promise; +export function chmodAsync(path: string, mode: number | string): Promise; +export function fchmodAsync(fd: number, mode: number | string): Promise; +export function lchmodAsync(path: string, mode: number | string): Promise; +export function statAsync(path: string): Promise; +export function lstatAsync(path: string): Promise; +export function fstatAsync(fd: number): Promise; +export function linkAsync(srcpath: string, dstpath: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function readlinkAsync(path: string): Promise; +export function realpathAsync(path: string, cache?: string): Promise; +export function unlinkAsync(path: string): Promise; +export function rmdirAsync(path: string): Promise; +export function mkdirAsync(path: string, mode?: number | string): Promise; +export function readdirAsync(path: string): Promise; +export function closeAsync(fd: number): Promise; +export function openAsync(path: string, flags: string, mode?: string): Promise; +export function utimesAsync(path: string, atime: number, mtime: number): Promise; +export function futimesAsync(fd: number, atime: number, mtime: number): Promise; +export function fsyncAsync(fd: number): Promise; +export function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +export function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +/** + * readFileAsync + * @param filename + * @param options: + * string: encoding + * OpenOptions: options + */ +export function readFileAsync(filename: string, options: OpenOptions | string): Promise; +export function readFileAsync(filename: string): Promise; +/** + * writeFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * OpenOptions: options + */ +export function writeFileAsync(filename: string, data: any, options?: OpenOptions | string): Promise; +/** + * appendFileAsync + * @param filename + * @param data + * @param option: + * string: encoding + * OpenOptions: option + */ +export function appendFileAsync(filename: string, data: any, option?: OpenOptions | string): Promise; -export declare function existsAsync(path: string): Promise; -export declare function ensureDirAsync(path: string): Promise; +export function existsAsync(path: string): Promise; +export function ensureDirAsync(path: string): Promise; -export declare function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; -export declare function isDirectorySync(path: string): boolean; -export declare function isDirectoryAsync(path: string): Promise; +export function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export function isDirectorySync(path: string): boolean; +export function isDirectoryAsync(path: string): Promise; diff --git a/types/fs-extra-promise-es6/tslint.json b/types/fs-extra-promise-es6/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fs-extra-promise-es6/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index 592f61ca87..9f5a8b32bf 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -1,49 +1,49 @@ import fs = require('fs-extra-promise'); import stream = require('stream'); -var stats: fs.Stats; -var str: string; -var strArr: string[]; -var bool: boolean; -var num: number; -var src: string; -var dest: string; -var file: string; -var filename: string; -var dir: string; -var path: string; -var data: any; -var object: Object; -var buf: Buffer; -var buffer: NodeBuffer; -var modeNum: number; -var modeStr: string; -var encoding: string; -var type: string; -var flags: string; -var srcpath: string; -var dstpath: string; -var oldPath: string; -var newPath: string; -var cache: { [path: string]: string; }; -var offset: number; -var length: number; -var position: number; -var fd: number; -var len: number; -var uid: number; -var gid: number; -var atime: number; -var mtime: number; -var watchListener: (curr: fs.Stats, prev: fs.Stats) => void; -var statsCallback: (err: Error, stats: fs.Stats) => void; -var errorCallback: (err: Error) => void; -var openOpts: fs.ReadOptions; -var writeOpts: fs.WriteOptions; -var watcher: fs.FSWatcher; -var readStream: stream.Readable; -var writeStream: stream.Writable; -var isDirectory: boolean; +let stats: fs.Stats; +let str: string; +let strArr: string[]; +let bool: boolean; +let num: number; +let src: string; +let dest: string; +let file: string; +let filename: string; +let dir: string; +let path: string; +let data: any; +let object: object; +let buf: Buffer; +let buffer: NodeBuffer; +let modeNum: number; +let modeStr: string; +let encoding: string; +let type: string; +let flags: string; +let srcpath: string; +let dstpath: string; +let oldPath: string; +let newPath: string; +let cache: { [path: string]: string; }; +let offset: number; +let length: number; +let position: number; +let fd: number; +let len: number; +let uid: number; +let gid: number; +let atime: number; +let mtime: number; +let watchListener: (curr: fs.Stats, prev: fs.Stats) => void; +let statsCallback: (err: Error, stats: fs.Stats) => void; +let errorCallback: (err: Error) => void; +let openOpts: fs.ReadOptions; +let writeOpts: fs.WriteOptions; +let watcher: fs.FSWatcher; +let readStream: stream.Readable; +let writeStream: stream.Writable; +let isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -123,13 +123,10 @@ fs.linkSync(srcpath, dstpath); fs.symlink(srcpath, dstpath, type, errorCallback); fs.symlinkSync(srcpath, dstpath, type); fs.readlink(path, (err: Error, linkString: string) => { - }); fs.realpath(path, (err: Error, resolvedPath: string) => { - }); fs.realpath(path, cache, (err: Error, resolvedPath: string) => { - }); str = fs.realpathSync(path, cache); fs.unlink(path, errorCallback); @@ -141,13 +138,11 @@ fs.mkdir(path, modeStr, errorCallback); fs.mkdirSync(path, modeNum); fs.mkdirSync(path, modeStr); fs.readdir(path, (err: Error, files: string[]) => { - }); strArr = fs.readdirSync(path); fs.close(fd, errorCallback); fs.closeSync(fd); fs.open(path, flags, modeNum, (err: Error, fd: number) => { - }); num = fs.openSync(path, flags, modeNum); fs.utimes(path, atime, mtime, errorCallback); @@ -157,24 +152,18 @@ fs.futimesSync(fd, atime, mtime); fs.fsync(fd, errorCallback); fs.fsyncSync(fd); fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { - }); num = fs.writeSync(fd, buffer, offset, length, position); fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { - }); num = fs.readSync(fd, buffer, offset, length, position); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); fs.readFile(filename, encoding, (err: Error, data: string) => { - }); fs.readFile(filename, openOpts, (err: NodeJS.ErrnoException, data: Buffer) => { - }); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); buffer = fs.readFileSync(filename); str = fs.readFileSync(filename, encoding); @@ -201,10 +190,8 @@ fs.watchFile(filename, { }, watchListener); fs.unwatchFile(filename); watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { - }); fs.exists(path, (exists: boolean) => { - }); bool = fs.existsSync(path); @@ -221,10 +208,9 @@ writeStream = fs.createWriteStream(path, { encoding: str }); -var isDirectoryCallback = (err: Error, isDirectory: boolean) => { +let isDirectoryCallback = (err: Error, isDirectory: boolean) => { }; fs.isDirectory(path, isDirectoryCallback); fs.isDirectory(path); isDirectory = fs.isDirectorySync(path); fs.isDirectoryAsync(path); - diff --git a/types/fs-extra-promise/index.d.ts b/types/fs-extra-promise/index.d.ts index 36de7fdf19..d57fd93ed6 100644 --- a/types/fs-extra-promise/index.d.ts +++ b/types/fs-extra-promise/index.d.ts @@ -5,8 +5,6 @@ // TypeScript Version: 2.2 /// -/// -/// import * as stream from 'stream'; import { Stats } from 'fs'; @@ -20,77 +18,94 @@ export interface MkdirOptions { mode?: number; } -//promisified versions -export declare function copyAsync(src: string, dest: string): Promise; -export declare function copyAsync(src: string, dest: string, filter: CopyFilter): Promise; -export declare function copyAsync(src: string, dest: string, options: CopyOptions): Promise; +// promisified versions +/** + * copyAsync + * @param src + * @param dest + * @param options + * CopyFilter: filter + * CopyOptions: options + */ +export function copyAsync(src: string, dest: string, options?: CopyFilter | CopyOptions): Promise; -export declare function createFileAsync(file: string): Promise; +export function createFileAsync(file: string): Promise; -export declare function mkdirsAsync(dir: string, options?: MkdirOptions): Promise; -export declare function mkdirpAsync(dir: string, options?: MkdirOptions): Promise; +export function mkdirsAsync(dir: string, options?: MkdirOptions): Promise; +export function mkdirpAsync(dir: string, options?: MkdirOptions): Promise; -export declare function moveAsync(src: string, dest: string, options?: MoveOptions): Promise; +export function moveAsync(src: string, dest: string, options?: MoveOptions): Promise; -export declare function outputFileAsync(file: string, data: any): Promise; +export function outputFileAsync(file: string, data: any): Promise; -export declare function outputJsonAsync(file: string, data: any): Promise; -export declare function outputJSONAsync(file: string, data: any): Promise; +export function outputJsonAsync(file: string, data: any): Promise; +export function outputJSONAsync(file: string, data: any): Promise; -export declare function readJsonAsync(file: string): Promise; -export declare function readJsonAsync(file: string, options?: ReadOptions): Promise; -export declare function readJSONAsync(file: string): Promise; -export declare function readJSONAsync(file: string, options?: ReadOptions): Promise; +export function readJsonAsync(file: string, options?: ReadOptions): Promise; +export function readJSONAsync(file: string, options?: ReadOptions): Promise; -export declare function removeAsync(dir: string): Promise; +export function removeAsync(dir: string): Promise; -export declare function writeJsonAsync(file: string, object: any): Promise; -export declare function writeJsonAsync(file: string, object: any, options?: WriteOptions): Promise; -export declare function writeJSONAsync(file: string, object: any): Promise; -export declare function writeJSONAsync(file: string, object: any, options?: WriteOptions): Promise; +export function writeJsonAsync(file: string, object: any, options?: WriteOptions): Promise; +export function writeJSONAsync(file: string, object: any, options?: WriteOptions): Promise; -export declare function renameAsync(oldPath: string, newPath: string): Promise; -export declare function truncateAsync(fd: number, len: number): Promise; -export declare function chownAsync(path: string, uid: number, gid: number): Promise; -export declare function fchownAsync(fd: number, uid: number, gid: number): Promise; -export declare function lchownAsync(path: string, uid: number, gid: number): Promise; -export declare function chmodAsync(path: string, mode: number): Promise; -export declare function chmodAsync(path: string, mode: string): Promise; -export declare function fchmodAsync(fd: number, mode: number): Promise; -export declare function fchmodAsync(fd: number, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: number): Promise; -export declare function statAsync(path: string): Promise; -export declare function lstatAsync(path: string): Promise; -export declare function fstatAsync(fd: number): Promise; -export declare function linkAsync(srcpath: string, dstpath: string): Promise; -export declare function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; -export declare function readlinkAsync(path: string): Promise; -export declare function realpathAsync(path: string): Promise; -export declare function realpathAsync(path: string, cache: { [path: string]: string }): Promise; -export declare function unlinkAsync(path: string): Promise; -export declare function rmdirAsync(path: string): Promise; -export declare function mkdirAsync(path: string, mode?: number): Promise; -export declare function mkdirAsync(path: string, mode?: string): Promise; -export declare function readdirAsync(path: string): Promise; -export declare function closeAsync(fd: number): Promise; -export declare function openAsync(path: string, flags: string, mode?: string): Promise; -export declare function utimesAsync(path: string, atime: number, mtime: number): Promise; -export declare function futimesAsync(fd: number, atime: number, mtime: number): Promise; -export declare function fsyncAsync(fd: number): Promise; -export declare function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readFileAsync(filename: string, encoding: string): Promise; -export declare function readFileAsync(filename: string, options: ReadOptions): Promise; -export declare function readFileAsync(filename: string): Promise; -export declare function writeFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function writeFileAsync(filename: string, data: any, options?: WriteOptions): Promise; -export declare function appendFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function appendFileAsync(filename: string, data: any, option?: WriteOptions): Promise; +export function renameAsync(oldPath: string, newPath: string): Promise; +export function truncateAsync(fd: number, len: number): Promise; +export function chownAsync(path: string, uid: number, gid: number): Promise; +export function fchownAsync(fd: number, uid: number, gid: number): Promise; +export function lchownAsync(path: string, uid: number, gid: number): Promise; +export function chmodAsync(path: string, mode: number | string): Promise; +export function fchmodAsync(fd: number, mode: number | string): Promise; +export function lchmodAsync(path: string, mode: number | string): Promise; +export function statAsync(path: string): Promise; +export function lstatAsync(path: string): Promise; +export function fstatAsync(fd: number): Promise; +export function linkAsync(srcpath: string, dstpath: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function readlinkAsync(path: string): Promise; +export function realpathAsync(path: string, cache?: { [path: string]: string }): Promise; +export function unlinkAsync(path: string): Promise; +export function rmdirAsync(path: string): Promise; +export function mkdirAsync(path: string, mode?: number | string): Promise; +export function readdirAsync(path: string): Promise; +export function closeAsync(fd: number): Promise; +export function openAsync(path: string, flags: string, mode?: string): Promise; +export function utimesAsync(path: string, atime: number, mtime: number): Promise; +export function futimesAsync(fd: number, atime: number, mtime: number): Promise; +export function fsyncAsync(fd: number): Promise; +export function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +export function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +/** + * readFileAsync + * @param filename + * @param options: + * string: encoding + * ReadOptions: options + */ +export function readFileAsync(filename: string, options: string | ReadOptions): Promise; +export function readFileAsync(filename: string): Promise; +/** + * writeFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * WriteOptions: options + */ +export function writeFileAsync(filename: string, data: any, options?: string | WriteOptions): Promise; +/** + * appendFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * WriteOptions: options + */ +export function appendFileAsync(filename: string, data: any, option?: string | WriteOptions): Promise; -export declare function existsAsync(path: string): Promise; -export declare function ensureDirAsync(path: string): Promise; +export function existsAsync(path: string): Promise; +export function ensureDirAsync(path: string): Promise; -export declare function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; -export declare function isDirectorySync(path: string): boolean; -export declare function isDirectoryAsync(path: string): Promise; +export function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export function isDirectorySync(path: string): boolean; +export function isDirectoryAsync(path: string): Promise; diff --git a/types/fs-extra-promise/tslint.json b/types/fs-extra-promise/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fs-extra-promise/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From ee9ce4dec185284fd6cf5d4e2615aeb6a9244792 Mon Sep 17 00:00:00 2001 From: Melvin Groenhoff Date: Mon, 19 Jun 2017 12:15:58 +0200 Subject: [PATCH 63/90] Add typings for natsort --- types/natsort/index.d.ts | 16 ++++ types/natsort/natsort-tests.ts | 155 +++++++++++++++++++++++++++++++++ types/natsort/tsconfig.json | 22 +++++ types/natsort/tslint.json | 1 + 4 files changed, 194 insertions(+) create mode 100644 types/natsort/index.d.ts create mode 100644 types/natsort/natsort-tests.ts create mode 100644 types/natsort/tsconfig.json create mode 100644 types/natsort/tslint.json diff --git a/types/natsort/index.d.ts b/types/natsort/index.d.ts new file mode 100644 index 0000000000..bf448f218d --- /dev/null +++ b/types/natsort/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for natsort 1.0 +// Project: https://github.com/bubkoo/natsort +// Definitions by: Melvin Groenhoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function natsort(options?: natsort.Options): (a: any, b: any) => number; + +declare namespace natsort { + interface Options { + desc?: boolean; + insensitive?: boolean; + } +} + +export = natsort; +export as namespace nasort; diff --git a/types/natsort/natsort-tests.ts b/types/natsort/natsort-tests.ts new file mode 100644 index 0000000000..4e9d0c0fcb --- /dev/null +++ b/types/natsort/natsort-tests.ts @@ -0,0 +1,155 @@ +import * as natsort from "natsort"; + +const someArr = [2, 5, 3, 4, 1, 'a', 'B']; + +someArr.sort(natsort()); +someArr.sort(natsort({ desc: true })); +someArr.sort(natsort({ insensitive: true })); + +// sort with object array +const objArr = [ + { val: 'B' }, + { val: 'a' }, + { val: 'D' }, + { val: 'c' } +]; + +const sorter = natsort(); + +objArr.sort((a, b) => { + return sorter(a.val, b.val); +}); + +// simple numerics +['10', 9, 2, '1', '4'].sort(natsort()); +// ['1',2,'4',9,'10'] + +// floats +[ + '10.0401', + 10.022, + 10.042, + '10.021999' +].sort(natsort()); +// [ +// '10.021999', +// 10.022, +// '10.0401', +// 10.042 +// ] + +// float & decimal notation +[ + '10.04f', + '10.039F', + '10.038d', + '10.037D' +].sort(natsort()); +// [ +// '10.037D', +// '10.038d', +// '10.039F', +// '10.04f' +// ] + +// scientific notation +[ + '1.528535047e5', + '1.528535047e7', + '1.528535047e3' +].sort(natsort()); +// [ +// '1.528535047e3', +// '1.528535047e5', +// '1.528535047e7' +// ] + +// ip addresses +[ + '192.168.0.100', + '192.168.0.1', + '192.168.1.1' +].sort(natsort()); +// [ +// '192.168.0.1', +// '192.168.0.100', +// '192.168.1.1' +// ] + +// Filenames +[ + 'car.mov', + '01alpha.sgi', + '001alpha.sgi', + 'my.string_41299.tif' +].sort(natsort()); +// [ +// '001alpha.sgi', +// '01alpha.sgi', +// 'car.mov', +// 'my.string_41299.tif' +// ] + +// dates +[ + '10/12/2008', + '10/11/2008', + '10/11/2007', + '10/12/2007' +].sort(natsort()); +// [ +// '10/11/2007', +// '10/12/2007', +// '10/11/2008', +// '10/12/2008' +// ] + +// money +[ + '$10002.00', + '$10001.02', + '$10001.01' +].sort(natsort()); +// [ +// '$10001.01', +// '$10001.02', +// '$10002.00' +// ] + +// versions +[ + '1.0.2', + '1.0.1', + '1.0.0', + '1.0.9' +].sort(natsort()); +// [ +// '1.0.0', +// '1.0.1', +// '1.0.2', +// '1.0.9' +// ] + +// movie titles +[ + '1 Title - The Big Lebowski', + '1 Title - Gattaca', + '1 Title - Last Picture Show' +].sort(natsort()); +// [ +// '1 Title - Gattaca', +// '1 Title - Last Picture Show', +// '1 Title - The Big Lebowski' +// ] + +// by default - case-sensitive sorting +['a', 'B'].sort(natsort()); +// ['B', 'a'] + +// enable case-insensitive sorting +['a', 'B'].sort(natsort({ insensitive: true })); +// ['a', 'B'] + +// desc +[4, 2, 3, 5, 1].sort(natsort({ desc: true })); +// [1, 2, 3, 4, 5] diff --git a/types/natsort/tsconfig.json b/types/natsort/tsconfig.json new file mode 100644 index 0000000000..8fd932f326 --- /dev/null +++ b/types/natsort/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "natsort-tests.ts" + ] +} diff --git a/types/natsort/tslint.json b/types/natsort/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/natsort/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 151354bf00f22347eea3144ce68e4daa45870b63 Mon Sep 17 00:00:00 2001 From: Alex Brick Date: Mon, 19 Jun 2017 12:24:10 +0200 Subject: [PATCH 64/90] Swagger UI 2.0 does not require options --- types/swagger-tools/index.d.ts | 2 +- types/swagger-tools/swagger-tools-tests.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/swagger-tools/index.d.ts b/types/swagger-tools/index.d.ts index 340d962ba0..09d42138b6 100644 --- a/types/swagger-tools/index.d.ts +++ b/types/swagger-tools/index.d.ts @@ -58,7 +58,7 @@ export interface Middleware12 extends Middleware { } export interface Middleware20 extends Middleware { - swaggerUi(options: SwaggerUiOptions): NextHandleFunction; + swaggerUi(options?: SwaggerUiOptions): NextHandleFunction; } export type InitializeMiddlewareCallback12 = (middleware: Middleware12) => void; diff --git a/types/swagger-tools/swagger-tools-tests.ts b/types/swagger-tools/swagger-tools-tests.ts index e39670be7c..d4c695c418 100644 --- a/types/swagger-tools/swagger-tools-tests.ts +++ b/types/swagger-tools/swagger-tools-tests.ts @@ -36,6 +36,7 @@ swaggerTools.initializeMiddleware(swaggerDoc20, middleware => { // Serve the Swagger documents and Swagger UI app.use(middleware.swaggerUi(swaggerUiOptions)); + app.use(middleware.swaggerUi()); // Start the server createServer(app).listen(serverPort, () => { From e2e2568f83594f101acdd86dee47ff13ba94a180 Mon Sep 17 00:00:00 2001 From: petrce Date: Mon, 19 Jun 2017 14:55:04 +0100 Subject: [PATCH 65/90] Update index.d.ts added missing DataGroup.nestedGroups according this example: http://visjs.org/examples/timeline/groups/nestedGroups.html --- types/vis/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/vis/index.d.ts b/types/vis/index.d.ts index 5b7cc718b2..8ae7de8263 100644 --- a/types/vis/index.d.ts +++ b/types/vis/index.d.ts @@ -79,6 +79,7 @@ export interface DataGroup { style?: string; subgroupOrder?: string | (() => void); title?: string; + nestedGroups?: number[]; } export interface DataGroupOptions { From 9fdf0187a9c37578205ed7128ad9831484febcaf Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 10:12:57 -0400 Subject: [PATCH 66/90] [jquery] Clean up pass on effects-related methods on JQuery. Add tests for effects-related methods on JQuery. --- types/jquery/index.d.ts | 50 ++- types/jquery/jquery-tests.ts | 698 +++++++++++++++++++++++++++++++++++ 2 files changed, 728 insertions(+), 20 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index d497b698ac..fa4fe2d00b 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -180,7 +180,7 @@ interface JQuery { * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ - animate(properties: JQuery.PlainObject, + animate(properties: JQuery.PlainObject, duration: JQuery.Duration, easing: string, complete?: (this: TElement) => void): this; @@ -194,22 +194,29 @@ interface JQuery { * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ - animate(properties: JQuery.PlainObject, + animate(properties: JQuery.PlainObject, duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; /** * Perform a custom animation of a set of CSS properties. * * @param properties An object of CSS properties and values that the animation will move toward. - * @param duration_easing_complete_options A string or number determining how long the animation will run. - * A string indicating which easing function to use for the transition. - * A function to call once the animation is complete, called once per matched element. - * A map of additional options to pass to the method. + * @param options A map of additional options to pass to the method. * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ - animate(properties: JQuery.PlainObject, - duration_easing_complete_options?: JQuery.Duration | string | ((this: TElement) => void) | JQuery.EffectsOptions): this; + animate(properties: JQuery.PlainObject, + options: JQuery.EffectsOptions): this; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param complete A function to call once the animation is complete, called once per matched element. + * @see {@link https://api.jquery.com/animate/} + * @since 1.0 + */ + animate(properties: JQuery.PlainObject, + complete?: (this: TElement) => void): this; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * @@ -692,7 +699,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - fadeIn(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + fadeIn(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display the matched elements by fading them to opaque. * @@ -725,7 +732,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - fadeOut(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + fadeOut(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Hide the matched elements by fading them to transparent. * @@ -779,7 +786,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - fadeToggle(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + fadeToggle(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display or hide the matched elements by animating their opacity. * @@ -1694,7 +1701,7 @@ interface JQuery { * @see {@link https://api.jquery.com/prop/} * @since 1.6 */ - prop(propertyName: string, value: any): this; // tslint:disable-line:unified-signatures + prop(propertyName: string, value: any): this; // tslint:disable-line:unified-signatures /** * Set one or more properties for the set of matched elements. * @@ -1994,7 +2001,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - slideDown(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + slideDown(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display the matched elements with a sliding motion. * @@ -2027,7 +2034,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - slideToggle(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + slideToggle(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Display or hide the matched elements with a sliding motion. * @@ -2060,7 +2067,7 @@ interface JQuery { * @since 1.0 * @since 1.4.3 */ - slideUp(duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; + slideUp(duration_easing: JQuery.Duration | string, complete: (this: TElement) => void): this; /** * Hide the matched elements with a sliding motion. * @@ -2153,17 +2160,19 @@ interface JQuery { * @see {@link https://api.jquery.com/toggle/} * @since 1.0 */ - toggle(duration: JQuery.Duration, complete?: (this: TElement) => void): this; + toggle(duration: JQuery.Duration, complete: (this: TElement) => void): this; /** * Display or hide the matched elements. * - * @param options A map of additional options to pass to the method. - * Use true to show the element or false to hide it. + * @param duration_complete_options_display A string or number determining how long the animation will run. + * A function to call once the animation is complete, called once per matched element. + * A map of additional options to pass to the method. + * Use true to show the element or false to hide it. * @see {@link https://api.jquery.com/toggle/} * @since 1.0 * @since 1.3 */ - toggle(options?: JQuery.EffectsOptions | boolean): this; + toggle(duration_complete_options_display?: JQuery.Duration | ((this: TElement) => void) | JQuery.EffectsOptions | boolean): this; /** * Add or remove one or more classes from each element in the set of matched elements, depending on * either the class's presence or the value of the state argument. @@ -4041,6 +4050,7 @@ declare namespace JQuery { // region Effects type Duration = number | 'fast' | 'slow'; + // TODO: Is the first element always a string or is that specific to the 'fx' queue? type Queue = { 0: string; } & Array>; interface QueueFunction { @@ -4092,7 +4102,7 @@ declare namespace JQuery { * An object containing one or more of the CSS properties defined by the properties argument and their * corresponding easing functions. */ - specialEasing?: PlainObject; + specialEasing?: PlainObject; /** * A function to call when the animation on an element begins. */ diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index f55232e43e..0e2e7ee350 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -742,6 +742,640 @@ function JQuery() { } } + function effects() { + function animate() { + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000, 'linear', function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000, 'linear'); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000, function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 'linear', function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 5000); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, 'linear'); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }, function() { + // $ExpectType HTMLElement + this; + + $(this).after('
Animation complete.
'); + }); + + // $ExpectType JQuery + $('#book').animate({ + width: 'toggle', + height: 'toggle' + }, { + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('#book').animate({ + width: ['toggle', 'swing'], + height: 200, + opacity: 'toggle' + }); + } + + function fadeIn() { + // $ExpectType JQuery + $('p').fadeIn(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn(5000, 'linear'); + + // $ExpectType JQuery + $('p').fadeIn(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn(5000); + + // $ExpectType JQuery + $('p').fadeIn('linear'); + + // $ExpectType JQuery + $('p').fadeIn(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeIn({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').fadeIn(); + } + + function fadeOut() { + // $ExpectType JQuery + $('p').fadeOut(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut(5000, 'linear'); + + // $ExpectType JQuery + $('p').fadeOut(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut(5000); + + // $ExpectType JQuery + $('p').fadeOut('linear'); + + // $ExpectType JQuery + $('p').fadeOut(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeOut({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').fadeOut(); + } + + function fadeToggle() { + // $ExpectType JQuery + $('p').fadeToggle(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle(5000, 'linear'); + + // $ExpectType JQuery + $('p').fadeToggle(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle(5000); + + // $ExpectType JQuery + $('p').fadeToggle('linear'); + + // $ExpectType JQuery + $('p').fadeToggle(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeToggle({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').fadeToggle(); + } + + function slideDown() { + // $ExpectType JQuery + $('p').slideDown(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown(5000, 'linear'); + + // $ExpectType JQuery + $('p').slideDown(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown(5000); + + // $ExpectType JQuery + $('p').slideDown('linear'); + + // $ExpectType JQuery + $('p').slideDown(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideDown({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').slideDown(); + } + + function slideToggle() { + // $ExpectType JQuery + $('p').slideToggle(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle(5000, 'linear'); + + // $ExpectType JQuery + $('p').slideToggle(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle(5000); + + // $ExpectType JQuery + $('p').slideToggle('linear'); + + // $ExpectType JQuery + $('p').slideToggle(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideToggle({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').slideToggle(); + } + + function slideUp() { + // $ExpectType JQuery + $('p').slideUp(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp(5000, 'linear'); + + // $ExpectType JQuery + $('p').slideUp(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp('linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp(5000); + + // $ExpectType JQuery + $('p').slideUp('linear'); + + // $ExpectType JQuery + $('p').slideUp(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').slideUp({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').slideUp(); + } + + function fadeTo() { + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9, 'linear'); + + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').fadeTo(5000, 0.9); + } + + function toggle() { + // $ExpectType JQuery + $('p').toggle(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').toggle(5000, 'linear'); + + // $ExpectType JQuery + $('p').toggle(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').toggle(5000); + + // $ExpectType JQuery + $('p').toggle(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').toggle('linear'); + + // $ExpectType JQuery + $('p').toggle(true); + + // $ExpectType JQuery + $('p').toggle(); + } + + function hide() { + // $ExpectType JQuery + $('p').hide(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').hide(5000, 'linear'); + + // $ExpectType JQuery + $('p').hide(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').hide(5000); + + // $ExpectType JQuery + $('p').hide(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').hide({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').hide(); + } + + function show() { + // $ExpectType JQuery + $('p').show(5000, 'linear', function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').show(5000, 'linear'); + + // $ExpectType JQuery + $('p').show(5000, function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').show(5000); + + // $ExpectType JQuery + $('p').show(function() { + // $ExpectType HTMLElement + this; + }); + + // $ExpectType JQuery + $('p').show({ + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete() { + $(this).after('
Animation complete.
'); + } + }); + + // $ExpectType JQuery + $('p').show(); + } + + function clearQueue() { + // $ExpectType JQuery + $('p').clearQueue('myQueue'); + + // $ExpectType JQuery + $('p').clearQueue(); + } + + function delay() { + // $ExpectType JQuery + $('p').delay('fast', 'myQueue'); + + // $ExpectType JQuery + $('p').delay('slow'); + } + + function dequeue() { + // $ExpectType JQuery + $('p').dequeue('myQueue'); + + // $ExpectType JQuery + $('p').dequeue(); + } + + function finish() { + // $ExpectType JQuery + $('p').finish('myQueue'); + + // $ExpectType JQuery + $('p').finish(); + } + + function queue() { + // $ExpectType JQuery + $('p').queue('myQueue', function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }); + + // $ExpectType JQuery + $('p').queue('myQueue', [ + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }, + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + } + ]); + + // $ExpectType JQuery + $('p').queue(function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }); + + // $ExpectType JQuery + $('p').queue([ + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + }, + function(next) { + // $ExpectType HTMLElement + this; + // $ExpectType () => void + next; + } + ]); + + // $ExpectType Queue + $('p').queue('myQueue'); + + // $ExpectType Queue + $('p').queue(); + } + + function stop() { + // $ExpectType JQuery + $('p').stop('myQueue', true, false); + + // $ExpectType JQuery + $('p').stop('myQueue', true); + + // $ExpectType JQuery + $('p').stop(true, false); + + // $ExpectType JQuery + $('p').stop(true); + } + } + function on() { function false_handler_shorthand() { $().on('events', false); @@ -864,6 +1498,70 @@ function JQueryStatic() { } } +function EffectsOptions() { + $('p').show({ + always(animation, jumpToEnd) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType boolean + jumpToEnd; + }, + complete() { + // $ExpectType HTMLElement + this; + }, + done(animation, jumpToEnd) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType boolean + jumpToEnd; + }, + duration: 5000, + easing: 'linear', + fail(animation, jumpToEnd) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType boolean + jumpToEnd; + }, + progress(animation, progress, remainingMs) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + // $ExpectType number + progress; + // $ExpectType number + remainingMs; + }, + queue: true, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + start(animation) { + // $ExpectType HTMLElement + this; + // $ExpectType Promise + animation; + }, + step(now, tween) { + // $ExpectType HTMLElement + this; + // $ExpectType number + now; + // $ExpectType Tween + tween; + } + }); +} + function JQuery_Event() { function type_guard(e: object) { if (e instanceof JQuery.Event) { From c231cbdc07cad59c97432873a19ea71b4d752d74 Mon Sep 17 00:00:00 2001 From: Sebastien PUECH Date: Mon, 19 Jun 2017 16:19:02 +0200 Subject: [PATCH 67/90] Fix the test. --- types/collections/index.d.ts | 0 types/collections/tsconfig.json | 16 ++++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) mode change 100755 => 100644 types/collections/index.d.ts diff --git a/types/collections/index.d.ts b/types/collections/index.d.ts old mode 100755 new mode 100644 diff --git a/types/collections/tsconfig.json b/types/collections/tsconfig.json index c90cfab20d..da6509eb06 100644 --- a/types/collections/tsconfig.json +++ b/types/collections/tsconfig.json @@ -1,13 +1,13 @@ { + "files": [ + "collections-tests.ts", + "index.d.ts" + ], "compilerOptions": { "module": "commonjs", "target": "es6", - "lib": ["es2015"], - "sourceMap": true, + "lib": ["es6"], "strict": true, - "typeRoots": ["."] - }, - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "noEmit": true + } +} From 3f29ccfca390f724ddcc51b4ff98401c08a706be Mon Sep 17 00:00:00 2001 From: Simon Archer Date: Mon, 19 Jun 2017 15:02:07 +0000 Subject: [PATCH 68/90] Definitions for react-paginate 4.3. --- types/react-paginate/index.d.ts | 12 ++++++++++-- types/react-paginate/react-paginate-tests.tsx | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/types/react-paginate/index.d.ts b/types/react-paginate/index.d.ts index b6b50170c2..92f0a36f8f 100644 --- a/types/react-paginate/index.d.ts +++ b/types/react-paginate/index.d.ts @@ -1,6 +1,9 @@ -// Type definitions for react-paginate 4.2 +// Type definitions for react-paginate 4.3 // Project: https://github.com/AdeleD/react-paginate -// Definitions by: Simon Hartcher , Wouter Hardeman , pegel03 +// Definitions by: Simon Hartcher +// Wouter Hardeman +// pegel03 +// Simon Archer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -111,6 +114,11 @@ interface ReactPaginateProps { * The method is called to generate the href attribute value on tag a of each page element. */ hrefBuilder?(pageIndex: number): void; + + /** + * Extra context to add to the aria-label HTML attribute. + */ + extraAriaContext?: string; } declare const ReactPaginate: React.ComponentClass; diff --git a/types/react-paginate/react-paginate-tests.tsx b/types/react-paginate/react-paginate-tests.tsx index 31efb805ce..bb7fe6d552 100644 --- a/types/react-paginate/react-paginate-tests.tsx +++ b/types/react-paginate/react-paginate-tests.tsx @@ -26,6 +26,7 @@ class Test extends React.Component<{}, {}> { nextLinkClassName={'next-a'} disabledClassName={'disabled'} hrefBuilder={(pageIndex: number) => null} + extraAriaContext={'aria'} /> ); } From a4d5894baa646f4cdf74675670afb1e20e542306 Mon Sep 17 00:00:00 2001 From: Sebastien PUECH Date: Mon, 19 Jun 2017 17:05:19 +0200 Subject: [PATCH 69/90] Fix2 --- types/collections/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/collections/index.d.ts b/types/collections/index.d.ts index f423eb458d..8a92df0f2d 100644 --- a/types/collections/index.d.ts +++ b/types/collections/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for collections v5.0.6 // Project: http://www.collectionsjs.com/ -// Definitions by: Scarabe Dore <> +// Definitions by: Scarabe Dore // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'collections/sorted-set' { @@ -130,4 +130,4 @@ declare module 'collections/sorted-set' { } export = internal.SortedSet; -} \ No newline at end of file +} From cd145b1f6a5bdbdfe124e71e7613bdcb35a3c1e7 Mon Sep 17 00:00:00 2001 From: Ryan Twomey Date: Mon, 19 Jun 2017 11:25:09 -0400 Subject: [PATCH 70/90] parse: Add fromJSON --- types/parse/index.d.ts | 3 ++- types/parse/parse-tests.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 95d173fffe..b4cd725529 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -327,11 +327,12 @@ declare namespace Parse { constructor(attributes?: string[], options?: any); static extend(className: string, protoProps?: any, classProps?: any): any; + static fromJSON(json: any, override: boolean): any; + static fetchAll(list: T[], options: SuccessFailureOptions): Promise; static fetchAllIfNeeded(list: T[], options: SuccessFailureOptions): Promise; static destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; static saveAll(list: T[], options?: Object.SaveAllOptions): Promise; - static registerSubclass(className: string, clazz: new (options?: any) => T): void; initialize(): void; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 282913d17e..ad1a2a2a83 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -56,6 +56,8 @@ function test_object() { gameScore.addUnique("skills", "kungfu"); game.set("gameScore", gameScore); + + var gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); } function test_query() { From 0f55ae3965f9b53548820d96949a8a096c6c8293 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 12:00:32 -0400 Subject: [PATCH 71/90] [jquery] Remove type argument on 'properties' paramater in .animate(). The type argument breaks compatibility with objects that do not have an index signature. --- types/jquery/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index fa4fe2d00b..48bf0ab6ba 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -180,7 +180,7 @@ interface JQuery { * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ - animate(properties: JQuery.PlainObject, + animate(properties: JQuery.PlainObject, duration: JQuery.Duration, easing: string, complete?: (this: TElement) => void): this; @@ -194,7 +194,7 @@ interface JQuery { * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ - animate(properties: JQuery.PlainObject, + animate(properties: JQuery.PlainObject, duration_easing: JQuery.Duration | string, complete?: (this: TElement) => void): this; /** @@ -205,7 +205,7 @@ interface JQuery { * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ - animate(properties: JQuery.PlainObject, + animate(properties: JQuery.PlainObject, options: JQuery.EffectsOptions): this; /** * Perform a custom animation of a set of CSS properties. @@ -215,7 +215,7 @@ interface JQuery { * @see {@link https://api.jquery.com/animate/} * @since 1.0 */ - animate(properties: JQuery.PlainObject, + animate(properties: JQuery.PlainObject, complete?: (this: TElement) => void): this; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. From 37e41d33e40db4729d41a2ac67cd0c3c4929c60f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 19 Jun 2017 09:30:38 -0700 Subject: [PATCH 72/90] Deprecate incorrect `resolve` overload and usage --- types/angular/angular-tests.ts | 1 - types/angular/index.d.ts | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index 4936f02e6e..fbcce34e81 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -368,7 +368,6 @@ namespace TestQ { result = $q.resolve(tResult); result = $q.resolve(promiseTResult); let result2: angular.IPromise = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); - let result3: angular.IPromise> = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); } // $q.when diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index d0e2d978dc..ec8e59b326 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1049,6 +1049,10 @@ declare namespace angular { * @param value Value or a promise */ resolve(value: IPromise|T): IPromise; + /** + * @deprecated Since TS 2.4, inference is stricter and no longer produces the desired type when T1 !== T2. + * To use resolve with two different types, pass a union type to the single-type-argument overload. + */ resolve(value: IPromise|T2): IPromise; /** * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. From 3ae7188ebcf3e2f77693edd244c85d23f95ae538 Mon Sep 17 00:00:00 2001 From: YairTawil Date: Mon, 19 Jun 2017 19:47:14 +0300 Subject: [PATCH 73/90] Added a necessary exporting to rison --- types/rison/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/rison/index.d.ts b/types/rison/index.d.ts index cfd6089fb6..d175f88832 100644 --- a/types/rison/index.d.ts +++ b/types/rison/index.d.ts @@ -2,7 +2,8 @@ // Project: https://github.com/Nanonid/rison // Definitions by: Andrei Kurosh // Definitions: https://github.com/borisyankov/DefinitelyTyped - +export = rison; +export as namespace rison; declare var rison: IRison; interface IRison { @@ -54,4 +55,4 @@ interface IRison { * @returns {} Resulting array. */ decode_array(encoded: string): T[]; -} \ No newline at end of file +} From 5b2eb2d8728caaf71230699bc2ebd9c2735ac119 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 13:36:58 -0400 Subject: [PATCH 74/90] [jquery] Fix imported JQueryStatic not returning a JQuery object when called with window. --- types/jquery/index.d.ts | 4 ++-- types/jquery/test/jquery-no-window-module-tests.ts | 8 ++++++++ types/jquery/test/jquery-slim-no-window-module-tests.ts | 8 ++++++++ types/jquery/test/jquery-slim-window-module-tests.ts | 8 ++++++++ types/jquery/test/jquery-window-module-tests.ts | 8 ++++++++ types/jquery/test/module-tests.ts | 7 ------- types/jquery/tsconfig.json | 5 ++++- 7 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 types/jquery/test/jquery-no-window-module-tests.ts create mode 100644 types/jquery/test/jquery-slim-no-window-module-tests.ts create mode 100644 types/jquery/test/jquery-slim-window-module-tests.ts create mode 100644 types/jquery/test/jquery-window-module-tests.ts delete mode 100644 types/jquery/test/module-tests.ts diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 48bf0ab6ba..cea056ef60 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -25,14 +25,14 @@ // TypeScript Version: 2.3 declare module 'jquery' { - function factory(window: Window): JQueryStatic; + function factory(window: Window): JQueryStatic & JQuery; const factoryOrJQuery: typeof factory & JQueryStatic; export = factoryOrJQuery; } declare module 'jquery/dist/jquery.slim' { - function factory(window: Window): JQueryStatic; + function factory(window: Window): JQueryStatic & JQuery; const factoryOrJQuery: typeof factory & JQueryStatic; export = factoryOrJQuery; diff --git a/types/jquery/test/jquery-no-window-module-tests.ts b/types/jquery/test/jquery-no-window-module-tests.ts new file mode 100644 index 0000000000..700be9d60c --- /dev/null +++ b/types/jquery/test/jquery-no-window-module-tests.ts @@ -0,0 +1,8 @@ +import jQueryFactory = require('jquery'); + +const jq = jQueryFactory(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQueryStatic' +// // $ExpectType JQueryStatic +// jq; +// jq === jQuery(); +jq === jQuery; diff --git a/types/jquery/test/jquery-slim-no-window-module-tests.ts b/types/jquery/test/jquery-slim-no-window-module-tests.ts new file mode 100644 index 0000000000..fdbd34e06c --- /dev/null +++ b/types/jquery/test/jquery-slim-no-window-module-tests.ts @@ -0,0 +1,8 @@ +import jQueryFactory = require('jquery/dist/jquery.slim'); + +const jq = jQueryFactory(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQueryStatic' +// // $ExpectType JQueryStatic +// jq; +// jq === jQuery(); +jq === jQuery; diff --git a/types/jquery/test/jquery-slim-window-module-tests.ts b/types/jquery/test/jquery-slim-window-module-tests.ts new file mode 100644 index 0000000000..8072811f08 --- /dev/null +++ b/types/jquery/test/jquery-slim-window-module-tests.ts @@ -0,0 +1,8 @@ +import * as jq from 'jquery/dist/jquery.slim'; + +const $window = jq(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQuery' +// // $ExpectType JQuery +// $window; +// $window === jq; +$window === jq(); diff --git a/types/jquery/test/jquery-window-module-tests.ts b/types/jquery/test/jquery-window-module-tests.ts new file mode 100644 index 0000000000..85f2c4c4ea --- /dev/null +++ b/types/jquery/test/jquery-window-module-tests.ts @@ -0,0 +1,8 @@ +import * as jq from 'jquery'; + +const $window = jq(window); +// ExpectType will report 'jq' as 'JQueryStatic & JQuery' even though the compiler seems to know that 'jq' is 'JQuery' +// // $ExpectType JQuery +// $window; +// $window === jq; +$window === jq(); diff --git a/types/jquery/test/module-tests.ts b/types/jquery/test/module-tests.ts deleted file mode 100644 index b55dee0370..0000000000 --- a/types/jquery/test/module-tests.ts +++ /dev/null @@ -1,7 +0,0 @@ -import factory = require('jquery'); -const jq = factory(window); -jq.noop(); - -import slimFactory = require('jquery/dist/jquery.slim'); -const slim = slimFactory(window); -slim.noop(); diff --git a/types/jquery/tsconfig.json b/types/jquery/tsconfig.json index ebfa01c813..21d35a63da 100644 --- a/types/jquery/tsconfig.json +++ b/types/jquery/tsconfig.json @@ -22,6 +22,9 @@ "jquery-tests.ts", "test/example-tests.ts", "test/longdesc-tests.ts", - "test/module-tests.ts" + "test/jquery-no-window-module-tests.ts", + "test/jquery-window-module-tests.ts", + "test/jquery-slim-no-window-module-tests.ts", + "test/jquery-slim-window-module-tests.ts" ] } From 3ea78455b9140bcef70345b646c50cab7f7b1491 Mon Sep 17 00:00:00 2001 From: Eric Henry Date: Fri, 2 Jun 2017 14:50:45 -0400 Subject: [PATCH 75/90] Update to the swagger-parser module --- types/swagger-parser/index.d.ts | 51 ++++- types/swagger-parser/swagger-parser-tests.ts | 202 ++++++++++++++++++- 2 files changed, 250 insertions(+), 3 deletions(-) diff --git a/types/swagger-parser/index.d.ts b/types/swagger-parser/index.d.ts index 6191a13a0e..f2a0c7a3e1 100644 --- a/types/swagger-parser/index.d.ts +++ b/types/swagger-parser/index.d.ts @@ -1,7 +1,54 @@ // Type definitions for swagger-parser 4.x // Project: https://www.npmjs.com/package/swagger-parser // Definitions by: Tobias Wolff +// Eric Henry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { Spec as Swagger } from '../swagger-schema-official'; -export function parse(api: any, options?: any): Promise; -export function parse(api: any, options: any, callback: (err: any, result?: any) => void): void; +export namespace SwaggerParser { + let api: any; + let $ref: any; +} + +export interface Options { + allow?: { + json?: boolean; + yaml?: boolean; + empty?: boolean; + unknown?: boolean; + }; + $ref?: { + internal?: boolean; + external?: boolean; + circular?: boolean | 'ignore'; + }; + validate?: { + schema?: boolean; + spec?: boolean; + }; + cache?: { + fs?: number; + http?: number; + https?: number; + }; +} + +export function parse(api: string | Swagger, options?: Options): Promise; +export function parse(api: string | Swagger, callback: (err: any, result?: any) => void): void; +export function parse(api: string | Swagger, options: Options, callback: (err: any, result?: any) => void): void; + +export function validate(api: string | Swagger, options?: Options): Promise; +export function validate(api: string | Swagger, callback: (err: any, result?: any) => void): void; +export function validate(api: string | Swagger, options: Options, callback: (err: any, result?: any) => void): void; + +export function dereference(api: string | Swagger, options?: Options): Promise; +export function dereference(api: string | Swagger, callback: (err: any, result?: any) => void): void; +export function dereference(api: string | Swagger, options: Options, callback: (err: any, result?: any) => void): void; + +export function bundle(api: string | Swagger, options?: Options): Promise; +export function bundle(api: string | Swagger, callback: (err: any, result?: any) => void): void; +export function bundle(api: string | Swagger, options: Options, callback: (err: any, result?: any) => void): void; + +export function resolve(api: string | Swagger, options?: Options): Promise; +export function resolve(api: string | Swagger, callback: (err: any, result?: any) => void): void; +export function resolve(api: string | Swagger, options: Options, callback: (err: any, result?: any) => void): void; diff --git a/types/swagger-parser/swagger-parser-tests.ts b/types/swagger-parser/swagger-parser-tests.ts index ba39d3e6cc..f880c801b2 100644 --- a/types/swagger-parser/swagger-parser-tests.ts +++ b/types/swagger-parser/swagger-parser-tests.ts @@ -1,7 +1,22 @@ import parser = require("swagger-parser"); +import { Spec as Swagger } from '../swagger-schema-official'; + +const swaggerMock: Swagger = { + swagger: '', + info: { + title: '', + version: '' + }, + paths: { '': {} } +} // Without callback which returns a promise -parser.parse("test.yaml").then((file: string) => { +parser.parse("test.yaml").then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.parse("test.yaml", {}).then((file) => { console.log(file); }); @@ -9,3 +24,188 @@ parser.parse("test.yaml").then((file: string) => { parser.parse("test.yaml", {}, (err, file) => { console.log(file); }); + +// With callback and no options +parser.parse("test.yaml", (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.parse(swaggerMock).then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.parse(swaggerMock, {}).then((file) => { + console.log(file); +}); + +// With callback +parser.parse(swaggerMock, {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.parse(swaggerMock, (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.dereference("test.yaml").then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.dereference("test.yaml", {}).then((file) => { + console.log(file); +}); + +// With callback +parser.dereference("test.yaml", {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.dereference("test.yaml", (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.dereference(swaggerMock).then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.dereference(swaggerMock, {}).then((file) => { + console.log(file); +}); + +// With callback +parser.dereference(swaggerMock, {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.dereference(swaggerMock, (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.bundle("test.yaml").then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.bundle("test.yaml", {}).then((file) => { + console.log(file); +}); + +// With callback +parser.bundle("test.yaml", {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.bundle("test.yaml", (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.bundle(swaggerMock).then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.bundle(swaggerMock, {}).then((file) => { + console.log(file); +}); + +// With callback +parser.bundle(swaggerMock, {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.bundle(swaggerMock, (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.resolve("test.yaml").then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.resolve("test.yaml", {}).then((file) => { + console.log(file); +}); + +// With callback +parser.resolve("test.yaml", {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.resolve("test.yaml", (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.resolve(swaggerMock).then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.resolve(swaggerMock, {}).then((file) => { + console.log(file); +}); + +// With callback +parser.resolve(swaggerMock, {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.resolve(swaggerMock, (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.validate("test.yaml").then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.validate("test.yaml", {}).then((file) => { + console.log(file); +}); + +// With callback +parser.validate("test.yaml", {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.validate("test.yaml", (err, file) => { + console.log(file); +}); + +// Without callback which returns a promise +parser.validate(swaggerMock).then((file) => { + console.log(file); +}); + +// with options but, Without callback which returns a promise +parser.validate(swaggerMock, {}).then((file) => { + console.log(file); +}); + +// With callback +parser.validate(swaggerMock, {}, (err, file) => { + console.log(file); +}); + +// With callback and no options +parser.validate(swaggerMock, (err, file) => { + console.log(file); +}); From 1119ad2d8194a433eee5e9f391aaed0af436cc4b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 19 Jun 2017 13:00:47 -0700 Subject: [PATCH 76/90] More fixes for 2.4. Not all for weak types: 2.4 also has been inference for generics, which finds more errors as well. --- types/angular/index.d.ts | 4 ++++ types/browserify/index.d.ts | 33 +++++++++++++++++---------- types/bunyan-config/index.d.ts | 19 ++++++++++++++- types/hapi/v8/hapi-tests.ts | 10 -------- types/js-data/v1/js-data-tests.ts | 2 +- types/sequelize/v3/index.d.ts | 1 + types/sequelize/v3/sequelize-tests.ts | 1 - 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index d0e2d978dc..2692f3929d 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1846,6 +1846,10 @@ declare namespace angular { * different in Angular 1 there is no direct mapping and care should be taken when upgrading. */ $postLink?(): void; + + // IController implementations frequently do not implement any of its methods. + // A string indexer indicates to TypeScript not to issue a weak type error in this case. + [s: string]: any; } /** diff --git a/types/browserify/index.d.ts b/types/browserify/index.d.ts index 6d03c76efe..5e2c3e86d7 100644 --- a/types/browserify/index.d.ts +++ b/types/browserify/index.d.ts @@ -36,13 +36,22 @@ interface FileOptions { // for each file in a bundle. type InputFile = string | NodeJS.ReadableStream | FileOptions; +/** + * Core options pertaining to a Browserify instance, extended by user options + */ +interface CustomOptions { + /** + * Custom properties can be defined on Options. + * These options are forwarded along to module-deps and browser-pack directly. + */ + [propName: string]: any; + /** the directory that Browserify starts bundling from for filenames that start with .. */ + basedir?: string; +} /** * Options pertaining to a Browserify instance. */ -interface Options { - // Custom properties can be defined on Options. - // These options are forwarded along to module-deps and browser-pack directly. - [propName: string]: any; +interface Options extends CustomOptions { // String, file object, or array of those types (they may be mixed) specifying entry file(s). entries?: InputFile | InputFile[]; // an array which will skip all require() and global parsing for each file in the array. @@ -115,32 +124,32 @@ interface BrowserifyObject extends NodeJS.EventEmitter { * If file is an array, each item in file will be externalized. * If file is another bundle, that bundle's contents will be read and excluded from the current bundle as the bundle in file gets bundled. */ - external(file: string[], opts?: { basedir?: string }): BrowserifyObject; - external(file: string, opts?: { basedir?: string }): BrowserifyObject; + external(file: string[], opts?: CustomOptions): BrowserifyObject; + external(file: string, opts?: CustomOptions): BrowserifyObject; external(file: BrowserifyObject): BrowserifyObject; /** * Prevent the module name or file at file from showing up in the output bundle. * Instead you will get a file with module.exports = {}. */ - ignore(file: string, opts?: { basedir?: string }): BrowserifyObject; + ignore(file: string, opts?: CustomOptions): BrowserifyObject; /** * Prevent the module name or file at file from showing up in the output bundle. * If your code tries to require() that file it will throw unless you've provided another mechanism for loading it. */ - exclude(file: string, opts?: { basedir?: string }): BrowserifyObject; + exclude(file: string, opts?: CustomOptions): BrowserifyObject; /** * Transform source code before parsing it for require() calls with the transform function or module name tr. * If tr is a function, it will be called with tr(file) and it should return a through-stream that takes the raw file contents and produces the transformed source. * If tr is a string, it should be a module name or file path of a transform module */ - transform(tr: string, opts?: T): BrowserifyObject; - transform(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject; + transform(tr: string, opts?: T): BrowserifyObject; + transform(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject; /** * Register a plugin with opts. Plugins can be a string module name or a function the same as transforms. * plugin(b, opts) is called with the Browserify instance b. */ - plugin(plugin: string, opts?: T): BrowserifyObject; - plugin(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject; + plugin(plugin: string, opts?: T): BrowserifyObject; + plugin(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject; /** * Reset the pipeline back to a normal state. This function is called automatically when bundle() is called multiple times. * This function triggers a 'reset' event. diff --git a/types/bunyan-config/index.d.ts b/types/bunyan-config/index.d.ts index 49b642eaa1..0ff84fd9d2 100644 --- a/types/bunyan-config/index.d.ts +++ b/types/bunyan-config/index.d.ts @@ -7,6 +7,23 @@ declare module "bunyan-config" { import * as bunyan from "bunyan"; + interface StreamConfiguration { + name: string, + params?: { + host: string, + port: number + } + } + + interface Stream { + type?: string; + level?: bunyan.LogLevel; + path?: string; + stream?: string | StreamConfiguration + closeOnExit?: boolean; + period?: string; + count?: number; + } /** * Configuration. @@ -14,7 +31,7 @@ declare module "bunyan-config" { */ interface Configuration { name: string; - streams?: bunyan.Stream[]; + streams?: Stream[]; level?: string | number; stream?: NodeJS.WritableStream; serializers?: {}; diff --git a/types/hapi/v8/hapi-tests.ts b/types/hapi/v8/hapi-tests.ts index 585e58e100..ee8af0d335 100644 --- a/types/hapi/v8/hapi-tests.ts +++ b/types/hapi/v8/hapi-tests.ts @@ -124,15 +124,5 @@ server.route([{ } }]); -// Implict handler -server.route({ - method: 'GET', - path: '/hello6', - handler: function (request, reply) { - request.log('info', { route: '/hello' }, Date.now()); - reply('hello world'); - } -}); - // Start the server server.start(); diff --git a/types/js-data/v1/js-data-tests.ts b/types/js-data/v1/js-data-tests.ts index 0832f066d9..69a056b081 100644 --- a/types/js-data/v1/js-data-tests.ts +++ b/types/js-data/v1/js-data-tests.ts @@ -30,7 +30,7 @@ User.find(1).then(function (user:IUser) { var user:IUser = User.createInstance({name: 'John'}); var store = new JSData.DS(); -var User2 = store.defineResource('user'); +var User2 = store.defineResource('user'); var user:IUser = User2.inject({id: 1, name: 'John'}); var user2:IUser = User2.inject({id: 1, age: 30}); diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index 1a3ce50d0c..1d062cd1da 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -3130,6 +3130,7 @@ declare namespace sequelize { */ include?: Array | IncludeOptions>; + all?: boolean | string; } /** diff --git a/types/sequelize/v3/sequelize-tests.ts b/types/sequelize/v3/sequelize-tests.ts index 9dcfd3e80b..78a89ed2d4 100644 --- a/types/sequelize/v3/sequelize-tests.ts +++ b/types/sequelize/v3/sequelize-tests.ts @@ -904,7 +904,6 @@ User.findOne( { where : { id : 1 }, attributes : ['id', ['username', 'name']] } User.findOne( { where : { id : 1 }, attributes : ['id'] } ); User.findOne( { where : { username : 'foo' }, logging : function( ) { } } ); User.findOne( { limit : 10 } ); -User.findOne( { include : [1] } ); User.findOne( { where : { title : 'homework' }, include : [User] } ); User.findOne( { where : { name : 'environment' }, include : [{ model : User, as : 'PrivateDomain' }] } ); User.findOne( { where : { username : 'foo' }, transaction : t } ).then( ( p ) => p ); From ebeece2d8e6e33faa2a3148fa8af9351262c9357 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 19 Jun 2017 14:18:03 -0700 Subject: [PATCH 77/90] Fix mime.lookup call in node-static-tests.ts --- types/node-static/node-static-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node-static/node-static-tests.ts b/types/node-static/node-static-tests.ts index 4bf2673ab4..471a8fde50 100644 --- a/types/node-static/node-static-tests.ts +++ b/types/node-static/node-static-tests.ts @@ -2,6 +2,6 @@ import {Server, version, mime} from 'node-static'; let server = new Server(__dirname); let pathname = server.resolve('./tsconfig.json'); -let mimetype = mime.lookup(pathname); +let mimetype = mime.lookup(pathname, ''); let versionNum = version.join('.'); console.log(`The node-static server constructed an instance of itself, fetched the mimetype of ${pathname} (${mimetype}), and has a version of ${versionNum}! The package is working.`); From 287414589e3fdd84f47fe793918217fb3f59fc9b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 19 Jun 2017 14:30:12 -0700 Subject: [PATCH 78/90] Use non-relative path to import swagger-schema-official --- types/swagger-parser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/swagger-parser/index.d.ts b/types/swagger-parser/index.d.ts index f2a0c7a3e1..e29c2630e2 100644 --- a/types/swagger-parser/index.d.ts +++ b/types/swagger-parser/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Tobias Wolff // Eric Henry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { Spec as Swagger } from '../swagger-schema-official'; +import { Spec as Swagger } from 'swagger-schema-official'; export namespace SwaggerParser { let api: any; From 5946b2ffad2b8669bd9231d00492cbf31b162905 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 19 Jun 2017 15:04:58 -0700 Subject: [PATCH 79/90] Remove redundant basedir declaration --- types/browserify/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/browserify/index.d.ts b/types/browserify/index.d.ts index 5e2c3e86d7..8b51a34dd5 100644 --- a/types/browserify/index.d.ts +++ b/types/browserify/index.d.ts @@ -60,8 +60,6 @@ interface Options extends CustomOptions { // an array of optional extra extensions for the module lookup machinery to use when the extension has not been specified. // By default Browserify considers only .js and .json files in such cases. extensions?: string[]; - // the directory that Browserify starts bundling from for filenames that start with .. - basedir?: string; // an array of directories that Browserify searches when looking for modules which are not referenced using relative path. // Can be absolute or relative to basedir. Equivalent of setting NODE_PATH environmental variable when calling Browserify command. paths?: string[]; From 82b6ab4b579c4f911542c2f019d4e6ff8328c290 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 19 Jun 2017 15:56:10 -0700 Subject: [PATCH 80/90] Don't use --strict to make tsconfig 2.0 compatible --- types/collections/tsconfig.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/collections/tsconfig.json b/types/collections/tsconfig.json index da6509eb06..6b5293a242 100644 --- a/types/collections/tsconfig.json +++ b/types/collections/tsconfig.json @@ -7,7 +7,10 @@ "module": "commonjs", "target": "es6", "lib": ["es6"], - "strict": true, + "forceConsistentCasingInFileNames": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, "noEmit": true } } From 74fd1f601de36965ab6ee0147a14d44755491e73 Mon Sep 17 00:00:00 2001 From: Flarna Date: Tue, 20 Jun 2017 01:01:48 +0200 Subject: [PATCH 81/90] - Added dedicated types for listeners to avoid unneeded copy/paste. - Added overloads for listen() to cover issue discussed in latest comments of #16705 --- types/node/index.d.ts | 136 +++++++++++++++++++++++---------------- types/node/node-tests.ts | 4 ++ 2 files changed, 84 insertions(+), 56 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 369b786f17..a9c5649efc 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -384,6 +384,18 @@ declare namespace NodeJS { "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" | "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO"; + type BeforeExitListener = (code: number) => void; + type DisconnectListener = () => void; + type ExitListener = (code: number) => void; + type RejectionHandledListender = (promise: Promise) => void; + type UncaughtExceptionListener = (error: Error) => void; + type UnhandledRejectionListener = (reason: any, promise: Promise) => void; + type WarningListener = (warning: Error) => void; + type MessageListener = (message: any, sendHandle: any) => void; + type SignalsListener = () => void; + type NewListenerListener = (type: string | symbol, listener: Function) => void; + type RemoveListenerListener = (type: string | symbol, listener: Function) => void; + export interface Socket extends ReadWriteStream { isTTY?: true; } @@ -471,17 +483,17 @@ declare namespace NodeJS { * 10. * 11. newListener/removeListener inherited from EventEmitter */ - addListener(event: "beforeExit", listener: (code: number) => void): this; - addListener(event: "disconnect", listener: () => void): this; - addListener(event: "exit", listener: (code: number) => void): this; - addListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; - addListener(event: "uncaughtException", listener: (error: Error) => void): this; - addListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - addListener(event: "warning", listener: (warning: Error) => void): this; - addListener(event: "message", listener: (message: any, sendHandle: any) => void): this; - addListener(event: Signals, listener: () => void): this; - addListener(event: "newListener", listener: (event: string, listener: Function) => void): this; - addListener(event: "removeListener", listener: (event: string, listener: Function) => void): this; + addListener(event: "beforeExit", listener: BeforeExitListener): this; + addListener(event: "disconnect", listener: DisconnectListener): this; + addListener(event: "exit", listener: ExitListener): this; + addListener(event: "rejectionHandled", listener: RejectionHandledListender): this; + addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + addListener(event: "warning", listener: WarningListener): this; + addListener(event: "message", listener: MessageListener): this; + addListener(event: Signals, listener: SignalsListener): this; + addListener(event: "newListener", listener: NewListenerListener): this; + addListener(event: "removeListener", listener: RemoveListenerListener): this; emit(event: "beforeExit", code: number): boolean; emit(event: "disconnect"): boolean; @@ -492,56 +504,68 @@ declare namespace NodeJS { emit(event: "warning", warning: Error): boolean; emit(event: "message", message: any, sendHandle: any): this; emit(event: Signals): boolean; - emit(event: "newListener", eventName: string, listener: Function): this; + emit(event: "newListener", eventName: string | symbol, listener: Function): this; emit(event: "removeListener", eventName: string, listener: Function): this; - on(event: "beforeExit", listener: (code: number) => void): this; - on(event: "disconnect", listener: () => void): this; - on(event: "exit", listener: (code: number) => void): this; - on(event: "rejectionHandled", listener: (promise: Promise) => void): this; - on(event: "uncaughtException", listener: (error: Error) => void): this; - on(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - on(event: "warning", listener: (warning: Error) => void): this; - on(event: "message", listener: (message: any, sendHandle: any) => void): this; - on(event: Signals, listener: () => void): this; - on(event: "newListener", listener: (event: string, listener: Function) => void): this; - on(event: "removeListener", listener: (event: string, listener: Function) => void): this; + on(event: "beforeExit", listener: BeforeExitListener): this; + on(event: "disconnect", listener: DisconnectListener): this; + on(event: "exit", listener: ExitListener): this; + on(event: "rejectionHandled", listener: RejectionHandledListender): this; + on(event: "uncaughtException", listener: UncaughtExceptionListener): this; + on(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + on(event: "warning", listener: WarningListener): this; + on(event: "message", listener: MessageListener): this; + on(event: Signals, listener: SignalsListener): this; + on(event: "newListener", listener: NewListenerListener): this; + on(event: "removeListener", listener: RemoveListenerListener): this; - once(event: "beforeExit", listener: (code: number) => void): this; - once(event: "disconnect", listener: () => void): this; - once(event: "exit", listener: (code: number) => void): this; - once(event: "rejectionHandled", listener: (promise: Promise) => void): this; - once(event: "uncaughtException", listener: (error: Error) => void): this; - once(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - once(event: "warning", listener: (warning: Error) => void): this; - once(event: "message", listener: (message: any, sendHandle: any) => void): this; - once(event: Signals, listener: () => void): this; - once(event: "newListener", listener: (event: string, listener: Function) => void): this; - once(event: "removeListener", listener: (event: string, listener: Function) => void): this; + once(event: "beforeExit", listener: BeforeExitListener): this; + once(event: "disconnect", listener: DisconnectListener): this; + once(event: "exit", listener: ExitListener): this; + once(event: "rejectionHandled", listener: RejectionHandledListender): this; + once(event: "uncaughtException", listener: UncaughtExceptionListener): this; + once(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + once(event: "warning", listener: WarningListener): this; + once(event: "message", listener: MessageListener): this; + once(event: Signals, listener: SignalsListener): this; + once(event: "newListener", listener: NewListenerListener): this; + once(event: "removeListener", listener: RemoveListenerListener): this; - prependListener(event: "beforeExit", listener: (code: number) => void): this; - prependListener(event: "disconnect", listener: () => void): this; - prependListener(event: "exit", listener: (code: number) => void): this; - prependListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; - prependListener(event: "uncaughtException", listener: (error: Error) => void): this; - prependListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - prependListener(event: "warning", listener: (warning: Error) => void): this; - prependListener(event: "message", listener: (message: any, sendHandle: any) => void): this; - prependListener(event: Signals, listener: () => void): this; - prependListener(event: "newListener", listener: (event: string, listener: Function) => void): this; - prependListener(event: "removeListener", listener: (event: string, listener: Function) => void): this; + prependListener(event: "beforeExit", listener: BeforeExitListener): this; + prependListener(event: "disconnect", listener: DisconnectListener): this; + prependListener(event: "exit", listener: ExitListener): this; + prependListener(event: "rejectionHandled", listener: RejectionHandledListender): this; + prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependListener(event: "warning", listener: WarningListener): this; + prependListener(event: "message", listener: MessageListener): this; + prependListener(event: Signals, listener: SignalsListener): this; + prependListener(event: "newListener", listener: NewListenerListener): this; + prependListener(event: "removeListener", listener: RemoveListenerListener): this; - prependOnceListener(event: "beforeExit", listener: (code: number) => void): this; - prependOnceListener(event: "disconnect", listener: () => void): this; - prependOnceListener(event: "exit", listener: (code: number) => void): this; - prependOnceListener(event: "rejectionHandled", listener: (promise: Promise) => void): this; - prependOnceListener(event: "uncaughtException", listener: (error: Error) => void): this; - prependOnceListener(event: "unhandledRejection", listener: (reason: any, promise: Promise) => void): this; - prependOnceListener(event: "warning", listener: (warning: Error) => void): this; - prependOnceListener(event: "message", listener: (message: any, sendHandle: any) => void): this; - prependOnceListener(event: Signals, listener: () => void): this; - prependOnceListener(event: "newListener", listener: (event: string, listener: Function) => void): this; - prependOnceListener(event: "removeListener", listener: (event: string, listener: Function) => void): this; + prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this; + prependOnceListener(event: "disconnect", listener: DisconnectListener): this; + prependOnceListener(event: "exit", listener: ExitListener): this; + prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListender): this; + prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependOnceListener(event: "warning", listener: WarningListener): this; + prependOnceListener(event: "message", listener: MessageListener): this; + prependOnceListener(event: Signals, listener: SignalsListener): this; + prependOnceListener(event: "newListener", listener: NewListenerListener): this; + prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this; + + listeners(event: "beforeExit"): BeforeExitListener[]; + listeners(event: "disconnect"): DisconnectListener[]; + listeners(event: "exit"): ExitListener[]; + listeners(event: "rejectionHandled"): RejectionHandledListender[]; + listeners(event: "uncaughtException"): UncaughtExceptionListener[]; + listeners(event: "unhandledRejection"): UnhandledRejectionListener[]; + listeners(event: "warning"): WarningListener[]; + listeners(event: "message"): MessageListener[]; + listeners(event: Signals): SignalsListener[]; + listeners(event: "newListener"): NewListenerListener[]; + listeners(event: "removeListener"): RemoveListenerListener[]; } export interface Global { diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 251ef2d7eb..6aa3109d7c 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1903,6 +1903,10 @@ namespace process_tests { process.prependOnceListener("SIGBREAK", () => { }); process.on("newListener", (event: string, listener: Function) => { }); process.once("removeListener", (event: string, listener: Function) => { }); + + const listeners = process.listeners('uncaughtException'); + const oldHandler = listeners[listeners.length - 1]; + process.addListener('uncaughtException', oldHandler); } } From f3527f0040937d7c3a0e0ffb4157abd715125127 Mon Sep 17 00:00:00 2001 From: Albert Kurniawan Date: Mon, 19 Jun 2017 23:06:00 +1000 Subject: [PATCH 82/90] Updated Ref signature to handle null cases --- types/react/index.d.ts | 8 ++++---- types/react/test/index.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 37abe824d7..0d9fd00d0e 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for React v15.0 // Project: http://facebook.github.io/react/ -// Definitions by: Asana , AssureSign , Microsoft , John Reilly , Benoit Benezech , Patricio Zavolinsky , Digiguru , Eric Anderson +// Definitions by: Asana , AssureSign , Microsoft , John Reilly , Benoit Benezech , Patricio Zavolinsky , Digiguru , Eric Anderson , Albert Kurniawan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -29,7 +29,7 @@ declare namespace React { type ComponentType

= ComponentClass

| StatelessComponent

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


From dfc6e0fdb506e73e5e57856980f7af4044466e51 Mon Sep 17 00:00:00 2001 From: Albert Kurniawan Date: Tue, 20 Jun 2017 17:12:54 +1000 Subject: [PATCH 84/90] Fixed broken redux-devtools-test --- types/redux-devtools/redux-devtools-tests.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/redux-devtools/redux-devtools-tests.tsx b/types/redux-devtools/redux-devtools-tests.tsx index 695fbe60ff..a64462198e 100644 --- a/types/redux-devtools/redux-devtools-tests.tsx +++ b/types/redux-devtools/redux-devtools-tests.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { compose, createStore, Reducer, Store, StoreEnhancerStoreCreator } from 'redux' +import { compose, createStore, Reducer, Store, GenericStoreEnhancer } from 'redux' import { Provider } from 'react-redux' import { createDevTools, persistState } from 'redux-devtools' @@ -12,10 +12,12 @@ const DevTools = createDevTools( ) -const finalCreateStore = compose( +const storeEnhancer = compose( DevTools.instrument(), persistState('test-session') -)(createStore) +) as GenericStoreEnhancer + +const finalCreateStore = storeEnhancer(createStore) const store: Store = finalCreateStore(reducer) From 22d4b7952696da61f7ec9413ed718d46d0718d3f Mon Sep 17 00:00:00 2001 From: Steven Liekens Date: Fri, 17 Feb 2017 12:43:23 +0100 Subject: [PATCH 85/90] Improve declaration of FunctionColumnRender Resolves #12687 --- types/datatables.net/datatables.net-tests.ts | 25 +++++++++++++++++++- types/datatables.net/index.d.ts | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/types/datatables.net/datatables.net-tests.ts b/types/datatables.net/datatables.net-tests.ts index ada38d5a21..8ec7ecb084 100644 --- a/types/datatables.net/datatables.net-tests.ts +++ b/types/datatables.net/datatables.net-tests.ts @@ -60,12 +60,35 @@ $(document).ready(function () { sort: "asc" }; - var colRenderFunc: DataTables.FunctionColumnRender = function (data, type, row, meta) { + var colRenderFunc: DataTables.FunctionColumnRender = (data: any, type: 'filter' | 'display' | 'type' | 'sort' | undefined | any, row: any, meta: DataTables.CellMetaSettings): any => { meta.col; meta.row; meta.settings; + switch (type) { + case undefined: + return data.value; + case 'filter': + return data.filterValue; + case 'display': + return data.displayValue; + case 'type': + return data.typeValue; + case 'sort': + return data.sortValue; + default: + // Extensibility: the render type can be a custom value, useful for plugins that require custom rendering. + // Custom values are declared as any. + return data.valueForPlugin; + } }; + colRenderFunc({}, 'filter', {}, null); + colRenderFunc({}, 'display', {}, null); + colRenderFunc({}, 'type', {}, null); + colRenderFunc({}, 'sort', {}, null); + colRenderFunc({}, undefined, {}, null); + colRenderFunc({}, 'custom value', {}, null); + var col: DataTables.ColumnSettings = { cellType: "th", diff --git a/types/datatables.net/index.d.ts b/types/datatables.net/index.d.ts index bb55b54722..37c57198c9 100644 --- a/types/datatables.net/index.d.ts +++ b/types/datatables.net/index.d.ts @@ -1604,7 +1604,7 @@ declare namespace DataTables { } interface FunctionColumnRender { - (data: any, t: string, row: any, meta: CellMetaSettings): void; + (data: any, type: 'filter' | 'display' | 'type' | 'sort' | undefined | any, row: any, meta: CellMetaSettings): any; } interface CellMetaSettings { From 85ce02feb35458518942f2203cb584b10383d470 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Tue, 20 Jun 2017 10:36:09 -0400 Subject: [PATCH 86/90] redux-mock-store typing test for MockStore and MockStoreCreator --- types/redux-mock-store/redux-mock-store-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/redux-mock-store/redux-mock-store-tests.ts b/types/redux-mock-store/redux-mock-store-tests.ts index 0937e70654..c83207998f 100644 --- a/types/redux-mock-store/redux-mock-store-tests.ts +++ b/types/redux-mock-store/redux-mock-store-tests.ts @@ -1,5 +1,5 @@ import * as Redux from 'redux'; -import configureStore from 'redux-mock-store'; +import configureStore, { MockStore, MockStoreCreator } from 'redux-mock-store'; // Redux store API tests // The following test are taken from ../redux/redux-tests.ts @@ -24,10 +24,10 @@ function loggingMiddleware() { }; } -const storeMock = configureStore([loggingMiddleware]); +const mockStoreCreator: MockStoreCreator = configureStore([loggingMiddleware]); const initialState = 0 -const store = storeMock(initialState); +const store: MockStore = mockStoreCreator(initialState); store.subscribe(() => { // ... From a1455376bfaab91115eddbf688ac2458ed6c84a7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 20 Jun 2017 10:05:45 -0700 Subject: [PATCH 87/90] Fix spacing --- types/gulp-sourcemaps/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/gulp-sourcemaps/index.d.ts b/types/gulp-sourcemaps/index.d.ts index 3b805e8fd8..8a038af6ec 100644 --- a/types/gulp-sourcemaps/index.d.ts +++ b/types/gulp-sourcemaps/index.d.ts @@ -16,8 +16,8 @@ interface WriteMapper { } interface CloneOptions { - contents?: boolean; - deep?: boolean; + contents?: boolean; + deep?: boolean; } interface WriteOptions { From b2929a8c7dbfd3b87823daedde6fc3c951370d19 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 20 Jun 2017 10:23:09 -0700 Subject: [PATCH 88/90] baidumap-web-sdk: Convert from crlf to lf (#17330) --- .../baidumap-web-sdk-tests.ts | 48 +- types/baidumap-web-sdk/baidumap.base.d.ts | 110 +-- types/baidumap-web-sdk/baidumap.control.d.ts | 262 +++--- types/baidumap-web-sdk/baidumap.core.d.ts | 306 +++--- types/baidumap-web-sdk/baidumap.maplayer.d.ts | 162 ++-- types/baidumap-web-sdk/baidumap.maptype.d.ts | 100 +- types/baidumap-web-sdk/baidumap.overlay.d.ts | 874 +++++++++--------- types/baidumap-web-sdk/baidumap.panorama.d.ts | 242 ++--- .../baidumap-web-sdk/baidumap.rightmenu.d.ts | 92 +- types/baidumap-web-sdk/baidumap.service.d.ts | 864 ++++++++--------- types/baidumap-web-sdk/baidumap.tools.d.ts | 120 +-- types/baidumap-web-sdk/index.d.ts | 56 +- types/baidumap-web-sdk/tslint.json | 15 + 13 files changed, 1633 insertions(+), 1618 deletions(-) create mode 100644 types/baidumap-web-sdk/tslint.json diff --git a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts index 0a4052b147..cc525509c6 100644 --- a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts +++ b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts @@ -1,24 +1,24 @@ -import "./index" -namespace BMapTests { - export class TestFixture { - //document: http://lbsyun.baidu.com/index.php?title=jspopular - public createMap(container: string | HTMLElement) { - navigator.geolocation.getCurrentPosition((position: Position) => { - let point = new BMap.Point(position.coords.longitude, position.coords.latitude); - let map = new BMap.Map(container); - map.centerAndZoom(point, 15); - }, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); - } - public addControl(map: BMap.Map) { - map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT })); - map.addControl(new BMap.NavigationControl()); - map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] })); - map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); - } - public addMarker(map: BMap.Map, point: BMap.Point) { - var marker = new BMap.Marker(point); - map.addOverlay(marker); - marker.setAnimation(BMAP_ANIMATION_BOUNCE); - } - } -} +import "./index" +namespace BMapTests { + export class TestFixture { + //document: http://lbsyun.baidu.com/index.php?title=jspopular + public createMap(container: string | HTMLElement) { + navigator.geolocation.getCurrentPosition((position: Position) => { + let point = new BMap.Point(position.coords.longitude, position.coords.latitude); + let map = new BMap.Map(container); + map.centerAndZoom(point, 15); + }, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); + } + public addControl(map: BMap.Map) { + map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT })); + map.addControl(new BMap.NavigationControl()); + map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] })); + map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); + } + public addMarker(map: BMap.Map, point: BMap.Point) { + var marker = new BMap.Marker(point); + map.addOverlay(marker); + marker.setAnimation(BMAP_ANIMATION_BOUNCE); + } + } +} diff --git a/types/baidumap-web-sdk/baidumap.base.d.ts b/types/baidumap-web-sdk/baidumap.base.d.ts index 4bea8ad872..9dc07a9377 100644 --- a/types/baidumap-web-sdk/baidumap.base.d.ts +++ b/types/baidumap-web-sdk/baidumap.base.d.ts @@ -1,56 +1,56 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -declare namespace BMap { - class Point { - constructor (lng: number, lat: number) - lng: number - lat: number - equals(other: Point): boolean - } - class Pixel { - constructor (x: number, y: number) - x: number - y: number - equals(other: Pixel): boolean - } - class Size { - constructor (width: number, height: number) - width: number - height: number - equals(other: Size): boolean - } - class Bounds { - constructor (minX: number, minY: number, maxX: number, maxY: number) - constructor (sw: Point, ne: Point) - minX: number - minY: number - maxX: number - maxY: number - equals(other: Bounds): boolean - containsPoint(point: Point): boolean - containsBounds(bounds: Bounds): boolean - intersects(other: Bounds): boolean - extend(point: Point): void - getCenter(): Point - isEmpty(): boolean - getSouthWest(): Point - getNorthEast(): Point - toSpan(): Point - } +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +declare namespace BMap { + class Point { + constructor (lng: number, lat: number) + lng: number + lat: number + equals(other: Point): boolean + } + class Pixel { + constructor (x: number, y: number) + x: number + y: number + equals(other: Pixel): boolean + } + class Size { + constructor (width: number, height: number) + width: number + height: number + equals(other: Size): boolean + } + class Bounds { + constructor (minX: number, minY: number, maxX: number, maxY: number) + constructor (sw: Point, ne: Point) + minX: number + minY: number + maxX: number + maxY: number + equals(other: Bounds): boolean + containsPoint(point: Point): boolean + containsBounds(bounds: Bounds): boolean + intersects(other: Bounds): boolean + extend(point: Point): void + getCenter(): Point + isEmpty(): boolean + getSouthWest(): Point + getNorthEast(): Point + toSpan(): Point + } } \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.control.d.ts b/types/baidumap-web-sdk/baidumap.control.d.ts index 2eb4344dc9..6e3fb771be 100644 --- a/types/baidumap-web-sdk/baidumap.control.d.ts +++ b/types/baidumap-web-sdk/baidumap.control.d.ts @@ -1,132 +1,132 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - class Control { - constructor() - defaultAnchor: ControlAnchor - defaultOffset: Size - initialize(map: Map): HTMLElement - setAnchor(anchor: ControlAnchor): void - getAnchor(): ControlAnchor - setOffset(offset: Size): void - getOffset(): Size - show(): void - hide(): void - isVisible(): boolean - } - interface NavigationControlOptions { - anchor?: ControlAnchor - offset?: Size - type?: NavigationControlType - showZoomInfo?: boolean - enableGeolocation?: boolean - } - interface ScaleControlOptions { - anchor?: ControlAnchor - offset?: Size - } - interface CopyrightControlOptions { - anchor?: ControlAnchor - offset?: Size - } - type ControlAnchor = number - class OverviewMapControl extends Control { - constructor(opts: OverviewMapControlOptions) - changeView(): void - setSize(size: Size): void - getSize(): Size - onviewchanged: (event: { type: string, target: any, isOpen: boolean }) => void - onviewchanging: (event: { type: string, target: any }) => void - } - type LengthUnit = string - class MapTypeControl extends Control { - constructor(opts?: MapTypeControlOptions) - } - class NavigationControl extends Control { - constructor(opts?: NavigationControlOptions) - getType(): NavigationControlOptions - setType(type: NavigationControlType): void - } - interface OverviewMapControlOptions { - anchor?: ControlAnchor - offset?: Size - size?: Size - isOpen?: boolean - } - class CopyrightControl extends Control { - constructor(opts?: CopyrightControlOptions) - addCopyright(copyright: Copyright): void - removeCopyright(id: number): void - getCopyright(id: number): Copyright - getCopyrightCollection(): Copyright[] - } - interface MapTypeControlOptions { - type?: MapTypeControlType, - mapTypes?: MapType[] - } - type NavigationControlType = number - class ScaleControl extends Control { - constructor(opts?: ScaleControlOptions) - getUnit(): LengthUnit - setUnit(unit: LengthUnit): void - } - interface Copyright { - id?: number - content?: string - bounds?: Bounds - } - type MapTypeControlType = number - class GeolocationControl extends Control { - constructor(opts?: GeolocationControlOptions) - } - interface GeolocationControlOptions { - anchor?: ControlAnchor - offset?: Size - showAddressBar?: boolean - enableAutoLocation?: boolean - locationIcon?: Icon - } - type StatusCode = number - class PanoramaControl extends Control { - constructor() - } -} -declare const BMAP_UNIT_METRIC: BMap.LengthUnit -declare const BMAP_UNIT_IMPERIAL: BMap.LengthUnit - -declare const BMAP_ANCHOR_TOP_LEFT: BMap.ControlAnchor -declare const BMAP_ANCHOR_TOP_RIGHT: BMap.ControlAnchor -declare const BMAP_ANCHOR_BOTTOM_LEFT: BMap.ControlAnchor -declare const BMAP_ANCHOR_BOTTOM_RIGHT: BMap.ControlAnchor - -declare const BMAP_NAVIGATION_CONTROL_LARGE: BMap.NavigationControlType -declare const BMAP_NAVIGATION_CONTROL_SMALL: BMap.NavigationControlType -declare const BMAP_NAVIGATION_CONTROL_PAN: BMap.NavigationControlType -declare const BMAP_NAVIGATION_CONTROL_ZOOM: BMap.NavigationControlType - -declare const BMAP_MAPTYPE_CONTROL_HORIZONTAL: BMap.MapTypeControlType -declare const BMAP_MAPTYPE_CONTROL_DROPDOWN: BMap.MapTypeControlType -declare const BMAP_MAPTYPE_CONTROL_MAP: BMap.MapTypeControlType - -declare const BMAP_STATUS_PERMISSION_DENIED: BMap.StatusCode -declare const BMAP_STATUS_SERVICE_UNAVAILABLE: BMap.StatusCode +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + class Control { + constructor() + defaultAnchor: ControlAnchor + defaultOffset: Size + initialize(map: Map): HTMLElement + setAnchor(anchor: ControlAnchor): void + getAnchor(): ControlAnchor + setOffset(offset: Size): void + getOffset(): Size + show(): void + hide(): void + isVisible(): boolean + } + interface NavigationControlOptions { + anchor?: ControlAnchor + offset?: Size + type?: NavigationControlType + showZoomInfo?: boolean + enableGeolocation?: boolean + } + interface ScaleControlOptions { + anchor?: ControlAnchor + offset?: Size + } + interface CopyrightControlOptions { + anchor?: ControlAnchor + offset?: Size + } + type ControlAnchor = number + class OverviewMapControl extends Control { + constructor(opts: OverviewMapControlOptions) + changeView(): void + setSize(size: Size): void + getSize(): Size + onviewchanged: (event: { type: string, target: any, isOpen: boolean }) => void + onviewchanging: (event: { type: string, target: any }) => void + } + type LengthUnit = string + class MapTypeControl extends Control { + constructor(opts?: MapTypeControlOptions) + } + class NavigationControl extends Control { + constructor(opts?: NavigationControlOptions) + getType(): NavigationControlOptions + setType(type: NavigationControlType): void + } + interface OverviewMapControlOptions { + anchor?: ControlAnchor + offset?: Size + size?: Size + isOpen?: boolean + } + class CopyrightControl extends Control { + constructor(opts?: CopyrightControlOptions) + addCopyright(copyright: Copyright): void + removeCopyright(id: number): void + getCopyright(id: number): Copyright + getCopyrightCollection(): Copyright[] + } + interface MapTypeControlOptions { + type?: MapTypeControlType, + mapTypes?: MapType[] + } + type NavigationControlType = number + class ScaleControl extends Control { + constructor(opts?: ScaleControlOptions) + getUnit(): LengthUnit + setUnit(unit: LengthUnit): void + } + interface Copyright { + id?: number + content?: string + bounds?: Bounds + } + type MapTypeControlType = number + class GeolocationControl extends Control { + constructor(opts?: GeolocationControlOptions) + } + interface GeolocationControlOptions { + anchor?: ControlAnchor + offset?: Size + showAddressBar?: boolean + enableAutoLocation?: boolean + locationIcon?: Icon + } + type StatusCode = number + class PanoramaControl extends Control { + constructor() + } +} +declare const BMAP_UNIT_METRIC: BMap.LengthUnit +declare const BMAP_UNIT_IMPERIAL: BMap.LengthUnit + +declare const BMAP_ANCHOR_TOP_LEFT: BMap.ControlAnchor +declare const BMAP_ANCHOR_TOP_RIGHT: BMap.ControlAnchor +declare const BMAP_ANCHOR_BOTTOM_LEFT: BMap.ControlAnchor +declare const BMAP_ANCHOR_BOTTOM_RIGHT: BMap.ControlAnchor + +declare const BMAP_NAVIGATION_CONTROL_LARGE: BMap.NavigationControlType +declare const BMAP_NAVIGATION_CONTROL_SMALL: BMap.NavigationControlType +declare const BMAP_NAVIGATION_CONTROL_PAN: BMap.NavigationControlType +declare const BMAP_NAVIGATION_CONTROL_ZOOM: BMap.NavigationControlType + +declare const BMAP_MAPTYPE_CONTROL_HORIZONTAL: BMap.MapTypeControlType +declare const BMAP_MAPTYPE_CONTROL_DROPDOWN: BMap.MapTypeControlType +declare const BMAP_MAPTYPE_CONTROL_MAP: BMap.MapTypeControlType + +declare const BMAP_STATUS_PERMISSION_DENIED: BMap.StatusCode +declare const BMAP_STATUS_SERVICE_UNAVAILABLE: BMap.StatusCode declare const BMAP_STATUS_TIMEOUT: BMap.StatusCode \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.core.d.ts b/types/baidumap-web-sdk/baidumap.core.d.ts index f736013589..24d1aed9f0 100644 --- a/types/baidumap-web-sdk/baidumap.core.d.ts +++ b/types/baidumap-web-sdk/baidumap.core.d.ts @@ -1,154 +1,154 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - class Map { - constructor(container: string | HTMLElement, opts?: MapOptions) - enableDragging(): void - disableDragging(): void - enableScrollWheelZoom(): void - disableScrollWheelZoom(): void - enableDoubleClickZoom(): void - disableDoubleClickZoom(): void - enableKeyboard(): void - disableKeyboard(): void - enableInertialDragging(): void - disableInertialDragging(): void - enableContinuousZoom(): void - disableContinuousZoom(): void - enablePinchToZoom(): void - disablePinchToZoom(): void - enableAutoResize(): void - disableAutoResize(): void - setDefaultCursor(cursor: string): void - getDefaultCursor(): string - setDraggingCursor(cursor: string): void - getDraggingCursor(): string - setMinZoom(zoom: number): void - setMaxZoom(zoom: number): void - setMapStyle(mapStyle: MapStyle): void - setPanorama(pano: Panorama): void - disable3DBuilding(): void - getBounds(): Bounds - getCenter(): Point - getDistance(start: Point, end: Point): number - getMapType(): MapType - getSize(): Size - getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport - getZoom(): number - getPanorama(): Panorama - centerAndZoom(center: Point, zoom: number): void - panTo(center: Point, opts?: PanOptions): void - panBy(x: number, y: number, opts?: PanOptions): void - reset(): void - setCenter(center: Point | string): void - setCurrentCity(city: string): void - setMapType(mapType: MapType): void - setViewport(view: Point[], viewportOptions?: ViewportOptions): void - setZoom(zoom: number): void - highResolutionEnabled(): boolean - zoomIn(): void - zoomOut(): void - addHotspot(hotspot: Hotspot): void - removeHotspot(hotspot: Hotspot): void - clearHotspots(): void - addControl(control: Control): void - removeControl(control: Control): void - getContainer(): HTMLElement - addContextMenu(menu: ContextMenu): void - removeContextMenu(menu: ContextMenu): void - addOverlay(overlay: Overlay): void - removeOverlay(overlay: Overlay): void - clearOverlays(): void - openInfoWindow(infoWnd: InfoWindow, point: Point): void - closeInfoWindow(): void - pointToOverlayPixel(point: Point): Pixel - overlayPixelToPoint(pixel: Pixel): Point - getInfoWindow(): InfoWindow - getOverlays(): Overlay[] - getPanes(): MapPanes - addTileLayer(tileLayer: TileLayer): void - removeTileLayer(tilelayer: TileLayer): void - getTileLayer(mapType: string): TileLayer - pixelToPoint(pixel: Pixel): Point - pointToPixel(point: Point): Pixel - onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onmaptypechange: (event: { type: string, target: any }) => void - onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onmouseover: (event: { type: string, target: any }) => void - onmouseout: (event: { type: string, target: any }) => void - onmovestart: (event: { type: string, target: any }) => void - onmoving: (event: { type: string, target: any }) => void - onmoveend: (event: { type: string, target: any }) => void - onzoomstart: (event: { type: string, target: any }) => void - onzoomend: (event: { type: string, target: any }) => void - onaddoverlay: (event: { type: string, target: any }) => void - onaddcontrol: (event: { type: string, target: any }) => void - onremovecontrol: (event: { type: string, target: any }) => void - onremoveoverlay: (event: { type: string, target: any }) => void - onclearoverlays: (event: { type: string, target: any }) => void - ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onaddtilelayer: (event: { type: string, target: any }) => void - onremovetilelayer: (event: { type: string, target: any }) => void - onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void - onresize: (event: { type: string, target: any, size: Size }) => void - onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void - onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void - onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void - ontilesloaded: (event: { type: string, target: any }) => void - ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - } - interface PanOptions { - noAnimation?: boolean - } - interface MapOptions { - minZoom?: number - maxZoom?: number - mapType?: MapType - enableHighResolution?: boolean - enableAutoResize?: boolean - enableMapClick?: boolean - } - interface Viewport { - center: Point - zoom: number - } - interface ViewportOptions { - enableAnimation?: boolean - margins?: number[] - zoomFactor?: number - delay?: number - } - type APIVersion = number - interface MapStyle { - features: any[] - style: string - } -} +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + class Map { + constructor(container: string | HTMLElement, opts?: MapOptions) + enableDragging(): void + disableDragging(): void + enableScrollWheelZoom(): void + disableScrollWheelZoom(): void + enableDoubleClickZoom(): void + disableDoubleClickZoom(): void + enableKeyboard(): void + disableKeyboard(): void + enableInertialDragging(): void + disableInertialDragging(): void + enableContinuousZoom(): void + disableContinuousZoom(): void + enablePinchToZoom(): void + disablePinchToZoom(): void + enableAutoResize(): void + disableAutoResize(): void + setDefaultCursor(cursor: string): void + getDefaultCursor(): string + setDraggingCursor(cursor: string): void + getDraggingCursor(): string + setMinZoom(zoom: number): void + setMaxZoom(zoom: number): void + setMapStyle(mapStyle: MapStyle): void + setPanorama(pano: Panorama): void + disable3DBuilding(): void + getBounds(): Bounds + getCenter(): Point + getDistance(start: Point, end: Point): number + getMapType(): MapType + getSize(): Size + getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport + getZoom(): number + getPanorama(): Panorama + centerAndZoom(center: Point, zoom: number): void + panTo(center: Point, opts?: PanOptions): void + panBy(x: number, y: number, opts?: PanOptions): void + reset(): void + setCenter(center: Point | string): void + setCurrentCity(city: string): void + setMapType(mapType: MapType): void + setViewport(view: Point[], viewportOptions?: ViewportOptions): void + setZoom(zoom: number): void + highResolutionEnabled(): boolean + zoomIn(): void + zoomOut(): void + addHotspot(hotspot: Hotspot): void + removeHotspot(hotspot: Hotspot): void + clearHotspots(): void + addControl(control: Control): void + removeControl(control: Control): void + getContainer(): HTMLElement + addContextMenu(menu: ContextMenu): void + removeContextMenu(menu: ContextMenu): void + addOverlay(overlay: Overlay): void + removeOverlay(overlay: Overlay): void + clearOverlays(): void + openInfoWindow(infoWnd: InfoWindow, point: Point): void + closeInfoWindow(): void + pointToOverlayPixel(point: Point): Pixel + overlayPixelToPoint(pixel: Pixel): Point + getInfoWindow(): InfoWindow + getOverlays(): Overlay[] + getPanes(): MapPanes + addTileLayer(tileLayer: TileLayer): void + removeTileLayer(tilelayer: TileLayer): void + getTileLayer(mapType: string): TileLayer + pixelToPoint(pixel: Pixel): Point + pointToPixel(point: Point): Pixel + onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onmaptypechange: (event: { type: string, target: any }) => void + onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onmouseover: (event: { type: string, target: any }) => void + onmouseout: (event: { type: string, target: any }) => void + onmovestart: (event: { type: string, target: any }) => void + onmoving: (event: { type: string, target: any }) => void + onmoveend: (event: { type: string, target: any }) => void + onzoomstart: (event: { type: string, target: any }) => void + onzoomend: (event: { type: string, target: any }) => void + onaddoverlay: (event: { type: string, target: any }) => void + onaddcontrol: (event: { type: string, target: any }) => void + onremovecontrol: (event: { type: string, target: any }) => void + onremoveoverlay: (event: { type: string, target: any }) => void + onclearoverlays: (event: { type: string, target: any }) => void + ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onaddtilelayer: (event: { type: string, target: any }) => void + onremovetilelayer: (event: { type: string, target: any }) => void + onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void + onresize: (event: { type: string, target: any, size: Size }) => void + onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void + onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void + onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void + ontilesloaded: (event: { type: string, target: any }) => void + ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + } + interface PanOptions { + noAnimation?: boolean + } + interface MapOptions { + minZoom?: number + maxZoom?: number + mapType?: MapType + enableHighResolution?: boolean + enableAutoResize?: boolean + enableMapClick?: boolean + } + interface Viewport { + center: Point + zoom: number + } + interface ViewportOptions { + enableAnimation?: boolean + margins?: number[] + zoomFactor?: number + delay?: number + } + type APIVersion = number + interface MapStyle { + features: any[] + style: string + } +} declare const BMAP_API_VERSION: BMap.APIVersion \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.maplayer.d.ts b/types/baidumap-web-sdk/baidumap.maplayer.d.ts index 4ed2230bfb..244fff0c7b 100644 --- a/types/baidumap-web-sdk/baidumap.maplayer.d.ts +++ b/types/baidumap-web-sdk/baidumap.maplayer.d.ts @@ -1,82 +1,82 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class TileLayer { - constructor(opts?: TileLayerOptions) - getTilesUrl(tileCoord: Pixel, zoom: number): string - getCopyright(): Copyright - isTransparentPng(): boolean - } - interface TileLayerOptions { - transparentPng?: boolean - tileUrlTemplate?: string - copyright?: Copyright - zIndex?: number - } - class TrafficLayer extends TileLayer { - constructor(opts?: TrafficLayerOptions) - } - interface TrafficLayerOptions { - predictDate?: PredictDate - } - interface PredictDate { - weekday: number - hour: number - } - class CustomLayer extends TileLayer { - constructor(opts: CustomLayerOptions) - onhotspotclick: (event: { type: string, target: any, content: any }) => void - } - interface Custompoi { - poiId: string - databoxId: string - title: string - address: string - phoneNumber: string - postcode: string - provinceCode: number - province: string - cityCode: number - city: string - districtCode: number - district: string - point: Point - tags: string[] - typeId: number - extendedData: any - } - class PanoramaCoverageLayer extends TileLayer { - constructor() - } - interface CustomLayerOptions { - databoxId?: string - geotableId?: string - q?: string - tags?: string - filter?: string - pointDensityType?: PointDensityType - } - type PointDensityType = number -} - -declare const BMAP_POINT_DENSITY_HIGH: BMap.PointDensityType -declare const BMAP_POINT_DENSITY_MEDIUM: BMap.PointDensityType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class TileLayer { + constructor(opts?: TileLayerOptions) + getTilesUrl(tileCoord: Pixel, zoom: number): string + getCopyright(): Copyright + isTransparentPng(): boolean + } + interface TileLayerOptions { + transparentPng?: boolean + tileUrlTemplate?: string + copyright?: Copyright + zIndex?: number + } + class TrafficLayer extends TileLayer { + constructor(opts?: TrafficLayerOptions) + } + interface TrafficLayerOptions { + predictDate?: PredictDate + } + interface PredictDate { + weekday: number + hour: number + } + class CustomLayer extends TileLayer { + constructor(opts: CustomLayerOptions) + onhotspotclick: (event: { type: string, target: any, content: any }) => void + } + interface Custompoi { + poiId: string + databoxId: string + title: string + address: string + phoneNumber: string + postcode: string + provinceCode: number + province: string + cityCode: number + city: string + districtCode: number + district: string + point: Point + tags: string[] + typeId: number + extendedData: any + } + class PanoramaCoverageLayer extends TileLayer { + constructor() + } + interface CustomLayerOptions { + databoxId?: string + geotableId?: string + q?: string + tags?: string + filter?: string + pointDensityType?: PointDensityType + } + type PointDensityType = number +} + +declare const BMAP_POINT_DENSITY_HIGH: BMap.PointDensityType +declare const BMAP_POINT_DENSITY_MEDIUM: BMap.PointDensityType declare const BMAP_POINT_DENSITY_LOW: BMap.PointDensityType \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.maptype.d.ts b/types/baidumap-web-sdk/baidumap.maptype.d.ts index 804b200cb1..01056212bc 100644 --- a/types/baidumap-web-sdk/baidumap.maptype.d.ts +++ b/types/baidumap-web-sdk/baidumap.maptype.d.ts @@ -1,51 +1,51 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class MapType { - constructor(name: string, layers: TileLayer | TileLayer[], opts?: MapTypeOptions) - getName(): string - getTileLayer(): TileLayer - getMinZoom(): number - getMaxZoom(): number - getProjection(): Projection - getTextColor(): string - getTips(): string - } - interface MapTypeOptions { - minZoom?: number - maxZoom?: number - errorImageUrl?: string - textColor?: number - tips?: string - } - interface Projection { - lngLatToPoint(lngLat: Point): Pixel - pointToLngLat(point: Pixel): Point - } - interface MercatorProjection extends Projection { - } - interface PerspectiveProjection extends Projection { - } -} -declare const BMAP_NORMAL_MAP: BMap.MapType -declare const BMAP_PERSPECTIVE_MAP: BMap.MapType -declare const BMAP_SATELLITE_MAP: BMap.MapType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class MapType { + constructor(name: string, layers: TileLayer | TileLayer[], opts?: MapTypeOptions) + getName(): string + getTileLayer(): TileLayer + getMinZoom(): number + getMaxZoom(): number + getProjection(): Projection + getTextColor(): string + getTips(): string + } + interface MapTypeOptions { + minZoom?: number + maxZoom?: number + errorImageUrl?: string + textColor?: number + tips?: string + } + interface Projection { + lngLatToPoint(lngLat: Point): Pixel + pointToLngLat(point: Pixel): Point + } + interface MercatorProjection extends Projection { + } + interface PerspectiveProjection extends Projection { + } +} +declare const BMAP_NORMAL_MAP: BMap.MapType +declare const BMAP_PERSPECTIVE_MAP: BMap.MapType +declare const BMAP_SATELLITE_MAP: BMap.MapType declare const BMAP_HYBRID_MAP: BMap.MapType \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.overlay.d.ts b/types/baidumap-web-sdk/baidumap.overlay.d.ts index 295c30ff8a..d723ac5e48 100644 --- a/types/baidumap-web-sdk/baidumap.overlay.d.ts +++ b/types/baidumap-web-sdk/baidumap.overlay.d.ts @@ -1,438 +1,438 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - interface Overlay { - initialize?(map: Map): HTMLElement - isVisible?(): boolean - draw?(): void - show?(): void - hide?(): void - } - type SymbolShapeType = number - interface PolylineOptions { - strokeColor?: string - strokeWeight?: number - strokeOpacity?: number - strokeStyle?: string - enableMassClear?: boolean - enableEditing?: boolean - enableClicking?: boolean - } - interface GroundOverlayOptions { - opacity?: number - imageURL?: string - displayOnMinLevel?: number - displayOnMaxLevel?: number - } - class Marker implements Overlay { - constructor(point: Point, opts?: MarkerOptions) - openInfoWindow(infoWnd: InfoWindow): void - closeInfoWindow(): void - setIcon(icon: Icon): void - getIcon(): Icon - setPosition(position: Point): void - getPosition(): Point - setOffset(offset: Size): void - getOffset(): Size - setLabel(label: Label): void - getLabel(): Label - setTitle(title: string): void - getTitle(): string - setTop(isTop: boolean): void - enableDragging(): void - disableDragging(): void - enableMassClear(): void - disableMassClear(): void - setZIndex(zIndex: number): void - getMap(): Map - addContextMenu(menu: ContextMenu): void - removeContextMenu(menu: ContextMenu): void - setAnimation(animation?: Animation): void - setRotation(rotation: number): void - getRotation(): number - setShadow(shadow: Icon): void - getShadow(): void - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - oninfowindowclose: (event: { type: string, target: any }) => void - oninfowindowopen: (event: { type: string, target: any }) => void - ondragstart: (event: { type: string, target: any }) => void - ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onrightclick: (event: { type: string, target: any }) => void - } - interface SymbolOptions { - anchor?: Size - fillColor?: string - fillOpacity?: number - scale?: number - rotation?: number - strokeColor?: string - strokeOpacity?: number - strokeWeight?: number - } - class IconSequence { - constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean) - } - class PointCollection implements Overlay { - constructor(points: Point[], opts?: PointCollectionOption) - setPoints(points: Point[]): void - setStyles(styles: PointCollectionOption): void - clear(): void - onclick: (event: { type: string, target: any, point: Point }) => void - onmouseover: (event: { type: string, target: any, point: Point }) => void - onmouseout: (event: { type: string, target: any, point: Point }) => void - } - interface MarkerOptions { - offset?: Size - icon?: Icon - enableMassClear?: boolean - enableDragging?: boolean - enableClicking?: boolean - raiseOnDrag?: boolean - draggingCursor?: string - rotation?: number - shadow?: Icon - title?: string - } - class InfoWindow implements Overlay { - constructor(content: string | HTMLElement, opts?: InfoWindowOptions) - setWidth(width: number): void - setHeight(height: number): void - redraw(): void - setTitle(title: string | HTMLElement): void - getTitle(): string | HTMLElement - setContent(content: string | HTMLElement): void - getContent(): string | HTMLElement - getPosition(): Point - enableMaximize(): void - disableMaximize(): void - isOpen(): boolean - setMaxContent(content: string): void - maximize(): void - restore(): void - enableAutoPan(): void - disableAutoPan(): void - enableCloseOnClick(): void - disableCloseOnClick(): void - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclose: (event: { type: string, target: any, point: Point }) => void - onopen: (event: { type: string, target: any, point: Point }) => void - onmaximize: (event: { type: string, target: any }) => void - onrestore: (event: { type: string, target: any }) => void - onclickclose: (event: { type: string, target: any }) => void - } - class Polygon implements Overlay { - constructor(points: Array, opts?: PolygonOptions) - setPath(path: Point[]): void - getPath(): Point[] - setStrokeColor(color: string): void - getStrokeColor(): string - setFillColor(color: string): void - getFillColor(): string - setStrokeOpacity(opacity: number): void - getStrokeOpacity(): number - setFillOpacity(opacity: number): void - getFillOpacity(): number - setStrokeWeight(weight: number): void - getStrokeWeight(): number - setStrokeStyle(style: string): void - getStrokeStyle(): string - getBounds(): Bounds - enableEditing(): void - disableEditing(): void - enableMassClear(): void - disableMassClear(): void - setPointAt(index: number, point: Point): void - setPositionAt(index: number, point: Point): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - onlineupdate: (event: { type: string, target: any }) => void - } - interface PointCollectionOption { - shape?: ShapeType - color?: string - size?: SizeType - } - type Animation = number - interface InfoWindowOptions { - width?: number - height?: number - maxWidth?: number - offset?: Size - title?: string - enableAutoPan?: boolean - enableCloseOnClick?: boolean - enableMessage?: boolean - message?: string - } - interface PolygonOptions { - strokeColor?: string - fillColor?: string - strokeWeight?: number - strokeOpacity?: number - fillOpacity?: number - strokeStyle?: number - enableMassClear?: boolean - enableEditing?: boolean - enableClicking?: boolean - } - type ShapeType = number - class Icon implements Overlay { - constructor(url: string, size: Size, opts?: IconOptions) - anchor: Size - size: Size - imageOffset: Size - imageSize: Size - imageUrl: Size - infoWindowAnchor: Size - printImageUrl: string - setImageUrl(imageUrl: string): void - setSize(size: Size): void - setImageSize(offset: Size): void - setAnchor(anchor: Size): void - setImageOffset(offset: Size): void - setInfoWindowAnchor(anchor: Size): void - setPrintImageUrl(url: string): void - } - class Label implements Overlay { - constructor(content: string, opts?: LabelOptions) - setStyle(styles: Object): void - setContent(content: string): void - setPosition(position: Point): void - getPosition(): Point - setOffset(offset: Size): void - getOffset(): Size - setTitle(title: string): void - getTitle(): string - enableMassClear(): void - disableMassClear(): void - setZIndex(zIndex: number): void - setPosition(position: Point): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any }) => void - onmousedown: (event: { type: string, target: any }) => void - onmouseup: (event: { type: string, target: any }) => void - onmouseout: (event: { type: string, target: any }) => void - onmouseover: (event: { type: string, target: any }) => void - onremove: (event: { type: string, target: any }) => void - onrightclick: (event: { type: string, target: any }) => void - } - class Circle implements Overlay { - constructor(center: Point, radius: number, opts?: CircleOptions) - setCenter(center: Point): void - getCenter(): Point - setRadius(radius: number): void - getRadius(): number - getBounds(): Bounds - setStrokeColor(color: string): void - getStrokeColor(): string - setFillColor(color: string): void - getFillColor(): string - setStrokeOpacity(opacity: number): void - getStrokeOpacity(): number - setFillOpacity(opacity: number): void - getFillOpacity(): number - setStrokeWeight(weight: number): void - getStrokeWeight(): number - setStrokeStyle(style: string): void - getStrokeStyle(): string - getBounds(): Bounds - enableEditing(): void - disableEditing(): void - enableMassClear(): void - disableMassClear(): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - onlineupdate: (event: { type: string, target: any }) => void - } - type SizeType = number - interface IconOptions { - anchor?: Size - imageOffset?: Size - infoWindowAnchor?: Size - printImageUrl?: string - } - interface LabelOptions { - offset?: Size - position?: Point - enableMassClear?: boolean - } - interface CircleOptions { - strokeColor?: string - fillColor?: string - strokeWeight?: number - strokeOpacity?: number - fillOpacity?: number - strokeStyle?: string - enableMassClear?: boolean - enableEditing?: boolean - enableClicking?: boolean - } - class Hotspot implements Overlay { - constructor(position: Point, opts?: HotspotOptions) - setPosition(position: Point): void - getPosition(): Point - setText(text: string): void - getText(): string - setUserData(data: any): void - getUserData(): any - } - class Symbol implements Overlay { - constructor(path: string | SymbolShapeType, opts?: SymbolOptions) - setPath(path: string | SymbolShapeType): void - setAnchor(anchor: Size): void - setRotation(rotation: number): void - setScale(scale: number): void - setStrokeWeight(strokeWeight: number): void - setStrokeColor(color: string): void - setStrokeOpacity(opacity: number): void - setFillOpacity(opacity: number): void - setFillColor(color: string): void - } - class Polyline implements Overlay { - constructor(points: Point[], opts?: PolylineOptions) - setPath(path: Point[]): void - getPath(): Point[] - setStrokeColor(color: string): void - getStrokeColor(): string - setFillColor(color: string): void - getFillColor(): string - setStrokeOpacity(opacity: number): void - getStrokeOpacity(): number - setFillOpacity(opacity: number): void - getFillOpacity(): number - setStrokeWeight(weight: number): void - getStrokeWeight(): number - setStrokeStyle(style: string): void - getStrokeStyle(): string - getBounds(): Bounds - enableEditing(): void - disableEditing(): void - enableMassClear(): void - disableMassClear(): void - setPointAt(index: number, point: Point): void - setPositionAt(index: number, point: Point): void - getMap(): Map - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onremove: (event: { type: string, target: any }) => void - onlineupdate: (event: { type: string, target: any }) => void - } - class GroundOverlay implements Overlay { - constructor(bounds: Bounds, opts?: GroundOverlayOptions) - setBounds(bounds: Bounds): void - getBounds(): Bounds - setOpacity(opcity: number): void - getOpacity(): number - setImageURL(url: string): void - getImageURL(): string - setDisplayOnMinLevel(level: number): void - getDisplayOnMinLevel(): number - setDispalyOnMaxLevel(level: number): void - getDispalyOnMaxLevel(): number - onclick: (event: { type: string, target: any }) => void - ondblclick: (event: { type: string, target: any }) => void - } - interface HotspotOptions { - text?: string - offsets?: number[] - userData?: any - minZoom?: number - maxZoom?: number - } - interface MapPanes { - floatPane?: HTMLElement - markerMouseTarget?: HTMLElement - floatShadow?: HTMLElement - labelPane?: HTMLElement - markerPane?: HTMLElement - markerShadow?: HTMLElement - mapPane?: HTMLElement - } -} - -declare const BMap_Symbol_SHAPE_CIRCLE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_RECTANGLE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_RHOMBUS: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_STAR: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_BACKWARD_CLOSED_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_FORWARD_CLOSED_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_BACKWARD_OPEN_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_FORWARD_OPEN_ARROW: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_POINT: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_PLANE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_CAMERA: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_WARNING: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_SMILE: BMap.SymbolShapeType -declare const BMap_Symbol_SHAPE_CLOCK: BMap.SymbolShapeType - - -declare const BMAP_ANIMATION_DROP: BMap.Animation -declare const BMAP_ANIMATION_BOUNCE: BMap.Animation - -declare const BMAP_POINT_SHAPE_CIRCLE: BMap.ShapeType -declare const APE_STAR: BMap.ShapeType -declare const APE_SQUARE: BMap.ShapeType -declare const APE_RHOMBUS: BMap.ShapeType -declare const APE_WATERDROP: BMap.ShapeType - -declare const BMAP_POINT_SIZE_TINY: BMap.SizeType -declare const BMAP_POINT_SIZE_SMALLER: BMap.SizeType -declare const BMAP_POINT_SIZE_SMALL: BMap.SizeType -declare const BMAP_POINT_SIZE_NORMAL: BMap.SizeType -declare const BMAP_POINT_SIZE_BIG: BMap.SizeType -declare const BMAP_POINT_SIZE_BIGGER: BMap.SizeType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + interface Overlay { + initialize?(map: Map): HTMLElement + isVisible?(): boolean + draw?(): void + show?(): void + hide?(): void + } + type SymbolShapeType = number + interface PolylineOptions { + strokeColor?: string + strokeWeight?: number + strokeOpacity?: number + strokeStyle?: string + enableMassClear?: boolean + enableEditing?: boolean + enableClicking?: boolean + } + interface GroundOverlayOptions { + opacity?: number + imageURL?: string + displayOnMinLevel?: number + displayOnMaxLevel?: number + } + class Marker implements Overlay { + constructor(point: Point, opts?: MarkerOptions) + openInfoWindow(infoWnd: InfoWindow): void + closeInfoWindow(): void + setIcon(icon: Icon): void + getIcon(): Icon + setPosition(position: Point): void + getPosition(): Point + setOffset(offset: Size): void + getOffset(): Size + setLabel(label: Label): void + getLabel(): Label + setTitle(title: string): void + getTitle(): string + setTop(isTop: boolean): void + enableDragging(): void + disableDragging(): void + enableMassClear(): void + disableMassClear(): void + setZIndex(zIndex: number): void + getMap(): Map + addContextMenu(menu: ContextMenu): void + removeContextMenu(menu: ContextMenu): void + setAnimation(animation?: Animation): void + setRotation(rotation: number): void + getRotation(): number + setShadow(shadow: Icon): void + getShadow(): void + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + oninfowindowclose: (event: { type: string, target: any }) => void + oninfowindowopen: (event: { type: string, target: any }) => void + ondragstart: (event: { type: string, target: any }) => void + ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onrightclick: (event: { type: string, target: any }) => void + } + interface SymbolOptions { + anchor?: Size + fillColor?: string + fillOpacity?: number + scale?: number + rotation?: number + strokeColor?: string + strokeOpacity?: number + strokeWeight?: number + } + class IconSequence { + constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean) + } + class PointCollection implements Overlay { + constructor(points: Point[], opts?: PointCollectionOption) + setPoints(points: Point[]): void + setStyles(styles: PointCollectionOption): void + clear(): void + onclick: (event: { type: string, target: any, point: Point }) => void + onmouseover: (event: { type: string, target: any, point: Point }) => void + onmouseout: (event: { type: string, target: any, point: Point }) => void + } + interface MarkerOptions { + offset?: Size + icon?: Icon + enableMassClear?: boolean + enableDragging?: boolean + enableClicking?: boolean + raiseOnDrag?: boolean + draggingCursor?: string + rotation?: number + shadow?: Icon + title?: string + } + class InfoWindow implements Overlay { + constructor(content: string | HTMLElement, opts?: InfoWindowOptions) + setWidth(width: number): void + setHeight(height: number): void + redraw(): void + setTitle(title: string | HTMLElement): void + getTitle(): string | HTMLElement + setContent(content: string | HTMLElement): void + getContent(): string | HTMLElement + getPosition(): Point + enableMaximize(): void + disableMaximize(): void + isOpen(): boolean + setMaxContent(content: string): void + maximize(): void + restore(): void + enableAutoPan(): void + disableAutoPan(): void + enableCloseOnClick(): void + disableCloseOnClick(): void + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclose: (event: { type: string, target: any, point: Point }) => void + onopen: (event: { type: string, target: any, point: Point }) => void + onmaximize: (event: { type: string, target: any }) => void + onrestore: (event: { type: string, target: any }) => void + onclickclose: (event: { type: string, target: any }) => void + } + class Polygon implements Overlay { + constructor(points: Array, opts?: PolygonOptions) + setPath(path: Point[]): void + getPath(): Point[] + setStrokeColor(color: string): void + getStrokeColor(): string + setFillColor(color: string): void + getFillColor(): string + setStrokeOpacity(opacity: number): void + getStrokeOpacity(): number + setFillOpacity(opacity: number): void + getFillOpacity(): number + setStrokeWeight(weight: number): void + getStrokeWeight(): number + setStrokeStyle(style: string): void + getStrokeStyle(): string + getBounds(): Bounds + enableEditing(): void + disableEditing(): void + enableMassClear(): void + disableMassClear(): void + setPointAt(index: number, point: Point): void + setPositionAt(index: number, point: Point): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + onlineupdate: (event: { type: string, target: any }) => void + } + interface PointCollectionOption { + shape?: ShapeType + color?: string + size?: SizeType + } + type Animation = number + interface InfoWindowOptions { + width?: number + height?: number + maxWidth?: number + offset?: Size + title?: string + enableAutoPan?: boolean + enableCloseOnClick?: boolean + enableMessage?: boolean + message?: string + } + interface PolygonOptions { + strokeColor?: string + fillColor?: string + strokeWeight?: number + strokeOpacity?: number + fillOpacity?: number + strokeStyle?: number + enableMassClear?: boolean + enableEditing?: boolean + enableClicking?: boolean + } + type ShapeType = number + class Icon implements Overlay { + constructor(url: string, size: Size, opts?: IconOptions) + anchor: Size + size: Size + imageOffset: Size + imageSize: Size + imageUrl: Size + infoWindowAnchor: Size + printImageUrl: string + setImageUrl(imageUrl: string): void + setSize(size: Size): void + setImageSize(offset: Size): void + setAnchor(anchor: Size): void + setImageOffset(offset: Size): void + setInfoWindowAnchor(anchor: Size): void + setPrintImageUrl(url: string): void + } + class Label implements Overlay { + constructor(content: string, opts?: LabelOptions) + setStyle(styles: Object): void + setContent(content: string): void + setPosition(position: Point): void + getPosition(): Point + setOffset(offset: Size): void + getOffset(): Size + setTitle(title: string): void + getTitle(): string + enableMassClear(): void + disableMassClear(): void + setZIndex(zIndex: number): void + setPosition(position: Point): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any }) => void + onmousedown: (event: { type: string, target: any }) => void + onmouseup: (event: { type: string, target: any }) => void + onmouseout: (event: { type: string, target: any }) => void + onmouseover: (event: { type: string, target: any }) => void + onremove: (event: { type: string, target: any }) => void + onrightclick: (event: { type: string, target: any }) => void + } + class Circle implements Overlay { + constructor(center: Point, radius: number, opts?: CircleOptions) + setCenter(center: Point): void + getCenter(): Point + setRadius(radius: number): void + getRadius(): number + getBounds(): Bounds + setStrokeColor(color: string): void + getStrokeColor(): string + setFillColor(color: string): void + getFillColor(): string + setStrokeOpacity(opacity: number): void + getStrokeOpacity(): number + setFillOpacity(opacity: number): void + getFillOpacity(): number + setStrokeWeight(weight: number): void + getStrokeWeight(): number + setStrokeStyle(style: string): void + getStrokeStyle(): string + getBounds(): Bounds + enableEditing(): void + disableEditing(): void + enableMassClear(): void + disableMassClear(): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + onlineupdate: (event: { type: string, target: any }) => void + } + type SizeType = number + interface IconOptions { + anchor?: Size + imageOffset?: Size + infoWindowAnchor?: Size + printImageUrl?: string + } + interface LabelOptions { + offset?: Size + position?: Point + enableMassClear?: boolean + } + interface CircleOptions { + strokeColor?: string + fillColor?: string + strokeWeight?: number + strokeOpacity?: number + fillOpacity?: number + strokeStyle?: string + enableMassClear?: boolean + enableEditing?: boolean + enableClicking?: boolean + } + class Hotspot implements Overlay { + constructor(position: Point, opts?: HotspotOptions) + setPosition(position: Point): void + getPosition(): Point + setText(text: string): void + getText(): string + setUserData(data: any): void + getUserData(): any + } + class Symbol implements Overlay { + constructor(path: string | SymbolShapeType, opts?: SymbolOptions) + setPath(path: string | SymbolShapeType): void + setAnchor(anchor: Size): void + setRotation(rotation: number): void + setScale(scale: number): void + setStrokeWeight(strokeWeight: number): void + setStrokeColor(color: string): void + setStrokeOpacity(opacity: number): void + setFillOpacity(opacity: number): void + setFillColor(color: string): void + } + class Polyline implements Overlay { + constructor(points: Point[], opts?: PolylineOptions) + setPath(path: Point[]): void + getPath(): Point[] + setStrokeColor(color: string): void + getStrokeColor(): string + setFillColor(color: string): void + getFillColor(): string + setStrokeOpacity(opacity: number): void + getStrokeOpacity(): number + setFillOpacity(opacity: number): void + getFillOpacity(): number + setStrokeWeight(weight: number): void + getStrokeWeight(): number + setStrokeStyle(style: string): void + getStrokeStyle(): string + getBounds(): Bounds + enableEditing(): void + disableEditing(): void + enableMassClear(): void + disableMassClear(): void + setPointAt(index: number, point: Point): void + setPositionAt(index: number, point: Point): void + getMap(): Map + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onremove: (event: { type: string, target: any }) => void + onlineupdate: (event: { type: string, target: any }) => void + } + class GroundOverlay implements Overlay { + constructor(bounds: Bounds, opts?: GroundOverlayOptions) + setBounds(bounds: Bounds): void + getBounds(): Bounds + setOpacity(opcity: number): void + getOpacity(): number + setImageURL(url: string): void + getImageURL(): string + setDisplayOnMinLevel(level: number): void + getDisplayOnMinLevel(): number + setDispalyOnMaxLevel(level: number): void + getDispalyOnMaxLevel(): number + onclick: (event: { type: string, target: any }) => void + ondblclick: (event: { type: string, target: any }) => void + } + interface HotspotOptions { + text?: string + offsets?: number[] + userData?: any + minZoom?: number + maxZoom?: number + } + interface MapPanes { + floatPane?: HTMLElement + markerMouseTarget?: HTMLElement + floatShadow?: HTMLElement + labelPane?: HTMLElement + markerPane?: HTMLElement + markerShadow?: HTMLElement + mapPane?: HTMLElement + } +} + +declare const BMap_Symbol_SHAPE_CIRCLE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_RECTANGLE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_RHOMBUS: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_STAR: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_BACKWARD_CLOSED_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_FORWARD_CLOSED_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_BACKWARD_OPEN_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_FORWARD_OPEN_ARROW: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_POINT: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_PLANE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_CAMERA: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_WARNING: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_SMILE: BMap.SymbolShapeType +declare const BMap_Symbol_SHAPE_CLOCK: BMap.SymbolShapeType + + +declare const BMAP_ANIMATION_DROP: BMap.Animation +declare const BMAP_ANIMATION_BOUNCE: BMap.Animation + +declare const BMAP_POINT_SHAPE_CIRCLE: BMap.ShapeType +declare const APE_STAR: BMap.ShapeType +declare const APE_SQUARE: BMap.ShapeType +declare const APE_RHOMBUS: BMap.ShapeType +declare const APE_WATERDROP: BMap.ShapeType + +declare const BMAP_POINT_SIZE_TINY: BMap.SizeType +declare const BMAP_POINT_SIZE_SMALLER: BMap.SizeType +declare const BMAP_POINT_SIZE_SMALL: BMap.SizeType +declare const BMAP_POINT_SIZE_NORMAL: BMap.SizeType +declare const BMAP_POINT_SIZE_BIG: BMap.SizeType +declare const BMAP_POINT_SIZE_BIGGER: BMap.SizeType declare const BMAP_POINT_SIZE_HUGE: BMap.SizeType \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.panorama.d.ts b/types/baidumap-web-sdk/baidumap.panorama.d.ts index 6b3e10f6b2..f087732fb4 100644 --- a/types/baidumap-web-sdk/baidumap.panorama.d.ts +++ b/types/baidumap-web-sdk/baidumap.panorama.d.ts @@ -1,121 +1,121 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class Panorama { - constructor(container: string | HTMLElement, opts?: PanoramaOptions) - getLinks(): PanoramaLink[] - getId(): string - getPosition(): Point - getPov(): PanoramaPov - getZoom(): number - setId(id: string): void - setPosition(position: Point): void - setPov(pov: PanoramaPov): void - setZoom(zoom: number): void - enableScrollWheelZoom(): void - disableScrollWheelZoom(): void - show(): void - hide(): void - addOverlay(overlay: PanoramaLabel): void - removeOverlay(overlay: PanoramaLabel): void - getSceneType(): PanoramaSceneType - setOptions(opts?: PanoramaOptions): void - setPanoramaPOIType(): PanoramaPOIType - onposition_changed: () => void - onlinks_changed: () => void - onpov_changed: () => void - onzoom_changed: () => void - onscene_type_changed: () => void - } - - interface PanoramaOptions { - navigationControl?: boolean - linksControl?: boolean - indoorSceneSwitchControl?: boolean - albumsControl?: boolean - albumsControlOptions?: AlbumsControlOptions - } - interface PanoramaLink { - description: string - heading: string - id: string - } - interface PanoramaPov { - heading: number - pitch: number - } - class PanoramaService { - constructor() - getPanoramaById(id: string, callback: (data: PanoramaData) => void): void - getPanoramaByLocation(point: Point, radius?: number, callback?: (data: PanoramaData) => void): void - } - interface PanoramaData { - id: string - description: string - links: PanoramaLink[] - position: Point - tiles: PanoramaTileData - } - interface PanoramaTileData { - centerHeading: number - tileSize: Size - worldSize: Size - } - class PanoramaLabel { - constructor(content: string, opts?: PanoramaLabelOptions) - setPosition(position: Point): void - getPosition(): Point - getPov(): PanoramaPov - setContent(content: string): void - getContent(): string - show(): void - hide(): void - setAltitude(altitude: number): void - getAltitude(): number - addEventListener(event: string, handler: Function): void - removeEventListener(event: string, handler: Function): void - onclick: (event: { type: string, target: any }) => void - onmouseover: (event: { type: string, target: any }) => void - onmouseout: (event: { type: string, target: any }) => void - onremove: (event: { type: string, target: any }) => void - } - interface PanoramaLabelOptions { - position?: Point - altitude?: number - } - interface AlbumsControlOptions { - anchor?: ControlAnchor - offset?: Size - maxWidth?: number | string - imageHeight?: number - } - type PanoramaSceneType = string - type PanoramaPOIType = string -} -declare const BMAP_PANORAMA_INDOOR_SCENE: string -declare const BMAP_PANORAMA_STREET_SCENE: string - -declare const BMAP_PANORAMA_POI_HOTEL: string -declare const BMAP_PANORAMA_POI_CATERING: string -declare const BMAP_PANORAMA_POI_MOVIE: string -declare const BMAP_PANORAMA_POI_TRANSIT: string -declare const BMAP_PANORAMA_POI_INDOOR_SCENE: string -declare const BMAP_PANORAMA_POI_NONE: string +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class Panorama { + constructor(container: string | HTMLElement, opts?: PanoramaOptions) + getLinks(): PanoramaLink[] + getId(): string + getPosition(): Point + getPov(): PanoramaPov + getZoom(): number + setId(id: string): void + setPosition(position: Point): void + setPov(pov: PanoramaPov): void + setZoom(zoom: number): void + enableScrollWheelZoom(): void + disableScrollWheelZoom(): void + show(): void + hide(): void + addOverlay(overlay: PanoramaLabel): void + removeOverlay(overlay: PanoramaLabel): void + getSceneType(): PanoramaSceneType + setOptions(opts?: PanoramaOptions): void + setPanoramaPOIType(): PanoramaPOIType + onposition_changed: () => void + onlinks_changed: () => void + onpov_changed: () => void + onzoom_changed: () => void + onscene_type_changed: () => void + } + + interface PanoramaOptions { + navigationControl?: boolean + linksControl?: boolean + indoorSceneSwitchControl?: boolean + albumsControl?: boolean + albumsControlOptions?: AlbumsControlOptions + } + interface PanoramaLink { + description: string + heading: string + id: string + } + interface PanoramaPov { + heading: number + pitch: number + } + class PanoramaService { + constructor() + getPanoramaById(id: string, callback: (data: PanoramaData) => void): void + getPanoramaByLocation(point: Point, radius?: number, callback?: (data: PanoramaData) => void): void + } + interface PanoramaData { + id: string + description: string + links: PanoramaLink[] + position: Point + tiles: PanoramaTileData + } + interface PanoramaTileData { + centerHeading: number + tileSize: Size + worldSize: Size + } + class PanoramaLabel { + constructor(content: string, opts?: PanoramaLabelOptions) + setPosition(position: Point): void + getPosition(): Point + getPov(): PanoramaPov + setContent(content: string): void + getContent(): string + show(): void + hide(): void + setAltitude(altitude: number): void + getAltitude(): number + addEventListener(event: string, handler: Function): void + removeEventListener(event: string, handler: Function): void + onclick: (event: { type: string, target: any }) => void + onmouseover: (event: { type: string, target: any }) => void + onmouseout: (event: { type: string, target: any }) => void + onremove: (event: { type: string, target: any }) => void + } + interface PanoramaLabelOptions { + position?: Point + altitude?: number + } + interface AlbumsControlOptions { + anchor?: ControlAnchor + offset?: Size + maxWidth?: number | string + imageHeight?: number + } + type PanoramaSceneType = string + type PanoramaPOIType = string +} +declare const BMAP_PANORAMA_INDOOR_SCENE: string +declare const BMAP_PANORAMA_STREET_SCENE: string + +declare const BMAP_PANORAMA_POI_HOTEL: string +declare const BMAP_PANORAMA_POI_CATERING: string +declare const BMAP_PANORAMA_POI_MOVIE: string +declare const BMAP_PANORAMA_POI_TRANSIT: string +declare const BMAP_PANORAMA_POI_INDOOR_SCENE: string +declare const BMAP_PANORAMA_POI_NONE: string diff --git a/types/baidumap-web-sdk/baidumap.rightmenu.d.ts b/types/baidumap-web-sdk/baidumap.rightmenu.d.ts index ef79b71641..b760c73561 100644 --- a/types/baidumap-web-sdk/baidumap.rightmenu.d.ts +++ b/types/baidumap-web-sdk/baidumap.rightmenu.d.ts @@ -1,47 +1,47 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// - -declare namespace BMap { - type ContextMenuIcon = string - interface MenuItemOptions { - width?: number - id?: string - iconUrl?: string - } - class MenuItem { - constructor(text: string, callback: (point: Point) => void, opts?: MenuItemOptions) - setText(text: string): void - setIcon(iconUrl: string): void - enable(): void - disable(): void - } - class ContextMenu { - constructor() - addItem(item: MenuItem): void - getItem(index: number): MenuItem - removeItem(item: MenuItem): void - addSeparator(): void - removeSeparator(index: number): void - onopen: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onclose: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - } -} -declare const BMAP_CONTEXT_MENU_ICON_ZOOMIN: string +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// + +declare namespace BMap { + type ContextMenuIcon = string + interface MenuItemOptions { + width?: number + id?: string + iconUrl?: string + } + class MenuItem { + constructor(text: string, callback: (point: Point) => void, opts?: MenuItemOptions) + setText(text: string): void + setIcon(iconUrl: string): void + enable(): void + disable(): void + } + class ContextMenu { + constructor() + addItem(item: MenuItem): void + getItem(index: number): MenuItem + removeItem(item: MenuItem): void + addSeparator(): void + removeSeparator(index: number): void + onopen: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onclose: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + } +} +declare const BMAP_CONTEXT_MENU_ICON_ZOOMIN: string declare const BMAP_CONTEXT_MENU_ICON_ZOOMOUT: string \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.service.d.ts b/types/baidumap-web-sdk/baidumap.service.d.ts index 54ca6f7e1d..dbff0b7dfe 100644 --- a/types/baidumap-web-sdk/baidumap.service.d.ts +++ b/types/baidumap-web-sdk/baidumap.service.d.ts @@ -1,432 +1,432 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -declare namespace BMap { - class LocalSearch { - constructor(location: Map | Point | string, opts?: LocalSearchOptions) - search(keyword: string | Array, option?: Object): void - searchInBounds(keyword: string | Array, bounds: Bounds, option?: Object): void - searchNearby(keyword: string | Array, center: LocalResultPoi | string | Point, radius: number, option?: Object): void - getResults(): LocalResult | LocalResult[] - clearResults(): void - gotoPage(page: number): void - enableAutoViewport(): void - disableAutoViewport(): void - enableFirstResultSelection(): void - disableFirstResultSelection(): void - setLocation(location: Map | Point | string): void - setPageCapacity(capacity: number): void - getPageCapacity(): number - setSearchCompleteCallback(callback: (results: LocalResult | LocalResult[]) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - } - type LineType = number - interface WalkingRouteResult { - city: string - getStart(): LocalResultPoi - getEnd(): LocalResultPoi - getNumPlans(): number - getPlan(i: number): RoutePlan - } - class BusLineSearch { - constructor(location: Map | Point | string, opts?: BusLineSearchOptions) - getBusList(keyword: string): void - getBusLine(busLstItem: BusListItem): void - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setLocation(location: Map | Point | string): void - getStatus(): ServiceStatusCode - toString(): string - setGetBusListCompleteCallback(callback: (rs: BusListResult) => void): void - setGetBusLineCompleteCallback(callback: (rs: BusLine) => void): void - setBusListHtmlSetCallback(callback: (container: HTMLElement) => void): void - setBusLineHtmlSetCallback(callback: (container: HTMLElement) => void): void - setPolylinesSetCallback(callback: (ply: Polyline) => void): void - setMarkersSetCallback(callback: (markers: Marker[]) => void): void - } - interface LocalSearchOptions { - renderOptions?: RenderOptions - onMarkersSet?: (pois: LocalResultPoi[]) => void - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void - onResultsHtmlSet?: (container: HTMLElement) => void - pageCapacity?: number - onSearchComplete?: (results: LocalResult[]) => void - } - class DrivingRoute { - constructor(location: Map | Point | string, opts?: DrivingRouteOptions) - search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi, opts?: Object): void - getResults(): DrivingRouteResult - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setLocation(location: Map | Point | string): void - setPolicy(policy: DrivingPolicy): void - setSearchCompleteCallback(callback: (results: DrivingRouteResult) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setPolylinesSetCallback(callback: (routes: Route[]) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - toString(): string - } - class Geocoder { - constructor() - getPoint(address: string, callback: (point: Point) => void, city: string): void - getLocation(point: Point, callback: (result: GeocoderResult) => void, opts?: LocationOptions): void - } - interface BusLineSearchOptions { - renderOptions?: RenderOptions - onGetBusListComplete?: (rs: BusListResult) => void - onGetBusLineComplete?: (rs: BusLine) => void - onBusListHtmlSet?: (container: HTMLElement) => void - onBusLineHtmlSet?: (container: HTMLElement) => void - onPolylinesSet?: (ply: Polyline) => void - onMarkersSet?: (sts: Marker[]) => void - } - interface CustomData { - geotableId: number - tags: string - filter: string - } - interface DrivingRouteOptions { - renderOptions?: RenderOptions - policy?: DrivingPolicy - onSearchComplete?: (results: DrivingRouteResult) => void - onMarkersSet?: (pois: LocalResultPoi[]) => void - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void - onPolylinesSet?: (routes: Route[]) => void - onResultsHtmlSet?: (container: HTMLElement) => void - } - interface GeocoderResult { - point: Point - address: string - addressComponents: AddressComponent - surroundingPoi: LocalResultPoi[] - business: string - } - interface BusListResult { - keyword: string - city: string - moreResultsUrl: string - getNumBusList(): number - getBusListItem(i: number): BusListItem - } - interface RenderOptions { - map: Map - panel?: string | HTMLElement - selectFirstResult?: boolean - autoViewport?: boolean - highlightMode?: HighlightModes - } - type DrivingPolicy = number - interface AddressComponent { - streetNumber: string - street: string - district: string - city: string - province: string - } - interface BusLine { - name: string - startTime: string - endTime: string - company: string - getNumBusStations(): string - getBusStation(i: number): BusStation - getPath(): Point[] - getPolyline(): Polyline - } - interface LocalResult { - keyword: string - center: LocalResultPoi - radius: number - bounds: Bounds - city: string - moreResultsUrl: string - province: string - suggestions: string[] - getPoi(i: number): LocalResultPoi - getCurrentNumPois(): number - getNumPois(): number - getNumPages(): number - getPageIndex(): number - getCityList(): any[] - } - - interface DrivingRouteResult { - policy: DrivingPolicy - city: string - moreResultsUrl: string - taxiFare: TaxiFare - getStart(): LocalResultPoi - getEnd(): LocalResultPoi - getNumPlans(): number - getPlan(i: number): RoutePlan - } - interface LocationOptions { - poiRadius?: number - numPois?: number - } - interface BusListItem { - name: string - } - interface LocalResultPoi { - title: string - point: Point - url: string - address: string - city: string - phoneNumber: string - postcode: string - type: PoiType - isAccurate: boolean - province: string - tags: string[] - detailUrl: string - } - interface TaxiFare { - day: TaxiFareDetail - night: TaxiFareDetail - distance: number - remark: string - } - class LocalCity { - constructor(opts?: LocalCityOptions) - get(callback: (result: LocalCityResult) => void): void - } - interface BusStation { - name: string - position: Point - } - type PoiType = number - interface TaxiFareDetail { - initialFare: number - unitFare: number - totalFare: number - } - interface LocalCityOptions { - renderOptions?: RenderOptions - } - class Autocomplete { - constructor(opts?: AutocompleteOptions) - show(): void - hide(): void - setTypes(types: string[]): void - setLocation(location: string | Map | Point): void - search(keywords: string): void - getResults(): AutocompleteResult - setInputValue(keyword: string): void - dispose(): void - onconfirm: (event: { type: string, target: any, item: any }) => void - onhighlight: (event: { type: string, target: any, fromitem: any, toitem: any }) => void - } - class TransitRoute { - constructor(location: Map | Point | string, opts?: TransitRouteOptions) - search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void - getResults(): TransitRouteResult - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setPageCapacity(capacity: number): void - setLocation(location: Map | Point | string): void - setPolicy(policy: TransitPolicy): void - setSearchCompleteCallback(callback: (results: TransitRouteResult) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setPolylinesSetCallback(callback: (lines: Line[], routes: Route[]) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - toString(): string - } - interface RoutePlan { - getNumRoutes(): number - getRoute(i: number): Route - getDistance(format?: boolean): string | number - getDuration(format?: boolean): string | number - getDragPois(): LocalResultPoi[] - } - interface LocalCityResult { - center: Point - level: number - name: string - } - interface AutocompleteOptions { - location?: string | Map | Point - types?: string[] - onSearchComplete?: (result: AutocompleteResult) => void - input?: string | HTMLElement - } - interface TransitRouteOptions { - renderOptions?: RenderOptions - policy?: TransitPolicy - pageCapacity?: number - onSearchComplete?: (result: TransitRouteResult) => void - onMarkersSet?: (pois: LocalResultPoi[], transfers: LocalResultPoi[]) => void - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void - onPolylinesSet?: (lines: Line[]) => void - onResultsHtmlSet?: (container: HTMLElement) => void - } - interface Route { - getNumRoutes(): number - getStep(i: number): Step - getDistance(format?: boolean): string | number - getIndex(): number - getPolyline(): Polyline - getPoints(): Point[] - getPath(): Point[] - getRouteType(): RouteType - } - class TrafficControl { - constructor() - setPanelOffset(offset: Size): void - show(): void - hide(): void - } - interface AutocompleteResultPoi { - province: string - City: string//wtf - district: string - street: string - streetNumber: string - business: string - } - type TransitPolicy = number - type RouteType = number - class Geolocation { - constructor() - getCurrentPosition(callback: (result: GeolocationResult) => void, opts?: PositionOptions): void - getStatus(): ServiceStatusCode - } - interface AutocompleteResult { - keyword: string - getPoi(i: number): AutocompleteResultPoi - getNumPois(): number - } - interface TransitRouteResult { - policy: TransitPolicy - city: string - moreResultsUrl: string - getStart(): LocalResultPoi - getEnd(): LocalResultPoi - getNumPlans(): number - getPlan(i: number): TransitRoutePlan - } - interface Step { - getPoint(): Point - getPosition(): Point - getIndex(): number - getDescription(includeHtml: boolean): string - getDistance(format?: boolean): string | number - } - interface GeolocationResult { - point: Point - accuracy: number - } - class Boundary { - constructor() - get(name: string, callback: (result: string[]) => void): void - } - interface TransitRoutePlan { - getNumLines(): number - getLine(i: number): Line - getNumRoutes(): number - getRoute(i: number): Route - getDistance(format?: boolean): string | number - getDuration(format?: boolean): string | number - getDescription(includeHtml: boolean): string - } - class WalkingRoute { - constructor(location: Map | Point | string, opts?: WalkingRouteOptions) - search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void - getResults(): WalkingRouteResult - clearResults(): void - enableAutoViewport(): void - disableAutoViewport(): void - setLocation(location: Map | Point | string): void - setSearchCompleteCallback(callback: (result: WalkingRouteResult) => void): void - setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void - setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void - setPolylinesSetCallback(callback: (routes: Route[]) => void): void - setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void - getStatus(): ServiceStatusCode - toString(): string - } - interface PositionOptions { - enableHighAccuracy?: boolean - timeout?: number - maximumAge?: number - } - interface Line { - title: string - type: LineType - getNumViaStops(): number - getGetOnStop(): LocalResultPoi - getGetOffStop(): LocalResultPoi - getPoints(): Point[] - getPath(): Point[] - getPolyline(): Polyline - getDistance(format?: boolean): string | number - } - interface WalkingRouteOptions { - renderOptions?: RenderOptions, - onSearchComplete?: (result: WalkingRouteResult) => void, - onMarkersSet?: (pois: LocalResultPoi[]) => void, - onPolylinesSet?: (routes: Route[]) => void, - onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void, - onResultsHtmlSet?: (container: HTMLElement) => void - } - type HighlightModes = number - type ServiceStatusCode = number -} - -declare const BMAP_LINE_TYPE_BUS: BMap.LineType -declare const BMAP_LINE_TYPE_SUBWAY: BMap.LineType -declare const BMAP_LINE_TYPE_FERRY: BMap.LineType - -declare const BMAP_DRIVING_POLICY_LEAST_TIME: BMap.DrivingPolicy -declare const BMAP_DRIVING_POLICY_LEAST_DISTANCE: BMap.DrivingPolicy -declare const BMAP_DRIVING_POLICY_AVOID_HIGHWAYS: BMap.DrivingPolicy - -declare const BMAP_POI_TYPE_NORMAL: BMap.PoiType -declare const BMAP_POI_TYPE_BUSSTOP: BMap.PoiType -declare const BMAP_POI_TYPE_SUBSTOP: BMap.PoiType - - -declare const BMAP_TRANSIT_POLICY_LEAST_TIME: BMap.TransitPolicy -declare const BMAP_TRANSIT_POLICY_LEAST_TRANSFER: BMap.TransitPolicy -declare const BMAP_TRANSIT_POLICY_LEAST_WALKING: BMap.TransitPolicy -declare const BMAP_TRANSIT_POLICY_AVOID_SUBWAYS: BMap.TransitPolicy - -declare const BMAP_ROUTE_TYPE_DRIVING: BMap.RouteType -declare const BMAP_ROUTE_TYPE_WALKING: BMap.RouteType - -declare const BMAP_HIGHLIGHT_STEP: BMap.HighlightModes -declare const BMAP_HIGHLIGHT_ROUTE: BMap.HighlightModes - -declare const BMAP_STATUS_SUCCESS: BMap.ServiceStatusCode -declare const BMAP_STATUS_CITY_LIST: BMap.ServiceStatusCode -declare const BMAP_STATUS_UNKNOWN_LOCATION: BMap.ServiceStatusCode -declare const BMAP_STATUS_UNKNOWN_ROUTE: BMap.ServiceStatusCode -declare const BMAP_STATUS_INVALID_KEY: BMap.ServiceStatusCode -declare const BMAP_STATUS_INVALID_REQUEST: BMap.ServiceStatusCode \ No newline at end of file +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +declare namespace BMap { + class LocalSearch { + constructor(location: Map | Point | string, opts?: LocalSearchOptions) + search(keyword: string | Array, option?: Object): void + searchInBounds(keyword: string | Array, bounds: Bounds, option?: Object): void + searchNearby(keyword: string | Array, center: LocalResultPoi | string | Point, radius: number, option?: Object): void + getResults(): LocalResult | LocalResult[] + clearResults(): void + gotoPage(page: number): void + enableAutoViewport(): void + disableAutoViewport(): void + enableFirstResultSelection(): void + disableFirstResultSelection(): void + setLocation(location: Map | Point | string): void + setPageCapacity(capacity: number): void + getPageCapacity(): number + setSearchCompleteCallback(callback: (results: LocalResult | LocalResult[]) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + } + type LineType = number + interface WalkingRouteResult { + city: string + getStart(): LocalResultPoi + getEnd(): LocalResultPoi + getNumPlans(): number + getPlan(i: number): RoutePlan + } + class BusLineSearch { + constructor(location: Map | Point | string, opts?: BusLineSearchOptions) + getBusList(keyword: string): void + getBusLine(busLstItem: BusListItem): void + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setLocation(location: Map | Point | string): void + getStatus(): ServiceStatusCode + toString(): string + setGetBusListCompleteCallback(callback: (rs: BusListResult) => void): void + setGetBusLineCompleteCallback(callback: (rs: BusLine) => void): void + setBusListHtmlSetCallback(callback: (container: HTMLElement) => void): void + setBusLineHtmlSetCallback(callback: (container: HTMLElement) => void): void + setPolylinesSetCallback(callback: (ply: Polyline) => void): void + setMarkersSetCallback(callback: (markers: Marker[]) => void): void + } + interface LocalSearchOptions { + renderOptions?: RenderOptions + onMarkersSet?: (pois: LocalResultPoi[]) => void + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void + onResultsHtmlSet?: (container: HTMLElement) => void + pageCapacity?: number + onSearchComplete?: (results: LocalResult[]) => void + } + class DrivingRoute { + constructor(location: Map | Point | string, opts?: DrivingRouteOptions) + search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi, opts?: Object): void + getResults(): DrivingRouteResult + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setLocation(location: Map | Point | string): void + setPolicy(policy: DrivingPolicy): void + setSearchCompleteCallback(callback: (results: DrivingRouteResult) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setPolylinesSetCallback(callback: (routes: Route[]) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + toString(): string + } + class Geocoder { + constructor() + getPoint(address: string, callback: (point: Point) => void, city: string): void + getLocation(point: Point, callback: (result: GeocoderResult) => void, opts?: LocationOptions): void + } + interface BusLineSearchOptions { + renderOptions?: RenderOptions + onGetBusListComplete?: (rs: BusListResult) => void + onGetBusLineComplete?: (rs: BusLine) => void + onBusListHtmlSet?: (container: HTMLElement) => void + onBusLineHtmlSet?: (container: HTMLElement) => void + onPolylinesSet?: (ply: Polyline) => void + onMarkersSet?: (sts: Marker[]) => void + } + interface CustomData { + geotableId: number + tags: string + filter: string + } + interface DrivingRouteOptions { + renderOptions?: RenderOptions + policy?: DrivingPolicy + onSearchComplete?: (results: DrivingRouteResult) => void + onMarkersSet?: (pois: LocalResultPoi[]) => void + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void + onPolylinesSet?: (routes: Route[]) => void + onResultsHtmlSet?: (container: HTMLElement) => void + } + interface GeocoderResult { + point: Point + address: string + addressComponents: AddressComponent + surroundingPoi: LocalResultPoi[] + business: string + } + interface BusListResult { + keyword: string + city: string + moreResultsUrl: string + getNumBusList(): number + getBusListItem(i: number): BusListItem + } + interface RenderOptions { + map: Map + panel?: string | HTMLElement + selectFirstResult?: boolean + autoViewport?: boolean + highlightMode?: HighlightModes + } + type DrivingPolicy = number + interface AddressComponent { + streetNumber: string + street: string + district: string + city: string + province: string + } + interface BusLine { + name: string + startTime: string + endTime: string + company: string + getNumBusStations(): string + getBusStation(i: number): BusStation + getPath(): Point[] + getPolyline(): Polyline + } + interface LocalResult { + keyword: string + center: LocalResultPoi + radius: number + bounds: Bounds + city: string + moreResultsUrl: string + province: string + suggestions: string[] + getPoi(i: number): LocalResultPoi + getCurrentNumPois(): number + getNumPois(): number + getNumPages(): number + getPageIndex(): number + getCityList(): any[] + } + + interface DrivingRouteResult { + policy: DrivingPolicy + city: string + moreResultsUrl: string + taxiFare: TaxiFare + getStart(): LocalResultPoi + getEnd(): LocalResultPoi + getNumPlans(): number + getPlan(i: number): RoutePlan + } + interface LocationOptions { + poiRadius?: number + numPois?: number + } + interface BusListItem { + name: string + } + interface LocalResultPoi { + title: string + point: Point + url: string + address: string + city: string + phoneNumber: string + postcode: string + type: PoiType + isAccurate: boolean + province: string + tags: string[] + detailUrl: string + } + interface TaxiFare { + day: TaxiFareDetail + night: TaxiFareDetail + distance: number + remark: string + } + class LocalCity { + constructor(opts?: LocalCityOptions) + get(callback: (result: LocalCityResult) => void): void + } + interface BusStation { + name: string + position: Point + } + type PoiType = number + interface TaxiFareDetail { + initialFare: number + unitFare: number + totalFare: number + } + interface LocalCityOptions { + renderOptions?: RenderOptions + } + class Autocomplete { + constructor(opts?: AutocompleteOptions) + show(): void + hide(): void + setTypes(types: string[]): void + setLocation(location: string | Map | Point): void + search(keywords: string): void + getResults(): AutocompleteResult + setInputValue(keyword: string): void + dispose(): void + onconfirm: (event: { type: string, target: any, item: any }) => void + onhighlight: (event: { type: string, target: any, fromitem: any, toitem: any }) => void + } + class TransitRoute { + constructor(location: Map | Point | string, opts?: TransitRouteOptions) + search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void + getResults(): TransitRouteResult + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setPageCapacity(capacity: number): void + setLocation(location: Map | Point | string): void + setPolicy(policy: TransitPolicy): void + setSearchCompleteCallback(callback: (results: TransitRouteResult) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setPolylinesSetCallback(callback: (lines: Line[], routes: Route[]) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + toString(): string + } + interface RoutePlan { + getNumRoutes(): number + getRoute(i: number): Route + getDistance(format?: boolean): string | number + getDuration(format?: boolean): string | number + getDragPois(): LocalResultPoi[] + } + interface LocalCityResult { + center: Point + level: number + name: string + } + interface AutocompleteOptions { + location?: string | Map | Point + types?: string[] + onSearchComplete?: (result: AutocompleteResult) => void + input?: string | HTMLElement + } + interface TransitRouteOptions { + renderOptions?: RenderOptions + policy?: TransitPolicy + pageCapacity?: number + onSearchComplete?: (result: TransitRouteResult) => void + onMarkersSet?: (pois: LocalResultPoi[], transfers: LocalResultPoi[]) => void + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void + onPolylinesSet?: (lines: Line[]) => void + onResultsHtmlSet?: (container: HTMLElement) => void + } + interface Route { + getNumRoutes(): number + getStep(i: number): Step + getDistance(format?: boolean): string | number + getIndex(): number + getPolyline(): Polyline + getPoints(): Point[] + getPath(): Point[] + getRouteType(): RouteType + } + class TrafficControl { + constructor() + setPanelOffset(offset: Size): void + show(): void + hide(): void + } + interface AutocompleteResultPoi { + province: string + City: string//wtf + district: string + street: string + streetNumber: string + business: string + } + type TransitPolicy = number + type RouteType = number + class Geolocation { + constructor() + getCurrentPosition(callback: (result: GeolocationResult) => void, opts?: PositionOptions): void + getStatus(): ServiceStatusCode + } + interface AutocompleteResult { + keyword: string + getPoi(i: number): AutocompleteResultPoi + getNumPois(): number + } + interface TransitRouteResult { + policy: TransitPolicy + city: string + moreResultsUrl: string + getStart(): LocalResultPoi + getEnd(): LocalResultPoi + getNumPlans(): number + getPlan(i: number): TransitRoutePlan + } + interface Step { + getPoint(): Point + getPosition(): Point + getIndex(): number + getDescription(includeHtml: boolean): string + getDistance(format?: boolean): string | number + } + interface GeolocationResult { + point: Point + accuracy: number + } + class Boundary { + constructor() + get(name: string, callback: (result: string[]) => void): void + } + interface TransitRoutePlan { + getNumLines(): number + getLine(i: number): Line + getNumRoutes(): number + getRoute(i: number): Route + getDistance(format?: boolean): string | number + getDuration(format?: boolean): string | number + getDescription(includeHtml: boolean): string + } + class WalkingRoute { + constructor(location: Map | Point | string, opts?: WalkingRouteOptions) + search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void + getResults(): WalkingRouteResult + clearResults(): void + enableAutoViewport(): void + disableAutoViewport(): void + setLocation(location: Map | Point | string): void + setSearchCompleteCallback(callback: (result: WalkingRouteResult) => void): void + setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void + setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void + setPolylinesSetCallback(callback: (routes: Route[]) => void): void + setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void + getStatus(): ServiceStatusCode + toString(): string + } + interface PositionOptions { + enableHighAccuracy?: boolean + timeout?: number + maximumAge?: number + } + interface Line { + title: string + type: LineType + getNumViaStops(): number + getGetOnStop(): LocalResultPoi + getGetOffStop(): LocalResultPoi + getPoints(): Point[] + getPath(): Point[] + getPolyline(): Polyline + getDistance(format?: boolean): string | number + } + interface WalkingRouteOptions { + renderOptions?: RenderOptions, + onSearchComplete?: (result: WalkingRouteResult) => void, + onMarkersSet?: (pois: LocalResultPoi[]) => void, + onPolylinesSet?: (routes: Route[]) => void, + onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void, + onResultsHtmlSet?: (container: HTMLElement) => void + } + type HighlightModes = number + type ServiceStatusCode = number +} + +declare const BMAP_LINE_TYPE_BUS: BMap.LineType +declare const BMAP_LINE_TYPE_SUBWAY: BMap.LineType +declare const BMAP_LINE_TYPE_FERRY: BMap.LineType + +declare const BMAP_DRIVING_POLICY_LEAST_TIME: BMap.DrivingPolicy +declare const BMAP_DRIVING_POLICY_LEAST_DISTANCE: BMap.DrivingPolicy +declare const BMAP_DRIVING_POLICY_AVOID_HIGHWAYS: BMap.DrivingPolicy + +declare const BMAP_POI_TYPE_NORMAL: BMap.PoiType +declare const BMAP_POI_TYPE_BUSSTOP: BMap.PoiType +declare const BMAP_POI_TYPE_SUBSTOP: BMap.PoiType + + +declare const BMAP_TRANSIT_POLICY_LEAST_TIME: BMap.TransitPolicy +declare const BMAP_TRANSIT_POLICY_LEAST_TRANSFER: BMap.TransitPolicy +declare const BMAP_TRANSIT_POLICY_LEAST_WALKING: BMap.TransitPolicy +declare const BMAP_TRANSIT_POLICY_AVOID_SUBWAYS: BMap.TransitPolicy + +declare const BMAP_ROUTE_TYPE_DRIVING: BMap.RouteType +declare const BMAP_ROUTE_TYPE_WALKING: BMap.RouteType + +declare const BMAP_HIGHLIGHT_STEP: BMap.HighlightModes +declare const BMAP_HIGHLIGHT_ROUTE: BMap.HighlightModes + +declare const BMAP_STATUS_SUCCESS: BMap.ServiceStatusCode +declare const BMAP_STATUS_CITY_LIST: BMap.ServiceStatusCode +declare const BMAP_STATUS_UNKNOWN_LOCATION: BMap.ServiceStatusCode +declare const BMAP_STATUS_UNKNOWN_ROUTE: BMap.ServiceStatusCode +declare const BMAP_STATUS_INVALID_KEY: BMap.ServiceStatusCode +declare const BMAP_STATUS_INVALID_REQUEST: BMap.ServiceStatusCode \ No newline at end of file diff --git a/types/baidumap-web-sdk/baidumap.tools.d.ts b/types/baidumap-web-sdk/baidumap.tools.d.ts index cd3ba6b619..c1bc6bf929 100644 --- a/types/baidumap-web-sdk/baidumap.tools.d.ts +++ b/types/baidumap-web-sdk/baidumap.tools.d.ts @@ -1,61 +1,61 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -declare namespace BMap { - class PushpinTool { - constructor(map: Map, opts?: PushpinToolOptions) - open(): boolean - close(): boolean - setIcon(icon: Icon): Icon - getIcon(): Icon - setCursor(cursor: string): string - getCursor(): string - toString(): string - onmarkend: (event: { type: string, target: any, marker: Marker }) => void - } - interface PushpinToolOptions { - icon?: Icon - cursor?: string - followText?: string - } - class DistanceTool { - constructor(map: Map) - open(): boolean - close(): void - toString(): string - ondrawend: (event: { type: string, target: any, points: Point[], polylines: Polyline[], distance: number }) => void - } - class DragAndZoomTool { - constructor(map: Map, opts?: DragAndZoomToolOptions) - open(): boolean - close(): void - toString(): string - ondrawend: (event: { type: string, target: any, bounds: Bounds[] }) => void - } - interface DragAndZoomToolOptions { - zoomType?: ZoomType, - autoClose?: boolean, - followText?: string - } - type ZoomType = number -} -declare const BMAP_ZOOM_IN: BMap.ZoomType +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +declare namespace BMap { + class PushpinTool { + constructor(map: Map, opts?: PushpinToolOptions) + open(): boolean + close(): boolean + setIcon(icon: Icon): Icon + getIcon(): Icon + setCursor(cursor: string): string + getCursor(): string + toString(): string + onmarkend: (event: { type: string, target: any, marker: Marker }) => void + } + interface PushpinToolOptions { + icon?: Icon + cursor?: string + followText?: string + } + class DistanceTool { + constructor(map: Map) + open(): boolean + close(): void + toString(): string + ondrawend: (event: { type: string, target: any, points: Point[], polylines: Polyline[], distance: number }) => void + } + class DragAndZoomTool { + constructor(map: Map, opts?: DragAndZoomToolOptions) + open(): boolean + close(): void + toString(): string + ondrawend: (event: { type: string, target: any, bounds: Bounds[] }) => void + } + interface DragAndZoomToolOptions { + zoomType?: ZoomType, + autoClose?: boolean, + followText?: string + } + type ZoomType = number +} +declare const BMAP_ZOOM_IN: BMap.ZoomType declare const BMAP_ZOOM_OUT: BMap.ZoomType \ No newline at end of file diff --git a/types/baidumap-web-sdk/index.d.ts b/types/baidumap-web-sdk/index.d.ts index cfab71e884..ac8f27c87b 100644 --- a/types/baidumap-web-sdk/index.d.ts +++ b/types/baidumap-web-sdk/index.d.ts @@ -1,28 +1,28 @@ -// Type definitions for BaiduMap v2.0 -// Project: http://lbsyun.baidu.com/index.php?title=jspopular -// Definitions by: Codemonk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* ***************************************************************************** -Copyright [Codemonk] [Codemonk@live.cn] - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -***************************************************************************** */ - -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// \ No newline at end of file +// Type definitions for BaiduMap v2.0 +// Project: http://lbsyun.baidu.com/index.php?title=jspopular +// Definitions by: Codemonk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* ***************************************************************************** +Copyright [Codemonk] [Codemonk@live.cn] + +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/types/baidumap-web-sdk/tslint.json b/types/baidumap-web-sdk/tslint.json new file mode 100644 index 0000000000..aab43caa1d --- /dev/null +++ b/types/baidumap-web-sdk/tslint.json @@ -0,0 +1,15 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // All are TODOs + "eofline": false, + "comment-format": false, + "dt-header": false, + "max-line-length": false, + "member-access": false, + "no-namespace": false, + "no-useless-files": false, + "no-var": false, + "semicolon": false + } +} From 96545154cc6488643a7064a6dc4ec9726c7af12a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Jun 2017 13:55:38 -0700 Subject: [PATCH 89/90] bittorrent-protocol: Use same default event handler as stream.Readable --- types/bittorrent-protocol/index.d.ts | 3 +- types/node/index.d.ts | 224 +++++++++++++-------------- types/node/node-tests.ts | 2 +- 3 files changed, 115 insertions(+), 114 deletions(-) diff --git a/types/bittorrent-protocol/index.d.ts b/types/bittorrent-protocol/index.d.ts index b5ef1a4a44..7c205edc33 100644 --- a/types/bittorrent-protocol/index.d.ts +++ b/types/bittorrent-protocol/index.d.ts @@ -81,7 +81,7 @@ declare namespace BittorrentProtocol { // TODO: bitfield is a bitfield instance on(event: 'bitfield', listener: (bitfield: any) => void): this; - on(event: string | 'keep-alive' | 'choke' | 'unchoke' | 'interested' | 'uninterested' | 'timeout', listener: () => void): this; + on(event: 'keep-alive' | 'choke' | 'unchoke' | 'interested' | 'uninterested' | 'timeout', listener: () => void): this; on(event: 'upload' | 'have' | 'download' | 'port', listener: (length: number) => void): this; on(event: 'handshake', listener: (infoHash: string, peerId: string, extensions: Extension[]) => void): this; on(event: 'request', listener: (index: number, offset: number, length: number, respond: () => void) => void): this; @@ -89,6 +89,7 @@ declare namespace BittorrentProtocol { on(event: 'cancel', listener: (index: number, offset: number, length: number) => void): this; on(event: 'extended', listener: (ext: 'handshake' | string, buf: any) => void): void; on(event: 'unknownmessage', listener: (buffer: Buffer) => void): this; + on(event: string, listener: (...args: any[]) => void): this; } } diff --git a/types/node/index.d.ts b/types/node/index.d.ts index d207554eda..815b776e42 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -288,10 +288,10 @@ declare namespace NodeJS { } export class EventEmitter { - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; @@ -299,8 +299,8 @@ declare namespace NodeJS { emit(event: string | symbol, ...args: any[]): boolean; listenerCount(type: string | symbol): number; // Added in Node 6... - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; eventNames(): (string | symbol)[]; } @@ -340,10 +340,10 @@ declare namespace NodeJS { intercept(cb: (data: any) => any): any; dispose(): void; - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + removeListener(event: string, listener: (...args: any[]) => void): this; removeAllListeners(event?: string): this; } @@ -393,8 +393,8 @@ declare namespace NodeJS { type WarningListener = (warning: Error) => void; type MessageListener = (message: any, sendHandle: any) => void; type SignalsListener = () => void; - type NewListenerListener = (type: string | symbol, listener: Function) => void; - type RemoveListenerListener = (type: string | symbol, listener: Function) => void; + type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void; + type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void; export interface Socket extends ReadWriteStream { isTTY?: true; @@ -504,8 +504,8 @@ declare namespace NodeJS { emit(event: "warning", warning: Error): boolean; emit(event: "message", message: any, sendHandle: any): this; emit(event: Signals): boolean; - emit(event: "newListener", eventName: string | symbol, listener: Function): this; - emit(event: "removeListener", eventName: string, listener: Function): this; + emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this; on(event: "beforeExit", listener: BeforeExitListener): this; on(event: "disconnect", listener: DisconnectListener): this; @@ -738,12 +738,12 @@ declare module "events" { static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated static defaultMaxListeners: number; - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; @@ -982,7 +982,7 @@ declare module "cluster" { * 5. message * 6. online */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "disconnect", listener: () => void): this; addListener(event: "error", listener: (code: number, signal: string) => void): this; addListener(event: "exit", listener: (code: number, signal: string) => void): this; @@ -990,7 +990,7 @@ declare module "cluster" { addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. addListener(event: "online", listener: () => void): this; - emit(event: string, listener: Function): boolean + emit(event: string, listener: (...args: any[]) => void): boolean emit(event: "disconnect"): boolean emit(event: "error", code: number, signal: string): boolean emit(event: "exit", code: number, signal: string): boolean @@ -998,7 +998,7 @@ declare module "cluster" { emit(event: "message", message: any, handle: net.Socket | net.Server): boolean emit(event: "online"): boolean - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "disconnect", listener: () => void): this; on(event: "error", listener: (code: number, signal: string) => void): this; on(event: "exit", listener: (code: number, signal: string) => void): this; @@ -1006,7 +1006,7 @@ declare module "cluster" { on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. on(event: "online", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "disconnect", listener: () => void): this; once(event: "error", listener: (code: number, signal: string) => void): this; once(event: "exit", listener: (code: number, signal: string) => void): this; @@ -1014,7 +1014,7 @@ declare module "cluster" { once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. once(event: "online", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "disconnect", listener: () => void): this; prependListener(event: "error", listener: (code: number, signal: string) => void): this; prependListener(event: "exit", listener: (code: number, signal: string) => void): this; @@ -1022,7 +1022,7 @@ declare module "cluster" { prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. prependListener(event: "online", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "disconnect", listener: () => void): this; prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; @@ -1055,7 +1055,7 @@ declare module "cluster" { * 6. online * 7. setup */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "disconnect", listener: (worker: Worker) => void): this; addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; addListener(event: "fork", listener: (worker: Worker) => void): this; @@ -1064,7 +1064,7 @@ declare module "cluster" { addListener(event: "online", listener: (worker: Worker) => void): this; addListener(event: "setup", listener: (settings: any) => void): this; - emit(event: string, listener: Function): boolean; + emit(event: string, listener: (...args: any[]) => void): boolean; emit(event: "disconnect", worker: Worker): boolean; emit(event: "exit", worker: Worker, code: number, signal: string): boolean; emit(event: "fork", worker: Worker): boolean; @@ -1073,7 +1073,7 @@ declare module "cluster" { emit(event: "online", worker: Worker): boolean; emit(event: "setup", settings: any): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "disconnect", listener: (worker: Worker) => void): this; on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; on(event: "fork", listener: (worker: Worker) => void): this; @@ -1082,7 +1082,7 @@ declare module "cluster" { on(event: "online", listener: (worker: Worker) => void): this; on(event: "setup", listener: (settings: any) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "disconnect", listener: (worker: Worker) => void): this; once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; once(event: "fork", listener: (worker: Worker) => void): this; @@ -1091,7 +1091,7 @@ declare module "cluster" { once(event: "online", listener: (worker: Worker) => void): this; once(event: "setup", listener: (settings: any) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "disconnect", listener: (worker: Worker) => void): this; prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; prependListener(event: "fork", listener: (worker: Worker) => void): this; @@ -1100,7 +1100,7 @@ declare module "cluster" { prependListener(event: "online", listener: (worker: Worker) => void): this; prependListener(event: "setup", listener: (settings: any) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; @@ -1133,7 +1133,7 @@ declare module "cluster" { * 6. online * 7. setup */ - export function addListener(event: string, listener: Function): Cluster; + export function addListener(event: string, listener: (...args: any[]) => void): Cluster; export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1142,7 +1142,7 @@ declare module "cluster" { export function addListener(event: "online", listener: (worker: Worker) => void): Cluster; export function addListener(event: "setup", listener: (settings: any) => void): Cluster; - export function emit(event: string, listener: Function): boolean; + export function emit(event: string, listener: (...args: any[]) => void): boolean; export function emit(event: "disconnect", worker: Worker): boolean; export function emit(event: "exit", worker: Worker, code: number, signal: string): boolean; export function emit(event: "fork", worker: Worker): boolean; @@ -1151,7 +1151,7 @@ declare module "cluster" { export function emit(event: "online", worker: Worker): boolean; export function emit(event: "setup", settings: any): boolean; - export function on(event: string, listener: Function): Cluster; + export function on(event: string, listener: (...args: any[]) => void): Cluster; export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function on(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1160,7 +1160,7 @@ declare module "cluster" { export function on(event: "online", listener: (worker: Worker) => void): Cluster; export function on(event: "setup", listener: (settings: any) => void): Cluster; - export function once(event: string, listener: Function): Cluster; + export function once(event: string, listener: (...args: any[]) => void): Cluster; export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function once(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1169,14 +1169,14 @@ declare module "cluster" { export function once(event: "online", listener: (worker: Worker) => void): Cluster; export function once(event: "setup", listener: (settings: any) => void): Cluster; - export function removeListener(event: string, listener: Function): Cluster; + export function removeListener(event: string, listener: (...args: any[]) => void): Cluster; export function removeAllListeners(event?: string): Cluster; export function setMaxListeners(n: number): Cluster; export function getMaxListeners(): number; export function listeners(event: string): Function[]; export function listenerCount(type: string): number; - export function prependListener(event: string, listener: Function): Cluster; + export function prependListener(event: string, listener: (...args: any[]) => void): Cluster; export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1185,7 +1185,7 @@ declare module "cluster" { export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster; export function prependListener(event: "setup", listener: (settings: any) => void): Cluster; - export function prependOnceListener(event: string, listener: Function): Cluster; + export function prependOnceListener(event: string, listener: (...args: any[]) => void): Cluster; export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster; @@ -1583,29 +1583,29 @@ declare module "repl" { * 2. reset **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "exit", listener: () => void): this; - addListener(event: "reset", listener: Function): this; + addListener(event: "reset", listener: (...args: any[]) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: "exit"): boolean; emit(event: "reset", context: any): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "exit", listener: () => void): this; - on(event: "reset", listener: Function): this; + on(event: "reset", listener: (...args: any[]) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "exit", listener: () => void): this; - once(event: "reset", listener: Function): this; + once(event: "reset", listener: (...args: any[]) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "exit", listener: () => void): this; - prependListener(event: "reset", listener: Function): this; + prependListener(event: "reset", listener: (...args: any[]) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "exit", listener: () => void): this; - prependOnceListener(event: "reset", listener: Function): this; + prependOnceListener(event: "reset", listener: (...args: any[]) => void): this; } export function start(options: ReplOptions): REPLServer; @@ -1643,7 +1643,7 @@ declare module "readline" { * 7. SIGTSTP **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "line", listener: (input: any) => void): this; addListener(event: "pause", listener: () => void): this; @@ -1661,7 +1661,7 @@ declare module "readline" { emit(event: "SIGINT"): boolean; emit(event: "SIGTSTP"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "line", listener: (input: any) => void): this; on(event: "pause", listener: () => void): this; @@ -1670,7 +1670,7 @@ declare module "readline" { on(event: "SIGINT", listener: () => void): this; on(event: "SIGTSTP", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "line", listener: (input: any) => void): this; once(event: "pause", listener: () => void): this; @@ -1679,7 +1679,7 @@ declare module "readline" { once(event: "SIGINT", listener: () => void): this; once(event: "SIGTSTP", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "line", listener: (input: any) => void): this; prependListener(event: "pause", listener: () => void): this; @@ -1688,7 +1688,7 @@ declare module "readline" { prependListener(event: "SIGINT", listener: () => void): this; prependListener(event: "SIGTSTP", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "line", listener: (input: any) => void): this; prependOnceListener(event: "pause", listener: () => void): this; @@ -1779,7 +1779,7 @@ declare module "child_process" { * 5. message **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: (code: number, signal: string) => void): this; addListener(event: "disconnect", listener: () => void): this; addListener(event: "error", listener: (err: Error) => void): this; @@ -1793,28 +1793,28 @@ declare module "child_process" { emit(event: "exit", code: number, signal: string): boolean; emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: (code: number, signal: string) => void): this; on(event: "disconnect", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "exit", listener: (code: number, signal: string) => void): this; on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: (code: number, signal: string) => void): this; once(event: "disconnect", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "exit", listener: (code: number, signal: string) => void): this; once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: (code: number, signal: string) => void): this; prependListener(event: "disconnect", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; prependListener(event: "exit", listener: (code: number, signal: string) => void): this; prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this; prependOnceListener(event: "disconnect", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; @@ -2246,7 +2246,7 @@ declare module "net" { * 7. lookup * 8. timeout */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: (had_error: boolean) => void): this; addListener(event: "connect", listener: () => void): this; addListener(event: "data", listener: (data: Buffer) => void): this; @@ -2266,7 +2266,7 @@ declare module "net" { emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; emit(event: "timeout"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: (had_error: boolean) => void): this; on(event: "connect", listener: () => void): this; on(event: "data", listener: (data: Buffer) => void): this; @@ -2276,7 +2276,7 @@ declare module "net" { on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; on(event: "timeout", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: (had_error: boolean) => void): this; once(event: "connect", listener: () => void): this; once(event: "data", listener: (data: Buffer) => void): this; @@ -2286,7 +2286,7 @@ declare module "net" { once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; once(event: "timeout", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: (had_error: boolean) => void): this; prependListener(event: "connect", listener: () => void): this; prependListener(event: "data", listener: (data: Buffer) => void): this; @@ -2296,7 +2296,7 @@ declare module "net" { prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; prependListener(event: "timeout", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; prependOnceListener(event: "connect", listener: () => void): this; prependOnceListener(event: "data", listener: (data: Buffer) => void): this; @@ -2345,7 +2345,7 @@ declare module "net" { * 3. error * 4. listening */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "connection", listener: (socket: Socket) => void): this; addListener(event: "error", listener: (err: Error) => void): this; @@ -2357,25 +2357,25 @@ declare module "net" { emit(event: "error", err: Error): boolean; emit(event: "listening"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "connection", listener: (socket: Socket) => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "listening", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "connection", listener: (socket: Socket) => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "listening", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "connection", listener: (socket: Socket) => void): this; prependListener(event: "error", listener: (err: Error) => void): this; prependListener(event: "listening", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; @@ -2448,7 +2448,7 @@ declare module "dgram" { * 3. listening * 4. message **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "error", listener: (err: Error) => void): this; addListener(event: "listening", listener: () => void): this; @@ -2460,25 +2460,25 @@ declare module "dgram" { emit(event: "listening"): boolean; emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "listening", listener: () => void): this; on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "listening", listener: () => void): this; once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; prependListener(event: "listening", listener: () => void): this; prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; prependOnceListener(event: "listening", listener: () => void): this; @@ -2522,23 +2522,23 @@ declare module "fs" { * 1. change * 2. error */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; addListener(event: "error", listener: (code: number, signal: string) => void): this; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; on(event: "error", listener: (code: number, signal: string) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; once(event: "error", listener: (code: number, signal: string) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; prependListener(event: "error", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; } @@ -2554,23 +2554,23 @@ declare module "fs" { * 1. open * 2. close */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "open", listener: (fd: number) => void): this; addListener(event: "close", listener: () => void): this; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "open", listener: (fd: number) => void): this; on(event: "close", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "open", listener: (fd: number) => void): this; once(event: "close", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "open", listener: (fd: number) => void): this; prependListener(event: "close", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "open", listener: (fd: number) => void): this; prependOnceListener(event: "close", listener: () => void): this; } @@ -2585,23 +2585,23 @@ declare module "fs" { * 1. open * 2. close */ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "open", listener: (fd: number) => void): this; addListener(event: "close", listener: () => void): this; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "open", listener: (fd: number) => void): this; on(event: "close", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "open", listener: (fd: number) => void): this; once(event: "close", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "open", listener: (fd: number) => void): this; prependListener(event: "close", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "open", listener: (fd: number) => void): this; prependOnceListener(event: "close", listener: () => void): this; } @@ -3364,7 +3364,7 @@ declare module "tls" { * 1. OCSPResponse * 2. secureConnect **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; addListener(event: "secureConnect", listener: () => void): this; @@ -3372,19 +3372,19 @@ declare module "tls" { emit(event: "OCSPResponse", response: Buffer): boolean; emit(event: "secureConnect"): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "OCSPResponse", listener: (response: Buffer) => void): this; on(event: "secureConnect", listener: () => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "OCSPResponse", listener: (response: Buffer) => void): this; once(event: "secureConnect", listener: () => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; prependListener(event: "secureConnect", listener: () => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; prependOnceListener(event: "secureConnect", listener: () => void): this; } @@ -3454,7 +3454,7 @@ declare module "tls" { * 4. resumeSession * 5. secureConnection **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; @@ -3468,28 +3468,28 @@ declare module "tls" { emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean; emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; @@ -3744,8 +3744,8 @@ declare module "stream" { * 4. readable * 5. error **/ - addListener(event: string, listener: Function): this; - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "data", listener: (chunk: Buffer | string) => void): this; addListener(event: "end", listener: () => void): this; @@ -3759,35 +3759,35 @@ declare module "stream" { emit(event: "readable"): boolean; emit(event: "error", err: Error): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "data", listener: (chunk: Buffer | string) => void): this; on(event: "end", listener: () => void): this; on(event: "readable", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "data", listener: (chunk: Buffer | string) => void): this; once(event: "end", listener: () => void): this; once(event: "readable", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; prependListener(event: "end", listener: () => void): this; prependListener(event: "readable", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; prependOnceListener(event: "end", listener: () => void): this; prependOnceListener(event: "readable", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; - removeListener(event: string, listener: Function): this; + removeListener(event: string, listener: (...args: any[]) => void): this; removeListener(event: "close", listener: () => void): this; removeListener(event: "data", listener: (chunk: Buffer | string) => void): this; removeListener(event: "end", listener: () => void): this; @@ -3824,7 +3824,7 @@ declare module "stream" { * 5. pipe * 6. unpipe **/ - addListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: () => void): this; addListener(event: "drain", listener: () => void): this; addListener(event: "error", listener: (err: Error) => void): this; @@ -3840,7 +3840,7 @@ declare module "stream" { emit(event: "pipe", src: Readable): boolean; emit(event: "unpipe", src: Readable): boolean; - on(event: string, listener: Function): this; + on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: () => void): this; on(event: "drain", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; @@ -3848,7 +3848,7 @@ declare module "stream" { on(event: "pipe", listener: (src: Readable) => void): this; on(event: "unpipe", listener: (src: Readable) => void): this; - once(event: string, listener: Function): this; + once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "drain", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; @@ -3856,7 +3856,7 @@ declare module "stream" { once(event: "pipe", listener: (src: Readable) => void): this; once(event: "unpipe", listener: (src: Readable) => void): this; - prependListener(event: string, listener: Function): this; + prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: () => void): this; prependListener(event: "drain", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; @@ -3864,7 +3864,7 @@ declare module "stream" { prependListener(event: "pipe", listener: (src: Readable) => void): this; prependListener(event: "unpipe", listener: (src: Readable) => void): this; - prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: () => void): this; prependOnceListener(event: "drain", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; @@ -3872,7 +3872,7 @@ declare module "stream" { prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; - removeListener(event: string, listener: Function): this; + removeListener(event: string, listener: (...args: any[]) => void): this; removeListener(event: "close", listener: () => void): this; removeListener(event: "drain", listener: () => void): this; removeListener(event: "error", listener: (err: Error) => void): this; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 22dce9c2ad..aeefc2bbdc 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -88,7 +88,7 @@ namespace assert_tests { namespace events_tests { let emitter: events.EventEmitter; let event: string | symbol; - let listener: Function; + let listener: (...args: any[]) => void; let any: any; { From f5239925acf2ee07ab4fecd2ceeb0247f2ed1297 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 20 Jun 2017 12:06:26 -0700 Subject: [PATCH 90/90] Fix more tests --- types/gulp-istanbul/gulp-istanbul-tests.ts | 6 +++--- types/gulp-watch/gulp-watch-tests.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/gulp-istanbul/gulp-istanbul-tests.ts b/types/gulp-istanbul/gulp-istanbul-tests.ts index a57932419d..af15f5df54 100644 --- a/types/gulp-istanbul/gulp-istanbul-tests.ts +++ b/types/gulp-istanbul/gulp-istanbul-tests.ts @@ -5,7 +5,7 @@ function testFramework(): NodeJS.ReadWriteStream { return null; } -gulp.task('test', function (cb: Function) { +gulp.task('test', function (cb: () => void) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul()) // Covering files .pipe(gulp.dest('test-tmp/')) @@ -17,7 +17,7 @@ gulp.task('test', function (cb: Function) { }); }); -gulp.task('test', function (cb: Function) { +gulp.task('test', function (cb: () => void) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul({includeUntested: true})) // Covering files .pipe(istanbul.hookRequire()) @@ -29,7 +29,7 @@ gulp.task('test', function (cb: Function) { }); }); -gulp.task('test', function (cb: Function) { +gulp.task('test', function (cb: () => void) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul({includeUntested: true})) // Covering files .pipe(istanbul.hookRequire()) diff --git a/types/gulp-watch/gulp-watch-tests.ts b/types/gulp-watch/gulp-watch-tests.ts index 0260a24bb6..de531257a5 100644 --- a/types/gulp-watch/gulp-watch-tests.ts +++ b/types/gulp-watch/gulp-watch-tests.ts @@ -7,7 +7,7 @@ gulp.task('stream', () => .pipe(gulp.dest('build')) ); -gulp.task('callback', (cb: Function) => +gulp.task('callback', (cb: () => void) => watch('css/**/*.css', () => gulp.src('css/**/*.css') .pipe(watch('css/**/*.css'))