From fece0e0e6b46241e066062deb23771a23b19319e Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 09:08:47 -0400 Subject: [PATCH 001/112] RSVP: switch to `export =` with `allowSyntheticDefaultExports`. --- types/rsvp/index.d.ts | 299 ++++++++++++++++++++------------------- types/rsvp/tsconfig.json | 5 +- 2 files changed, 153 insertions(+), 151 deletions(-) diff --git a/types/rsvp/index.d.ts b/types/rsvp/index.d.ts index c0a7dc8b07..5372bdd7d5 100644 --- a/types/rsvp/index.d.ts +++ b/types/rsvp/index.d.ts @@ -14,98 +14,98 @@ // Credit for that file goes to: Barrie Nemetchek , Andrew Gaspar , John Reilly declare namespace RSVP { - type Resolution = (value: T) => U | Thenable; - type Rejection = (error: C) => D | Thenable; + type Resolution = (value: T) => U | Thenable; + type Rejection = (error: C) => D | Thenable; - interface Thenable { - then(label?: string): Thenable; - then(onFulfillment: Resolution, label?: string): Thenable; - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Thenable; - } + interface Thenable { + then(label?: string): Thenable; + then(onFulfillment: Resolution, label?: string): Thenable; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Thenable; + } - interface Catchable { - catch(label?: string): Catchable; - catch(onRejection: (error: C) => D, label?: string): Catchable; - } + interface Catchable { + catch(label?: string): Catchable; + catch(onRejection: (error: C) => D, label?: string): Catchable; + } - interface Deferred { - promise: Promise; - resolve(value: T): void; - reject(reason: C): void; - } + interface Deferred { + promise: Promise; + resolve(value: T): void; + reject(reason: C): void; + } - type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; - interface IPromiseState { - state: PromiseStates; - value: T; - reason: C; - } + type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; + interface IPromiseState { + state: PromiseStates; + value: T; + reason: C; + } - class Resolved implements IPromiseState { - state: 'fulfilled'; - value: T; - reason: never; - } + class Resolved implements IPromiseState { + state: 'fulfilled'; + value: T; + reason: never; + } - class Rejected implements IPromiseState { - state: 'rejected'; - value: never; - reason: C; - } + class Rejected implements IPromiseState { + state: 'rejected'; + value: never; + reason: C; + } - class Pending implements IPromiseState { - state: 'pending'; - value: never; - reason: never; - } + class Pending implements IPromiseState { + state: 'pending'; + value: never; + reason: never; + } - type PromiseState = Resolved | Rejected | Pending; + type PromiseState = Resolved | Rejected | Pending; - type PromiseHash = { [P in keyof T]: Thenable | T[P] }; + type PromiseHash = { [P in keyof T]: Thenable | T[P] }; - type SettledHash = { [P in keyof T]: PromiseState }; + type SettledHash = { [P in keyof T]: PromiseState }; - interface InstrumentEvent { - guid: string; // guid of promise. Must be globally unique, not just within the implementation - childGuid: string; // child of child promise (for chained via `then`) - eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] - detail: any; // fulfillment value or rejection reason, if applicable - label: string; // label passed to promise's constructor - timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now - } + interface InstrumentEvent { + guid: string; // guid of promise. Must be globally unique, not just within the implementation + childGuid: string; // child of child promise (for chained via `then`) + eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] + detail: any; // fulfillment value or rejection reason, if applicable + label: string; // label passed to promise's constructor + timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now + } - interface ObjectWithEventMixins { - on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - on(eventName: 'error', errorHandler: (reason: any) => void): void; - on(eventName: string, callback: (value: any) => void): void; - off(eventName: string, callback?: (value: any) => void): void; - trigger(eventName: string, options?: any, label?: string): void; - } + interface ObjectWithEventMixins { + on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + on(eventName: 'error', errorHandler: (reason: any) => void): void; + on(eventName: string, callback: (value: any) => void): void; + off(eventName: string, callback?: (value: any) => void): void; + trigger(eventName: string, options?: any, label?: string): void; + } - class Promise implements Thenable, Catchable { - /** + class Promise implements Thenable, Catchable { + /** * If you call resolve in the body of the callback passed to the constructor, * your promise is fulfilled with result object passed to resolve. * If you call reject your promise is rejected with the object passed to reject. * For consistency and debugging (eg stack traces), obj should be an instanceof Error. * Any errors thrown in the constructor callback will be implicitly passed to reject(). */ - constructor( - callback: ( - resolve: (result?: T | Thenable) => void, - reject: (error: C | Thenable) => void - ) => void, - label?: string - ); + constructor( + callback: ( + resolve: (result?: T | Thenable) => void, + reject: (error: C | Thenable) => void + ) => void, + label?: string + ); - /** + /** * onFulfillment is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. * Both are optional, if either/both are omitted the next onFulfillment/onRejected in the chain is called. * Both callbacks have a single parameter , the fulfillment value or rejection reason. @@ -116,31 +116,31 @@ declare namespace RSVP { * @param onRejected called when/if "promise" rejects * @param label useful for tooling */ - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Promise; - then(onFulfillment: Resolution, label?: string): Promise; - then(label?: string): Promise; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Promise; + then(onFulfillment: Resolution, label?: string): Promise; + then(label?: string): Promise; - /** + /** * Sugar for promise.then(undefined, onRejected) */ - catch(label?: string): Promise; - catch(onRejection: Rejection, label?: string): Promise; + catch(label?: string): Promise; + catch(onRejection: Rejection, label?: string): Promise; - finally(finallyCallback: Function): Promise; + finally(finallyCallback: Function): Promise; - /** + /** * `RSVP.Promise.all` accepts an array of promises, and returns a new promise which * is fulfilled with an array of fulfillment values for the passed promises, or * rejected with the reason of the first passed promise to be rejected. It casts all * elements of the passed iterable to promises as it runs this algorithm. */ - static all(promises: Thenable[], label?: string): Promise; + static all(promises: Thenable[], label?: string): Promise; - /** + /** * `RSVP.Promise.race` returns a new promise which is settled in the same way as the * first passed promise to settle. * @@ -150,67 +150,67 @@ declare namespace RSVP { * become rejected before the other promises became fulfilled, the returned * promise will become rejected. */ - static race(promises: Promise[]): Promise; + static race(promises: Promise[]): Promise; - /** + /** * Returns a promise that will become resolved with the passed `value` */ - static resolve(value: T, label?: string): Promise; + static resolve(value: T, label?: string): Promise; - /** + /** * Deprecated in favor of resolve */ - static cast(value: T, label?: string): Promise; + static cast(value: T, label?: string): Promise; - /** + /** * Returns a promise rejected with the passed `reason`. */ - static reject(reason: C): Promise; - } + static reject(reason: C): Promise; + } - export namespace EventTarget { - /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ - function mixin(object: object): ObjectWithEventMixins; + export namespace EventTarget { + /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ + function mixin(object: object): ObjectWithEventMixins; - /** Registers a callback to be executed when `eventName` is triggered */ - function on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - function on(eventName: 'error', errorHandler: (reason: any) => void): void; - function on(eventName: string, callback: (value: any) => void): void; + /** Registers a callback to be executed when `eventName` is triggered */ + function on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + function on(eventName: 'error', errorHandler: (reason: any) => void): void; + function on(eventName: string, callback: (value: any) => void): void; - /** + /** * You can use `off` to stop firing a particular callback for an event. * * If you don't pass a `callback` argument to `off`, ALL callbacks for the * event will not be executed when the event fires. */ - function off(eventName: string, callback?: (value: any) => void): void; + function off(eventName: string, callback?: (value: any) => void): void; - /** + /** * Use `trigger` to fire custom events. * * You can also pass a value as a second argument to `trigger` that will be * passed as an argument to all event listeners for the event */ - function trigger(eventName: string, options?: any, label?: string): void; - } + function trigger(eventName: string, options?: any, label?: string): void; + } - export function configure( - configName: 'instrument' | 'instrument-with-stack', - shouldInstrument: boolean - ): void; - export function configure(configName: string, value: any): void; + export function configure( + configName: 'instrument' | 'instrument-with-stack', + shouldInstrument: boolean + ): void; + export function configure(configName: string, value: any): void; - /** + /** * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. * the array passed to all can be a mixture of promise-like objects and other objects. * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. */ - export function all(promises: Thenable[]): Promise; + export function all(promises: Thenable[]): Promise; - /** + /** * `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array * for its `promises` argument. * @@ -223,9 +223,9 @@ declare namespace RSVP { * If any of the `promises` given to `RSVP.hash` are rejected, the first promise * that is rejected will be given as the reason to the rejection handler. */ - export function hash(promises: PromiseHash): Promise; + export function hash(promises: PromiseHash): Promise; - /** + /** * `RSVP.map` is similar to JavaScript's native `map` method. `mapFn` is eagerly called * meaning that as soon as any promise resolves its value will be passed to `mapFn`. * `RSVP.map` returns a promise that will become fulfilled with the result of running @@ -235,21 +235,21 @@ declare namespace RSVP { * that is rejected will be given as an argument to the returned promise's * rejection handler. */ - export function map( - promises: Thenable[], - mapFn: (item: T) => U, - label?: string - ): Promise; + export function map( + promises: Thenable[], + mapFn: (item: T) => U, + label?: string + ): Promise; - /** + /** * `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing * a fail-fast method, it waits until all the promises have returned and * shows you all the results. This is useful if you want to handle multiple * promises' failure states together as a set. */ - export function allSettled(promises: Thenable[]): Promise[], C>; + export function allSettled(promises: Thenable[]): Promise[], C>; - /** + /** * `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object * instead of an array for its `promises` argument. * @@ -259,14 +259,14 @@ declare namespace RSVP { * with their states and values/reasons. This is useful if you want to * handle multiple promises' failure states together as a set. */ - export function hashSettled(promises: PromiseHash): Promise, C>; + export function hashSettled(promises: PromiseHash): Promise, C>; - /** + /** * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ - function race(promises: Promise[]): Promise; + function race(promises: Promise[]): Promise; - /** + /** * `RSVP.denodeify` takes a "node-style" function and returns a function that * will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the * browser when you'd prefer to use promises over using callbacks. For example, @@ -324,12 +324,12 @@ declare namespace RSVP { * }); * ``` */ - export function denodeify( - nodeFunction: Function, - options: boolean | string[] - ): (...args: A[]) => Promise; + export function denodeify( + nodeFunction: Function, + options: boolean | string[] + ): (...args: A[]) => Promise; - /** + /** * `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. * `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s * interface. New code should use the `RSVP.Promise` constructor instead. @@ -339,32 +339,32 @@ declare namespace RSVP { * * reject - a function that causes the `promise` property on this object to become rejected * * resolve - a function that causes the `promise` property on this object to become fulfilled. */ - export function defer(label?: string): Deferred; + export function defer(label?: string): Deferred; - /** + /** * `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. */ - export function reject(reason: C): Promise; + export function reject(reason: C): Promise; - /** + /** * `RSVP.Promise.resolve` returns a promise that will become resolved with the * passed `value`. */ - export function resolve(value: T): Promise; + export function resolve(value: T): Promise; - /** + /** * `RSVP.filter` is similar to JavaScript's native `filter` method, except that it * waits for all promises to become fulfilled before running the `filterFn` on * each item in given to `promises`. `RSVP.filter` returns a promise that will * become fulfilled with the result of running `filterFn` on the values the * promises become fulfilled with. */ - export function filter( - promises: Thenable[], - filterFn: (value: T) => boolean | Promise - ): Promise; + export function filter( + promises: Thenable[], + filterFn: (value: T) => boolean | Promise + ): Promise; - /** + /** * `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event * loop in order to aid debugging. * @@ -376,7 +376,8 @@ declare namespace RSVP { * or domain/cause uncaught exception in Node. `rethrow` will also throw the * error again so the error can be handled by the promise per the spec. */ - export function rethrow(reason: C): void; + export function rethrow(reason: C): void; } -export default RSVP; +// export default RSVP; +export = RSVP; diff --git a/types/rsvp/tsconfig.json b/types/rsvp/tsconfig.json index 58c8e605be..fee17b279a 100644 --- a/types/rsvp/tsconfig.json +++ b/types/rsvp/tsconfig.json @@ -13,10 +13,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", "rsvp-tests.ts" ] -} \ No newline at end of file +} From 0196f2468ea3f38b96afe01e77fd7980710c8ac2 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 09:18:16 -0400 Subject: [PATCH 002/112] Update RSVP dependencies to allow synthetic imports. --- types/ember-testing-helpers/tsconfig.json | 3 ++- types/ember/tsconfig.json | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/types/ember-testing-helpers/tsconfig.json b/types/ember-testing-helpers/tsconfig.json index aaf474ecba..cd7634bd25 100644 --- a/types/ember-testing-helpers/tsconfig.json +++ b/types/ember-testing-helpers/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index d2f27dfec9..fbc4052a08 100644 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,10 +14,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", "ember-tests.ts" ] -} \ No newline at end of file +} From 6ecbed72420aa10dac76a64db6ced41e217f645b Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 09:19:55 -0400 Subject: [PATCH 003/112] Fix spacing in RSVP (thanks, Prettier). --- types/rsvp/index.d.ts | 296 +++++++++++++++++++++--------------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/types/rsvp/index.d.ts b/types/rsvp/index.d.ts index 5372bdd7d5..1aa764d785 100644 --- a/types/rsvp/index.d.ts +++ b/types/rsvp/index.d.ts @@ -14,98 +14,98 @@ // Credit for that file goes to: Barrie Nemetchek , Andrew Gaspar , John Reilly declare namespace RSVP { - type Resolution = (value: T) => U | Thenable; - type Rejection = (error: C) => D | Thenable; + type Resolution = (value: T) => U | Thenable; + type Rejection = (error: C) => D | Thenable; - interface Thenable { - then(label?: string): Thenable; - then(onFulfillment: Resolution, label?: string): Thenable; - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Thenable; - } + interface Thenable { + then(label?: string): Thenable; + then(onFulfillment: Resolution, label?: string): Thenable; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Thenable; + } - interface Catchable { - catch(label?: string): Catchable; - catch(onRejection: (error: C) => D, label?: string): Catchable; - } + interface Catchable { + catch(label?: string): Catchable; + catch(onRejection: (error: C) => D, label?: string): Catchable; + } - interface Deferred { - promise: Promise; - resolve(value: T): void; - reject(reason: C): void; - } + interface Deferred { + promise: Promise; + resolve(value: T): void; + reject(reason: C): void; + } - type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; - interface IPromiseState { - state: PromiseStates; - value: T; - reason: C; - } + type PromiseStates = 'fulfilled' | 'rejected' | 'pending'; + interface IPromiseState { + state: PromiseStates; + value: T; + reason: C; + } - class Resolved implements IPromiseState { - state: 'fulfilled'; - value: T; - reason: never; - } + class Resolved implements IPromiseState { + state: 'fulfilled'; + value: T; + reason: never; + } - class Rejected implements IPromiseState { - state: 'rejected'; - value: never; - reason: C; - } + class Rejected implements IPromiseState { + state: 'rejected'; + value: never; + reason: C; + } - class Pending implements IPromiseState { - state: 'pending'; - value: never; - reason: never; - } + class Pending implements IPromiseState { + state: 'pending'; + value: never; + reason: never; + } - type PromiseState = Resolved | Rejected | Pending; + type PromiseState = Resolved | Rejected | Pending; - type PromiseHash = { [P in keyof T]: Thenable | T[P] }; + type PromiseHash = { [P in keyof T]: Thenable | T[P] }; - type SettledHash = { [P in keyof T]: PromiseState }; + type SettledHash = { [P in keyof T]: PromiseState }; - interface InstrumentEvent { - guid: string; // guid of promise. Must be globally unique, not just within the implementation - childGuid: string; // child of child promise (for chained via `then`) - eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] - detail: any; // fulfillment value or rejection reason, if applicable - label: string; // label passed to promise's constructor - timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now - } + interface InstrumentEvent { + guid: string; // guid of promise. Must be globally unique, not just within the implementation + childGuid: string; // child of child promise (for chained via `then`) + eventName: string; // one of ['created', 'chained', 'fulfilled', 'rejected'] + detail: any; // fulfillment value or rejection reason, if applicable + label: string; // label passed to promise's constructor + timeStamp: number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now + } - interface ObjectWithEventMixins { - on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - on(eventName: 'error', errorHandler: (reason: any) => void): void; - on(eventName: string, callback: (value: any) => void): void; - off(eventName: string, callback?: (value: any) => void): void; - trigger(eventName: string, options?: any, label?: string): void; - } + interface ObjectWithEventMixins { + on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + on(eventName: 'error', errorHandler: (reason: any) => void): void; + on(eventName: string, callback: (value: any) => void): void; + off(eventName: string, callback?: (value: any) => void): void; + trigger(eventName: string, options?: any, label?: string): void; + } - class Promise implements Thenable, Catchable { - /** + class Promise implements Thenable, Catchable { + /** * If you call resolve in the body of the callback passed to the constructor, * your promise is fulfilled with result object passed to resolve. * If you call reject your promise is rejected with the object passed to reject. * For consistency and debugging (eg stack traces), obj should be an instanceof Error. * Any errors thrown in the constructor callback will be implicitly passed to reject(). */ - constructor( - callback: ( - resolve: (result?: T | Thenable) => void, - reject: (error: C | Thenable) => void - ) => void, - label?: string - ); + constructor( + callback: ( + resolve: (result?: T | Thenable) => void, + reject: (error: C | Thenable) => void + ) => void, + label?: string + ); - /** + /** * onFulfillment is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. * Both are optional, if either/both are omitted the next onFulfillment/onRejected in the chain is called. * Both callbacks have a single parameter , the fulfillment value or rejection reason. @@ -116,31 +116,31 @@ declare namespace RSVP { * @param onRejected called when/if "promise" rejects * @param label useful for tooling */ - then( - onFulfillment: Resolution, - onRejected: Rejection, - label?: string - ): Promise; - then(onFulfillment: Resolution, label?: string): Promise; - then(label?: string): Promise; + then( + onFulfillment: Resolution, + onRejected: Rejection, + label?: string + ): Promise; + then(onFulfillment: Resolution, label?: string): Promise; + then(label?: string): Promise; - /** + /** * Sugar for promise.then(undefined, onRejected) */ - catch(label?: string): Promise; - catch(onRejection: Rejection, label?: string): Promise; + catch(label?: string): Promise; + catch(onRejection: Rejection, label?: string): Promise; - finally(finallyCallback: Function): Promise; + finally(finallyCallback: Function): Promise; - /** + /** * `RSVP.Promise.all` accepts an array of promises, and returns a new promise which * is fulfilled with an array of fulfillment values for the passed promises, or * rejected with the reason of the first passed promise to be rejected. It casts all * elements of the passed iterable to promises as it runs this algorithm. */ - static all(promises: Thenable[], label?: string): Promise; + static all(promises: Thenable[], label?: string): Promise; - /** + /** * `RSVP.Promise.race` returns a new promise which is settled in the same way as the * first passed promise to settle. * @@ -150,67 +150,67 @@ declare namespace RSVP { * become rejected before the other promises became fulfilled, the returned * promise will become rejected. */ - static race(promises: Promise[]): Promise; + static race(promises: Promise[]): Promise; - /** + /** * Returns a promise that will become resolved with the passed `value` */ - static resolve(value: T, label?: string): Promise; + static resolve(value: T, label?: string): Promise; - /** + /** * Deprecated in favor of resolve */ - static cast(value: T, label?: string): Promise; + static cast(value: T, label?: string): Promise; - /** + /** * Returns a promise rejected with the passed `reason`. */ - static reject(reason: C): Promise; - } + static reject(reason: C): Promise; + } - export namespace EventTarget { - /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ - function mixin(object: object): ObjectWithEventMixins; + export namespace EventTarget { + /** `RSVP.EventTarget.mixin` extends an object with EventTarget methods. */ + function mixin(object: object): ObjectWithEventMixins; - /** Registers a callback to be executed when `eventName` is triggered */ - function on( - eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', - listener: (event: InstrumentEvent) => void - ): void; - function on(eventName: 'error', errorHandler: (reason: any) => void): void; - function on(eventName: string, callback: (value: any) => void): void; + /** Registers a callback to be executed when `eventName` is triggered */ + function on( + eventName: 'created' | 'chained' | 'fulfilled' | 'rejected', + listener: (event: InstrumentEvent) => void + ): void; + function on(eventName: 'error', errorHandler: (reason: any) => void): void; + function on(eventName: string, callback: (value: any) => void): void; - /** + /** * You can use `off` to stop firing a particular callback for an event. * * If you don't pass a `callback` argument to `off`, ALL callbacks for the * event will not be executed when the event fires. */ - function off(eventName: string, callback?: (value: any) => void): void; + function off(eventName: string, callback?: (value: any) => void): void; - /** + /** * Use `trigger` to fire custom events. * * You can also pass a value as a second argument to `trigger` that will be * passed as an argument to all event listeners for the event */ - function trigger(eventName: string, options?: any, label?: string): void; - } + function trigger(eventName: string, options?: any, label?: string): void; + } - export function configure( - configName: 'instrument' | 'instrument-with-stack', - shouldInstrument: boolean - ): void; - export function configure(configName: string, value: any): void; + export function configure( + configName: 'instrument' | 'instrument-with-stack', + shouldInstrument: boolean + ): void; + export function configure(configName: string, value: any): void; - /** + /** * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. * the array passed to all can be a mixture of promise-like objects and other objects. * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. */ - export function all(promises: Thenable[]): Promise; + export function all(promises: Thenable[]): Promise; - /** + /** * `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array * for its `promises` argument. * @@ -223,9 +223,9 @@ declare namespace RSVP { * If any of the `promises` given to `RSVP.hash` are rejected, the first promise * that is rejected will be given as the reason to the rejection handler. */ - export function hash(promises: PromiseHash): Promise; + export function hash(promises: PromiseHash): Promise; - /** + /** * `RSVP.map` is similar to JavaScript's native `map` method. `mapFn` is eagerly called * meaning that as soon as any promise resolves its value will be passed to `mapFn`. * `RSVP.map` returns a promise that will become fulfilled with the result of running @@ -235,21 +235,21 @@ declare namespace RSVP { * that is rejected will be given as an argument to the returned promise's * rejection handler. */ - export function map( - promises: Thenable[], - mapFn: (item: T) => U, - label?: string - ): Promise; + export function map( + promises: Thenable[], + mapFn: (item: T) => U, + label?: string + ): Promise; - /** + /** * `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing * a fail-fast method, it waits until all the promises have returned and * shows you all the results. This is useful if you want to handle multiple * promises' failure states together as a set. */ - export function allSettled(promises: Thenable[]): Promise[], C>; + export function allSettled(promises: Thenable[]): Promise[], C>; - /** + /** * `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object * instead of an array for its `promises` argument. * @@ -259,14 +259,14 @@ declare namespace RSVP { * with their states and values/reasons. This is useful if you want to * handle multiple promises' failure states together as a set. */ - export function hashSettled(promises: PromiseHash): Promise, C>; + export function hashSettled(promises: PromiseHash): Promise, C>; - /** + /** * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ - function race(promises: Promise[]): Promise; + function race(promises: Promise[]): Promise; - /** + /** * `RSVP.denodeify` takes a "node-style" function and returns a function that * will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the * browser when you'd prefer to use promises over using callbacks. For example, @@ -324,12 +324,12 @@ declare namespace RSVP { * }); * ``` */ - export function denodeify( - nodeFunction: Function, - options: boolean | string[] - ): (...args: A[]) => Promise; + export function denodeify( + nodeFunction: Function, + options: boolean | string[] + ): (...args: A[]) => Promise; - /** + /** * `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. * `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s * interface. New code should use the `RSVP.Promise` constructor instead. @@ -339,32 +339,32 @@ declare namespace RSVP { * * reject - a function that causes the `promise` property on this object to become rejected * * resolve - a function that causes the `promise` property on this object to become fulfilled. */ - export function defer(label?: string): Deferred; + export function defer(label?: string): Deferred; - /** + /** * `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. */ - export function reject(reason: C): Promise; + export function reject(reason: C): Promise; - /** + /** * `RSVP.Promise.resolve` returns a promise that will become resolved with the * passed `value`. */ - export function resolve(value: T): Promise; + export function resolve(value: T): Promise; - /** + /** * `RSVP.filter` is similar to JavaScript's native `filter` method, except that it * waits for all promises to become fulfilled before running the `filterFn` on * each item in given to `promises`. `RSVP.filter` returns a promise that will * become fulfilled with the result of running `filterFn` on the values the * promises become fulfilled with. */ - export function filter( - promises: Thenable[], - filterFn: (value: T) => boolean | Promise - ): Promise; + export function filter( + promises: Thenable[], + filterFn: (value: T) => boolean | Promise + ): Promise; - /** + /** * `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event * loop in order to aid debugging. * @@ -376,7 +376,7 @@ declare namespace RSVP { * or domain/cause uncaught exception in Node. `rethrow` will also throw the * error again so the error can be handled by the promise per the spec. */ - export function rethrow(reason: C): void; + export function rethrow(reason: C): void; } // export default RSVP; From c1bbbe3c691c07c6017c11ecf7bf6c12a357fb0a Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 11 Aug 2017 18:08:42 -0400 Subject: [PATCH 004/112] Use `import =` for RSVP tests; drop corresponding tsconfig setting. --- types/rsvp/index.d.ts | 1 - types/rsvp/rsvp-tests.ts | 2 +- types/rsvp/tsconfig.json | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/types/rsvp/index.d.ts b/types/rsvp/index.d.ts index 1aa764d785..8f2fdfee04 100644 --- a/types/rsvp/index.d.ts +++ b/types/rsvp/index.d.ts @@ -379,5 +379,4 @@ declare namespace RSVP { export function rethrow(reason: C): void; } -// export default RSVP; export = RSVP; diff --git a/types/rsvp/rsvp-tests.ts b/types/rsvp/rsvp-tests.ts index 519947dcc7..aec0acfede 100644 --- a/types/rsvp/rsvp-tests.ts +++ b/types/rsvp/rsvp-tests.ts @@ -1,4 +1,4 @@ -import RSVP from 'rsvp'; +import RSVP = require('rsvp'); let promise1: RSVP.Promise = RSVP.Promise.resolve(1); let promise1a: RSVP.Promise = RSVP.resolve(1); diff --git a/types/rsvp/tsconfig.json b/types/rsvp/tsconfig.json index fee17b279a..4eb44a2f7d 100644 --- a/types/rsvp/tsconfig.json +++ b/types/rsvp/tsconfig.json @@ -13,8 +13,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", From 2ff76c2755156481894f7db78a7fa539b2aa3112 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 14 Aug 2017 14:06:21 -0700 Subject: [PATCH 005/112] Remove `--allowSyntheticDefaultImports` --- types/ember-testing-helpers/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/ember-testing-helpers/tsconfig.json b/types/ember-testing-helpers/tsconfig.json index cd7634bd25..aaf474ecba 100644 --- a/types/ember-testing-helpers/tsconfig.json +++ b/types/ember-testing-helpers/tsconfig.json @@ -14,8 +14,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", From 43a1348b9146b0c6130a37f28d019eb2924ad9a3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 14 Aug 2017 14:06:48 -0700 Subject: [PATCH 006/112] Remove `--allowSyntheticDefaultImports` --- types/ember/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index fbc4052a08..b73838d20e 100644 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,8 +14,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", From 16caa8fc42719ecda67d71002c4f3022a285d7ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20B=C3=ADro=C5=A1?= Date: Wed, 23 Aug 2017 07:55:33 +0200 Subject: [PATCH 007/112] Added SubmissionError into export for immutabable Added SubmissionError into export in redux-from/immutable/index.d.ts in order to be able to use SubmissionError with immutable store state. In redux-form/lib/SubmissionError.d.ts changed default generic from void to any, in order to be able to use it as is state redux-form docs. http://redux-form.com/7.0.3/examples/submitValidation/ Because there is no way to pass anoter type into generic constructor from real project. --- types/redux-form/immutable/index.d.ts | 1 + types/redux-form/lib/SubmissionError.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/redux-form/immutable/index.d.ts b/types/redux-form/immutable/index.d.ts index 3eacb2338c..fe5cc6904d 100644 --- a/types/redux-form/immutable/index.d.ts +++ b/types/redux-form/immutable/index.d.ts @@ -20,4 +20,5 @@ export { isPristine, isSubmitting, isValid, + SubmissionError } from "redux-form"; diff --git a/types/redux-form/lib/SubmissionError.d.ts b/types/redux-form/lib/SubmissionError.d.ts index ffe7a0064a..790cb8e697 100644 --- a/types/redux-form/lib/SubmissionError.d.ts +++ b/types/redux-form/lib/SubmissionError.d.ts @@ -1,7 +1,7 @@ import { FormErrors } from "redux-form"; -export interface SubmissionErrorConstructor { +export interface SubmissionErrorConstructor { new (errors?: FormErrors): Error; } -declare const SubmissionError: SubmissionErrorConstructor; +declare const SubmissionError: SubmissionErrorConstructor; From 6800cd1a0aa752cf6f2e05cb7d5317fd5d3856c1 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Thu, 24 Aug 2017 17:54:13 +1000 Subject: [PATCH 008/112] add: xhr-mock --- types/xhr-mock/index.d.ts | 57 ++++++++++++++++++++++++++++++++ types/xhr-mock/tsconfig.json | 23 +++++++++++++ types/xhr-mock/tslint.json | 1 + types/xhr-mock/xhr-mock-tests.ts | 25 ++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 types/xhr-mock/index.d.ts create mode 100644 types/xhr-mock/tsconfig.json create mode 100644 types/xhr-mock/tslint.json create mode 100644 types/xhr-mock/xhr-mock-tests.ts diff --git a/types/xhr-mock/index.d.ts b/types/xhr-mock/index.d.ts new file mode 100644 index 0000000000..eacec1c5fc --- /dev/null +++ b/types/xhr-mock/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for xhr-mock 1.9 +// Project: https://github.com/jameslnewell/xhr-mock#readme +// Definitions by: Joscha Feth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace mock { + interface Headers { + [k: string]: string; + } + + interface MockResponse { + status(code: number): this; + status(): number; + statusText(statusText: string): this; + statusText(): string; + header(name: string, value: string): this; + header(name: string): string | null; + headers(obj: Headers): this; + headers(): Headers; + body(body: string): this; + body(): string; + timeout(timeout: boolean | number): this; + timeout(): boolean | number; + } + + interface MockRequest { + method(): string; + url(): string; + query(): string; + header(name: string, value: string): this; + header(name: string): string | null; + headers(obj: Headers): this; + headers(): Headers; + body(body: string): this; + body(): string; + progress(loaded: number, total: number, lengthComputable?: boolean): void; + } + + type MockFunction = (req: MockRequest, res: MockResponse) => MockResponse | null; + + interface XhrMock { + XMLHttpRequest: XMLHttpRequest; + setup(): this; + teardown(): this; + reset(): this; + mock(method: string, url: string, fn: mock.MockFunction): this; + get(url: string, fn: mock.MockFunction): this; + post(url: string, fn: mock.MockFunction): this; + put(url: string, fn: mock.MockFunction): this; + patch(url: string, fn: mock.MockFunction): this; + delete(url: string, fn: mock.MockFunction): this; + } +} + +declare var mock: mock.XhrMock; +export = mock; +export as namespace mock; diff --git a/types/xhr-mock/tsconfig.json b/types/xhr-mock/tsconfig.json new file mode 100644 index 0000000000..6a5c03268f --- /dev/null +++ b/types/xhr-mock/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "xhr-mock-tests.ts" + ] +} diff --git a/types/xhr-mock/tslint.json b/types/xhr-mock/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/xhr-mock/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/xhr-mock/xhr-mock-tests.ts b/types/xhr-mock/xhr-mock-tests.ts new file mode 100644 index 0000000000..fd26b3a43f --- /dev/null +++ b/types/xhr-mock/xhr-mock-tests.ts @@ -0,0 +1,25 @@ +// replace the real XHR object with the mock XHR object +mock.setup(); + +// create a mock response for all POST requests with the URL http://localhost/api/user +mock.post('http://localhost/api/user', (req: mock.MockRequest, res: mock.MockResponse) => { + // return null; //simulate an error + // return res.timeout(true); //simulate a timeout + + return res + .status(201) + .header('Content-Type', 'application/json') + .body(JSON.stringify({data: { + first_name: 'John', last_name: 'Smith' + }})); +}); + +// create an instance of the (mock) XHR object and use as per normal +const xhr = new XMLHttpRequest(); + +xhr.onreadystatechange = () => { + if (xhr.readyState === 4) { + // when you're finished put the real XHR object back + mock.teardown(); + } +}; From 149dde5da4afd0172f82a1bdd66b23581e4a56c2 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Thu, 24 Aug 2017 09:02:31 -0400 Subject: [PATCH 009/112] Revert "Remove `--allowSyntheticDefaultImports`" (from ember-testing-helpers) This reverts commit 2ff76c2755156481894f7db78a7fa539b2aa3112. --- types/ember-testing-helpers/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/ember-testing-helpers/tsconfig.json b/types/ember-testing-helpers/tsconfig.json index aaf474ecba..cd7634bd25 100644 --- a/types/ember-testing-helpers/tsconfig.json +++ b/types/ember-testing-helpers/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", From 4ad5e86ffe81753f4fd3b53171ab33d9f313947e Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Thu, 24 Aug 2017 09:02:49 -0400 Subject: [PATCH 010/112] Revert "Remove `--allowSyntheticDefaultImports`" (from ember) This reverts commit 43a1348b9146b0c6130a37f28d019eb2924ad9a3. --- types/ember/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index b73838d20e..fbc4052a08 100644 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", From fbc01f889d2cf65cf724b3e4d8e6d6635eaa6b20 Mon Sep 17 00:00:00 2001 From: loopArray <525029662@qq.com> Date: Sun, 27 Aug 2017 00:13:06 +0800 Subject: [PATCH 011/112] fixed some ts error My environment is typescript 2.4.2, which reminds me of the wrong type. `[ts] JSX element type 'Icon' does not have any construct or call signatures.` When you add `typeof` changes like this, there is no error --- types/react-native-vector-icons/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native-vector-icons/index.d.ts b/types/react-native-vector-icons/index.d.ts index 3e9af9e042..b9dfc622c3 100644 --- a/types/react-native-vector-icons/index.d.ts +++ b/types/react-native-vector-icons/index.d.ts @@ -24,7 +24,7 @@ export function createIconSet( glyphMap: {}, fontFamily: string, fontFile?: string -): Icon; +): typeof Icon; /** * Convenience method to create a custom font based on a fontello config file. @@ -41,7 +41,7 @@ export function createIconSet( * @param {{}} config * @returns {Icon} */ -export function createIconSetFromFontello(config: {}): Icon; +export function createIconSetFromFontello(config: {}): typeof Icon; /** * Convenience method to create a custom font from IcoMoon @@ -59,4 +59,4 @@ export function createIconSetFromFontello(config: {}): Icon; * @param {{}} config * @returns {Icon} */ -export function createIconSetFromIcoMoon(config: {}): Icon; +export function createIconSetFromIcoMoon(config: {}): typeof Icon; From 0d4f8a72c5fbe648821b195c2b96438434c6aca5 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sun, 27 Aug 2017 10:51:24 +0200 Subject: [PATCH 012/112] feat(fs-extra): callbacks can return `null` as value when there is no error --- types/fs-extra/fs-extra-tests.ts | 2 +- types/fs-extra/index.d.ts | 146 ++++++++++++++++--------------- 2 files changed, 75 insertions(+), 73 deletions(-) diff --git a/types/fs-extra/fs-extra-tests.ts b/types/fs-extra/fs-extra-tests.ts index 22232bc297..a807428548 100644 --- a/types/fs-extra/fs-extra-tests.ts +++ b/types/fs-extra/fs-extra-tests.ts @@ -14,7 +14,7 @@ const fd = 0; const modeNum = 0; const modeStr = ""; const object = {}; -const errorCallback = (err: Error) => { }; +const errorCallback = (err: Error | null) => { }; const readOptions: fs.ReadOptions = { reviver: {} }; diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index 0231cac2d2..90e26418ba 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -14,140 +14,141 @@ import { Stats } from "fs"; export * from "fs"; export function copy(src: string, dest: string, options?: CopyOptions): Promise; -export function copy(src: string, dest: string, callback: (err: Error) => void): void; -export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error) => void): void; +export function copy(src: string, dest: string, callback: (err: Error | null) => void): void; +export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error | null) => void): void; export function copySync(src: string, dest: string, options?: CopyOptions): void; export function move(src: string, dest: string, options?: MoveOptions): Promise; -export function move(src: string, dest: string, callback: (err: Error) => void): void; -export function move(src: string, dest: string, options: MoveOptions, callback: (err: Error) => void): void; +export function move(src: string, dest: string, callback: (err: Error | null) => void): void; +export function move(src: string, dest: string, options: MoveOptions, callback: (err: Error | null) => void): void; export function moveSync(src: string, dest: string, options?: MoveOptions): void; export function createFile(file: string): Promise; -export function createFile(file: string, callback: (err: Error) => void): void; +export function createFile(file: string, callback: (err: Error | null) => void): void; export function createFileSync(file: string): void; export function ensureDir(path: string): Promise; -export function ensureDir(path: string, callback: (err: Error) => void): void; +export function ensureDir(path: string, callback: (err: Error | null) => void): void; export function ensureDirSync(path: string): void; export function mkdirs(dir: string): Promise; -export function mkdirs(dir: string, callback: (err: Error) => void): void; +export function mkdirs(dir: string, callback: (err: Error | null) => void): void; export function mkdirp(dir: string): Promise; -export function mkdirp(dir: string, callback: (err: Error) => void): void; +export function mkdirp(dir: string, callback: (err: Error | null) => void): void; export function mkdirsSync(dir: string): void; export function mkdirpSync(dir: string): void; export function outputFile(file: string, data: any): Promise; -export function outputFile(file: string, data: any, callback: (err: Error) => void): void; +export function outputFile(file: string, data: any, callback: (err: Error | null) => void): void; export function outputFileSync(file: string, data: any): void; export function readJson(file: string, options?: ReadOptions): Promise; -export function readJson(file: string, callback: (err: Error, jsonObject: any) => void): void; -export function readJson(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void; +export function readJson(file: string, callback: (err: Error | null, jsonObject: any) => void): void; +export function readJson(file: string, options: ReadOptions, callback: (err: Error | null, jsonObject: any) => void): void; export function readJSON(file: string, options?: ReadOptions): Promise; -export function readJSON(file: string, callback: (err: Error, jsonObject: any) => void): void; -export function readJSON(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void; +export function readJSON(file: string, callback: (err: Error | null, jsonObject: any) => void): void; +export function readJSON(file: string, options: ReadOptions, callback: (err: Error | null, jsonObject: any) => void): void; export function readJsonSync(file: string, options?: ReadOptions): any; export function readJSONSync(file: string, options?: ReadOptions): any; export function remove(dir: string): Promise; -export function remove(dir: string, callback: (err: Error) => void): void; +export function remove(dir: string, callback: (err: Error | null) => void): void; export function removeSync(dir: string): void; export function outputJSON(file: string, data: any, options?: WriteOptions): Promise; -export function outputJSON(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void; -export function outputJSON(file: string, data: any, callback: (err: Error) => void): void; +export function outputJSON(file: string, data: any, options: WriteOptions, callback: (err: Error | null) => void): void; +export function outputJSON(file: string, data: any, callback: (err: Error | null) => void): void; export function outputJson(file: string, data: any, options?: WriteOptions): Promise; -export function outputJson(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void; -export function outputJson(file: string, data: any, callback: (err: Error) => void): void; +export function outputJson(file: string, data: any, options: WriteOptions, callback: (err: Error | null) => void): void; +export function outputJson(file: string, data: any, callback: (err: Error | null) => void): void; export function outputJsonSync(file: string, data: any, options?: WriteOptions): void; export function outputJSONSync(file: string, data: any, options?: WriteOptions): void; export function writeJSON(file: string, object: any, options?: WriteOptions): Promise; -export function writeJSON(file: string, object: any, callback: (err: Error) => void): void; -export function writeJSON(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void; +export function writeJSON(file: string, object: any, callback: (err: Error | null) => void): void; +export function writeJSON(file: string, object: any, options: WriteOptions, callback: (err: Error | null) => void): void; export function writeJson(file: string, object: any, options?: WriteOptions): Promise; -export function writeJson(file: string, object: any, callback: (err: Error) => void): void; -export function writeJson(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void; +export function writeJson(file: string, object: any, callback: (err: Error | null) => void): void; +export function writeJson(file: string, object: any, options: WriteOptions, callback: (err: Error | null) => void): void; export function writeJsonSync(file: string, object: any, options?: WriteOptions): void; export function writeJSONSync(file: string, object: any, options?: WriteOptions): void; export function ensureFile(path: string): Promise; -export function ensureFile(path: string, callback: (err: Error) => void): void; +export function ensureFile(path: string, callback: (err: Error | null) => void): void; export function ensureFileSync(path: string): void; export function ensureLink(src: string, dest: string): Promise; -export function ensureLink(src: string, dest: string, callback: (err: Error) => void): void; +export function ensureLink(src: string, dest: string, callback: (err: Error | null) => void): void; export function ensureLinkSync(src: string, dest: string): void; export function ensureSymlink(src: string, dest: string, type?: SymlinkType): Promise; -export function ensureSymlink(src: string, dest: string, type: SymlinkType, callback: (err: Error) => void): void; -export function ensureSymlink(src: string, dest: string, callback: (err: Error) => void): void; +export function ensureSymlink(src: string, dest: string, type: SymlinkType, callback: (err: Error | null) => void): void; +export function ensureSymlink(src: string, dest: string, callback: (err: Error | null) => void): void; export function ensureSymlinkSync(src: string, dest: string, type?: SymlinkType): void; export function emptyDir(path: string): Promise; -export function emptyDir(path: string, callback: (err: Error) => void): void; +export function emptyDir(path: string, callback: (err: Error | null) => void): void; export function emptyDirSync(path: string): void; export function pathExists(path: string): Promise; -export function pathExists(path: string, callback: (err: Error, exists: boolean) => void): void; +export function pathExists(path: string, callback: (err: Error | null, exists: boolean) => void): void; export function pathExistsSync(path: string): boolean; // fs async methods // copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v6/index.d.ts /** Tests a user's permissions for the file specified by path. */ -export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; -export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; +export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; +export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; export function access(path: string | Buffer, mode?: number): Promise; -export function appendFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number | string; flag?: string; }, callback: (err: NodeJS.ErrnoException) => void): void; -export function appendFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void; +export function appendFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number | string; flag?: string; }, + callback: (err: NodeJS.ErrnoException | null) => void): void; +export function appendFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException | null) => void): void; export function appendFile(file: string | Buffer | number, data: any, options?: { encoding?: string; mode?: number | string; flag?: string; }): Promise; -export function chmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function chmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function chmod(path: string | Buffer, mode: string | number): Promise; export function chown(path: string | Buffer, uid: number, gid: number): Promise; -export function chown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function chown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; -export function close(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function close(fd: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function close(fd: number): Promise; -export function fchmod(fd: number, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function fchmod(fd: number, mode: string | number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function fchmod(fd: number, mode: string | number): Promise; -export function fchown(fd: number, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function fchown(fd: number, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function fchown(fd: number, uid: number, gid: number): Promise; export function fdatasync(fd: number, callback: () => void): void; export function fdatasync(fd: number): Promise; -export function fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any): void; export function fstat(fd: number): Promise; -export function fsync(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function fsync(fd: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function fsync(fd: number): Promise; -export function ftruncate(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; -export function ftruncate(fd: number, len: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function ftruncate(fd: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; +export function ftruncate(fd: number, len: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function ftruncate(fd: number, len?: number): Promise; -export function futimes(fd: number, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void; -export function futimes(fd: number, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void; +export function futimes(fd: number, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; +export function futimes(fd: number, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function futimes(fd: number, atime: number, mtime: number): Promise; export function futimes(fd: number, atime: Date, mtime: Date): Promise; -export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function lchown(path: string | Buffer, uid: number, gid: number): Promise; -export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function link(srcpath: string | Buffer, dstpath: string | Buffer): Promise; -export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any): void; export function lstat(path: string | Buffer): Promise; /** @@ -156,7 +157,7 @@ export function lstat(path: string | Buffer): Promise; * @param path * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; /** * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. * @@ -164,35 +165,36 @@ export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoExcept * @param mode * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function mkdir(path: string | Buffer, mode: number | string, callback: (err?: NodeJS.ErrnoException) => void): void; +export function mkdir(path: string | Buffer, mode: number | string, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function mkdir(path: string | Buffer): Promise; -export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; -export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; +export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; +export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; export function open(path: string | Buffer, flags: string | number, mode?: number): Promise; -export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; +export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: Buffer) => void): void; export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null): Promise; -export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; -export function readFile(file: string | Buffer | number, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; +export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; +export function readFile(file: string | Buffer | number, encoding: string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void; export function readFile(file: string | Buffer | number, options: { flag?: string; } | { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; export function readFile(file: string | Buffer | number, options: { flag?: string; } | { encoding: string; flag?: string; }): Promise; // tslint:disable-next-line:unified-signatures export function readFile(file: string | Buffer | number, encoding: string): Promise; export function readFile(file: string | Buffer | number): Promise; -export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void; +export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; export function readdir(path: string | Buffer): Promise; -export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void; +export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, linkString: string) => any): void; export function readlink(path: string | Buffer): Promise; -export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; -export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; +export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => any): void; +export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => any): void; export function realpath(path: string | Buffer, cache?: { [path: string]: string }): Promise; -export function rename(oldPath: string, newPath: string, callback: (err?: NodeJS.ErrnoException) => void): void; +export function rename(oldPath: string, newPath: string, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function rename(oldPath: string, newPath: string): Promise; /** @@ -201,17 +203,17 @@ export function rename(oldPath: string, newPath: string): Promise; * @param path * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function rmdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function rmdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function rmdir(path: string | Buffer): Promise; -export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any): void; export function stat(path: string | Buffer): Promise; -export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err?: NodeJS.ErrnoException) => void): void; +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): Promise; -export function truncate(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; -export function truncate(path: string | Buffer, len: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function truncate(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; +export function truncate(path: string | Buffer, len: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function truncate(path: string | Buffer, len?: number): Promise; /** @@ -220,25 +222,25 @@ export function truncate(path: string | Buffer, len?: number): Promise; * @param path * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function unlink(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function unlink(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function unlink(path: string | Buffer): Promise; export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void; -export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void; +export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function utimes(path: string | Buffer, atime: number, mtime: number): Promise; export function utimes(path: string | Buffer, atime: Date, mtime: Date): Promise; export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; -export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; -export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; -export function write(fd: number, data: any, offset: number, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; -export function write(fd: number, data: any, offset: number, encoding: string, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; +export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; +export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; +export function write(fd: number, data: any, offset: number, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; +export function write(fd: number, data: any, offset: number, encoding: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; export function write(fd: number, buffer: Buffer, offset: number, length: number, position?: number | null): Promise; export function write(fd: number, data: any, offset: number, encoding?: string): Promise; -export function writeFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void; +export function writeFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException | null) => void): void; export function writeFile(file: string | Buffer | number, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): Promise; -export function writeFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback: (err: NodeJS.ErrnoException) => void): void; +export function writeFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback: (err: NodeJS.ErrnoException | null) => void): void; /** * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. @@ -247,7 +249,7 @@ export function writeFile(file: string | Buffer | number, data: any, options: { * @param callback The created folder path is passed as a string to the callback's second parameter. */ export function mkdtemp(prefix: string): Promise; -export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException, folder: string) => void): void; +export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void; export interface PathEntry { path: string; From 15e604f2f37524a9bc39e35a61bc6d26696fd31e Mon Sep 17 00:00:00 2001 From: Frank Tan Date: Sun, 27 Aug 2017 16:11:16 -0400 Subject: [PATCH 013/112] [react-redux] Make `connect` input types optional For convenience. --- types/react-redux/index.d.ts | 22 +++++++++++----------- types/react-redux/react-redux-tests.tsx | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index b83252a745..44c18a91a5 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -67,66 +67,66 @@ export type InferableComponentEnhancer = */ export declare function connect(): InferableComponentEnhancer>; -export declare function connect( +export declare function connect( mapStateToProps: MapStateToPropsParam ): InferableComponentEnhancerWithProps, TOwnProps>; -export declare function connect( +export declare function connect( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: Options ): InferableComponentEnhancerWithProps & TStateProps, TOwnProps>; -export declare function connect( +export declare function connect( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, options: Options ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, options: Options ): InferableComponentEnhancerWithProps; -export declare function connect( +export declare function connect( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index 5a9b038dc5..619a25a7df 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -57,26 +57,26 @@ interface ICounterDispatchProps { onIncrement: () => void } // with higher order functions -connect( +connect( () => mapStateToProps, () => mapDispatchToProps )(Counter); // with higher order functions using parameters -connect( +connect( (initialState: CounterState, ownProps) => mapStateToProps, (dispatch: Dispatch, ownProps) => mapDispatchToProps )(Counter); // only first argument -connect( +connect( () => mapStateToProps )(Counter); // wrap only one argument -connect( +connect( mapStateToProps, () => mapDispatchToProps )(Counter); // with extra arguments -connect( +connect( () => mapStateToProps, () => mapDispatchToProps, (s: ICounterStateProps, d: ICounterDispatchProps) => From 582bba204d4918c447cd6cc68aca775c5123b481 Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Wed, 2 Aug 2017 11:52:55 +0800 Subject: [PATCH 014/112] Update typing for pg --- types/pg/index.d.ts | 31 +++++++++++---------- types/pg/pg-tests.ts | 63 +++++++++++++++++++++++++----------------- types/pg/tsconfig.json | 4 +-- types/pg/tslint.json | 5 ++++ 4 files changed, 61 insertions(+), 42 deletions(-) create mode 100644 types/pg/tslint.json diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index da6f4db575..fc20d5fd85 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -9,9 +9,11 @@ import events = require("events"); import stream = require("stream"); import pgTypes = require("pg-types"); -export declare function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; -export declare function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; -export declare function end(): void; +// tslint:disable-next-line unified-signatures +export function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; +// tslint:disable-next-line unified-signatures +export function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; +export function end(): void; export interface ConnectionConfig { user?: string; @@ -64,7 +66,7 @@ export interface ResultBuilder extends QueryResult { addRow(row: any): void; } -export declare class Pool extends events.EventEmitter { +export class Pool extends events.EventEmitter { // `new Pool('pg://user@localhost/mydb')` is not allowed. // But it passes type check because of issue: // https://github.com/Microsoft/TypeScript/issues/7485 @@ -76,9 +78,8 @@ export declare class Pool extends events.EventEmitter { end(callback?: () => void): Promise; query(queryStream: QueryConfig & stream.Readable): stream.Readable; - query(queryTextOrConfig: string | QueryConfig): Promise; - query(queryText: string, values: any[]): Promise; - + query(queryConfig: QueryConfig): Promise; + query(queryText: string, values?: any[]): Promise; query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; @@ -86,18 +87,17 @@ export declare class Pool extends events.EventEmitter { on(event: "connect" | "acquire", listener: (client: Client) => void): this; } -export declare class Client extends events.EventEmitter { - constructor(connection: string); - constructor(config: ClientConfig); +export class Client extends events.EventEmitter { + constructor(connection: string); // tslint:disable-line unified-signatures + constructor(config: ClientConfig); // tslint:disable-line unified-signatures connect(callback?: (err: Error) => void): void; end(callback?: (err: Error) => void): void; release(err?: Error): void; query(queryStream: QueryConfig & stream.Readable): stream.Readable; - query(queryTextOrConfig: string | QueryConfig): Promise; - query(queryText: string, values: any[]): Promise; - + query(queryConfig: QueryConfig): Promise; + query(queryText: string, values?: any[]): Promise; query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; @@ -110,16 +110,17 @@ export declare class Client extends events.EventEmitter { on(event: "drain", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "notification" | "notice", listener: (message: any) => void): this; + // tslint:disable-next-line unified-signatures on(event: "end", listener: () => void): this; } -export declare class Query extends events.EventEmitter { +export class Query extends events.EventEmitter { on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "end", listener: (result: ResultBuilder) => void): this; } -export declare class Events extends events.EventEmitter { +export class Events extends events.EventEmitter { on(event: "error", listener: (err: Error, client: Client) => void): this; } diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index 4b4cfba7ec..6bdf408bee 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -1,8 +1,9 @@ import * as pg from "pg"; -var conString = "postgres://username:password@localhost/database"; +const conString = "postgres://username:password@localhost/database"; // https://github.com/brianc/node-pg-types +// tslint:disable-next-line no-unnecessary-callback-wrapper pg.types.setTypeParser(20, val => Number(val)); // Client pooling @@ -15,8 +16,7 @@ pg.connect(conString, (err, client, done) => { if (err) { done(err); return console.error("Error running query", err); - } - else { + } else { done(); } console.log(result.rows[0]["number"]); @@ -26,7 +26,7 @@ pg.connect(conString, (err, client, done) => { }); // Simple -var client = new pg.Client(conString); +const client = new pg.Client(conString); client.connect(err => { if (err) { return console.error("Could not connect to postgres", err); @@ -46,36 +46,49 @@ client.on('end', () => console.log("Client was disconnected.")); // client pooling -var config = { - user: 'foo', //env var: PGUSER - database: 'my_db', //env var: PGDATABASE - password: 'secret', //env var: PGPASSWORD - 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, +const config = { + user: 'foo', + database: 'my_db', + password: 'secret', + port: 5432, + max: 10, + idleTimeoutMillis: 30000, + Promise, }; -var pool = new pg.Pool(config); +const pool = new pg.Pool(config); pool.connect((err, client, done) => { - if(err) { - return console.error('error fetching client from pool', err); - } - client.query('SELECT $1::int AS number', ['1'], (err, result) => { - done(); - - if(err) { - return console.error('error running query', err); + if (err) { + return console.error('error fetching client from pool', err); } - console.log(result.rows[0].number); - }); + client.query('SELECT $1::int AS number', ['1'], (err, result) => { + done(); + + if (err) { + return console.error('error running query', err); + } + console.log(result.rows[0].number); + }); }); pool.on('error', (err, client) => { - console.error('idle client error', err.message, err.stack) -}) + console.error('idle client error', err.message, err.stack); +}); pool.end(); pool.end(() => { console.log("pool is closed"); }); + +// Promise + +function query(sql: string, binds?: any[]): void { + // binds: any[] | undefined + pool.query(sql, binds) + .then((result: pg.QueryResult) => { + console.log(result.rows[0].number); + }) + .catch((err: any) => { + console.error('error running query', err); + }); +} diff --git a/types/pg/tsconfig.json b/types/pg/tsconfig.json index 3535f4d43f..6905c7197c 100644 --- a/types/pg/tsconfig.json +++ b/types/pg/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "pg-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/pg/tslint.json b/types/pg/tslint.json new file mode 100644 index 0000000000..495d29983d --- /dev/null +++ b/types/pg/tslint.json @@ -0,0 +1,5 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + } +} From 59035dd08eb992d11440874d99785707e36677af Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Thu, 3 Aug 2017 11:32:19 +0800 Subject: [PATCH 015/112] Fix review comment --- types/pg/index.d.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index fc20d5fd85..b2c3634f5c 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -9,10 +9,9 @@ import events = require("events"); import stream = require("stream"); import pgTypes = require("pg-types"); -// tslint:disable-next-line unified-signatures -export function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; -// tslint:disable-next-line unified-signatures -export function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; +export function connect( + connectionOrConfig: string | ClientConfig, + callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; export function end(): void; export interface ConnectionConfig { @@ -88,8 +87,7 @@ export class Pool extends events.EventEmitter { } export class Client extends events.EventEmitter { - constructor(connection: string); // tslint:disable-line unified-signatures - constructor(config: ClientConfig); // tslint:disable-line unified-signatures + constructor(connectionOrConfig: string | ClientConfig); connect(callback?: (err: Error) => void): void; end(callback?: (err: Error) => void): void; From 3653eef83fb63e92c9751ea67670f0c43b9ef150 Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Fri, 11 Aug 2017 14:37:31 +0800 Subject: [PATCH 016/112] Update to pg 7.1 API --- types/pg/index.d.ts | 21 +++--- types/pg/pg-tests.ts | 144 +++++++++++++++++++++++++---------------- types/pg/tsconfig.json | 1 + 3 files changed, 100 insertions(+), 66 deletions(-) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index b2c3634f5c..92aeb91c86 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for pg 6.1 +// Type definitions for pg 7.1 // Project: https://github.com/brianc/node-postgres // Definitions by: Phips Peter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -9,11 +9,6 @@ import events = require("events"); import stream = require("stream"); import pgTypes = require("pg-types"); -export function connect( - connectionOrConfig: string | ClientConfig, - callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; -export function end(): void; - export interface ConnectionConfig { user?: string; database?: string; @@ -41,6 +36,7 @@ export interface PoolConfig extends ClientConfig { max?: number; min?: number; refreshIdle?: boolean; + connectionTimeoutMillis?: number; idleTimeoutMillis?: number; reapIntervalMillis?: number; returnToHead?: boolean; @@ -74,7 +70,8 @@ export class Pool extends events.EventEmitter { connect(): Promise; connect(callback: (err: Error, client: Client, done: () => void) => void): void; - end(callback?: () => void): Promise; + end(): Promise; + end(callback: () => void): void; query(queryStream: QueryConfig & stream.Readable): stream.Readable; query(queryConfig: QueryConfig): Promise; @@ -87,10 +84,14 @@ export class Pool extends events.EventEmitter { } export class Client extends events.EventEmitter { - constructor(connectionOrConfig: string | ClientConfig); + constructor(config: ClientConfig); + + connect(): Promise; + connect(callback: (err: Error) => void): void; + + end(): Promise; + end(callback: (err: Error) => void): void; - connect(callback?: (err: Error) => void): void; - end(callback?: (err: Error) => void): void; release(err?: Error): void; query(queryStream: QueryConfig & stream.Readable): stream.Readable; diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index 6bdf408bee..d3359d930a 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -1,32 +1,15 @@ import * as pg from "pg"; -const conString = "postgres://username:password@localhost/database"; - // https://github.com/brianc/node-pg-types // tslint:disable-next-line no-unnecessary-callback-wrapper pg.types.setTypeParser(20, val => Number(val)); -// Client pooling -pg.defaults.ssl = true; -pg.connect(conString, (err, client, done) => { - if (err) { - return console.error("Error fetching client from pool", err); - } - client.query("SELECT $1::int AS number", ["1"], (err, result) => { - if (err) { - done(err); - return console.error("Error running query", err); - } else { - done(); - } - console.log(result.rows[0]["number"]); - return null; - }); - return null; +const client = new pg.Client({ + host: 'my.database-server.com', + port: 5334, + user: 'database-user', + password: 'secretpassword!!', }); - -// Simple -const client = new pg.Client(conString); client.connect(err => { if (err) { return console.error("Could not connect to postgres", err); @@ -44,51 +27,100 @@ client.connect(err => { }); client.on('end', () => console.log("Client was disconnected.")); -// client pooling +client.connect() + .then(() => console.log('connected')) + .catch(e => console.error('connection error', e.stack)); -const config = { - user: 'foo', - database: 'my_db', - password: 'secret', - port: 5432, - max: 10, - idleTimeoutMillis: 30000, - Promise, +client.query('SELECT NOW()', (err, res) => { + if (err) throw err; + console.log(res); + client.end(); +}); + +client.query('SELECT $1::text as name', ['brianc'], (err, res) => { + if (err) throw err; + console.log(res); + client.end(); +}); + +const query = { + name: 'get-name', + text: 'SELECT $1::text', + values: ['brianc'], + rowMode: 'array' }; -const pool = new pg.Pool(config); +client.query(query, (err, res) => { + if (err) { + console.error(err.stack); + } else { + console.log(res.rows); + } +}); +client.query(query) + .then(res => { + console.log(res.rows); + }) + .catch(e => { + console.error(e.stack); + }); +client.end((err) => { + console.log('client has disconnected'); + if (err) { + console.log('error during disconnection', err.stack); + } +}); + +client.end() + .then(() => console.log('client has disconnected')) + .catch(err => console.error('error during disconnection', err.stack)); + +const pool = new pg.Pool({ + host: 'localhost', + port: 5432, + user: 'database-user', + database: 'my_db', + max: 20, + idleTimeoutMillis: 30000, + connectionTimeoutMillis: 2000, +}); pool.connect((err, client, done) => { - if (err) { - return console.error('error fetching client from pool', err); - } - client.query('SELECT $1::int AS number', ['1'], (err, result) => { - done(); + if (err) { + return console.error('error fetching client from pool', err); + } + client.query('SELECT $1::int AS number', ['1'], (err, result) => { + done(); - if (err) { - return console.error('error running query', err); - } - console.log(result.rows[0].number); - }); + if (err) { + return console.error('error running query', err); + } + console.log(result.rows[0].number); + }); }); pool.on('error', (err, client) => { - console.error('idle client error', err.message, err.stack); + console.error('idle client error', err.message, err.stack); }); -pool.end(); +pool.query('SELECT $1::text as name', ['brianc'], (err, result) => { + if (err) { + return console.error('Error executing query', err.stack); + } + console.log(result.rows[0].name); +}); + +pool.query('SELECT $1::text as name', ['brianc']) + .then((res) => console.log(res.rows[0].name)) + .catch(err => console.error('Error executing query', err.stack)); + pool.end(() => { - console.log("pool is closed"); + console.log('pool has ended'); }); -// Promise +pool.end().then(() => console.log('pool has ended')); -function query(sql: string, binds?: any[]): void { - // binds: any[] | undefined - pool.query(sql, binds) - .then((result: pg.QueryResult) => { - console.log(result.rows[0].number); - }) - .catch((err: any) => { - console.error('error running query', err); - }); -} +(async () => { + const client = await pool.connect(); + await client.query('SELECT NOW()'); + client.release(); +})(); diff --git a/types/pg/tsconfig.json b/types/pg/tsconfig.json index 6905c7197c..caa997a916 100644 --- a/types/pg/tsconfig.json +++ b/types/pg/tsconfig.json @@ -4,6 +4,7 @@ "lib": [ "es6" ], + "target": "es6", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From c03e601a5079f67aae15d2780e8c01d2136da18e Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Fri, 11 Aug 2017 16:23:04 +0800 Subject: [PATCH 017/112] Update pg-query-stream test to use pg@7.1 API. --- types/pg-query-stream/pg-query-stream-tests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/pg-query-stream/pg-query-stream-tests.ts b/types/pg-query-stream/pg-query-stream-tests.ts index 6c4c034102..1df78ea648 100644 --- a/types/pg-query-stream/pg-query-stream-tests.ts +++ b/types/pg-query-stream/pg-query-stream-tests.ts @@ -8,7 +8,8 @@ const options: QueryStream.Options = { const query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000], options); -pg.connect('', (err, client, done) => { +const pool = new pg.Pool(); +pool.connect((err, client, done) => { const stream = client.query(query); stream.on('end', () => { client.end(); @@ -17,3 +18,4 @@ pg.connect('', (err, client, done) => { console.log(data); }); }); +pool.end(); From 854a2af8e5ff411490b48cc14f960ead8f4c1874 Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Tue, 22 Aug 2017 18:26:00 +0800 Subject: [PATCH 018/112] Add properties totalCount, idleCount, waitingCount --- types/pg/index.d.ts | 4 ++++ types/pg/pg-tests.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index 92aeb91c86..ebba2d0f7d 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -67,6 +67,10 @@ export class Pool extends events.EventEmitter { // https://github.com/Microsoft/TypeScript/issues/7485 constructor(config?: PoolConfig); + readonly totalCount: number; + readonly idleCount: number; + readonly waitingCount: number; + connect(): Promise; connect(callback: (err: Error, client: Client, done: () => void) => void): void; diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index d3359d930a..81eadd0b13 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -84,6 +84,7 @@ const pool = new pg.Pool({ idleTimeoutMillis: 30000, connectionTimeoutMillis: 2000, }); +console.log(pool.totalCount); pool.connect((err, client, done) => { if (err) { return console.error('error fetching client from pool', err); From a26b2c6e97871596a94e4c2d5529bb229861080a Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Fri, 25 Aug 2017 17:33:35 +0800 Subject: [PATCH 019/112] Remove properties which are no more available in pg 7.1 --- types/pg/index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index ebba2d0f7d..04a84f1dfd 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -35,11 +35,9 @@ export interface PoolConfig extends ClientConfig { // properties from module 'node-pool' max?: number; min?: number; - refreshIdle?: boolean; connectionTimeoutMillis?: number; idleTimeoutMillis?: number; - reapIntervalMillis?: number; - returnToHead?: boolean; + application_name?: string; Promise?: PromiseConstructorLike; } From 84a47dcbebb349bd3f72810b7ec2f63b85629c4a Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Fri, 25 Aug 2017 17:59:24 +0800 Subject: [PATCH 020/112] New test rule expects a github URL. --- types/pg/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index 04a84f1dfd..1383dc2a22 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for pg 7.1 // Project: https://github.com/brianc/node-postgres -// Definitions by: Phips Peter +// Definitions by: Phips Peter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 3bc2634b096e54d3c6c5a5af7ef58051bc1847dd Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Mon, 28 Aug 2017 10:56:04 +0800 Subject: [PATCH 021/112] Fix lint rule no-void-expression --- types/pg/pg-tests.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index 81eadd0b13..bc1bfd30e0 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -12,11 +12,13 @@ const client = new pg.Client({ }); client.connect(err => { if (err) { - return console.error("Could not connect to postgres", err); + console.error("Could not connect to postgres", err); + return; } client.query("SELECT NOW() AS 'theTime'", (err, result) => { if (err) { - return console.error("Error running query", err); + console.error("Error running query", err); + return; } console.log(result.rowCount); console.log(result.rows[0]["theTime"]); @@ -87,13 +89,15 @@ const pool = new pg.Pool({ console.log(pool.totalCount); pool.connect((err, client, done) => { if (err) { - return console.error('error fetching client from pool', err); + console.error('error fetching client from pool', err); + return; } client.query('SELECT $1::int AS number', ['1'], (err, result) => { done(); if (err) { - return console.error('error running query', err); + console.error('error running query', err); + return; } console.log(result.rows[0].number); }); @@ -105,7 +109,8 @@ pool.on('error', (err, client) => { pool.query('SELECT $1::text as name', ['brianc'], (err, result) => { if (err) { - return console.error('Error executing query', err.stack); + console.error('Error executing query', err.stack); + return; } console.log(result.rows[0].name); }); From fda3af0b02fa78cddd809e77bfeb6fed536a2f48 Mon Sep 17 00:00:00 2001 From: rhysd Date: Tue, 29 Aug 2017 19:25:56 +0900 Subject: [PATCH 022/112] fix #19372 --- types/rc-tooltip/index.d.ts | 12 +++++------- types/rc-tooltip/rc-tooltip-tests.tsx | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/types/rc-tooltip/index.d.ts b/types/rc-tooltip/index.d.ts index c24f0018fd..20f65e3059 100644 --- a/types/rc-tooltip/index.d.ts +++ b/types/rc-tooltip/index.d.ts @@ -5,9 +5,11 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// +import * as React from 'react'; -declare namespace Tooltip { +export as namespace RCTooltip; + +declare namespace RCTooltip { export type Trigger = "hover" | "click" | "focus"; export type Placement = "left" | "right" | "top" | "bottom" | @@ -34,8 +36,4 @@ declare namespace Tooltip { } } -declare class Tooltip extends React.Component {} - -declare module "rc-tooltip" { - export = Tooltip -} +export default class Tooltip extends React.Component {} diff --git a/types/rc-tooltip/rc-tooltip-tests.tsx b/types/rc-tooltip/rc-tooltip-tests.tsx index 832a292e97..25eedad8eb 100644 --- a/types/rc-tooltip/rc-tooltip-tests.tsx +++ b/types/rc-tooltip/rc-tooltip-tests.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; -import * as Tooltip from 'rc-tooltip'; +import Tooltip from 'rc-tooltip'; ReactDOM.render( tooltip}> From 891ea85b105bbbc2fe428d36caed8e6e62becd75 Mon Sep 17 00:00:00 2001 From: rhysd Date: Tue, 29 Aug 2017 19:31:54 +0900 Subject: [PATCH 023/112] add tests for RCTooltip namespace --- types/rc-tooltip/rc-tooltip-tests.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/rc-tooltip/rc-tooltip-tests.tsx b/types/rc-tooltip/rc-tooltip-tests.tsx index 25eedad8eb..06b230a55b 100644 --- a/types/rc-tooltip/rc-tooltip-tests.tsx +++ b/types/rc-tooltip/rc-tooltip-tests.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; -import Tooltip from 'rc-tooltip'; +import Tooltip, {RCTooltip} from 'rc-tooltip'; ReactDOM.render( tooltip}> @@ -50,3 +50,9 @@ ReactDOM.render( , document.querySelector('.another-app') ); + +const props: RCTooltip.Props = { + placement: "bottomRight", + trigger: ['click', 'focus'], + overlay: () => tooltip, +}; From 5677208b599570119ab8712bee1e2a9765a6b64d Mon Sep 17 00:00:00 2001 From: Frank Tan Date: Tue, 29 Aug 2017 11:28:29 -0400 Subject: [PATCH 024/112] [react-redux] Fix incorrect change in connect. Accidentally removed {} in 3rd generic position and turned this into a 3-arity version vs the original 4-arity. --- types/react-redux/react-redux-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index 619a25a7df..e369003434 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -76,7 +76,7 @@ connect( () => mapDispatchToProps )(Counter); // with extra arguments -connect( +connect( () => mapStateToProps, () => mapDispatchToProps, (s: ICounterStateProps, d: ICounterDispatchProps) => From f43d588a4a194b9325cad4ae99228f4e71006f7a Mon Sep 17 00:00:00 2001 From: Juan Carlos Paucar Date: Tue, 29 Aug 2017 13:19:31 -0500 Subject: [PATCH 025/112] Include subQuery for sequelize version 3 as well --- types/sequelize/v3/index.d.ts | 5 +++++ types/sequelize/v3/sequelize-tests.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index bb9511c5ed..c0372c6b66 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -3221,6 +3221,11 @@ declare namespace sequelize { * Apply DISTINCT(col) for FindAndCount(all) */ distinct?: boolean; + + /** + * Prevents a subquery on the main table when using include + */ + subQuery?: boolean; } /** diff --git a/types/sequelize/v3/sequelize-tests.ts b/types/sequelize/v3/sequelize-tests.ts index 3f1ef022bb..4a3ba51753 100644 --- a/types/sequelize/v3/sequelize-tests.ts +++ b/types/sequelize/v3/sequelize-tests.ts @@ -896,6 +896,7 @@ User.findAll( { attributes: [[s.fn('count', Sequelize.col('*')), 'count']] }); User.findAll( { attributes: [[s.fn('count', Sequelize.col('*')), 'count']], group: ['sex'] }); User.findAll( { attributes: [s.cast(s.fn('count', Sequelize.col('*')), 'INTEGER')] }); User.findAll( { attributes: [[s.cast(s.fn('count', Sequelize.col('*')), 'INTEGER'), 'count']] }); +User.findAll( { subQuery: false, include : [User], order : [['id', 'ASC NULLS LAST']] } ); User.findById( 'a string' ); From adcf24f32d70efed4ab820adadd454575d09de20 Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Wed, 30 Aug 2017 10:55:55 +0800 Subject: [PATCH 026/112] Add connectionString property to the config object --- types/pg/index.d.ts | 1 + types/pg/pg-tests.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index 1383dc2a22..ec5b929aa4 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -15,6 +15,7 @@ export interface ConnectionConfig { password?: string; port?: number; host?: string; + connectionString?: string; } export interface Defaults extends ConnectionConfig { diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index bc1bfd30e0..1f1e312544 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -77,6 +77,10 @@ client.end() .then(() => console.log('client has disconnected')) .catch(err => console.error('error during disconnection', err.stack)); +const poolOne = new pg.Pool({ + connectionString: 'postgresql://dbuser:secretpassword@database.server.com:3211/mydb' +}); + const pool = new pg.Pool({ host: 'localhost', port: 5432, From 1c389ce93d7812925dba0a05d1981c05b3ce4f1d Mon Sep 17 00:00:00 2001 From: maxpaj Date: Wed, 30 Aug 2017 15:08:07 +0200 Subject: [PATCH 027/112] fluent-ffmpeg filter functions Added alternative parameter types for the filter functions. Resources: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/search?utf8=%E2%9C%93&q=withAudioFilters&type= https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/search?utf8=%E2%9C%93&q=withVideoFilters&type= --- types/fluent-ffmpeg/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index e1380dc78e..a27277e14a 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -144,10 +144,10 @@ declare namespace Ffmpeg { audioFrequency(freq: number): FfmpegCommand; withAudioQuality(quality: number): FfmpegCommand; audioQuality(quality: number): FfmpegCommand; - withAudioFilter(filters: { filter: string, options: any }): FfmpegCommand; - withAudioFilters(filters: { filter: string, options: any }): FfmpegCommand; - audioFilter(filters: { filter: string, options: any }): FfmpegCommand; - audioFilters(filters: { filter: string, options: any }): FfmpegCommand; + withAudioFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + withAudioFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + audioFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + audioFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; // options/video; withNoVideo(): FfmpegCommand; @@ -156,10 +156,10 @@ declare namespace Ffmpeg { videoCodec(codec: string): FfmpegCommand; withVideoBitrate(bitrate: string | number): FfmpegCommand; videoBitrate(bitrate: string | number): FfmpegCommand; - withVideoFilter(filters: { filter: string, options: any }): FfmpegCommand; - withVideoFilters(filters: { filter: string, options: any }): FfmpegCommand; - videoFilter(filters: { filter: string, options: any }): FfmpegCommand; - videoFilters(filters: { filter: string, options: any }): FfmpegCommand; + withVideoFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + withVideoFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + videoFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + videoFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; withOutputFps(fps: number): FfmpegCommand; withOutputFPS(fps: number): FfmpegCommand; withFpsOutput(fps: number): FfmpegCommand; From e31c1ee9197a888eb58d1265a60adb5f4afae029 Mon Sep 17 00:00:00 2001 From: maxpaj Date: Wed, 30 Aug 2017 15:12:14 +0200 Subject: [PATCH 028/112] Change signature type from Object to Object[] --- types/fluent-ffmpeg/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index a27277e14a..5d45a3d465 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -144,10 +144,10 @@ declare namespace Ffmpeg { audioFrequency(freq: number): FfmpegCommand; withAudioQuality(quality: number): FfmpegCommand; audioQuality(quality: number): FfmpegCommand; - withAudioFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; - withAudioFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; - audioFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; - audioFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + withAudioFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + withAudioFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + audioFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + audioFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; // options/video; withNoVideo(): FfmpegCommand; @@ -156,10 +156,10 @@ declare namespace Ffmpeg { videoCodec(codec: string): FfmpegCommand; withVideoBitrate(bitrate: string | number): FfmpegCommand; videoBitrate(bitrate: string | number): FfmpegCommand; - withVideoFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; - withVideoFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; - videoFilter(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; - videoFilters(filters: { filter: string, options: any } | String | String[]): FfmpegCommand; + withVideoFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + withVideoFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + videoFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + videoFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; withOutputFps(fps: number): FfmpegCommand; withOutputFPS(fps: number): FfmpegCommand; withFpsOutput(fps: number): FfmpegCommand; From e7e82f42fb8908216c6f5c84be5645a6cd5e881d Mon Sep 17 00:00:00 2001 From: Niklas Wulf Date: Wed, 30 Aug 2017 16:00:21 +0200 Subject: [PATCH 029/112] [nes] Fix Socket.disconnect typo --- types/nes/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/nes/index.d.ts b/types/nes/index.d.ts index aab6827ed7..c5526049de 100644 --- a/types/nes/index.d.ts +++ b/types/nes/index.d.ts @@ -91,7 +91,7 @@ declare module nes { id: string; app: Object; auth: nes.SocketAuthObject; - disconect(callback?: () => void): void; + disconnect(callback?: () => void): void; send(message: any, callback?: (err?: any) => void): void; publish(path: string, message: any, callback?: (err?: any) => void): void; revoke(path: string, message: any, callback?: (err?: any) => void): void; From bdd079afbeae2fd8b7c4e539536352b72d7d4009 Mon Sep 17 00:00:00 2001 From: Niklas Wulf Date: Wed, 30 Aug 2017 16:10:00 +0200 Subject: [PATCH 030/112] [nes] Add test/socket.ts --- types/nes/test/socket.ts | 16 ++++++++++++++++ types/nes/tsconfig.json | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 types/nes/test/socket.ts diff --git a/types/nes/test/socket.ts b/types/nes/test/socket.ts new file mode 100644 index 0000000000..7f7617d462 --- /dev/null +++ b/types/nes/test/socket.ts @@ -0,0 +1,16 @@ +// from https://github.com/hapijs/nes/blob/v6.4.3/lib/socket.js + +import Nes = require('nes'); + +const socket: Nes.Socket = undefined; + +const cb = () => { }; +socket.disconnect(cb); +const s: string = socket.id; +const o: Object = socket.app; +const auth: Nes.SocketAuthObject = socket.auth; + +const cb2 = (err?: any) => { }; +socket.send('message', (err?: any) => { }); +socket.publish('path', 'message', cb2); +socket.revoke('path', 'message', cb2); diff --git a/types/nes/tsconfig.json b/types/nes/tsconfig.json index cb28129b71..c03d7c22ee 100644 --- a/types/nes/tsconfig.json +++ b/types/nes/tsconfig.json @@ -26,9 +26,10 @@ "test/route-authentication-server.ts", "test/route-invocation-client.ts", "test/route-invocation-server.ts", + "test/socket.ts", "test/subscription-filter-client.ts", "test/subscription-filter-server.ts", "test/subscriptions-client.ts", "test/subscriptions-server.ts" ] -} \ No newline at end of file +} From 96da366c9b1bf48bc3d74f33f843c354251c56a5 Mon Sep 17 00:00:00 2001 From: William Lohan Date: Wed, 30 Aug 2017 12:57:33 -0700 Subject: [PATCH 031/112] update uuid --- types/uuid/uuid-tests.ts | 4 ++++ types/uuid/v5.d.ts | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/types/uuid/uuid-tests.ts b/types/uuid/uuid-tests.ts index ec69275db9..dc0bdcbdcf 100644 --- a/types/uuid/uuid-tests.ts +++ b/types/uuid/uuid-tests.ts @@ -48,3 +48,7 @@ const a: string = v5('hello', MY_NAMESPACE); const b: string = v5('world', MY_NAMESPACE); const c: Buffer = v5('world', MY_NAMESPACE, new Buffer(16)); const d: number[] = v5('world', MY_NAMESPACE, [], 0); + +// https://github.com/kelektiv/node-uuid#quickstart---commonjs-recommended +const e = v5('hello.example.com', v5.DNS); +const f = v5('http://example.com/hello', v5.URL); diff --git a/types/uuid/v5.d.ts b/types/uuid/v5.d.ts index 67b8c8d051..170bcdcef4 100644 --- a/types/uuid/v5.d.ts +++ b/types/uuid/v5.d.ts @@ -1,5 +1,12 @@ import { v5 } from './interfaces'; -declare const v5: v5; +interface v5Static { + // https://github.com/kelektiv/node-uuid/blob/master/v5.js#L47 + DNS: string; + // https://github.com/kelektiv/node-uuid/blob/master/v5.js#L48 + URL: string; +} + +declare const v5: v5Static & v5; export = v5; From 9ddbcfc2e04572d05f8463f0c09f12540d686a04 Mon Sep 17 00:00:00 2001 From: Eirikur Nilsson Date: Wed, 30 Aug 2017 22:35:42 +0000 Subject: [PATCH 032/112] Update types Add `.when()` method for conditional configuration Add devServer changes. Inherit Config from ChainedMap Export EntryPoint --- types/webpack-chain/index.d.ts | 82 +++++++++++++--------- types/webpack-chain/webpack-chain-tests.ts | 7 ++ 2 files changed, 55 insertions(+), 34 deletions(-) diff --git a/types/webpack-chain/index.d.ts b/types/webpack-chain/index.d.ts index 4a13f91530..68839d423c 100644 --- a/types/webpack-chain/index.d.ts +++ b/types/webpack-chain/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack-chain 3.0 +// Type definitions for webpack-chain 4.0 // Project: https://github.com/mozilla-neutrino/webpack-chain // Definitions by: Eirikur Nilsson , Paul Sachs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,9 +8,42 @@ import * as https from 'https'; export = Config; -declare class Config { +declare namespace __Config { + class Chained { + end(): Parent; + } + + class TypedChainedMap extends Chained { + clear(): this; + delete(key: string): this; + has(key: string): boolean; + get(key: string): Value; + set(key: string, value: Value): this; + merge(obj: { [key: string]: Value }): this; + entries(): { [key: string]: Value }; + values(): Value[]; + when(condition: boolean, trueBrancher: (obj: any) => void, falseBrancher?: (obj: any) => void): this; + } + + class ChainedMap extends TypedChainedMap {} + + class TypedChainedSet extends Chained { + add(value: Value): this; + prepend(value: Value): this; + clear(): this; + delete(key: string): this; + has(key: string): boolean; + merge(arr: Value[]): this; + values(): Value[]; + when(condition: boolean, trueBrancher: (obj: any) => void, falseBrancher?: (obj: any) => void): this; + } + + class ChainedSet extends TypedChainedSet {} +} + +declare class Config extends __Config.ChainedMap { devServer: Config.DevServer; - entryPoints: Config.EntryPoints; + entryPoints: Config.TypedChainedMap; module: Config.Module; node: Config.ChainedMap; output: Config.Output; @@ -35,42 +68,18 @@ declare class Config { watch(value: boolean): this; watchOptions(value: webpack.Options.WatchOptions): this; - entry(name: string): Config.ChainedSet; + entry(name: string): Config.EntryPoint; plugin(name: string): Config.Plugin; toConfig(): webpack.Configuration; - merge(obj: any): this; } declare namespace Config { - class Chained { - end(): Parent; - } - - class TypedChainedMap extends Chained { - clear(): this; - delete(key: string): this; - has(key: string): boolean; - get(key: string): Value; - set(key: string, value: Value): this; - merge(obj: { [key: string]: Value }): this; - entries(): { [key: string]: Value }; - values(): Value[]; - } - - class ChainedMap extends TypedChainedMap {} - - class TypedChainedSet extends Chained { - add(value: Value): this; - prepend(value: Value): this; - clear(): this; - delete(key: string): this; - has(key: string): boolean; - merge(arr: Value[]): this; - values(): Value[]; - } - - class ChainedSet extends TypedChainedSet {} + class Chained extends __Config.Chained {} + class TypedChainedMap extends __Config.TypedChainedMap {} + class ChainedMap extends __Config.TypedChainedMap {} + class TypedChainedSet extends __Config.TypedChainedSet {} + class ChainedSet extends __Config.TypedChainedSet {} class Plugins extends TypedChainedMap> {} @@ -128,11 +137,16 @@ declare namespace Config { noInfo(value: boolean): this; overlay(value: boolean | { warnings?: boolean, errors?: boolean }): this; port(value: number): this; + progress(value: boolean): this; proxy(value: any): this; + public(value: string): this; + publicPath(publicPath: string): this; quiet(value: boolean): this; setup(value: (expressApp: any) => void): this; + staticOptions(value: any): this; stats(value: webpack.Options.Stats): this; watchContentBase(value: boolean): this; + watchOptions(value: any): this; } class Performance extends ChainedMap { @@ -142,7 +156,7 @@ declare namespace Config { assetFilter(value: (assetFilename: string) => boolean): this; } - class EntryPoints extends TypedChainedMap> {} + class EntryPoint extends TypedChainedSet {} class Resolve extends ChainedMap { alias: TypedChainedMap; diff --git a/types/webpack-chain/webpack-chain-tests.ts b/types/webpack-chain/webpack-chain-tests.ts index 1118fe0d26..07593687cf 100644 --- a/types/webpack-chain/webpack-chain-tests.ts +++ b/types/webpack-chain/webpack-chain-tests.ts @@ -29,11 +29,13 @@ config .target('web') .watch(true) .watchOptions({}) + .when(false, config => config.watch(true), config => config.watch(false)) .entry('main') .add('index.js') .delete('index.js') .clear() + .when(false, entry => entry.clear(), entry => entry.clear()) .end() .entryPoints @@ -71,15 +73,20 @@ config errors: true, }) .port(8080) + .progress(true) .proxy({}) + .public('foo') + .publicPath('bar') .quiet(false) .setup(app => {}) + .staticOptions({}) .stats({ reasons: true, errors: true, warnings: false, }) .watchContentBase(true) + .watchOptions({}) .end() .module From aed2ea47a9207127b3e21186b568911fce7a8ba0 Mon Sep 17 00:00:00 2001 From: Eirikur Nilsson Date: Wed, 30 Aug 2017 22:53:46 +0000 Subject: [PATCH 033/112] Fix when type --- types/webpack-chain/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/webpack-chain/index.d.ts b/types/webpack-chain/index.d.ts index 68839d423c..6f6c46daa8 100644 --- a/types/webpack-chain/index.d.ts +++ b/types/webpack-chain/index.d.ts @@ -22,7 +22,7 @@ declare namespace __Config { merge(obj: { [key: string]: Value }): this; entries(): { [key: string]: Value }; values(): Value[]; - when(condition: boolean, trueBrancher: (obj: any) => void, falseBrancher?: (obj: any) => void): this; + when(condition: boolean, trueBrancher: (obj: this) => void, falseBrancher?: (obj: this) => void): this; } class ChainedMap extends TypedChainedMap {} @@ -35,7 +35,7 @@ declare namespace __Config { has(key: string): boolean; merge(arr: Value[]): this; values(): Value[]; - when(condition: boolean, trueBrancher: (obj: any) => void, falseBrancher?: (obj: any) => void): this; + when(condition: boolean, trueBrancher: (obj: this) => void, falseBrancher?: (obj: this) => void): this; } class ChainedSet extends TypedChainedSet {} From c88276a0d4b106d3ec2f6cff8f9112c41f5ac77c Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Thu, 31 Aug 2017 09:07:35 +1000 Subject: [PATCH 034/112] remove global --- types/xhr-mock/index.d.ts | 1 - types/xhr-mock/xhr-mock-tests.ts | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/xhr-mock/index.d.ts b/types/xhr-mock/index.d.ts index eacec1c5fc..2f85e44c8d 100644 --- a/types/xhr-mock/index.d.ts +++ b/types/xhr-mock/index.d.ts @@ -54,4 +54,3 @@ declare namespace mock { declare var mock: mock.XhrMock; export = mock; -export as namespace mock; diff --git a/types/xhr-mock/xhr-mock-tests.ts b/types/xhr-mock/xhr-mock-tests.ts index fd26b3a43f..37fc651d64 100644 --- a/types/xhr-mock/xhr-mock-tests.ts +++ b/types/xhr-mock/xhr-mock-tests.ts @@ -1,3 +1,5 @@ +import mock = require('xhr-mock'); + // replace the real XHR object with the mock XHR object mock.setup(); From 991a5e70fac3dd953e6f888e183c4bf011760282 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Tue, 22 Aug 2017 19:56:07 -0400 Subject: [PATCH 035/112] Add ToggleButton and ToggleButtonGroup It's a new feature in v0.31.1 --- types/react-bootstrap/index.d.ts | 2 ++ types/react-bootstrap/lib/ToggleButton.d.ts | 11 +++++++++ .../lib/ToggleButtonGroup.d.ts | 21 +++++++++++++++++ types/react-bootstrap/lib/index.d.ts | 4 ++++ .../test/react-bootstrap-tests.tsx | 23 ++++++++++++++++++- 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 types/react-bootstrap/lib/ToggleButton.d.ts create mode 100644 types/react-bootstrap/lib/ToggleButtonGroup.d.ts diff --git a/types/react-bootstrap/index.d.ts b/types/react-bootstrap/index.d.ts index b59403cc39..5c55ce6910 100644 --- a/types/react-bootstrap/index.d.ts +++ b/types/react-bootstrap/index.d.ts @@ -119,6 +119,8 @@ export { TabPane, Tabs, Thumbnail, + ToggleButton, + ToggleButtonGroup, Tooltip, Well, utils, diff --git a/types/react-bootstrap/lib/ToggleButton.d.ts b/types/react-bootstrap/lib/ToggleButton.d.ts new file mode 100644 index 0000000000..2de57ca211 --- /dev/null +++ b/types/react-bootstrap/lib/ToggleButton.d.ts @@ -0,0 +1,11 @@ +import * as React from 'react'; + +declare class ToggleButton extends React.Component { } +declare namespace ToggleButton { } +export = ToggleButton + +interface ToggleButtonProps extends React.HTMLProps { + checked?: boolean; + name?: string; + value: number|string; +} diff --git a/types/react-bootstrap/lib/ToggleButtonGroup.d.ts b/types/react-bootstrap/lib/ToggleButtonGroup.d.ts new file mode 100644 index 0000000000..30849be038 --- /dev/null +++ b/types/react-bootstrap/lib/ToggleButtonGroup.d.ts @@ -0,0 +1,21 @@ +import * as React from 'react'; + +declare class ToggleButtonGroup extends React.Component { } +declare namespace ToggleButtonGroup { } +export = ToggleButtonGroup + +interface ToggleButtonGroupProps extends React.HTMLProps { + /** Required if `type` is set to "radio" */ + name?: string; + type: "radio" | "checkbox"; + /** + * You'll usually want to use string|number|string[]|number[] here, + * but you can technically use any|any[]. + */ + defaultValue?: any; + /** + * You'll usually want to use string|number|string[]|number[] here, + * but you can technically use any|any[]. + */ + value?: any; +} diff --git a/types/react-bootstrap/lib/index.d.ts b/types/react-bootstrap/lib/index.d.ts index 28078e1bcd..9cf3b61777 100644 --- a/types/react-bootstrap/lib/index.d.ts +++ b/types/react-bootstrap/lib/index.d.ts @@ -83,6 +83,8 @@ import * as TabPane from './TabPane'; import * as Tabs from './Tabs'; import * as Thumbnail from './Thumbnail'; import * as Tooltip from './Tooltip'; +import * as ToggleButton from './ToggleButton' +import * as ToggleButtonGroup from './ToggleButtonGroup' import * as Well from './Well'; import * as utils from './utils'; @@ -173,6 +175,8 @@ export { Tabs, Thumbnail, Tooltip, + ToggleButton, + ToggleButtonGroup, Well, utils, } diff --git a/types/react-bootstrap/test/react-bootstrap-tests.tsx b/types/react-bootstrap/test/react-bootstrap-tests.tsx index 873132e64b..445e65dc12 100644 --- a/types/react-bootstrap/test/react-bootstrap-tests.tsx +++ b/types/react-bootstrap/test/react-bootstrap-tests.tsx @@ -12,7 +12,8 @@ import { Label, Badge, Jumbotron, PageHeader, Glyphicon, Table, Form, FormGroup, ControlLabel, FormControl, HelpBlock, - Radio, Checkbox, Media, InputGroup + Radio, Checkbox, Media, InputGroup, ToggleButtonGroup, + ToggleButton } from 'react-bootstrap'; export class ReactBootstrapTest extends Component { @@ -1270,6 +1271,26 @@ export class ReactBootstrapTest extends Component { + +
+ + + Checkbox 1 (pre-checked) + Checkbox 2 + Checkbox 3 (pre-checked) + + + + + + + Radio 1 (pre-checked) + + Radio 2 + Radio 3 + + +
); } From bcc93afc0888102247cf4a8435475e80dc1780e2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 30 Aug 2017 16:20:35 -0700 Subject: [PATCH 036/112] Added type declarations for 'jpeg-js'. --- types/jpeg-js/index.d.ts | 18 ++++++++++++++++++ types/jpeg-js/jpeg-js-tests.ts | 17 +++++++++++++++++ types/jpeg-js/tsconfig.json | 22 ++++++++++++++++++++++ types/jpeg-js/tslint.json | 1 + 4 files changed, 58 insertions(+) create mode 100644 types/jpeg-js/index.d.ts create mode 100644 types/jpeg-js/jpeg-js-tests.ts create mode 100644 types/jpeg-js/tsconfig.json create mode 100644 types/jpeg-js/tslint.json diff --git a/types/jpeg-js/index.d.ts b/types/jpeg-js/index.d.ts new file mode 100644 index 0000000000..b3525b5449 --- /dev/null +++ b/types/jpeg-js/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for jpeg-js 0.3 +// Project: https://github.com/eugeneware/jpeg-js#readme +// Definitions by: Daniel Rosenwasser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export interface RawImageData { + data: D; + width: number; + height: number; +} + +export function decode(jpegData: ArrayLike | Iterable | ArrayBuffer, useTypedArray: true): RawImageData; +export function decode(jpegData: ArrayLike | Iterable | ArrayBuffer, useTypedArray?: false): RawImageData; +export function decode(jpegData: ArrayLike | Iterable | ArrayBuffer, useTypedArray: boolean): RawImageData; + +export function encode(imgData: RawImageData, qu?: number): RawImageData; diff --git a/types/jpeg-js/jpeg-js-tests.ts b/types/jpeg-js/jpeg-js-tests.ts new file mode 100644 index 0000000000..9b66878e5d --- /dev/null +++ b/types/jpeg-js/jpeg-js-tests.ts @@ -0,0 +1,17 @@ +/// + +import fs = require("fs"); +import jpeg = require("jpeg-js"); + +const x = fs.readFileSync("hello.jpg"); +const decoded = jpeg.decode(x, true); + +const { width, height } = decoded; + +width; // $ExpectType number +height; // $ExpectType number +decoded.data; // $ExpectType Uint8Array + +fs.writeFileSync("re-encoded.jpg", jpeg.encode({ + width, height, data: decoded.data +}, 50)); diff --git a/types/jpeg-js/tsconfig.json b/types/jpeg-js/tsconfig.json new file mode 100644 index 0000000000..1e3c116f4f --- /dev/null +++ b/types/jpeg-js/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es2015" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jpeg-js-tests.ts" + ] +} diff --git a/types/jpeg-js/tslint.json b/types/jpeg-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jpeg-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e2149cb99684a40929b5903e013ec34000b81bec Mon Sep 17 00:00:00 2001 From: loopArray <525029662@qq.com> Date: Thu, 31 Aug 2017 10:25:19 +0800 Subject: [PATCH 037/112] add missing TabBarItem add missing TabBarItem --- types/react-native-vector-icons/Icon.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-native-vector-icons/Icon.d.ts b/types/react-native-vector-icons/Icon.d.ts index bb56a01794..07fd38f91b 100644 --- a/types/react-native-vector-icons/Icon.d.ts +++ b/types/react-native-vector-icons/Icon.d.ts @@ -197,6 +197,7 @@ export class Icon extends React.Component { export namespace Icon { class ToolbarAndroid extends React.Component {} + class TabBarItem extends React.Component {} class TabBarItemIOS extends React.Component {} class Button extends React.Component {} } From eb124c3a5757b75bf201abc6e0a52993261f956f Mon Sep 17 00:00:00 2001 From: loopArray <525029662@qq.com> Date: Thu, 31 Aug 2017 10:26:01 +0800 Subject: [PATCH 038/112] add Custom Icon test --- .../react-native-vector-icons-tests.tsx | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index 99a2b3ac8b..7d71ccfc01 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -1,9 +1,22 @@ import * as React from 'react'; import { View, Text, TabBarIOS } from 'react-native'; +import { createIconSet } from 'react-native-vector-icons'; import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import Ionicon from 'react-native-vector-icons/Ionicons'; +const glyphMap = { + "station": 58918 +} + +const CustomIcon = createIconSet(glyphMap, 'FontCustom', 'FontCustom.ttf'); + +const CustomIconButton = CustomIcon.Button; +const CustomIconTabBarItem = CustomIcon.TabBarItem; +const CustomIconTabBarItemIOS = CustomIcon.TabBarItemIOS; +const CustomIconToolbarAndroid = CustomIcon.ToolbarAndroid; +const CustomIcongetImageSource = CustomIcon.getImageSource; + class Example extends React.Component { handleButton() { console.log('You pressed me'); @@ -30,7 +43,7 @@ class Example extends React.Component { } } -class TabTest extends React.Component { +class TabTest extends React.Component { constructor() { super(); @@ -49,7 +62,7 @@ class TabTest extends React.Component { selectedIconColor="pink" renderAsOriginal selected={this.state.selectedTab === 'tab1'} - onPress={() => this.setState({selectedTab: 'tab1'})} + onPress={() => this.setState({ selectedTab: 'tab1' })} > @@ -61,7 +74,7 @@ class TabTest extends React.Component { selectedIconColor='pink' renderAsOriginal selected={this.state.selectedTab === 'tab2'} - onPress={() => this.setState({selectedTab: 'tab2'})} + onPress={() => this.setState({ selectedTab: 'tab2' })} > @@ -69,3 +82,33 @@ class TabTest extends React.Component { ); } } + +class TestCustomIcon extends React.Component { + constructor() { + super(); + } + + handleButton() { + console.log('You pressed me'); + } + + render() { + return ( + + {/* Custom Icon */} + + + {/* Custom Icon button */} + this.handleButton()} + > + + Hello CustomIcon! + + + + ); + } +} From 65106bb98734b1c652d17668bfa2f9df6ad3aa87 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 30 Aug 2017 20:42:22 -0700 Subject: [PATCH 039/112] Don't reference 'node' in tests for 'jpeg-js'. --- types/jpeg-js/jpeg-js-tests.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/jpeg-js/jpeg-js-tests.ts b/types/jpeg-js/jpeg-js-tests.ts index 9b66878e5d..17bbc4fd5f 100644 --- a/types/jpeg-js/jpeg-js-tests.ts +++ b/types/jpeg-js/jpeg-js-tests.ts @@ -1,7 +1,5 @@ -/// - -import fs = require("fs"); import jpeg = require("jpeg-js"); +import fs = require("fs"); const x = fs.readFileSync("hello.jpg"); const decoded = jpeg.decode(x, true); From fab36d348cb3e3efcb2ca54dbea28e84c5eaabb1 Mon Sep 17 00:00:00 2001 From: Samphan Raruenrom Date: Thu, 31 Aug 2017 13:02:37 +0700 Subject: [PATCH 040/112] meteor: fix to allow strictNullChecks --- types/meteor/ejson.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/meteor/ejson.d.ts b/types/meteor/ejson.d.ts index 45ae2627c0..a6294fb8be 100644 --- a/types/meteor/ejson.d.ts +++ b/types/meteor/ejson.d.ts @@ -5,10 +5,10 @@ interface EJSONableCustomType { typeName(): string; } interface EJSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType | undefined | null; } interface JSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[]; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | undefined | null; } interface EJSON extends EJSONable { } @@ -44,10 +44,10 @@ declare module "meteor/ejson" { typeName(): string; } interface EJSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType | undefined | null; } interface JSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[]; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | undefined | null; } interface EJSON extends EJSONable { } From 4e786d53cee6a08fdd1e21bfae02b4c0b0733da8 Mon Sep 17 00:00:00 2001 From: Samphan Raruenrom Date: Thu, 31 Aug 2017 13:13:16 +0700 Subject: [PATCH 041/112] meteor: add methods to Mongo.ObjectID These method are accessible from meteor Mongo.ObjectID but missing. Per https://docs.meteor.com/api/collections.html#Mongo-ObjectID : "Mongo.ObjectID follows the same API as the Node MongoDB driver ObjectID class" When I check the Node.js MongoDB Driver API, only these two methods are interesting. (getTimestamp() doesn't make sense in Meteor). I've a test that call both methods successfully. --- types/meteor/mongo.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/meteor/mongo.d.ts b/types/meteor/mongo.d.ts index af632bdab1..99f931ec28 100644 --- a/types/meteor/mongo.d.ts +++ b/types/meteor/mongo.d.ts @@ -214,7 +214,10 @@ declare module "meteor/mongo" { interface ObjectIDStatic { new (hexString?: string): ObjectID; } - interface ObjectID { } + interface ObjectID { + toHexString(): string; + equals(otherID: ObjectID): boolean; + } function setConnectionOptions(options: any): void; } From c37768ab5ae36eaab8041878837d6e51f685918e Mon Sep 17 00:00:00 2001 From: loopArray <525029662@qq.com> Date: Thu, 31 Aug 2017 14:48:45 +0800 Subject: [PATCH 042/112] Update react-native-vector-icons-tests.tsx --- .../react-native-vector-icons-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index 7d71ccfc01..9615de18f4 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -6,7 +6,7 @@ import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import Ionicon from 'react-native-vector-icons/Ionicons'; const glyphMap = { - "station": 58918 + "custom": 58918 } const CustomIcon = createIconSet(glyphMap, 'FontCustom', 'FontCustom.ttf'); From 9bf1a6a4d656eaf17f64f53ae62aaf91a912ee43 Mon Sep 17 00:00:00 2001 From: maxpaj Date: Thu, 31 Aug 2017 09:03:48 +0200 Subject: [PATCH 043/112] Replaced `String` type with `string` --- types/fluent-ffmpeg/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index 5d45a3d465..1b86816787 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -144,10 +144,10 @@ declare namespace Ffmpeg { audioFrequency(freq: number): FfmpegCommand; withAudioQuality(quality: number): FfmpegCommand; audioQuality(quality: number): FfmpegCommand; - withAudioFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; - withAudioFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; - audioFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; - audioFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + withAudioFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + withAudioFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + audioFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + audioFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; // options/video; withNoVideo(): FfmpegCommand; @@ -156,10 +156,10 @@ declare namespace Ffmpeg { videoCodec(codec: string): FfmpegCommand; withVideoBitrate(bitrate: string | number): FfmpegCommand; videoBitrate(bitrate: string | number): FfmpegCommand; - withVideoFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; - withVideoFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; - videoFilter(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; - videoFilters(filters: { filter: string, options: any }[] | String | String[]): FfmpegCommand; + withVideoFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + withVideoFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + videoFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + videoFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; withOutputFps(fps: number): FfmpegCommand; withOutputFPS(fps: number): FfmpegCommand; withFpsOutput(fps: number): FfmpegCommand; From 27baba70b1aa52050b14fa40fa093928e972523a Mon Sep 17 00:00:00 2001 From: maxpaj Date: Thu, 31 Aug 2017 09:23:24 +0200 Subject: [PATCH 044/112] Corrected parameters and extracted AudoVideoFilter interface --- types/fluent-ffmpeg/index.d.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index 1b86816787..2ecd56f1a5 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -104,6 +104,11 @@ declare namespace Ffmpeg { fastSeek?: boolean; size?: string; } + + interface AudioVideoFilter { + filter: string; + options: string | string[] | Object; + } class FfmpegCommand extends events.EventEmitter { constructor(options?: FfmpegCommandOptions); @@ -144,10 +149,10 @@ declare namespace Ffmpeg { audioFrequency(freq: number): FfmpegCommand; withAudioQuality(quality: number): FfmpegCommand; audioQuality(quality: number): FfmpegCommand; - withAudioFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; - withAudioFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; - audioFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; - audioFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + withAudioFilter(filters: string | string[] | Array): FfmpegCommand; + withAudioFilters(filters: string | string[] | Array): FfmpegCommand; + audioFilter(filters: string | string[] | Array): FfmpegCommand; + audioFilters(filters: string | string[] | Array): FfmpegCommand; // options/video; withNoVideo(): FfmpegCommand; @@ -156,10 +161,10 @@ declare namespace Ffmpeg { videoCodec(codec: string): FfmpegCommand; withVideoBitrate(bitrate: string | number): FfmpegCommand; videoBitrate(bitrate: string | number): FfmpegCommand; - withVideoFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; - withVideoFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; - videoFilter(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; - videoFilters(filters: { filter: string, options: any }[] | string | Array): FfmpegCommand; + withVideoFilter(filters: string | string[] | Array): FfmpegCommand; + withVideoFilters(filters: string | string[] | Array): FfmpegCommand; + videoFilter(filters: string | string[] | Array): FfmpegCommand; + videoFilters(filters: string | string[] | Array): FfmpegCommand; withOutputFps(fps: number): FfmpegCommand; withOutputFPS(fps: number): FfmpegCommand; withFpsOutput(fps: number): FfmpegCommand; From 79e7c252f342624e5cca70cebe1db8fbdb467fdc Mon Sep 17 00:00:00 2001 From: maxpaj Date: Thu, 31 Aug 2017 09:34:11 +0200 Subject: [PATCH 045/112] Fix Travis errors --- types/fluent-ffmpeg/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index 2ecd56f1a5..2f57bb8347 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -104,10 +104,10 @@ declare namespace Ffmpeg { fastSeek?: boolean; size?: string; } - + interface AudioVideoFilter { filter: string; - options: string | string[] | Object; + options: string | string[] | object; } class FfmpegCommand extends events.EventEmitter { @@ -149,10 +149,10 @@ declare namespace Ffmpeg { audioFrequency(freq: number): FfmpegCommand; withAudioQuality(quality: number): FfmpegCommand; audioQuality(quality: number): FfmpegCommand; - withAudioFilter(filters: string | string[] | Array): FfmpegCommand; - withAudioFilters(filters: string | string[] | Array): FfmpegCommand; - audioFilter(filters: string | string[] | Array): FfmpegCommand; - audioFilters(filters: string | string[] | Array): FfmpegCommand; + withAudioFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + withAudioFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + audioFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + audioFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; // options/video; withNoVideo(): FfmpegCommand; From 7644721413e0d93332f6794454889c86eb92784a Mon Sep 17 00:00:00 2001 From: maxpaj Date: Thu, 31 Aug 2017 09:34:53 +0200 Subject: [PATCH 046/112] Some more fix... --- types/fluent-ffmpeg/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index 2f57bb8347..97b07c8bd6 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -161,10 +161,10 @@ declare namespace Ffmpeg { videoCodec(codec: string): FfmpegCommand; withVideoBitrate(bitrate: string | number): FfmpegCommand; videoBitrate(bitrate: string | number): FfmpegCommand; - withVideoFilter(filters: string | string[] | Array): FfmpegCommand; - withVideoFilters(filters: string | string[] | Array): FfmpegCommand; - videoFilter(filters: string | string[] | Array): FfmpegCommand; - videoFilters(filters: string | string[] | Array): FfmpegCommand; + withVideoFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + withVideoFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + videoFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + videoFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; withOutputFps(fps: number): FfmpegCommand; withOutputFPS(fps: number): FfmpegCommand; withFpsOutput(fps: number): FfmpegCommand; From fe214f98c28b65e99038b59d259b7a73f9340126 Mon Sep 17 00:00:00 2001 From: maxpaj Date: Thu, 31 Aug 2017 09:41:49 +0200 Subject: [PATCH 047/112] Use `{}` instead of `object`. --- types/fluent-ffmpeg/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index 97b07c8bd6..87bdbfe15c 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -107,7 +107,7 @@ declare namespace Ffmpeg { interface AudioVideoFilter { filter: string; - options: string | string[] | object; + options: string | string[] | {}; } class FfmpegCommand extends events.EventEmitter { From 84b7de8cef99095bc52e0123c602e16e194f7aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Wachter?= Date: Thu, 31 Aug 2017 11:00:43 +0200 Subject: [PATCH 048/112] [pg] Reexport the 'pg' module under an attribute 'native' Gives optional access to the native client if installed. --- types/pg/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index da6f4db575..d8f41a7e36 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -126,3 +126,7 @@ export declare class Events extends events.EventEmitter { export const types: typeof pgTypes; export const defaults: Defaults & ClientConfig; + +import * as Pg from 'pg'; + +export const native: typeof Pg | null; From 6e75e3644b622e3a7e96d4273d8951c74893e396 Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Thu, 31 Aug 2017 17:57:20 +0800 Subject: [PATCH 049/112] Copy v6 types to its folder --- types/pg/v6/index.d.ts | 128 ++++++++++++++++++++++++++++++++++++++ types/pg/v6/pg-tests.ts | 81 ++++++++++++++++++++++++ types/pg/v6/tsconfig.json | 25 ++++++++ 3 files changed, 234 insertions(+) create mode 100644 types/pg/v6/index.d.ts create mode 100644 types/pg/v6/pg-tests.ts create mode 100644 types/pg/v6/tsconfig.json diff --git a/types/pg/v6/index.d.ts b/types/pg/v6/index.d.ts new file mode 100644 index 0000000000..5624989ac7 --- /dev/null +++ b/types/pg/v6/index.d.ts @@ -0,0 +1,128 @@ +// Type definitions for pg 6.1 +// Project: https://github.com/brianc/node-postgres +// Definitions by: Phips Peter +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import events = require("events"); +import stream = require("stream"); +import pgTypes = require("pg-types"); + +export declare function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; +export declare function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; +export declare function end(): void; + +export interface ConnectionConfig { + user?: string; + database?: string; + password?: string; + port?: number; + host?: string; +} + +export interface Defaults extends ConnectionConfig { + poolSize?: number; + poolIdleTimeout?: number; + reapIntervalMillis?: number; + binary?: boolean; + parseInt8?: boolean; +} + +import { TlsOptions } from "tls"; + +export interface ClientConfig extends ConnectionConfig { + ssl?: boolean | TlsOptions; +} + +export interface PoolConfig extends ClientConfig { + // properties from module 'node-pool' + max?: number; + min?: number; + refreshIdle?: boolean; + idleTimeoutMillis?: number; + reapIntervalMillis?: number; + returnToHead?: boolean; + application_name?: string; + Promise?: PromiseConstructorLike; +} + +export interface QueryConfig { + name?: string; + text: string; + values?: any[]; +} + +export interface QueryResult { + command: string; + rowCount: number; + oid: number; + rows: any[]; +} + +export interface ResultBuilder extends QueryResult { + addRow(row: any): void; +} + +export declare class Pool extends events.EventEmitter { + // `new Pool('pg://user@localhost/mydb')` is not allowed. + // But it passes type check because of issue: + // https://github.com/Microsoft/TypeScript/issues/7485 + constructor(config?: PoolConfig); + + connect(): Promise; + connect(callback: (err: Error, client: Client, done: () => void) => void): void; + + end(callback?: () => void): Promise; + + query(queryStream: QueryConfig & stream.Readable): stream.Readable; + query(queryTextOrConfig: string | QueryConfig): Promise; + query(queryText: string, values: any[]): Promise; + + query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; + query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; + + on(event: "error", listener: (err: Error, client: Client) => void): this; + on(event: "connect" | "acquire", listener: (client: Client) => void): this; +} + +export declare class Client extends events.EventEmitter { + constructor(connection: string); + constructor(config: ClientConfig); + + connect(callback?: (err: Error) => void): void; + end(callback?: (err: Error) => void): void; + release(err?: Error): void; + + query(queryStream: QueryConfig & stream.Readable): stream.Readable; + query(queryTextOrConfig: string | QueryConfig): Promise; + query(queryText: string, values: any[]): Promise; + + query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; + query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; + + copyFrom(queryText: string): stream.Writable; + copyTo(queryText: string): stream.Readable; + + pauseDrain(): void; + resumeDrain(): void; + + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "notification" | "notice", listener: (message: any) => void): this; + on(event: "end", listener: () => void): this; +} + +export declare class Query extends events.EventEmitter { + on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "end", listener: (result: ResultBuilder) => void): this; +} + +export declare class Events extends events.EventEmitter { + on(event: "error", listener: (err: Error, client: Client) => void): this; +} + +export const types: typeof pgTypes; + +export const defaults: Defaults & ClientConfig; diff --git a/types/pg/v6/pg-tests.ts b/types/pg/v6/pg-tests.ts new file mode 100644 index 0000000000..4b4cfba7ec --- /dev/null +++ b/types/pg/v6/pg-tests.ts @@ -0,0 +1,81 @@ +import * as pg from "pg"; + +var conString = "postgres://username:password@localhost/database"; + +// https://github.com/brianc/node-pg-types +pg.types.setTypeParser(20, val => Number(val)); + +// Client pooling +pg.defaults.ssl = true; +pg.connect(conString, (err, client, done) => { + if (err) { + return console.error("Error fetching client from pool", err); + } + client.query("SELECT $1::int AS number", ["1"], (err, result) => { + if (err) { + done(err); + return console.error("Error running query", err); + } + else { + done(); + } + console.log(result.rows[0]["number"]); + return null; + }); + return null; +}); + +// Simple +var client = new pg.Client(conString); +client.connect(err => { + if (err) { + return console.error("Could not connect to postgres", err); + } + client.query("SELECT NOW() AS 'theTime'", (err, result) => { + if (err) { + return console.error("Error running query", err); + } + console.log(result.rowCount); + console.log(result.rows[0]["theTime"]); + client.end(); + return null; + }); + return null; +}); +client.on('end', () => console.log("Client was disconnected.")); + +// client pooling + +var config = { + user: 'foo', //env var: PGUSER + database: 'my_db', //env var: PGDATABASE + password: 'secret', //env var: PGPASSWORD + 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, +}; +var pool = new pg.Pool(config); + +pool.connect((err, client, done) => { + if(err) { + return console.error('error fetching client from pool', err); + } + client.query('SELECT $1::int AS number', ['1'], (err, result) => { + done(); + + if(err) { + return console.error('error running query', err); + } + console.log(result.rows[0].number); + }); +}); + +pool.on('error', (err, client) => { + console.error('idle client error', err.message, err.stack) +}) + +pool.end(); +pool.end(() => { + console.log("pool is closed"); +}); diff --git a/types/pg/v6/tsconfig.json b/types/pg/v6/tsconfig.json new file mode 100644 index 0000000000..2c44f5862b --- /dev/null +++ b/types/pg/v6/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "pg": [ "pg/v6" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "pg-tests.ts" + ] +} From 2a5c1e01447c284ea115981d8f8e69e3f14f208e Mon Sep 17 00:00:00 2001 From: loopArray <525029662@qq.com> Date: Thu, 31 Aug 2017 22:30:16 +0800 Subject: [PATCH 050/112] Update react-native-vector-icons-tests.tsx --- .../react-native-vector-icons-tests.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index 9615de18f4..e6dc2bb600 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -6,8 +6,8 @@ import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import Ionicon from 'react-native-vector-icons/Ionicons'; const glyphMap = { - "custom": 58918 -} + 'custom': 58918 +}; const CustomIcon = createIconSet(glyphMap, 'FontCustom', 'FontCustom.ttf'); From 3d7c85d2d034d485d4ff0c0a97ad07a9c1652545 Mon Sep 17 00:00:00 2001 From: loopArray <525029662@qq.com> Date: Thu, 31 Aug 2017 22:34:21 +0800 Subject: [PATCH 051/112] Update react-native-vector-icons-tests.tsx --- .../react-native-vector-icons-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index e6dc2bb600..b6adf8d8c6 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -6,7 +6,7 @@ import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import Ionicon from 'react-native-vector-icons/Ionicons'; const glyphMap = { - 'custom': 58918 + custom: 58918 }; const CustomIcon = createIconSet(glyphMap, 'FontCustom', 'FontCustom.ttf'); From 76e8326e9f5d8584894de47046c7f1cdc570fb18 Mon Sep 17 00:00:00 2001 From: Graham Mendick Date: Thu, 31 Aug 2017 15:54:51 +0100 Subject: [PATCH 052/112] Updated typings and tests for Navigation 4.0.1 --- types/navigation/index.d.ts | 8 ++++++++ types/navigation/navigation-tests.ts | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/types/navigation/index.d.ts b/types/navigation/index.d.ts index 6f05956a8a..fdc729f11c 100644 --- a/types/navigation/index.d.ts +++ b/types/navigation/index.d.ts @@ -347,6 +347,10 @@ export class StateContext { * Gets the NavigationData for the last displayed State */ oldData: any; + /** + * Gets the Url for the last displayed State + */ + oldUrl: string; /** * Gets the State of the last Crumb in the crumb trail */ @@ -355,6 +359,10 @@ export class StateContext { * Gets the NavigationData of the last Crumb in the crumb trail */ previousData: any; + /** + * Gets the Url of the last Crumb in the crumb trail + */ + previousUrl: string; /** * Gets the current State */ diff --git a/types/navigation/navigation-tests.ts b/types/navigation/navigation-tests.ts index f710670953..37e597f841 100644 --- a/types/navigation/navigation-tests.ts +++ b/types/navigation/navigation-tests.ts @@ -83,12 +83,14 @@ link = stateNavigator.fluent() // State Context let state: State = stateNavigator.stateContext.state; -const url: string = stateNavigator.stateContext.url; +let url: string = stateNavigator.stateContext.url; const title: string = stateNavigator.stateContext.title; let page: number = stateNavigator.stateContext.data.page; state = stateNavigator.stateContext.oldState; +url = stateNavigator.stateContext.oldUrl; page = stateNavigator.stateContext.oldData.page; state = stateNavigator.stateContext.previousState; +url = stateNavigator.stateContext.previousUrl; page = stateNavigator.stateContext.previousData.page; // Navigation Data From 341edc76faabd58a2f184d4c9de66b5787cef26c Mon Sep 17 00:00:00 2001 From: bizen241 Date: Fri, 1 Sep 2017 01:48:38 +0900 Subject: [PATCH 053/112] [vfile]: add types --- types/vfile/index.d.ts | 152 +++++++++++++++++++++++++++++++++++++ types/vfile/tsconfig.json | 22 ++++++ types/vfile/tslint.json | 1 + types/vfile/vfile-tests.ts | 47 ++++++++++++ 4 files changed, 222 insertions(+) create mode 100644 types/vfile/index.d.ts create mode 100644 types/vfile/tsconfig.json create mode 100644 types/vfile/tslint.json create mode 100644 types/vfile/vfile-tests.ts diff --git a/types/vfile/index.d.ts b/types/vfile/index.d.ts new file mode 100644 index 0000000000..590fed550b --- /dev/null +++ b/types/vfile/index.d.ts @@ -0,0 +1,152 @@ +// Type definitions for VFile 2.2 +// Project: https://github.com/vfile/vfile +// Definitions by: bizen241 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import * as Unist from 'unist'; + +export = VFile; + +/** + * Create a new virtual file. + * Path related properties are set in the following order (least specific to most specific): `history`, `path`, `basename`, `stem`, `extname`, `dirname`. + * It’s not possible to set either `dirname` or `extname` without setting either `history`, `path`, `basename`, or `stem` as well. + * @param options If `options` is `string` or `Buffer`, treats it as `{contents: options}`. If `options` is a `VFile`, returns it. All other options are set on the newly created `vfile`. + */ +declare function VFile(options?: string | Buffer | Partial): VFile.VFile; + +declare namespace VFile { + interface VFile { + [key: string]: any; + /** + * Raw value. + */ + contents: string | Buffer | null; + /** + * Base of `path`. + * Defaults to `process.cwd()`. + */ + cwd: string; + /** + * Path of `vfile`. + * Cannot be nullified. + */ + path?: string; + /** + * Current name (including extension) of `vfile`. + * Cannot contain path separators. + * Cannot be nullified either (use `file.path = file.dirname` instead). + */ + basename?: string; + /** + * Name (without extension) of `vfile`. + * Cannot be nullified, and cannot contain path separators. + */ + stem?: string; + /** + * Extension (with dot) of `vfile`. + * Cannot be set if there's no `path` yet and cannot contain path separators. + */ + extname?: string; + /** + * Path to parent directory of `vfile`. + * Cannot be set if there's no `path` yet. + */ + dirname?: string; + /** + * List of file-paths the file moved between. + */ + history: string[]; + /** + * List of messages associated with the file. + */ + messages: VFileMessage[]; + /** + * Place to store custom information. + * It's OK to store custom data directly on the `vfile`, moving it to `data` gives a little more privacy. + */ + data: object; + /** + * Convert contents of `vfile` to string. + * @param encoding If `contents` is a buffer, `encoding` is used to stringify buffers (default: `'utf8'`). + */ + toString(encoding?: string): string; + /** + * Associates a message with the file for `reason` at `position`. + * When an error is passed in as `reason`, copies the stack. + * Each message has a `fatal` property which by default is set to `false` (ie. `warning`). + * @param reason Reason for message. Uses the stack and message of the error if given. + * @param position Place at which the message occurred in `vfile`. + * @param ruleId Category of message. + */ + message(reason: string | Error, position?: Unist.Node | Unist.Point | Unist.Position, ruleId?: string): VFileMessage; + /** + * Associates an informational message with the file, where `fatal` is set to `null`. + * Calls `message()` internally. + * @param reason Reason for message. Uses the stack and message of the error if given. + * @param position Place at which the message occurred in `vfile`. + * @param ruleId Category of message. + */ + info(reason: string | Error, position?: Unist.Node | Unist.Point | Unist.Position, ruleId?: string): VFileMessage; + /** + * Associates a fatal message with the file, then immediately throws it. + * Note: fatal errors mean a file is no longer processable. + * Calls `message()` internally. + * @param reason Reason for message. Uses the stack and message of the error if given. + * @param position Place at which the message occurred in `vfile`. + * @param ruleId Category of message. + */ + fail(reason: string | Error, position?: Unist.Node | Unist.Point | Unist.Position, ruleId?: string): VFileMessage; + } + + /** + * File-related message describing something at certain position. + */ + interface VFileMessage extends Error { + /** + * File-path, when the message was triggered. + */ + file: string; + /** + * Reason for message. + */ + reason: string; + /** + * Category of message. + */ + ruleId: string | null; + /** + * Namespace of warning. + */ + source: string | null; + /** + * If true, marks associated file as no longer processable. + */ + fatal: boolean | null; + /** + * Starting line of error. + */ + line: number | null; + /** + * Starting column of error. + */ + column: number | null; + /** + * Full range information, when available. + * Has start and end properties, both set to an object with line and column, set to number?. + */ + location: { + start: { + line: number | null; + column: number | null; + }; + end: { + line: number | null; + column: number | null; + }; + }; + } +} diff --git a/types/vfile/tsconfig.json b/types/vfile/tsconfig.json new file mode 100644 index 0000000000..7615c6e59a --- /dev/null +++ b/types/vfile/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", + "vfile-tests.ts" + ] +} diff --git a/types/vfile/tslint.json b/types/vfile/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vfile/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vfile/vfile-tests.ts b/types/vfile/vfile-tests.ts new file mode 100644 index 0000000000..aae566154b --- /dev/null +++ b/types/vfile/vfile-tests.ts @@ -0,0 +1,47 @@ +import * as vfile from 'vfile'; +import * as Unist from 'unist'; + +vfile(); +vfile('string'); +vfile(Buffer.from('string')); +vfile(vfile()); +vfile({ stem: 'readme', extname: '.md' }); +vfile({ custom: 'data' }); +try { + vfile({ extname: '.md' }); +} catch (e) { + console.log('Error: set extname without path'); +} + +const file: vfile.VFile = vfile({ contents: 'contents' }); + +file.path = '~/readme.txt'; +file.basename = 'example.txt'; +file.stem = 'readme'; +file.extname = '.md'; +file.data = { + key: 'value', +}; + +const history: string[] = file.history; +const contents: string = file.toString(); + +console.log('file.history =>', history); +console.log('file.contents =>', contents); + +const position: Unist.Point = { + line: 1, + column: 1, +}; + +file.message('reason', position); +file.info('reason', position); +try { + file.fail('reason', position); +} catch (e) { + console.log('Error: associated a fatal message'); +} + +const messages: vfile.VFileMessage[] = file.messages; + +console.log('file.messages =>', messages); From 9a49b95c1a483e2aeddcc6b2e82367e4fbfdfffa Mon Sep 17 00:00:00 2001 From: ikatyang Date: Fri, 1 Sep 2017 09:35:17 +0800 Subject: [PATCH 054/112] feat(prettier): add `sync` option --- types/prettier/index.d.ts | 8 +++++++- types/prettier/prettier-tests.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/types/prettier/index.d.ts b/types/prettier/index.d.ts index 48c89a5c57..07cf09fbba 100644 --- a/types/prettier/index.d.ts +++ b/types/prettier/index.d.ts @@ -102,6 +102,10 @@ export interface ResolveConfigOptions { * If set to `false`, all caching will be bypassed. */ useCache?: boolean; + /** + * If set to `true`, result will be returned directly. + */ + sync?: boolean; } /** @@ -114,7 +118,9 @@ export interface ResolveConfigOptions { * * The promise will be rejected if there was an error parsing the configuration file. */ -export function resolveConfig(filePath?: string, options?: ResolveConfigOptions): Promise; +export function resolveConfig(filePath: string | undefined, options: ResolveConfigOptions & { sync: true }): null | Options; +export function resolveConfig(filePath?: string, options?: ResolveConfigOptions & { sync?: false }): Promise; +export function resolveConfig(filePath?: string, options?: ResolveConfigOptions): null | Options | Promise; /** * As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache. diff --git a/types/prettier/prettier-tests.ts b/types/prettier/prettier-tests.ts index a51e8902c4..e88ebe4770 100644 --- a/types/prettier/prettier-tests.ts +++ b/types/prettier/prettier-tests.ts @@ -24,4 +24,30 @@ prettier.resolveConfig('path/to/somewhere').then(options => { } }); +prettier.resolveConfig('path/to/somewhere', undefined).then(options => { + if (options !== null) { + const formatted = prettier.format('hello world', options); + } +}); + +prettier.resolveConfig('path/to/somewhere', {}).then(options => { + if (options !== null) { + const formatted = prettier.format('hello world', options); + } +}); + +prettier.resolveConfig('path/to/somewhere', { sync: false }).then(options => { + if (options !== null) { + const formatted = prettier.format('hello world', options); + } +}); + +// $ExpectType Options | Promise | null +prettier.resolveConfig('path/to/somewhere', { sync: true as boolean }); + +const options = prettier.resolveConfig('path/to/somewhere', { sync: true }); +if (options !== null) { + const formatted = prettier.format('hello world', options); +} + prettier.clearConfigCache(); From 1c7070ef2ea0552a868fab0ac4aa73236bd87c11 Mon Sep 17 00:00:00 2001 From: ikatyang Date: Fri, 1 Sep 2017 13:47:54 +0800 Subject: [PATCH 055/112] feat(prettier): replace `sync` option with `.sync()` method --- types/prettier/index.d.ts | 11 ++++------- types/prettier/prettier-tests.ts | 23 +---------------------- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/types/prettier/index.d.ts b/types/prettier/index.d.ts index 07cf09fbba..317a514912 100644 --- a/types/prettier/index.d.ts +++ b/types/prettier/index.d.ts @@ -102,10 +102,6 @@ export interface ResolveConfigOptions { * If set to `false`, all caching will be bypassed. */ useCache?: boolean; - /** - * If set to `true`, result will be returned directly. - */ - sync?: boolean; } /** @@ -118,9 +114,10 @@ export interface ResolveConfigOptions { * * The promise will be rejected if there was an error parsing the configuration file. */ -export function resolveConfig(filePath: string | undefined, options: ResolveConfigOptions & { sync: true }): null | Options; -export function resolveConfig(filePath?: string, options?: ResolveConfigOptions & { sync?: false }): Promise; -export function resolveConfig(filePath?: string, options?: ResolveConfigOptions): null | Options | Promise; +export function resolveConfig(filePath?: string, options?: ResolveConfigOptions): Promise; +export namespace resolveConfig { + function sync(filePath?: string, options?: ResolveConfigOptions): null | Options; +} /** * As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache. diff --git a/types/prettier/prettier-tests.ts b/types/prettier/prettier-tests.ts index e88ebe4770..8d95196101 100644 --- a/types/prettier/prettier-tests.ts +++ b/types/prettier/prettier-tests.ts @@ -24,28 +24,7 @@ prettier.resolveConfig('path/to/somewhere').then(options => { } }); -prettier.resolveConfig('path/to/somewhere', undefined).then(options => { - if (options !== null) { - const formatted = prettier.format('hello world', options); - } -}); - -prettier.resolveConfig('path/to/somewhere', {}).then(options => { - if (options !== null) { - const formatted = prettier.format('hello world', options); - } -}); - -prettier.resolveConfig('path/to/somewhere', { sync: false }).then(options => { - if (options !== null) { - const formatted = prettier.format('hello world', options); - } -}); - -// $ExpectType Options | Promise | null -prettier.resolveConfig('path/to/somewhere', { sync: true as boolean }); - -const options = prettier.resolveConfig('path/to/somewhere', { sync: true }); +const options = prettier.resolveConfig.sync('path/to/somewhere'); if (options !== null) { const formatted = prettier.format('hello world', options); } From 04338685ff819b05a8353a6397f447fee90a21a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 1 Sep 2017 10:06:57 +0200 Subject: [PATCH 056/112] Make Callback type generic --- types/nano/index.d.ts | 90 +++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/types/nano/index.d.ts b/types/nano/index.d.ts index ab80e563d4..2378d3eb8b 100644 --- a/types/nano/index.d.ts +++ b/types/nano/index.d.ts @@ -19,7 +19,7 @@ declare namespace nano { request?(params: any): void; } - type Callback = (error: any, result: any, headers?: any) => void; + type Callback = (error: any, response: R, headers?: any) => void; interface ServerScope { readonly config: ServerConfig; @@ -29,77 +29,77 @@ declare namespace nano { request: RequestFunction; relax: RequestFunction; dinosaur: RequestFunction; - auth(username: string, userpass: string, callback?: Callback): Request; - session(callback?: Callback): Request; - updates(params?: UpdatesParams, callback?: Callback): Request; - followUpdates(params?: any, callback?: Callback): EventEmitter; - uuids(num: number, callback: Callback): Request; + auth(username: string, userpass: string, callback?: Callback): Request; + session(callback?: Callback): Request; + updates(params?: UpdatesParams, callback?: Callback): Request; + followUpdates(params?: any, callback?: Callback): EventEmitter; + uuids(num: number, callback: Callback): Request; } interface DatabaseScope { - create(name: string, callback?: Callback): Request; - get(name: string, callback?: Callback): Request; - destroy(name: string, callback?: Callback): Request; - list(callback?: Callback): Request; + create(name: string, callback?: Callback): Request; + get(name: string, callback?: Callback): Request; + destroy(name: string, callback?: Callback): Request; + list(callback?: Callback): Request; use(db: string): DocumentScope; - compact(name: string, designname?: string, callback?: Callback): Request; + compact(name: string, designname?: string, callback?: Callback): Request; replicate( source: string | DocumentScope, target: string | DocumentScope, options?: any, - callback?: Callback + callback?: Callback ): Request; - changes(name: string, params?: any, callback?: Callback): Request; + changes(name: string, params?: any, callback?: Callback): Request; follow( source: string, params?: DatabaseScopeFollowUpdatesParams, - callback?: Callback + callback?: Callback ): EventEmitter; - followUpdates(params?: any, callback?: Callback): EventEmitter; - updates(params?: UpdatesParams, callback?: Callback): Request; + followUpdates(params?: any, callback?: Callback): EventEmitter; + updates(params?: UpdatesParams, callback?: Callback): Request; } interface DocumentScope { readonly config: ServerConfig; - info(callback?: Callback): Request; + info(callback?: Callback): Request; replicate( target: string | DocumentScope, options?: any, - callback?: Callback + callback?: Callback ): Request; - compact(callback?: Callback): Request; - changes(params?: any, callback?: Callback): Request; + compact(callback?: Callback): Request; + changes(params?: any, callback?: Callback): Request; follow( params?: DocumentScopeFollowUpdatesParams, - callback?: Callback + callback?: Callback ): EventEmitter; - auth(username: string, userpass: string, callback?: Callback): Request; - session(callback?: Callback): Request; - insert(document: any, params?: any, callback?: Callback): Request; - get(docname: string, params?: any, callback?: Callback): Request; - head(docname: string, callback: Callback): Request; + auth(username: string, userpass: string, callback?: Callback): Request; + session(callback?: Callback): Request; + insert(document: any, params?: any, callback?: Callback): Request; + get(docname: string, params?: any, callback?: Callback): Request; + head(docname: string, callback: Callback): Request; copy( src_document: string, dst_document: string, options: any, - callback?: Callback + callback?: Callback ): Request; - destroy(docname: string, rev: string, callback?: Callback): Request; + destroy(docname: string, rev: string, callback?: Callback): Request; bulk( docs: BulkModifyDocsWrapper, params?: any, - callback?: Callback + callback?: Callback ): Request; - list(params?: any, callback?: Callback): Request; + list(params?: any, callback?: Callback): Request; fetch( docnames: BulkFetchDocsWrapper, params?: any, - callback?: Callback + callback?: Callback ): Request; fetchRevs( docnames: BulkFetchDocsWrapper, params?: any, - callback?: Callback + callback?: Callback ): Request; multipart: Multipart; attachment: Attachment; @@ -108,46 +108,46 @@ declare namespace nano { showname: string, doc_id: string, params?: any, - callback?: Callback + callback?: Callback ): Request; atomic( designname: string, updatename: string, docname: string, body?: any, - callback?: Callback + callback?: Callback ): Request; updateWithHandler( designname: string, updatename: string, docname: string, body?: any, - callback?: Callback + callback?: Callback ): Request; search( designname: string, searchname: string, params?: any, - callback?: Callback + callback?: Callback ): Request; spatial( ddoc: string, viewname: string, params?: any, - callback?: Callback + callback?: Callback ): Request; view( designname: string, viewname: string, params?: any, - callback?: Callback + callback?: Callback ): Request; viewWithList( designname: string, viewname: string, listname: string, params?: any, - callback?: Callback + callback?: Callback ): Request; server: ServerScope; } @@ -157,9 +157,9 @@ declare namespace nano { doc: any, attachments: any[], params: string | any, - callback?: Callback + callback?: Callback ): Request; - get(docname: string, params?: string | any, callback?: Callback): Request; + get(docname: string, params?: string | any, callback?: Callback): Request; } interface Attachment { @@ -169,19 +169,19 @@ declare namespace nano { att: any, contenttype: string, params?: any, - callback?: Callback + callback?: Callback ): Request; get( docname: string, attname: string, params?: any, - callback?: Callback + callback?: Callback ): Request; destroy( docname: string, attname: string, params?: any, - callback?: Callback + callback?: Callback ): Request; } @@ -192,7 +192,7 @@ declare namespace nano { type RequestFunction = ( options?: RequestOptions | string, - callback?: Callback + callback?: Callback ) => void; interface RequestOptions { From cdeb13e7744226addde443bfabd6df7db1989410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 1 Sep 2017 10:26:08 +0200 Subject: [PATCH 057/112] Make DocumentScope generic (accepts document model) --- types/nano/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/types/nano/index.d.ts b/types/nano/index.d.ts index 2378d3eb8b..59ff766010 100644 --- a/types/nano/index.d.ts +++ b/types/nano/index.d.ts @@ -8,7 +8,7 @@ import { Request, CoreOptions } from "request"; declare function nano( config: nano.Configuration | string -): nano.ServerScope | nano.DocumentScope; +): nano.ServerScope | nano.DocumentScope; declare namespace nano { interface Configuration { @@ -24,8 +24,8 @@ declare namespace nano { interface ServerScope { readonly config: ServerConfig; db: DatabaseScope; - use(db: string): DocumentScope; - scope(db: string): DocumentScope; + use(db: string): DocumentScope; + scope(db: string): DocumentScope; request: RequestFunction; relax: RequestFunction; dinosaur: RequestFunction; @@ -41,11 +41,11 @@ declare namespace nano { get(name: string, callback?: Callback): Request; destroy(name: string, callback?: Callback): Request; list(callback?: Callback): Request; - use(db: string): DocumentScope; + use(db: string): DocumentScope; compact(name: string, designname?: string, callback?: Callback): Request; - replicate( - source: string | DocumentScope, - target: string | DocumentScope, + replicate( + source: string | DocumentScope, + target: string | DocumentScope, options?: any, callback?: Callback ): Request; @@ -59,11 +59,11 @@ declare namespace nano { updates(params?: UpdatesParams, callback?: Callback): Request; } - interface DocumentScope { + interface DocumentScope { readonly config: ServerConfig; info(callback?: Callback): Request; replicate( - target: string | DocumentScope, + target: string | DocumentScope, options?: any, callback?: Callback ): Request; From dde5981408bbdda9792ed9fb86f76f7ef05d1d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 1 Sep 2017 13:22:24 +0200 Subject: [PATCH 058/112] Add overload to many methods to allow skip params attribute --- types/nano/index.d.ts | 162 ++++++++++++++++++++++++++---------------- 1 file changed, 101 insertions(+), 61 deletions(-) diff --git a/types/nano/index.d.ts b/types/nano/index.d.ts index 59ff766010..37e7491436 100644 --- a/types/nano/index.d.ts +++ b/types/nano/index.d.ts @@ -31,8 +31,10 @@ declare namespace nano { dinosaur: RequestFunction; auth(username: string, userpass: string, callback?: Callback): Request; session(callback?: Callback): Request; - updates(params?: UpdatesParams, callback?: Callback): Request; - followUpdates(params?: any, callback?: Callback): EventEmitter; + updates(callback?: Callback): Request; + updates(params: UpdatesParams, callback?: Callback): Request; + followUpdates(callback?: Callback): EventEmitter; + followUpdates(params: any, callback?: Callback): EventEmitter; uuids(num: number, callback: Callback): Request; } @@ -42,145 +44,183 @@ declare namespace nano { destroy(name: string, callback?: Callback): Request; list(callback?: Callback): Request; use(db: string): DocumentScope; - compact(name: string, designname?: string, callback?: Callback): Request; + compact(name: string, callback?: Callback): Request; + compact(name: string, designname: string, callback?: Callback): Request; + replicate( + source: string | DocumentScope, + target: string | DocumentScope, + callback?: Callback + ): Request replicate( source: string | DocumentScope, target: string | DocumentScope, options?: any, callback?: Callback ): Request; - changes(name: string, params?: any, callback?: Callback): Request; - follow( - source: string, - params?: DatabaseScopeFollowUpdatesParams, - callback?: Callback - ): EventEmitter; - followUpdates(params?: any, callback?: Callback): EventEmitter; - updates(params?: UpdatesParams, callback?: Callback): Request; + changes(name: string, callback?: Callback): Request; + changes(name: string, params: any, callback?: Callback): Request; + follow(source: string, callback?: Callback): EventEmitter; + follow(source: string, params: DatabaseScopeFollowUpdatesParams, callback?: Callback): EventEmitter; + followUpdates(callback?: Callback): EventEmitter; + followUpdates(params: any, callback?: Callback): EventEmitter; + updates(callback?: Callback): Request; + updates(params: UpdatesParams, callback?: Callback): Request; } interface DocumentScope { readonly config: ServerConfig; info(callback?: Callback): Request; + replicate( + target: string | DocumentScope, + callback?: Callback + ): Request replicate( target: string | DocumentScope, - options?: any, - callback?: Callback - ): Request; - compact(callback?: Callback): Request; - changes(params?: any, callback?: Callback): Request; - follow( - params?: DocumentScopeFollowUpdatesParams, - callback?: Callback - ): EventEmitter; - auth(username: string, userpass: string, callback?: Callback): Request; - session(callback?: Callback): Request; - insert(document: any, params?: any, callback?: Callback): Request; - get(docname: string, params?: any, callback?: Callback): Request; - head(docname: string, callback: Callback): Request; - copy( - src_document: string, - dst_document: string, options: any, callback?: Callback ): Request; + compact(callback?: Callback): Request; + changes(callback?: Callback): Request; + changes(params: any, callback?: Callback): Request; + follow(callback?: Callback): EventEmitter; + follow(params: DocumentScopeFollowUpdatesParams, callback?: Callback): EventEmitter; + auth(username: string, userpass: string, callback?: Callback): Request; + session(callback?: Callback): Request; + insert(document: any, callback?: Callback): Request; + insert(document: any, params: any, callback?: Callback): Request; + get(docname: string, callback?: Callback): Request; + get(docname: string, params: any, callback?: Callback): Request; + head(docname: string, callback: Callback): Request; + copy(src_document: string, dst_document: string, callback?: Callback): Request; + copy(src_document: string, dst_document: string, options: any, callback?: Callback): Request; destroy(docname: string, rev: string, callback?: Callback): Request; - bulk( - docs: BulkModifyDocsWrapper, - params?: any, - callback?: Callback - ): Request; - list(params?: any, callback?: Callback): Request; - fetch( - docnames: BulkFetchDocsWrapper, - params?: any, - callback?: Callback - ): Request; - fetchRevs( - docnames: BulkFetchDocsWrapper, - params?: any, - callback?: Callback - ): Request; + bulk(docs: BulkModifyDocsWrapper, callback?: Callback): Request; + bulk(docs: BulkModifyDocsWrapper, params?: any, callback?: Callback): Request; + list(callback?: Callback): Request; + list(params: any, callback?: Callback): Request; + fetch(docnames: BulkFetchDocsWrapper, callback?: Callback): Request; + fetch(docnames: BulkFetchDocsWrapper, params: any, callback?: Callback): Request; + fetchRevs(docnames: BulkFetchDocsWrapper, callback?: Callback): Request; + fetchRevs(docnames: BulkFetchDocsWrapper, params?: any, callback?: Callback): Request; multipart: Multipart; attachment: Attachment; show( designname: string, showname: string, doc_id: string, - params?: any, + callback?: Callback + ): Request; + show( + designname: string, + showname: string, + doc_id: string, + params: any, callback?: Callback ): Request; atomic( designname: string, updatename: string, docname: string, - body?: any, + callback?: Callback + ): Request; + atomic( + designname: string, + updatename: string, + docname: string, + body: any, callback?: Callback ): Request; updateWithHandler( designname: string, updatename: string, docname: string, - body?: any, + callback?: Callback + ): Request; + updateWithHandler( + designname: string, + updatename: string, + docname: string, + body: any, callback?: Callback ): Request; search( designname: string, searchname: string, - params?: any, + callback?: Callback + ): Request; + search( + designname: string, + searchname: string, + params: any, callback?: Callback ): Request; spatial( ddoc: string, viewname: string, - params?: any, + callback?: Callback + ): Request; + spatial( + ddoc: string, + viewname: string, + params: any, callback?: Callback ): Request; view( designname: string, viewname: string, - params?: any, + callback?: Callback + ): Request; + view( + designname: string, + viewname: string, + params: any, callback?: Callback ): Request; viewWithList( designname: string, viewname: string, listname: string, - params?: any, + callback?: Callback + ): Request; + viewWithList( + designname: string, + viewname: string, + listname: string, + params: any, callback?: Callback ): Request; server: ServerScope; } interface Multipart { - insert( - doc: any, - attachments: any[], - params: string | any, - callback?: Callback - ): Request; - get(docname: string, params?: string | any, callback?: Callback): Request; + insert(doc: any, attachments: any[], callback?: Callback): Request; + insert(doc: any, attachments: any[], params: string | any, callback?: Callback): Request; + get(docname: string, callback?: Callback): Request; + get(docname: string, params: string | any, callback?: Callback): Request; } interface Attachment { + insert(docname: string, attname: string, att: any, contenttype: string, callback?: Callback): Request; insert( docname: string, attname: string, att: any, contenttype: string, - params?: any, + params: any, callback?: Callback ): Request; + get(docname: string, attname: string, callback?: Callback): Request; get( docname: string, attname: string, - params?: any, + params: any, callback?: Callback ): Request; + destroy(docname: string, attname: string, callback?: Callback): Request; destroy( docname: string, attname: string, - params?: any, + params: any, callback?: Callback ): Request; } From 8a21c431de62d15672802ff248ce1f699a0c787a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 1 Sep 2017 13:23:06 +0200 Subject: [PATCH 059/112] Imports in alphabetic order --- types/nano/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/nano/index.d.ts b/types/nano/index.d.ts index 37e7491436..7a03be1684 100644 --- a/types/nano/index.d.ts +++ b/types/nano/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { EventEmitter } from "events"; -import { Request, CoreOptions } from "request"; +import { CoreOptions, Request } from "request"; declare function nano( config: nano.Configuration | string From 0b8c9754b2d83107d28a6bcd256b77de4a10ed73 Mon Sep 17 00:00:00 2001 From: Anton Vasin Date: Fri, 1 Sep 2017 14:50:14 +0300 Subject: [PATCH 060/112] Allow to use function for linkTo --- types/storybook__addon-links/index.d.ts | 4 +++- types/storybook__addon-links/storybook__addon-links-tests.tsx | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/storybook__addon-links/index.d.ts b/types/storybook__addon-links/index.d.ts index 802e193afb..08f3648855 100644 --- a/types/storybook__addon-links/index.d.ts +++ b/types/storybook__addon-links/index.d.ts @@ -6,4 +6,6 @@ import * as React from 'react'; -export function linkTo(book: string, kind?: string): React.MouseEventHandler; +export type LinkToFunction = (...args: any[]) => string; + +export function linkTo(book: string | LinkToFunction, kind?: string | LinkToFunction): React.MouseEventHandler; diff --git a/types/storybook__addon-links/storybook__addon-links-tests.tsx b/types/storybook__addon-links/storybook__addon-links-tests.tsx index 9b3abb6f6e..2f138daf20 100644 --- a/types/storybook__addon-links/storybook__addon-links-tests.tsx +++ b/types/storybook__addon-links/storybook__addon-links-tests.tsx @@ -8,4 +8,7 @@ storiesOf('Button', module) )) .add('Second', () => ( + )) + .add('With function', () => ( + )); From e84cf3ef7bdc333cb439e615a034ca2bc6176c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Wachter?= Date: Fri, 1 Sep 2017 14:31:45 +0200 Subject: [PATCH 061/112] [pg]: Add a "Notification" type and pass it to the notification event listener See: https://node-postgres.com/api/client#client-on-39-notification-39-notification-notification-gt-void-gt-void --- types/pg/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index da6f4db575..258188c937 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -60,6 +60,12 @@ export interface QueryResult { rows: any[]; } +export interface Notification { + processId: number, + channel: string, + payload?: string +} + export interface ResultBuilder extends QueryResult { addRow(row: any): void; } @@ -109,7 +115,7 @@ export declare class Client extends events.EventEmitter { on(event: "drain", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; - on(event: "notification" | "notice", listener: (message: any) => void): this; + on(event: "notification" | "notice", listener: (message: Notification) => void): this; on(event: "end", listener: () => void): this; } From 599f7a5876a375449087da4c9481d4d0bd7f7054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 1 Sep 2017 15:04:09 +0200 Subject: [PATCH 062/112] Update list of authors --- types/nano/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/nano/index.d.ts b/types/nano/index.d.ts index 7a03be1684..4c8a3068a5 100644 --- a/types/nano/index.d.ts +++ b/types/nano/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for nano 6.2 // Project: https://github.com/apache/couchdb-nano // Definitions by: Tim Jacobi +// KovΓ‘cs Vince // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { EventEmitter } from "events"; From d9b76059b989ac5e2515c872823bd247e232c3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 1 Sep 2017 15:04:44 +0200 Subject: [PATCH 063/112] Add interface for responses --- types/nano/index.d.ts | 850 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 798 insertions(+), 52 deletions(-) diff --git a/types/nano/index.d.ts b/types/nano/index.d.ts index 4c8a3068a5..6457c7b582 100644 --- a/types/nano/index.d.ts +++ b/types/nano/index.d.ts @@ -4,6 +4,8 @@ // KovΓ‘cs Vince // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + import { EventEmitter } from "events"; import { CoreOptions, Request } from "request"; @@ -30,87 +32,144 @@ declare namespace nano { request: RequestFunction; relax: RequestFunction; dinosaur: RequestFunction; - auth(username: string, userpass: string, callback?: Callback): Request; - session(callback?: Callback): Request; - updates(callback?: Callback): Request; - updates(params: UpdatesParams, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/authn.html#cookie-authentication + auth(username: string, userpass: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session + session(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(params: UpdatesParams, callback?: Callback): Request; followUpdates(callback?: Callback): EventEmitter; followUpdates(params: any, callback?: Callback): EventEmitter; uuids(num: number, callback: Callback): Request; } interface DatabaseScope { - create(name: string, callback?: Callback): Request; - get(name: string, callback?: Callback): Request; - destroy(name: string, callback?: Callback): Request; - list(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#put--db + create(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#get--db + get(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#delete--db + destroy(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_all_dbs + list(callback?: Callback): Request; use(db: string): DocumentScope; compact(name: string, callback?: Callback): Request; - compact(name: string, designname: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact + compact(name: string, designname: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate replicate( source: string | DocumentScope, target: string | DocumentScope, - callback?: Callback + callback?: Callback ): Request + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate replicate( source: string | DocumentScope, target: string | DocumentScope, - options?: any, - callback?: Callback + options: DatabaseReplicateOptions, + callback?: Callback ): Request; - changes(name: string, callback?: Callback): Request; - changes(name: string, params: any, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + changes(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact + changes(name: string, params: DatabaseChangesParams, callback?: Callback): Request; follow(source: string, callback?: Callback): EventEmitter; follow(source: string, params: DatabaseScopeFollowUpdatesParams, callback?: Callback): EventEmitter; - followUpdates(callback?: Callback): EventEmitter; - followUpdates(params: any, callback?: Callback): EventEmitter; - updates(callback?: Callback): Request; - updates(params: UpdatesParams, callback?: Callback): Request; + followUpdates(params?: any, callback?: Callback): EventEmitter; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(params: UpdatesParams, callback?: Callback): Request; } interface DocumentScope { readonly config: ServerConfig; - info(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#get--db + info(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate replicate( target: string | DocumentScope, - callback?: Callback + callback?: Callback ): Request + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate replicate( target: string | DocumentScope, options: any, - callback?: Callback + callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact compact(callback?: Callback): Request; - changes(callback?: Callback): Request; - changes(params: any, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + changes(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + changes(params: DatabaseChangesParams, callback?: Callback): Request; follow(callback?: Callback): EventEmitter; follow(params: DocumentScopeFollowUpdatesParams, callback?: Callback): EventEmitter; - auth(username: string, userpass: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/authn.html#cookie-authentication + auth(username: string, userpass: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session session(callback?: Callback): Request; - insert(document: any, callback?: Callback): Request; - insert(document: any, params: any, callback?: Callback): Request; - get(docname: string, callback?: Callback): Request; - get(docname: string, params: any, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + insert(document: ViewDocument | D & MaybeDocument, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + insert( + document: ViewDocument | D & MaybeDocument, + params: DocumentInsertParams | string | null, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + get(docname: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + get(docname: string, params?: DocumentGetParams, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#head--db-docid head(docname: string, callback: Callback): Request; - copy(src_document: string, dst_document: string, callback?: Callback): Request; - copy(src_document: string, dst_document: string, options: any, callback?: Callback): Request; - destroy(docname: string, rev: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid + copy(src_document: string, dst_document: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid + copy( + src_document: string, + dst_document: string, + options: DocumentCopyOptions, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#delete--db-docid + destroy(docname: string, rev: string, callback?: Callback): Request; bulk(docs: BulkModifyDocsWrapper, callback?: Callback): Request; - bulk(docs: BulkModifyDocsWrapper, params?: any, callback?: Callback): Request; - list(callback?: Callback): Request; - list(params: any, callback?: Callback): Request; - fetch(docnames: BulkFetchDocsWrapper, callback?: Callback): Request; - fetch(docnames: BulkFetchDocsWrapper, params: any, callback?: Callback): Request; - fetchRevs(docnames: BulkFetchDocsWrapper, callback?: Callback): Request; - fetchRevs(docnames: BulkFetchDocsWrapper, params?: any, callback?: Callback): Request; - multipart: Multipart; + bulk(docs: BulkModifyDocsWrapper, params: any, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + list(callback?: Callback>): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + list(params: DocumentListParams, callback?: Callback>): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs + fetch(docnames: BulkFetchDocsWrapper, callback?: Callback>): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs + fetch( + docnames: BulkFetchDocsWrapper, + params: DocumentFetchParams, + callback?: Callback> + ): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs + fetchRevs(docnames: BulkFetchDocsWrapper, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs + fetchRevs( + docnames: BulkFetchDocsWrapper, + params: DocumentFetchParams, + callback?: Callback + ): Request; + multipart: Multipart; attachment: Attachment; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func show( designname: string, showname: string, doc_id: string, callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func show( designname: string, showname: string, @@ -118,31 +177,35 @@ declare namespace nano { params: any, callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid atomic( designname: string, updatename: string, docname: string, - callback?: Callback + callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid atomic( designname: string, updatename: string, docname: string, body: any, - callback?: Callback + callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid updateWithHandler( designname: string, updatename: string, docname: string, - callback?: Callback + callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid updateWithHandler( designname: string, updatename: string, docname: string, body: any, - callback?: Callback + callback?: Callback ): Request; search( designname: string, @@ -166,42 +229,52 @@ declare namespace nano { params: any, callback?: Callback ): Request; - view( + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view + view( designname: string, viewname: string, - callback?: Callback + callback?: Callback> ): Request; - view( + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view + view( designname: string, viewname: string, - params: any, - callback?: Callback + params: DocumentViewParams, + callback?: Callback> ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#db-design-design-doc-list-list-name-view-name viewWithList( designname: string, viewname: string, listname: string, callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#db-design-design-doc-list-list-name-view-name viewWithList( designname: string, viewname: string, listname: string, - params: any, + params: DocumentViewParams, callback?: Callback ): Request; server: ServerScope; } - interface Multipart { - insert(doc: any, attachments: any[], callback?: Callback): Request; - insert(doc: any, attachments: any[], params: string | any, callback?: Callback): Request; + interface Multipart { + // http://docs.couchdb.org/en/latest/api/document/common.html#creating-multiple-attachments + insert(doc: D, attachments: any[], callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#creating-multiple-attachments + insert(doc: D, attachments: any[], params: string | any, callback?: Callback): Request; get(docname: string, callback?: Callback): Request; get(docname: string, params: string | any, callback?: Callback): Request; } interface Attachment { + insert(docname: string, attname: string, att: null, contenttype: string): NodeJS.WritableStream; insert(docname: string, attname: string, att: any, contenttype: string, callback?: Callback): Request; + insert(docname: string, attname: string, att: null, contenttype: string, params: any): NodeJS.WritableStream; insert( docname: string, attname: string, @@ -250,10 +323,12 @@ declare namespace nano { multipart?: any[]; } + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates interface UpdatesParams { feed: "longpoll" | "continuous" | "eventsource"; timeout: number; heartbeat: boolean; + since: string; } interface DocumentScopeFollowUpdatesParams { @@ -284,6 +359,677 @@ declare namespace nano { interface BulkFetchDocsWrapper { keys: string[]; } + + // ------------------------------------- + // Document + // ------------------------------------- + + interface MaybeIdentifiedDocument { + _id?: string; + } + + interface IdentifiedDocument { + _id: string; + } + + interface MaybeRevisionedDocument { + _rev?: string; + } + + interface RevisionedDocument { + _rev: string; + } + + interface MaybeDocument extends MaybeIdentifiedDocument, MaybeRevisionedDocument { + } + + interface Document extends IdentifiedDocument, RevisionedDocument { + } + + // ------------------------------------- + // View + // ------------------------------------- + + interface View { + map?(doc: D & Document): void; + reduce?(doc: D & Document): void; + } + + interface ViewDocument extends IdentifiedDocument { + views: { + [name: string]: View + }; + } + + // ------------------------------------- + // Database scope request and response + // ------------------------------------- + + // http://docs.couchdb.org/en/latest/api/database/common.html#put--db + interface DatabaseCreateResponse { + // Operation status. Available in case of success + ok?: boolean; + + // Error type. Available if response code is 4xx + error?: string; + + // Error description. Available if response code is 4xx + reason?: string; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#get--db + interface DatabaseGetResponse { + // Set to true if the database compaction routine is operating on this database. + compact_running: boolean; + + // The name of the database. + db_name: string; + + // The version of the physical format used for the data when it is stored on disk. + disk_format_version: number; + + // The number of bytes of live data inside the database file. + data_size: number; + + // The length of the database file on disk. Views indexes are not included in the calculation. + disk_size: number; + + // A count of the documents in the specified database. + doc_count: number; + + // Number of deleted documents + doc_del_count: number; + + // Timestamp of when the database was opened, expressed in microseconds since the epoch. + instance_start_time: string; + + // The number of purge operations on the database. + purge_seq: number; + + sizes: { + // The size of live data inside the database, in bytes. + active: number; + + // The uncompressed size of database contents in bytes. + external: number; + + // The size of the database file on disk in bytes. Views indexes + file: number; + }; + + // The current number of updates to the database. + update_seq: number; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#delete--db + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact + interface OkResponse { + // Operation status + ok: boolean; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + interface DatabaseReplicateOptions { + // Cancels the replication + cancel?: boolean; + + // Configure the replication to be continuous + continuous?: boolean; + + // Creates the target database. Required administrator’s privileges on target server. + create_target?: boolean; + + // Array of document IDs to be synchronized + doc_ids?: string[]; + + // The name of a filter function. + filter ?: string; + + // Address of a proxy server through which replication should occur (protocol can be β€œhttp” or β€œsocks5”) + proxy ?: string; + + // Source database name or URL + source?: string; + + // Target database name or URL + target?: string; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + interface DatabaseReplicationHistoryItem { + // Number of document write failures + doc_write_failures: number; + + // Number of documents read + docs_read: number; + + // Number of documents written to target + docs_written: number; + + // Last sequence number in changes stream + end_last_seq: number; + + // Date/Time replication operation completed in RFC 2822 format + end_time: string; + + // Number of missing documents checked + missing_checked: number; + + // Number of missing documents found + missing_found: number; + + // Last recorded sequence number + recorded_seq: number; + + // Session ID for this replication operation + session_id: string; + + // First sequence number in changes stream + start_last_seq: number; + + // Date/Time replication operation started in RFC 2822 format + start_time: string; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + interface DatabaseReplicateResponse { + // Replication history + history: DatabaseReplicationHistoryItem[]; + + // Replication status + ok: boolean; + + // Replication protocol version + replication_id_version: number; + + // Unique session ID + session_id: string; + + // Last sequence number read from source database + source_last_seq: number; + } + + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + interface DatabaseChangesParams { + // List of document IDs to filter the changes feed as valid JSON array. Used with _doc_ids filter. Since length of + // URL is limited, it is better to use POST /{db}/_changes instead. + doc_ids?: string[]; + + // Includes conflicts information in response. Ignored if include_docs isn’t true. Default is false. + conflicts?: boolean; + + // Return the change results in descending sequence order (most recent change first). Default is false. + descending?: boolean; + + // - normal Specifies Normal Polling Mode. All past changes are returned immediately. Default. + // - longpoll Specifies Long Polling Mode. Waits until at least one change has occurred, sends the change, then + // closes the connection. Most commonly used in conjunction with since=now, to wait for the next change. + // - continuous Sets Continuous Mode. Sends a line of JSON per event. Keeps the socket open until timeout. + // - eventsource Sets Event Source Mode. Works the same as Continuous Mode, but sends the events in EventSource + // format. + feed?: "normal" | "longpoll" | "continuous" | "eventsource"; + + // Reference to a filter function from a design document that will filter whole stream emitting only filtered + // events. See the section Change Notifications in the book CouchDB The Definitive Guide for more information. + filter?: string; + + // Period in milliseconds after which an empty line is sent in the results. Only applicable for longpoll, + // continuous, and eventsource feeds. Overrides any timeout to keep the feed alive indefinitely. Default is 60000. + // May be true to use default value. + heartbeat?: number; + + // Include the associated document with each result. If there are conflicts, only the winning revision is returned. + // Default is false. + include_docs?: boolean; + + // Include the Base64-encoded content of attachments in the documents that are included if include_docs is true. + // Ignored if include_docs isn’t true. Default is false. + attachments?: boolean; + + // Include encoding information in attachment stubs if include_docs is true and the particular attachment is + // compressed. Ignored if include_docs isn’t true. Default is false. + att_encoding_info?: boolean; + + // Limit number of result rows to the specified value (note that using 0 here has the same effect as 1). + limit?: number; + + // Start the results from the change immediately after the given update sequence. Can be valid update sequence or + // now value. Default is 0. + since?: number; + + // Specifies how many revisions are returned in the changes array. The default, main_only, will only return the + // current β€œwinning” revision; all_docs will return all leaf revisions (including conflicts and deleted former + // conflicts). + style?: string; + + // Maximum period in milliseconds to wait for a change before the response is sent, even if there are no results. + // Only applicable for longpoll or continuous feeds. Default value is specified by httpd/changes_timeout + // configuration option. Note that 60000 value is also the default maximum timeout to prevent undetected dead + // connections. + timeout?: number; + + // Allows to use view functions as filters. Documents counted as β€œpassed” for view filter in case if map function + // emits at least one record for them. See _view for more info. + view?: string; + } + + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + interface DatabaseChangesResultItem { + // List of document’s leaves with single field rev. + changes: Array<{ rev: string }>; + + // Document ID. + id: string; + + // Update sequence. + seq: any; + + // true if the document is deleted. + deleted: boolean; + } + + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + interface DatabaseChangesResponse { + // Last change update sequence + last_seq: any; + + // Count of remaining items in the feed + pending: number; + + // Changes made to a database + results: DatabaseChangesResultItem[]; + } + + // http://docs.couchdb.org/en/latest/api/server/authn.html#cookie-authentication + interface DatabaseAuthResponse { + // Operation status + ok: boolean; + + // Username + name: string; + + // List of user roles + roles: string[]; + } + + // http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session + interface DatabaseSessionResponse { + // Operation status + ok: boolean; + + // User context for the current user + userCtx: any; + + // Server authentication configuration + info: any; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + interface DatabaseUpdatesResultItem { + // Database name. + db_name: string; + + // A database event is one of created, updated, deleted. + type: string; + + // Update sequence of the event. + seq: any; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + interface DatabaseUpdatesResponse { + // An array of database events. For longpoll and continuous modes, the entire response is the contents of the + // results array. + results: DatabaseUpdatesResultItem[]; + + // The last sequence ID reported. + last_seq: string; + } + + // ------------------------------------- + // Document scope request and response + // ------------------------------------- + + interface DocumentResponseRowMeta { + id: string; + key: string; + value: { + rev: string; + }; + } + + interface DocumentResponseRow extends DocumentResponseRowMeta { + doc?: D & Document; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + interface DocumentInsertParams { + // Document’s revision if updating an existing document. Alternative to If-Match header or document key. + rev?: string; + + // Stores document in batch mode. + batch?: "ok"; + + // Prevents insertion of a conflicting document. Possible values: true (default) and false. If false, a + // well-formed _rev must be included in the document. new_edits=false is used by the replicator to insert + // documents into the target database even if that leads to the creation of conflicts. + new_edits?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + interface DocumentInsertResponse { + // Document ID + id: string; + + // Operation status + ok: boolean; + + // Revision MVCC token + rev: string; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#delete--db-docid + interface DocumentDestroyResponse { + // Document ID + id: string; + + // Operation status + ok: boolean; + + // Revision MVCC token + rev: string; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + interface DocumentGetParams { + // Includes attachments bodies in response. Default is false. + attachments?: boolean; + + // Includes encoding information in attachment stubs if the particular attachment is compressed. Default is + // false. + att_encoding_info?: boolean; + + // Includes attachments only since specified revisions. Doesn’t includes attachments for specified revisions. + atts_since?: any[]; + + // Includes information about conflicts in document. Default is false. + conflicts?: boolean; + + // Includes information about deleted conflicted revisions. Default is false. + deleted_conflicts?: boolean; + + // Forces retrieving latest β€œleaf” revision, no matter what rev was requested. Default is false. + latest?: boolean; + + // Includes last update sequence for the document. Default is false. + local_seq?: boolean; + + // Acts same as specifying all conflicts, deleted_conflicts and revs_info query parameters. Default is false. + meta?: boolean; + + // Retrieves documents of specified leaf revisions. Additionally, it accepts value as all to return all leaf + // revisions. + open_revs?: any[]; + + // Retrieves document of specified revision. + rev?: string; + + // Includes list of all known document revisions. + revs?: boolean; + + // Includes detailed information for all known document revisions. Default is false. + revs_info?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + interface DocumentGetResponse { + // Document ID. + _id: string; + + // Revision MVCC token. + _rev: string; + + // Deletion flag. Available if document was removed. + _deleted?: boolean; + + // Attachment’s stubs. Available if document has any attachments. + _attachments?: any; + + // List of conflicted revisions. Available if requested with conflicts=true query parameter. + _conflicts?: any[]; + + // List of deleted conflicted revisions. Available if requested with deleted_conflicts=true query parameter. + _deleted_conflicts?: any[]; + + // Document’s update sequence in current database. Available if requested with local_seq=true query parameter. + _local_seq?: string; + + // List of objects with information about local revisions and their status. Available if requested with + // open_revs query parameter. + _revs_info?: any[]; + + // List of local revision tokens without. Available if requested with revs=true query parameter. + _revisions?: any; + } + + interface DocumentCopyOptions { + overwrite?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid + interface DocumentCopyResponse { + // Document ID + id: string; + + // Operation status + ok: boolean; + + // Revision MVCC token + rev: string; + } + + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + interface DocumentListParams { + // Includes conflicts information in response. Ignored if include_docs isn’t true. Default is false. + conflicts?: boolean; + + // Return the documents in descending by key order. Default is false. + descending?: boolean; + + // Stop returning records when the specified key is reached. + end_key?: string; + + // Stop returning records when the specified document ID is reached. + end_key_doc_id?: string; + + // Include the full content of the documents in the return. Default is false. + include_docs?: boolean; + + // Specifies whether the specified end key should be included in the result. Default is true. + inclusive_end?: boolean; + + // Return only documents that match the specified key. + key?: string; + + // Return only documents that match the specified keys. + keys?: string; // This can be string[] too ??? + + // Limit the number of the returned documents to the specified number. + limit?: number; + + // Skip this number of records before starting to return the results. Default is 0. + skip?: number; + + // Allow the results from a stale view to be used, without triggering a rebuild of all views within the + // encompassing design doc. Supported values: ok and update_after. + stale?: string; + + // Return records starting with the specified key. + start_key?: string; + + // Return records starting with the specified document ID. + start_key_doc_id?: string; + + // Response includes an update_seq value indicating which sequence id of the underlying database the view + // reflects. Default is false. + update_seq?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + interface DocumentListResponse { + // Offset where the document list started. + offset: number; + + // Array of view row objects. By default the information returned contains only the document ID and revision. + rows: Array>; + + // Number of documents in the database/view. Note that this is not the number of rows returned in the actual + // query. + total_rows: number; + + // Current update sequence for the database. + update_seq?: number; + } + + interface DocumentFetchParams { + conflicts?: boolean; + descending?: boolean; + end_key?: string; + end_key_doc_id?: string; + inclusive_end?: boolean; + key?: string; + keys?: string; // This can be string[] too ??? + limit?: number; + skip?: number; + stale?: string; + start_key?: string; + start_key_doc_id?: string; + update_seq?: boolean; + } + + interface DocumentFetchResponse { + offset: number; + rows: Array>; + total_rows: number; + update_seq?: number; + } + + interface DocumentFetchRevsResponse { + offset: number; + rows: DocumentResponseRowMeta[]; + total_rows: number; + update_seq?: number; + } + + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + interface DocumentViewParams { + // Includes conflicts information in response. Ignored if include_docs isn’t true. Default is false. + conflicts?: boolean; + + // Return the documents in descending by key order. Default is false. + descending?: boolean; + + // Stop returning records when the specified key is reached. + endkey?: any; + + // Alias for endkey param. + end_key?: any; + + // Stop returning records when the specified document ID is reached. Requires endkey to be specified for this + // to have any effect. + endkey_docid?: string; + + // Alias for endkey_docid param. + end_key_doc_id?: string; + + // Group the results using the reduce function to a group or single row. Default is false. + group?: boolean; + + // Specify the group level to be used. + group_level?: number; + + // Include the associated document with each row. Default is false. + include_docs?: boolean; + + // Include the Base64-encoded content of attachments in the documents that are included if include_docs is + // true. Ignored if include_docs isn’t true. Default is false. + attachments?: boolean; + + // Include encoding information in attachment stubs if include_docs is true and the particular attachment is + // compressed. Ignored if include_docs isn’t true. Default is false. + att_encoding_info?: boolean; + + // Specifies whether the specified end key should be included in the result. Default is true. + inclusive_end?: boolean; + + // Return only documents that match the specified key. + key?: any; + + // Return only documents where the key matches one of the keys specified in the array. + keys?: any[]; + + // Limit the number of the returned documents to the specified number. + limit?: number; + + // Use the reduction function. Default is true. + reduce?: boolean; + + // Skip this number of records before starting to return the results. Default is 0. + skip?: number; + + // Sort returned rows. Setting this to false offers a performance boost. The total_rows and offset fields are + // not available when this is set to false. Default is true. + sorted?: boolean; + + // Whether or not the view results should be returned from a stable set of shards. Default is false. + stable?: boolean; + // Allow the results from a stale view to be used. Supported values: ok, update_after and false. ok is + // equivalent to stable=true&update=false. update_after is equivalent to stable=true&update=lazy. false is + // equivalent to stable=false&update=true. + stale?: string; + + // Return records starting with the specified key. + startkey?: any; + + // Alias for startkey param + start_key?: any; + + // Return records starting with the specified document ID. Requires startkey to be specified for this to have + // any effect. + startkey_docid?: string; + + // Alias for startkey_docid param + start_key_doc_id?: string; + + // Whether or not the view in question should be updated prior to responding to the user. Supported values: + // true, false, lazy. Default is true. + update?: string; + + // Response includes an update_seq value indicating which sequence id of the database the view reflects. + // Default is false. + update_seq?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + interface DocumentViewResponse { + // Offset where the document list started. + offset: number; + + // Array of view row objects. By default the information returned contains only the document ID and revision. + rows: Array<{ + id: string; + key: string; + value: V; + }>; + + // Number of documents in the database/view. + total_rows: number; + + // Current update sequence for the database + update_seq: any; + } } export = nano; From 96410e7010d4f35cbe530fcde2de36bcd4309999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 1 Sep 2017 15:04:55 +0200 Subject: [PATCH 064/112] Fix test cases --- types/nano/nano-tests.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/types/nano/nano-tests.ts b/types/nano/nano-tests.ts index 33cfe4534d..522064f993 100644 --- a/types/nano/nano-tests.ts +++ b/types/nano/nano-tests.ts @@ -1,6 +1,5 @@ -import * as nano from "nano"; import * as fs from "fs"; -import * as path from "path"; +import * as nano from "nano"; /* * Instantiate with configuration object @@ -67,10 +66,15 @@ db.replicate("a", "b", (error: any) => {}); /* * Document Scope */ -const mydb: nano.DocumentScope = instance.use("mydb"); +interface SomeDocument{ + name: string +} -mydb.insert({ foo: "baz" }, null, (err, response) => {}); -mydb.insert({ foo: "baz" }, "foobar", (error, foo) => {}); +const mydb: nano.DocumentScope = instance.use("mydb"); + +mydb.insert({ name: "baz" }, null, (err, response) => {}); +mydb.insert({ name: "baz" }, "foobar", (error, foo) => {}); +mydb.insert({ name: "baz" }, { new_edits: true }, (error, foo) => {}); mydb.get("foobaz", { revs_info: true }, (error, foobaz) => {}); mydb.head("foobaz", (error, body, headers) => {}); mydb.copy( @@ -129,7 +133,7 @@ mydb.attachment.get("new_string", "att", (error: any, helloWorld: any) => {}); /* * Multipart */ -mydb.multipart.insert({ foo: "baz" }, [{}], "foobaz", (error, foo) => {}); +mydb.multipart.insert({ name: "baz" }, [{}], "foobaz", (error, foo) => {}); mydb.multipart.get("foobaz", (error: any, foobaz: any, headers: any) => {}); /* From a9babc189ea272261a96f9b4d1aacc64c972f241 Mon Sep 17 00:00:00 2001 From: Derek Brown Date: Fri, 1 Sep 2017 13:48:21 -0400 Subject: [PATCH 065/112] Add DiskQuota option to HostConfig Added in latest version of API: https://docs.docker.com/engine/api/v1.30/#operation/ContainerCreate --- types/dockerode/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts index aa6c03bf29..199fe1de75 100644 --- a/types/dockerode/index.d.ts +++ b/types/dockerode/index.d.ts @@ -488,6 +488,7 @@ declare namespace Dockerode { CpusetCpus: string; CpusetMems: string; Devices?: any; + DiskQuota: number; KernelMemory: number; Memory: number; MemoryReservation: number; From 4f7a218f250c94028d532b3bcda3ddafc8b3f5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Tabille=20Manjabosco?= Date: Thu, 24 Aug 2017 22:21:18 -0300 Subject: [PATCH 066/112] react-virtualized: Update types for WindowScroller --- .../dist/es/WindowScroller.d.ts | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/types/react-virtualized/dist/es/WindowScroller.d.ts b/types/react-virtualized/dist/es/WindowScroller.d.ts index 5ee54eb178..d19e83c06d 100644 --- a/types/react-virtualized/dist/es/WindowScroller.d.ts +++ b/types/react-virtualized/dist/es/WindowScroller.d.ts @@ -2,23 +2,27 @@ import { Validator, Requireable, PureComponent } from 'react' export type WindowScrollerChildProps = { height: number, + width: number, isScrolling: boolean, - scrollTop: number + scrollTop: number, + onChildScroll: () => void }; export type WindowScrollerProps = { /** * Function responsible for rendering children. * This function should implement the following signature: - * ({ height, isScrolling, scrollTop }) => PropTypes.element + * ({ height: number, width: number, isScrolling: boolean, scrollTop: number, onChildScroll: function }) => PropTypes.element */ children?: (props: WindowScrollerChildProps) => React.ReactNode; /** Callback to be invoked on-resize: ({ height }) */ - onResize?: (prams: { height: number }) => void; + onResize?: (params: { height: number, width: number }) => void; /** Callback to be invoked on-scroll: ({ scrollTop }) */ onScroll?: (params: { scrollTop: number }) => void; /** Element to attach scroll event listeners. Defaults to window. */ scrollElement?: HTMLElement; + /** Wait this amount of time after the last scroll event before resetting WindowScroller pointer-events; defaults to 150ms */ + scrollingResetTimeInterval?: number; /** * PLEASE NOTE * The [key: string]: any; line is here on purpose @@ -28,23 +32,28 @@ export type WindowScrollerProps = { */ [key: string]: any; } + export type WindowScrollerState = { height: number, + width: number, isScrolling: boolean, + scrollLeft: number scrollTop: number } export class WindowScroller extends PureComponent { static propTypes: { - children: Validator<(props: WindowScrollerChildProps) => React.ReactNode>, - onResize: Validator<(params: { height: number }) => void>, + children: Requireable<(props: WindowScrollerChildProps) => React.ReactNode>, + onResize: Validator<(params: { height: number, width: number }) => void>, onScroll: Validator<(params: { scrollTop: number }) => void>, - scrollElement: HTMLElement + scrollElement: Validator, + scrollingResetTimeInterval: Validator }; static defaultProps: { onResize: () => {}, - onScroll: () => {} + onScroll: () => {}, + scrollingResetTimeInterval: 150 }; constructor(props: WindowScrollerProps); From 5895bc8046b1f26d92f9f7929790e63deefc2a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=81aziuk?= Date: Fri, 1 Sep 2017 23:58:57 +0200 Subject: [PATCH 067/112] [argparse] Namespace add typeings for Namespace --- types/argparse/index.d.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/types/argparse/index.d.ts b/types/argparse/index.d.ts index 2661b01c12..2701f96ac3 100644 --- a/types/argparse/index.d.ts +++ b/types/argparse/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for argparse v1.0.3 +// Type definitions for argparse v1.0 // Project: https://github.com/nodeca/argparse // Definitions by: Andrew Schurman +// Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -19,7 +20,15 @@ export declare class ArgumentParser extends ArgumentGroup { error(err: string | Error): void; } -interface Namespace { } +declare class Namespace { + constructor(options: object); + get(key: K, defaultValue?: D): this[K] | D; + isset(key: K): boolean; + set(key: K, value: V): this; + set(key: K, value: V): this & Record; + set(obj: K): this & K; + unset(key: K, defaultValue?: D): this[K] | D; +} declare class SubParser { addParser(name: string, options?: SubArgumentParserOptions): ArgumentParser; From 6dfaa31b61496a51e62d9f78d8c1a4197cbc15bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=81aziuk?= Date: Sat, 2 Sep 2017 00:06:40 +0200 Subject: [PATCH 068/112] lint --- types/argparse/tslint.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 types/argparse/tslint.json diff --git a/types/argparse/tslint.json b/types/argparse/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/argparse/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From c7607729061e8056b4dac5902b8f9986ae705bda Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 2 Sep 2017 01:02:32 -0400 Subject: [PATCH 069/112] [rnmk] Add Indeterminate component to MKProgress --- types/react-native-material-kit/index.d.ts | 9 +++++++++ .../react-native-material-kit-tests.tsx | 1 + 2 files changed, 10 insertions(+) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index 5556bd4282..d9564be179 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -305,6 +305,11 @@ export interface MKProgressProperties extends ViewProperties { bufferAniDuration?: number; } +export interface IndeterminateProgressProperties extends ViewProperties { + progressColor?: string; + progressAniDuration?: number; +} + export interface BaseSlider extends ViewProperties { min?: number; max?: number; @@ -382,6 +387,10 @@ export class MKRipple extends React.Component {} export class MKProgress extends React.Component {} +export namespace MKProgress { + class Indeterminate extends React.Component {} +} + export class MKSlider extends React.Component {} export class MKRangeSlider extends diff --git a/types/react-native-material-kit/react-native-material-kit-tests.tsx b/types/react-native-material-kit/react-native-material-kit-tests.tsx index 3a3efa11c0..4cb415d791 100644 --- a/types/react-native-material-kit/react-native-material-kit-tests.tsx +++ b/types/react-native-material-kit/react-native-material-kit-tests.tsx @@ -78,6 +78,7 @@ const MKIconToggleTest = () => //// PROGRESS const MKProgressTest = () => ; +const MKIndeterminateProgressTest = () => ; //// SLIDER interface MKSliderTestState { From 280f1873f1d71927abc7448f88e2f9d85590b101 Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Sat, 2 Sep 2017 10:11:14 +0300 Subject: [PATCH 070/112] update subscribe signature --- types/graphql/subscription/subscribe.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/graphql/subscription/subscribe.d.ts b/types/graphql/subscription/subscribe.d.ts index b7b40076bf..30efc010ec 100644 --- a/types/graphql/subscription/subscribe.d.ts +++ b/types/graphql/subscription/subscribe.d.ts @@ -14,7 +14,7 @@ export function subscribe( operationName?: string, fieldResolver?: GraphQLFieldResolver, subscribeFieldResolver?: GraphQLFieldResolver -): AsyncIterator; +): Promise | ExecutionResult>; export function createSourceEventStream( schema: GraphQLSchema, @@ -26,4 +26,4 @@ export function createSourceEventStream( }, operationName?: string, fieldResolver?: GraphQLFieldResolver -): AsyncIterable; +): Promise>; From 20634d7ac57c2bc3adfdf8336f4229c92aed9daf Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Sat, 2 Sep 2017 10:15:53 +0300 Subject: [PATCH 071/112] update contributers --- types/graphql/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index e85060bab5..905dcbdd7b 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -7,6 +7,7 @@ // Kepennar // Mikhail Novikov // Ivan Goncharov +// Hagai Cohen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 49fe06fc5e2b2dc4c3b7317c62097b5c09bedd57 Mon Sep 17 00:00:00 2001 From: James Kelly Date: Sat, 2 Sep 2017 20:02:33 +1000 Subject: [PATCH 072/112] Add Uint8Array to MIDIOutput send The spec for Web MIDI API MIDIOutput.send at: https://webaudio.github.io/web-midi-api/#dom-midioutput-send suggests that both number[] and Uint8Array are acceptable types for sending data on a MIDI output port. The relevant text that allows for Uint8Array states: "... while still enabling use of Uint8Arrays for efficiency in large ..." An obvious use case is to forward MIDI events received on MIDIInputs as these are already in the form of a Uint8Array types. Tested with Chrome 60.0.3112.113 on Mac OS 10.12.6. --- types/webmidi/index.d.ts | 2 +- types/webmidi/webmidi-tests.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/webmidi/index.d.ts b/types/webmidi/index.d.ts index b1f3cb0f61..0d64baaaa7 100644 --- a/types/webmidi/index.d.ts +++ b/types/webmidi/index.d.ts @@ -145,7 +145,7 @@ declare namespace WebMidi { * to zero (or another time in the past), the data is to be sent as soon as * possible. */ - send(data: number[], timestamp?: number): void; + send(data: number[] | Uint8Array, timestamp?: number): void; /** * Clears any pending send data that has not yet been sent from the MIDIOutput 's diff --git a/types/webmidi/webmidi-tests.ts b/types/webmidi/webmidi-tests.ts index da4dca38c2..99335204fa 100644 --- a/types/webmidi/webmidi-tests.ts +++ b/types/webmidi/webmidi-tests.ts @@ -20,6 +20,7 @@ const onFulfilled = (item: WebMidi.MIDIAccess) => { for (const op of outputs) { this._outputs.push(op); op.send([ 0x90, 0x45, 0x7f ]); + op.send(new Uint8Array([ 0x90, 0x45, 0x7f ])); } for (const input of this._inputs) { From d7406dc4d9edc4714ea9866ffa2629fb4028622f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=81aziuk?= Date: Sat, 2 Sep 2017 14:16:52 +0200 Subject: [PATCH 073/112] lint --- types/argparse/argparse-tests.ts | 288 ++++++++++++++----------------- types/argparse/index.d.ts | 34 ++-- 2 files changed, 146 insertions(+), 176 deletions(-) diff --git a/types/argparse/argparse-tests.ts b/types/argparse/argparse-tests.ts index f5b9e76f81..fe5d4fd765 100644 --- a/types/argparse/argparse-tests.ts +++ b/types/argparse/argparse-tests.ts @@ -1,25 +1,24 @@ - // near copy of each of the tests from https://github.com/nodeca/argparse/tree/master/examples import { ArgumentParser, RawDescriptionHelpFormatter } from 'argparse'; -var args: any; +let args: any; -var simpleExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse example', +const simpleExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse example', }); simpleExample.addArgument( - ['-f', '--foo'], - { - help: 'foo bar', - } + ['-f', '--foo'], + { + help: 'foo bar', + } ); simpleExample.addArgument( - ['-b', '--bar'], - { - help: 'bar foo', - } + ['-b', '--bar'], + { + help: 'bar foo', + } ); simpleExample.printHelp(); @@ -35,13 +34,10 @@ args = simpleExample.parseArgs('--foo 5 --bar 6'.split(' ')); console.dir(args); console.log('-----------'); - - - -var choicesExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: choice' +const choicesExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: choice' }); choicesExample.addArgument(['foo'], { choices: 'abc' }); @@ -55,56 +51,53 @@ console.log('-----------'); // choicesExample.parseArgs(['X']); // console.dir(args); - - - -var constantExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: constant' +const constantExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: constant' }); constantExample.addArgument( - ['-a'], - { - action: 'storeConst', - dest: 'answer', - help: 'store constant', - constant: 42 - } + ['-a'], + { + action: 'storeConst', + dest: 'answer', + help: 'store constant', + constant: 42 + } ); constantExample.addArgument( - ['--str'], - { - action: 'appendConst', - dest: 'types', - help: 'append constant "str" to types', - constant: 'str' - } + ['--str'], + { + action: 'appendConst', + dest: 'types', + help: 'append constant "str" to types', + constant: 'str' + } ); constantExample.addArgument( - ['--int'], - { - action: 'appendConst', - dest: 'types', - help: 'append constant "int" to types', - constant: 'int' - } + ['--int'], + { + action: 'appendConst', + dest: 'types', + help: 'append constant "int" to types', + constant: 'int' + } ); constantExample.addArgument( - ['--true'], - { - action: 'storeTrue', - help: 'store true constant' - } + ['--true'], + { + action: 'storeTrue', + help: 'store true constant' + } ); constantExample.addArgument( - ['--false'], - { - action: 'storeFalse', - help: 'store false constant' - } + ['--false'], + { + action: 'storeFalse', + help: 'store false constant' + } ); constantExample.printHelp(); @@ -113,27 +106,24 @@ console.log('-----------'); args = constantExample.parseArgs('-a --str --int --true'.split(' ')); console.dir(args); - - - -var nargsExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: nargs' +const nargsExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: nargs' }); nargsExample.addArgument( - ['-f', '--foo'], - { - help: 'foo bar', - nargs: 1 - } + ['-f', '--foo'], + { + help: 'foo bar', + nargs: 1 + } ); nargsExample.addArgument( - ['-b', '--bar'], - { - help: 'bar foo', - nargs: '*' - } + ['-b', '--bar'], + { + help: 'bar foo', + nargs: '*' + } ); nargsExample.printHelp(); @@ -145,40 +135,34 @@ console.log('-----------'); args = nargsExample.parseArgs('--bar b c f --foo a'.split(' ')); console.dir(args); - - - -var parent_parser = new ArgumentParser({ addHelp: false }); +const parent_parser = new ArgumentParser({ addHelp: false }); // note addHelp:false to prevent duplication of the -h option parent_parser.addArgument( - ['--parent'], - { type: 'int', help: 'parent' } + ['--parent'], + { type: 'int', help: 'parent' } ); -var foo_parser = new ArgumentParser({ - parents: [parent_parser], - description: 'child1' +const foo_parser = new ArgumentParser({ + parents: [parent_parser], + description: 'child1' }); foo_parser.addArgument(['foo']); args = foo_parser.parseArgs(['--parent', '2', 'XXX']); console.log(args); -var bar_parser = new ArgumentParser({ - parents: [parent_parser], - description: 'child2' +const bar_parser = new ArgumentParser({ + parents: [parent_parser], + description: 'child2' }); bar_parser.addArgument(['--bar']); args = bar_parser.parseArgs(['--bar', 'YYY']); console.log(args); - - - -var prefixCharsExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: prefix_chars', - prefixChars: '-+' +const prefixCharsExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: prefix_chars', + prefixChars: '-+' }); prefixCharsExample.addArgument(['+f', '++foo']); prefixCharsExample.addArgument(['++bar'], { action: 'storeTrue' }); @@ -193,39 +177,36 @@ console.dir(args); args = prefixCharsExample.parseArgs(['++foo', '2', '++bar']); console.dir(args); - - - -var subparserExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: sub-commands' +const subparserExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: sub-commands' }); -var subparsers = subparserExample.addSubparsers({ - title: 'subcommands', - dest: "subcommand_name" +const subparsers = subparserExample.addSubparsers({ + title: 'subcommands', + dest: "subcommand_name" }); -var bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' }); +let bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' }); bar.addArgument( - ['-f', '--foo'], - { - action: 'store', - help: 'foo3 bar3' - } + ['-f', '--foo'], + { + action: 'store', + help: 'foo3 bar3' + } ); -var bar = subparsers.addParser( - 'c2', - { aliases: ['co'], addHelp: true, help: 'c2 help' } +bar = subparsers.addParser( + 'c2', + { aliases: ['co'], addHelp: true, help: 'c2 help' } ); bar.addArgument( - ['-b', '--bar'], - { - action: 'store', - type: 'int', - help: 'foo3 bar3' - } + ['-b', '--bar'], + { + action: 'store', + type: 'int', + help: 'foo3 bar3' + } ); subparserExample.printHelp(); console.log('-----------'); @@ -241,66 +222,57 @@ console.dir(args); console.log('-----------'); subparserExample.parseArgs(['c1', '-h']); - - - -var functionExample = new ArgumentParser({ description: 'Process some integers.' }); +const functionExample = new ArgumentParser({ description: 'Process some integers.' }); function sum(arr: number[]) { - return arr.reduce(function(a, b) { - return a + b; - }, 0); + return arr.reduce((a, b) => a + b, 0); } function max(arr: number[]) { - return Math.max.apply(Math, arr); + return Math.max.apply(Math, arr); } - functionExample.addArgument(['integers'], { - metavar: 'N', - type: 'int', - nargs: '+', - help: 'an integer for the accumulator' + metavar: 'N', + type: 'int', + nargs: '+', + help: 'an integer for the accumulator' }); functionExample.addArgument(['--sum'], { - dest: 'accumulate', - action: 'storeConst', - constant: sum, - defaultValue: max, - help: 'sum the integers (default: find the max)' + dest: 'accumulate', + action: 'storeConst', + constant: sum, + defaultValue: max, + help: 'sum the integers (default: find the max)' }); args = functionExample.parseArgs('--sum 1 2 -1'.split(' ')); console.log(args.accumulate(args.integers)); - - - -var formatterExample = new ArgumentParser({ - prog: 'PROG', - formatterClass: RawDescriptionHelpFormatter, - description: 'Keep the formatting\n' + - ' exactly as it is written\n' + - '\n' + - 'here\n' +const formatterExample = new ArgumentParser({ + prog: 'PROG', + formatterClass: RawDescriptionHelpFormatter, + description: 'Keep the formatting\n' + + ' exactly as it is written\n' + + '\n' + + 'here\n' }); formatterExample.addArgument(['--foo'], { - help: ' foo help should not\n' + - ' retain this odd formatting' + help: ' foo help should not\n' + + ' retain this odd formatting' }); formatterExample.addArgument(['spam'], { - 'help': 'spam help' + help: 'spam help', }); -var group = formatterExample.addArgumentGroup({ - title: 'title', - description: ' This text\n' + - ' should be indented\n' + - ' exactly like it is here\n' +const group = formatterExample.addArgumentGroup({ + title: 'title', + description: ' This text\n' + + ' should be indented\n' + + ' exactly like it is here\n' }); group.addArgument(['--bar'], { - help: 'bar help' + help: 'bar help' }); formatterExample.printHelp(); diff --git a/types/argparse/index.d.ts b/types/argparse/index.d.ts index 2701f96ac3..1fca8a676f 100644 --- a/types/argparse/index.d.ts +++ b/types/argparse/index.d.ts @@ -1,26 +1,24 @@ -// Type definitions for argparse v1.0 +// Type definitions for argparse 1.0 // Project: https://github.com/nodeca/argparse // Definitions by: Andrew Schurman // Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export declare class ArgumentParser extends ArgumentGroup { +export class ArgumentParser extends ArgumentGroup { constructor(options?: ArgumentParserOptions); - addSubparsers(options?: SubparserOptions): SubParser; - parseArgs(args?: string[], ns?: Namespace | Object): any; + parseArgs(args?: string[], ns?: Namespace | object): any; printUsage(): void; printHelp(): void; formatUsage(): string; formatHelp(): string; - parseKnownArgs(args?: string[], ns?: Namespace | Object): any[]; + parseKnownArgs(args?: string[], ns?: Namespace | object): any[]; convertArgLineToArg(argLine: string): string[]; exit(status: number, message: string): void; error(err: string | Error): void; } -declare class Namespace { +export class Namespace { constructor(options: object); get(key: K, defaultValue?: D): this[K] | D; isset(key: K): boolean; @@ -30,11 +28,11 @@ declare class Namespace { unset(key: K, defaultValue?: D): this[K] | D; } -declare class SubParser { +export class SubParser { addParser(name: string, options?: SubArgumentParserOptions): ArgumentParser; } -declare class ArgumentGroup { +export class ArgumentGroup { addArgument(args: string[], options?: ArgumentOptions): void; addArgumentGroup(options?: ArgumentGroupOptions): ArgumentGroup; addMutuallyExclusiveGroup(options?: { required: boolean }): ArgumentGroup; @@ -42,7 +40,7 @@ declare class ArgumentGroup { getDefault(dest: string): any; } -interface SubparserOptions { +export interface SubparserOptions { title?: string; description?: string; prog?: string; @@ -53,12 +51,12 @@ interface SubparserOptions { metavar?: string; } -interface SubArgumentParserOptions extends ArgumentParserOptions { +export interface SubArgumentParserOptions extends ArgumentParserOptions { aliases?: string[]; help?: string; } -interface ArgumentParserOptions { +export interface ArgumentParserOptions { description?: string; epilog?: string; addHelp?: boolean; @@ -71,19 +69,19 @@ interface ArgumentParserOptions { version?: string; } -interface ArgumentGroupOptions { +export interface ArgumentGroupOptions { prefixChars?: string; argumentDefault?: any; title?: string; description?: string; } -export declare class HelpFormatter { } -export declare class ArgumentDefaultsHelpFormatter { } -export declare class RawDescriptionHelpFormatter { } -export declare class RawTextHelpFormatter { } +export class HelpFormatter { } +export class ArgumentDefaultsHelpFormatter { } +export class RawDescriptionHelpFormatter { } +export class RawTextHelpFormatter { } -interface ArgumentOptions { +export interface ArgumentOptions { action?: string; optionStrings?: string[]; dest?: string; From 37c7dd3c6d3d93e7963b2a68a91d2c8588cadc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=81aziuk?= Date: Sat, 2 Sep 2017 14:23:22 +0200 Subject: [PATCH 074/112] typescript requirements --- types/argparse/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/argparse/index.d.ts b/types/argparse/index.d.ts index 1fca8a676f..509c569999 100644 --- a/types/argparse/index.d.ts +++ b/types/argparse/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Andrew Schurman // Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 export class ArgumentParser extends ArgumentGroup { constructor(options?: ArgumentParserOptions); From 9f2cfd9d09386fe63a788cdc27e23188ccfab532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=81aziuk?= Date: Sat, 2 Sep 2017 14:25:58 +0200 Subject: [PATCH 075/112] ban-types --- types/argparse/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/argparse/index.d.ts b/types/argparse/index.d.ts index 509c569999..f19aadbe96 100644 --- a/types/argparse/index.d.ts +++ b/types/argparse/index.d.ts @@ -89,7 +89,8 @@ export interface ArgumentOptions { nargs?: string | number; constant?: any; defaultValue?: any; - type?: string | Function; + // type may be a string (primitive) or a Function (constructor) + type?: string | Function; // tslint:disable-line:ban-types choices?: string | string[]; required?: boolean; help?: string; From ac013ff25480151fb80b9d345829211ec736dc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=81aziuk?= Date: Sat, 2 Sep 2017 14:37:39 +0200 Subject: [PATCH 076/112] formatting --- types/argparse/argparse-tests.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/types/argparse/argparse-tests.ts b/types/argparse/argparse-tests.ts index fe5d4fd765..aef18b665b 100644 --- a/types/argparse/argparse-tests.ts +++ b/types/argparse/argparse-tests.ts @@ -250,15 +250,11 @@ console.log(args.accumulate(args.integers)); const formatterExample = new ArgumentParser({ prog: 'PROG', formatterClass: RawDescriptionHelpFormatter, - description: 'Keep the formatting\n' + - ' exactly as it is written\n' + - '\n' + - 'here\n' + description: `Keep the formatting\nexactly as it is written\n\nhere\n`, }); formatterExample.addArgument(['--foo'], { - help: ' foo help should not\n' + - ' retain this odd formatting' + help: `foo help should not\nretain this odd formatting`, }); formatterExample.addArgument(['spam'], { @@ -267,9 +263,7 @@ formatterExample.addArgument(['spam'], { const group = formatterExample.addArgumentGroup({ title: 'title', - description: ' This text\n' + - ' should be indented\n' + - ' exactly like it is here\n' + description: `This text\nshould be indented\nexactly like it is here\n`, }); group.addArgument(['--bar'], { From 8563b0ce6a8b9d842c71feecb1eca05cb350719e Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Sat, 2 Sep 2017 09:42:57 -0700 Subject: [PATCH 077/112] [react-native-video] Add onProgress data --- types/react-native-video/index.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/types/react-native-video/index.d.ts b/types/react-native-video/index.d.ts index 8b31bfed0d..b264df6d64 100644 --- a/types/react-native-video/index.d.ts +++ b/types/react-native-video/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-native-video 1.0 +// Type definitions for react-native-video 2.0 // Project: https://github.com/react-native-community/react-native-video // Definitions by: HuHuanming +// abrahambotros // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -48,7 +49,10 @@ export interface VideoProperties extends ViewProperties { onLoad?(): void; onBuffer?(): void; onError?(): void; - onProgress?(): void; + onProgress?(data: { + currentTime: number, + playableDuration: number, + }): void; onSeek?(): void; onEnd?(): void; onFullscreenPlayerWillPresent?(): void; From 0fa3e15d6092dd6794085170bb41c0ff64e4decc Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Sat, 2 Sep 2017 09:49:12 -0700 Subject: [PATCH 078/112] [react-native-video] Add onProgress data test --- .../react-native-video-tests.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/types/react-native-video/react-native-video-tests.tsx b/types/react-native-video/react-native-video-tests.tsx index e0ec0bad73..b2ea41ce92 100644 --- a/types/react-native-video/react-native-video-tests.tsx +++ b/types/react-native-video/react-native-video-tests.tsx @@ -7,16 +7,27 @@ import { } from 'react-native'; import Video from 'react-native-video'; -class SwiperTest extends React.Component { +class VideoTest extends React.Component { constructor(props: {}) { super(props); } render(): React.ReactElement { return ( -