[Bluebird] cleanup lint errors (#20449)

* Cleanup Lint Error: ban-types

* Cleanup lint error: unified-signatures(exclude Promise.props())

* Cleanup lint error: array-type

* Setting max-line-length not to exceed current length

* Cleanup lint error: one-line

* Cleanup lint error: lintstrict-export-declare-modifiers

* [request] toJSON() return Object => object
This commit is contained in:
segayuu
2017-10-13 05:41:30 +09:00
committed by Wesley Wigham
parent 1587ff2a5c
commit 90649b73fe
6 changed files with 114 additions and 163 deletions

View File

@@ -7,7 +7,7 @@
import Promise = require("bluebird");
let obj: Object;
let obj: object;
let bool: boolean;
let num: number;
let str: string;
@@ -75,7 +75,7 @@ let numProm: Promise<number>;
let strProm: Promise<string>;
let anyProm: Promise<any>;
let boolProm: Promise<boolean>;
let objProm: Promise<Object>;
let objProm: Promise<object>;
let voidProm: Promise<void>;
let fooProm: Promise<Foo>;
@@ -90,7 +90,7 @@ let numThen: PromiseLike<number>;
let strThen: PromiseLike<string>;
let anyThen: PromiseLike<any>;
let boolThen: PromiseLike<boolean>;
let objThen: PromiseLike<Object>;
let objThen: PromiseLike<object>;
let voidThen: PromiseLike<void>;
let fooThen: PromiseLike<Foo>;
@@ -116,27 +116,27 @@ let barArrThen: PromiseLike<Bar[]>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
let numPromArr: Promise<number>[];
let strPromArr: Promise<string>[];
let anyPromArr: Promise<any>[];
let numPromArr: Array<Promise<number>>;
let strPromArr: Array<Promise<string>>;
let anyPromArr: Array<Promise<any>>;
let fooPromArr: Promise<Foo>[];
let barPromArr: Promise<Bar>[];
let fooPromArr: Array<Promise<Foo>>;
let barPromArr: Array<Promise<Bar>>;
// - - - - - - - - - - - - - - - - -
let numThenArr: PromiseLike<number>[];
let strThenArr: PromiseLike<string>[];
let anyThenArr: PromiseLike<any>[];
let numThenArr: Array<PromiseLike<number>>;
let strThenArr: Array<PromiseLike<string>>;
let anyThenArr: Array<PromiseLike<any>>;
let fooThenArr: PromiseLike<Foo>[];
let barThenArr: PromiseLike<Bar>[];
let fooThenArr: Array<PromiseLike<Foo>>;
let barThenArr: Array<PromiseLike<Bar>>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// booya!
let fooThenArrThen: PromiseLike<PromiseLike<Foo>[]>;
let barThenArrThen: PromiseLike<PromiseLike<Bar>[]>;
let fooThenArrThen: PromiseLike<Array<PromiseLike<Foo>>>;
let barThenArrThen: PromiseLike<Array<PromiseLike<Bar>>>;
let fooResolver: Promise.Resolver<Foo>;
let barResolver: Promise.Resolver<Bar>;
@@ -144,8 +144,8 @@ let barResolver: Promise.Resolver<Bar>;
let fooInspection: Promise.Inspection<Foo>;
let fooInspectionPromise: Promise<Promise.Inspection<Foo>>;
let fooInspectionArrProm: Promise<Promise.Inspection<Foo>[]>;
let barInspectionArrProm: Promise<Promise.Inspection<Bar>[]>;
let fooInspectionArrProm: Promise<Array<Promise.Inspection<Foo>>>;
let barInspectionArrProm: Promise<Array<Promise.Inspection<Bar>>>;
let BlueBird: typeof Promise;
@@ -168,8 +168,7 @@ barThen = barProm;
fooProm = new Promise((resolve: (value: Foo) => void, reject: (reason: any) => void) => {
if (bool) {
resolve(foo);
}
else {
} else {
reject(new Error(str));
}
});
@@ -185,8 +184,7 @@ fooProm = new Promise((resolve: (value: Foo) => void) => {
fooProm = new Promise<Foo>((resolve, reject) => {
if (bool) {
resolve(fooThen);
}
else {
} else {
reject(new Error(str));
}
});
@@ -375,7 +373,7 @@ fooProm = fooProm.catch(CustomError, reason => {
const booPredicate1 = (error: CustomError1) => true;
const booPredicate2 = (error: [number]) => true;
const booPredicate3 = (error: string) => true;
const booPredicate4 = (error: Object) => true;
const booPredicate4 = (error: object) => true;
const booPredicate5 = (error: any) => true;
fooProm = fooProm.catch(booPredicate1, error => {});
@@ -806,13 +804,13 @@ anyProm = Promise.fromCallback(callback => nodeCallbackFuncErrorOnly(callback),
declare let util: any;
function defaultFilter(name: string, func: Function) {
function defaultFilter(name: string, func: (...args: any[]) => any) {
return util.isIdentifier(name) &&
name.charAt(0) !== "_" &&
!util.isClass(func);
}
function DOMPromisifier(originalMethod: Function) {
function DOMPromisifier(originalMethod: (...args: any[]) => any) {
// return a function
return function promisified() {
let args = [].slice.call(arguments);

View File

@@ -340,8 +340,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* Like `.finally()`, but not called for rejections.
*/
tap<U>(onFulFill: (value: R) => PromiseLike<U>): Bluebird<R>;
tap<U>(onFulfill: (value: R) => U): Bluebird<R>;
tap<U>(onFulFill: (value: R) => PromiseLike<U> | U): Bluebird<R>;
/**
* Like `.catch()` but rethrows the error
@@ -350,33 +349,33 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
tapCatch<U>(onReject: (error?: any) => U | PromiseLike<U>): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | object,
onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
onReject: (error: E1 | E2 | E3) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
onReject: (error: E1 | E2) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
onReject: (error: E1) => U | PromiseLike<U>,
): Bluebird<R>;
@@ -521,33 +520,33 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
catchReturn<U>(value: U): Bluebird<U>;
catchReturn<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
value: U,
): Bluebird<U>;
@@ -565,33 +564,33 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
catchThrow(reason: Error): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | object,
reason: Error,
): Bluebird<R>;
@@ -603,7 +602,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
*/
toJSON(): Object;
toJSON(): object;
/**
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
@@ -695,11 +694,11 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
*/
static method<R, A1>(fn: (arg1: A1) => R | PromiseLike<R>): (arg1: A1) => Bluebird<R>
static method<R, A1, A2>(fn: (arg1: A1, arg2: A2) => R | PromiseLike<R>): (arg1: A1, arg2: A2) => Bluebird<R>
static method<R, A1, A2, A3>(fn: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike<R>): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<R>
static method<R, A1, A2, A3, A4>(fn: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike<R>): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<R>
static method<R, A1, A2, A3, A4, A5>(fn: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike<R>): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<R>
static method<R, A1>(fn: (arg1: A1) => R | PromiseLike<R>): (arg1: A1) => Bluebird<R>;
static method<R, A1, A2>(fn: (arg1: A1, arg2: A2) => R | PromiseLike<R>): (arg1: A1, arg2: A2) => Bluebird<R>;
static method<R, A1, A2, A3>(fn: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike<R>): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<R>;
static method<R, A1, A2, A3, A4>(fn: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike<R>): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<R>;
static method<R, A1, A2, A3, A4, A5>(fn: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike<R>): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<R>;
static method<R>(fn: (...args: any[]) => R | PromiseLike<R>): (...args: any[]) => Bluebird<R>;
/**
@@ -768,7 +767,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
*/
// TODO how to model promisifyAll?
static promisifyAll(target: Object, options?: Bluebird.PromisifyAllOptions): Object;
static promisifyAll(target: object, options?: Bluebird.PromisifyAllOptions): object;
/**
* Returns a promise that is resolved by a node style callback function.
@@ -810,7 +809,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static all<T1, T2>(values: [PromiseLike<T1> | T1, PromiseLike<T2> | T2]): Bluebird<[T1, T2]>;
static all<T1>(values: [PromiseLike<T1> | T1]): Bluebird<[T1]>;
// array with values
static all<R>(values: PromiseLike<(PromiseLike<R> | R)[]> | (PromiseLike<R> | R)[]): Bluebird<R[]>;
static all<R>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>): Bluebird<R[]>;
/**
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
@@ -819,25 +818,26 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* *The original object is not modified.*
*/
// trusted promise for object
// trusted promise for map
static props<K, V>(map: PromiseLike<Map<K, PromiseLike<V> | V>>): Bluebird<Map<K, V>>;
static props<T>(object: PromiseLike<Bluebird.ResolvableProps<T>>): Bluebird<T>;
// trusted promise for object
static props<T>(object: PromiseLike<Bluebird.ResolvableProps<T>>): Bluebird<T>; // tslint:disable-line:unified-signatures
// map
static props<K, V>(map: Map<K, PromiseLike<V> | V>): Bluebird<Map<K, V>>;
static props<K, V>(map: Map<K, PromiseLike<V> | V>): Bluebird<Map<K, V>>; // tslint:disable-line:unified-signatures
// object
static props<T>(object: Bluebird.ResolvableProps<T>): Bluebird<T>;
static props<T>(object: Bluebird.ResolvableProps<T>): Bluebird<T>; // tslint:disable-line:unified-signatures
/**
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
*/
static any<R>(values: PromiseLike<(PromiseLike<R> | R)[]> | (PromiseLike<R> | R)[]): Bluebird<R>;
static any<R>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>): Bluebird<R>;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
*
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
*/
static race<R>(values: PromiseLike<(PromiseLike<R> | R)[]> | (PromiseLike<R> | R)[]): Bluebird<R>;
static race<R>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>): Bluebird<R>;
/**
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
@@ -846,14 +846,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* *The original array is not modified.*
*/
// promise of array with promises of value
static some<R>(values: PromiseLike<PromiseLike<R>[]>, count: number): Bluebird<R[]>;
// promise of array with values
static some<R>(values: PromiseLike<R[]>, count: number): Bluebird<R[]>;
// array with promises of value
static some<R>(values: PromiseLike<R>[], count: number): Bluebird<R[]>;
// array with values
static some<R>(values: R[], count: number): Bluebird<R[]>;
static some<R>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>, count: number): Bluebird<R[]>;
/**
* Promise.join(
@@ -872,7 +865,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
// variadic array
/** @deprecated use .all instead */
static join<R>(...values: (R | PromiseLike<R>)[]): Bluebird<R[]>;
static join<R>(...values: Array<R | PromiseLike<R>>): Bluebird<R[]>;
/**
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
@@ -881,17 +874,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* *The original array is not modified.*
*/
// promise of array with promises of value
static map<R, U>(values: PromiseLike<PromiseLike<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
// promise of array with values
static map<R, U>(values: PromiseLike<R[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
// array with promises of value
static map<R, U>(values: PromiseLike<R>[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
// array with values
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
static map<R, U>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
/**
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
@@ -900,17 +883,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
*/
// promise of array with promises of value
static reduce<R, U>(values: PromiseLike<PromiseLike<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
// promise of array with values
static reduce<R, U>(values: PromiseLike<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
// array with promises of value
static reduce<R, U>(values: PromiseLike<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
// array with values
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
static reduce<R, U>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
/**
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
@@ -919,29 +892,14 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* *The original array is not modified.
*/
// promise of array with promises of value
static filter<R>(values: PromiseLike<PromiseLike<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
// promise of array with values
static filter<R>(values: PromiseLike<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
// array with promises of value
static filter<R>(values: PromiseLike<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
// array with values
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
static filter<R>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
/**
* Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
*
* Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
*/
// promise of array with promises of value
static each<R, U>(values: PromiseLike<PromiseLike<R>[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
// array with promises of value
static each<R, U>(values: PromiseLike<R>[], iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
// array with values OR promise of array with values
static each<R, U>(values: R[] | PromiseLike<R[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
static each<R, U>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
/**
* Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order.
@@ -950,7 +908,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well.
*/
static mapSeries<R, U>(values: (R | PromiseLike<R>)[] | PromiseLike<(R | PromiseLike<R>)[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<U[]>;
static mapSeries<R, U>(values: PromiseLike<Array<PromiseLike<R> | R>> | Array<PromiseLike<R> | R>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<U[]>;
/**
* A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`.
@@ -1015,26 +973,26 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
}
declare namespace Bluebird {
export interface ConcurrencyOption {
interface ConcurrencyOption {
concurrency: number;
}
export interface SpreadOption {
interface SpreadOption {
spread: boolean;
}
export interface FromNodeOptions {
interface FromNodeOptions {
multiArgs?: boolean;
}
export interface PromisifyOptions {
interface PromisifyOptions {
context?: any;
multiArgs?: boolean;
}
export interface PromisifyAllOptions extends PromisifyOptions {
interface PromisifyAllOptions extends PromisifyOptions {
suffix?: string;
filter?(name: string, func: (...args: any[]) => any, target?: any, passesDefaultFilter?: boolean): boolean;
// The promisifier gets a reference to the original method and should return a function which returns a promise
promisifier?(originalMethod: (...args: any[]) => any, defaultPromisifer: (...args: any[]) => (...args: any[]) => Bluebird<any>): () => PromiseLike<any>;
}
export interface CoroutineOptions {
interface CoroutineOptions {
yieldHandler(value: any): any;
}
@@ -1046,17 +1004,17 @@ declare namespace Bluebird {
*
* `OperationalError`s are caught in `.error` handlers.
*/
export class OperationalError extends Error { }
class OperationalError extends Error { }
/**
* Signals that an operation has timed out. Used as a custom cancellation reason in `.timeout`.
*/
export class TimeoutError extends Error { }
class TimeoutError extends Error { }
/**
* Signals that an operation has been aborted or cancelled. The default reason used by `.cancel`.
*/
export class CancellationError extends Error {}
class CancellationError extends Error {}
/**
* A collection of errors. `AggregateError` is an array-like object, with numeric indices and a `.length` property.
@@ -1066,7 +1024,7 @@ declare namespace Bluebird {
*
* `Promise.some` and `Promise.any` use `AggregateError` as rejection reason when they fail.
*/
export class AggregateError extends Error implements ArrayLike<Error> {
class AggregateError extends Error implements ArrayLike<Error> {
length: number;
[index: number]: Error;
join(separator?: string): string;
@@ -1091,15 +1049,14 @@ declare namespace Bluebird {
/**
* returned by `Bluebird.disposer()`.
*/
export class Disposer<R> {
}
class Disposer<R> {}
/** @deprecated Use PromiseLike<T> directly. */
export type Thenable<T> = PromiseLike<T>;
type Thenable<T> = PromiseLike<T>;
export type ResolvableProps<T> = object & { [K in keyof T]: PromiseLike<T[K]> | T[K] };
type ResolvableProps<T> = object & { [K in keyof T]: PromiseLike<T[K]> | T[K] };
export interface Resolver<R> {
interface Resolver<R> {
/**
* Returns a reference to the controlled promise that can be passed to clients.
*/
@@ -1125,7 +1082,7 @@ declare namespace Bluebird {
callback(err: any, value: R, ...values: R[]): void;
}
export interface Inspection<R> {
interface Inspection<R> {
/**
* See if the underlying promise was fulfilled at the creation time of this inspection object.
*/
@@ -1166,14 +1123,14 @@ declare namespace Bluebird {
*
* This method should be used before you use any of the methods which would otherwise alter the global Bluebird object - to avoid polluting global state.
*/
export function getNewLibraryCopy(): typeof Bluebird;
function getNewLibraryCopy(): typeof Bluebird;
/**
* This is relevant to browser environments with no module loader.
*
* Release control of the Promise namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
*/
export function noConflict(): typeof Bluebird;
function noConflict(): typeof Bluebird;
/**
* Changes how bluebird schedules calls a-synchronously.
@@ -1181,7 +1138,7 @@ declare namespace Bluebird {
* @param scheduler Should be a function that asynchronously schedules
* the calling of the passed in function
*/
export function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
}
export = Bluebird;

View File

@@ -2,16 +2,11 @@
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"ban-types": false,
"max-line-length": false,
"max-line-length": [true, 490],
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-generics": false,
"no-void-expression": false,
"one-line": false,
"prefer-const": false,
"strict-export-declare-modifiers": false,
"unified-signatures": false,
"void-return": false
}
}

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/request/request
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <https://github.com/joeskeen>, Christopher Currens <https://github.com/ccurrens>, Jon Stevens <https://github.com/lookfirst>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Typescript version: 2.3
// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts
@@ -235,7 +236,7 @@ declare namespace request {
pipeDest(dest: any): void;
setHeader(name: string, value: string, clobber?: boolean): Request;
setHeaders(headers: Headers): Request;
qs(q: Object, clobber?: boolean): Request;
qs(q: object, clobber?: boolean): Request;
form(): FormData;
form(form: any): Request;
multipart(multipart: RequestPart[]): Request;
@@ -264,7 +265,7 @@ declare namespace request {
resume(): void;
abort(): void;
destroy(): void;
toJSON(): Object;
toJSON(): object;
}
export interface Headers {

View File

@@ -14,7 +14,7 @@ var buffer: NodeBuffer = new Buffer('foo');
var num: number = 0;
var bool: boolean;
var date: Date;
var obj: Object;
var obj: object;
var dest: string = 'foo';
var uri: string = 'foo-bar';

View File

@@ -20,4 +20,4 @@
"index.d.ts",
"request-tests.ts"
]
}
}