From ed76f54ebda70c0ebe7d0eeba4f479b596154732 Mon Sep 17 00:00:00 2001 From: Ian Phillips Date: Tue, 20 Jun 2017 09:58:18 -0700 Subject: [PATCH 01/53] Add Backbone.Collection.clone() http://backbonejs.org/#Collection-clone --- types/backbone/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/backbone/index.d.ts b/types/backbone/index.d.ts index f151b2f42e..e2abd94568 100644 --- a/types/backbone/index.d.ts +++ b/types/backbone/index.d.ts @@ -229,6 +229,7 @@ declare namespace Backbone { **/ get(id: number|string|Model): TModel; has(key: number|string|Model): boolean; + clone(): Collection; create(attributes: any, options?: ModelSaveOptions): TModel; pluck(attribute: string): any[]; push(model: TModel, options?: AddOptions): TModel; From c31e5f331684e95f53b29f4586378cb4e5680256 Mon Sep 17 00:00:00 2001 From: Gregor Yushinov Date: Fri, 13 Oct 2017 03:13:21 +0200 Subject: [PATCH 02/53] Added eachAsync options for concurrency --- types/mongoose/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index cd7bb438d4..602b700958 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -469,6 +469,11 @@ declare module "mongoose" { static Messages: Object; } + interface EachAsyncOptions { + /** defaults to 1 */ + parallel?: number; + } + /* * section querycursor.js * http://mongoosejs.com/docs/api.html#querycursor-js @@ -502,7 +507,7 @@ declare module "mongoose" { * Returns a promise that resolves when done. * @param callback executed when all docs have been processed */ - eachAsync(fn: (doc: T) => any, callback?: (err: any) => void): Promise; + eachAsync(fn: (doc: T) => any, options: EachAsyncOptions, callback?: (err: any) => void): Promise; /** * Registers a transform function which subsequently maps documents retrieved From e08d727565ea52385bb3d860e69b3ac2dc7e1728 Mon Sep 17 00:00:00 2001 From: Gregor Yushinov Date: Thu, 19 Oct 2017 15:33:20 +0200 Subject: [PATCH 03/53] Added overload function definition for eachAsync --- types/mongoose/index.d.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 602b700958..3e1002fd3c 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -505,7 +505,18 @@ declare module "mongoose" { * Execute fn for every document in the cursor. If fn returns a promise, * will wait for the promise to resolve before iterating on to the next one. * Returns a promise that resolves when done. - * @param callback executed when all docs have been processed + * @param fn Function to be executed for every document in the cursor + * @param callback Executed when all docs have been processed + */ + eachAsync(fn: (doc: T) => any, callback?: (err: any) => void): Promise; + + /** + * Execute fn for every document in the cursor. If fn returns a promise, + * will wait for the promise to resolve before iterating on to the next one. + * Returns a promise that resolves when done. + * @param fn Function to be executed for every document in the cursor + * @param options Async options (e. g. parallel function execution) + * @param callback Executed when all docs have been processed */ eachAsync(fn: (doc: T) => any, options: EachAsyncOptions, callback?: (err: any) => void): Promise; From af5a9ebed43a1ac19ab8595a3cc3c1da4ef77ca7 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Sat, 21 Oct 2017 09:09:35 -0400 Subject: [PATCH 04/53] #20741: added a missing use case for differenceBy --- types/lodash/index.d.ts | 312 +++++++++++++++++------------------ types/lodash/lodash-tests.ts | 119 +++++++++++++ 2 files changed, 275 insertions(+), 156 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index ac954c6107..0969775149 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -581,64 +581,64 @@ declare namespace _ { * @param iteratee The iteratee invoked per element. * @returns Returns the new array of filtered values. */ - differenceBy( - array: List | null | undefined, - values?: List, - iteratee?: ValueIteratee - ): T[]; + differenceBy( + array: List | null | undefined, + values?: List, + iteratee?: ValueIteratee + ): T1[]; + + /** + * @see _.differenceBy + */ + differenceBy( + array: List | null | undefined, + values1: List, + values2: List, + iteratee?: ValueIteratee + ): T1[]; + + /** + * @see _.differenceBy + */ + differenceBy( + array: List | null | undefined, + values1: List, + values2: List, + values3: List, + iteratee?: ValueIteratee + ): T1[]; + + /** + * @see _.differenceBy + */ + differenceBy( + array: List | null | undefined, + values1: List, + values2: List, + values3: List, + values4: List, + iteratee?: ValueIteratee + ): T1[]; + + /** + * @see _.differenceBy + */ + differenceBy( + array: List | null | undefined, + values1: List, + values2: List, + values3: List, + values4: List, + values5: List, + iteratee?: ValueIteratee + ): T1[]; /** * @see _.differenceBy */ differenceBy( array: List | null | undefined, - values1: List, - values2: List, - iteratee?: ValueIteratee - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: List | null | undefined, - values1: List, - values2: List, - values3: List, - iteratee?: ValueIteratee - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: List | null | undefined, - values1: List, - values2: List, - values3: List, - values4: List, - iteratee?: ValueIteratee - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: List | null | undefined, - values1: List, - values2: List, - values3: List, - values4: List, - values5: List, - iteratee?: ValueIteratee - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: List | null | undefined, - ...values: Array | ValueIteratee> + ...values: any[] ): T[]; } @@ -646,64 +646,64 @@ declare namespace _ { /** * @see _.differenceBy */ - differenceBy( - this: LoDashImplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee - ): LoDashImplicitWrapper; + differenceBy( + this: LoDashImplicitWrapper | null | undefined>, + values?: List, + iteratee?: ValueIteratee + ): LoDashImplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + iteratee?: ValueIteratee + ): LoDashImplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + iteratee?: ValueIteratee + ): LoDashImplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + values4: List, + iteratee?: ValueIteratee + ): LoDashImplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + values4: List, + values5: List, + iteratee?: ValueIteratee + ): LoDashImplicitWrapper; /** * @see _.differenceBy */ differenceBy( this: LoDashImplicitWrapper | null | undefined>, - values1: List, - values2: List, - iteratee?: ValueIteratee - ): LoDashImplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashImplicitWrapper | null | undefined>, - values1: List, - values2: List, - values3: List, - iteratee?: ValueIteratee - ): LoDashImplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashImplicitWrapper | null | undefined>, - values1: List, - values2: List, - values3: List, - values4: List, - iteratee?: ValueIteratee - ): LoDashImplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashImplicitWrapper | null | undefined>, - values1: List, - values2: List, - values3: List, - values4: List, - values5: List, - iteratee?: ValueIteratee - ): LoDashImplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashImplicitWrapper | null | undefined>, - ...values: Array | ValueIteratee> + ...values: any[] ): LoDashImplicitWrapper; } @@ -711,64 +711,64 @@ declare namespace _ { /** * @see _.differenceBy */ - differenceBy( - this: LoDashExplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee - ): LoDashExplicitWrapper; + differenceBy( + this: LoDashExplicitWrapper | null | undefined>, + values?: List, + iteratee?: ValueIteratee + ): LoDashExplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + iteratee?: ValueIteratee + ): LoDashExplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + iteratee?: ValueIteratee + ): LoDashExplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + values4: List, + iteratee?: ValueIteratee + ): LoDashExplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + values4: List, + values5: List, + iteratee?: ValueIteratee + ): LoDashExplicitWrapper; /** * @see _.differenceBy */ differenceBy( this: LoDashExplicitWrapper | null | undefined>, - values1: List, - values2: List, - iteratee?: ValueIteratee - ): LoDashExplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashExplicitWrapper | null | undefined>, - values1: List, - values2: List, - values3: List, - iteratee?: ValueIteratee - ): LoDashExplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashExplicitWrapper | null | undefined>, - values1: List, - values2: List, - values3: List, - values4: List, - iteratee?: ValueIteratee - ): LoDashExplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashExplicitWrapper | null | undefined>, - values1: List, - values2: List, - values3: List, - values4: List, - values5: List, - iteratee?: ValueIteratee - ): LoDashExplicitWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - this: LoDashExplicitWrapper | null | undefined>, - ...values: Array | ValueIteratee> + ...values: any[] ): LoDashExplicitWrapper; } diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 19399ff23b..3fa2ae6325 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -298,6 +298,7 @@ namespace TestDifferenceBy { { let result: TResult[]; + result = _.differenceBy(array); result = _.differenceBy(array, arrayParam); result = _.differenceBy(array, listParam, arrayParam); result = _.differenceBy(array, arrayParam, listParam, arrayParam); @@ -326,6 +327,7 @@ namespace TestDifferenceBy { result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); + result = _.differenceBy(list); result = _.differenceBy(list, listParam); result = _.differenceBy(list, arrayParam, listParam); result = _.differenceBy(list, listParam, arrayParam, listParam); @@ -474,6 +476,123 @@ namespace TestDifferenceBy { result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); } + + { + interface T1 { + a: string; + b: string; + } + interface T2 { + a: string; + b: number; + } + interface T3 { + a: string; + b: boolean; + } + interface T4 { + a: string; + b: any[]; + } + + const t1: T1 = { a: 'a', b: 'b' }; + const t2: T2 = { a: 'a', b: 30 }; + const t3: T3 = { a: 'a', b: true }; + const t4: T4 = { a: 'a', b: [] }; + + // $ExpectType T1[] + _.differenceBy([t1], [t2], 'name'); + // $ExpectType T1[] + _.differenceBy([t1], [t2], (value) => { + value; // $ExpectType T1 | T2 + }); + // $ExpectType T1[] + _.differenceBy([t1], [t2, t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType (T1 | T2)[] + _.differenceBy([t1, t2], [t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType T1[] + _.differenceBy([t1], [t2], [t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType T1[] + _.differenceBy([t1], [t2], [t3], [t4], (value) => { + value; // $ExpectType T1 | T2 | T3 | T4 + }); + // $ExpectType T1[] + _.differenceBy([t1], [t2], [t3], [t4], [''], (value) => { + value; // $ExpectType string | T1 | T2 | T3 | T4 + }); + // $ExpectType T1[] + _.differenceBy([t1], [t2], [t3], [t4], [''], [42], (value) => { + value; // $ExpectType string | number | T1 | T2 | T3 | T4 + }); + + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceBy([t2], 'name'); + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceBy([t2], (value) => { + value; // $ExpectType T1 | T2 + }); + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceBy([t2, t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType LoDashImplicitWrapper<(T1 | T2)[]> + _([t1, t2]).differenceBy([t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceBy([t2], [t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceBy([t2], [t3], [t4], (value) => { + value; // $ExpectType T1 | T2 | T3 | T4 + }); + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceBy([t2], [t3], [t4], [''], (value) => { + value; // $ExpectType string | T1 | T2 | T3 | T4 + }); + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceBy([t2], [t3], [t4], [''], [42], (value) => { + value; // $ExpectType string | number | T1 | T2 | T3 | T4 + }); + + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceBy([t2], 'name'); + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceBy([t2], (value) => { + value; // $ExpectType T1 | T2 + }); + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceBy([t2, t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType LoDashExplicitWrapper<(T1 | T2)[]> + _.chain([t1, t2]).differenceBy([t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceBy([t2], [t3], (value) => { + value; // $ExpectType T1 | T2 | T3 + }); + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceBy([t2], [t3], [t4], (value) => { + value; // $ExpectType T1 | T2 | T3 | T4 + }); + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceBy([t2], [t3], [t4], [''], (value) => { + value; // $ExpectType string | T1 | T2 | T3 | T4 + }); + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceBy([t2], [t3], [t4], [''], [42], (value) => { + value; // $ExpectType string | number | T1 | T2 | T3 | T4 + }); + } } // _.drop From 04246ca369a3f27cb3a9d7b7449dddbf9d5b31c3 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Sat, 21 Oct 2017 10:14:28 -0400 Subject: [PATCH 05/53] Added a missing use case for flatMap --- types/lodash/index.d.ts | 18 ++++++++++++++++++ types/lodash/lodash-tests.ts | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 0969775149..6f06f9cd31 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -4780,6 +4780,13 @@ declare namespace _ { collection: List> | Dictionary> | NumericDictionary> | null | undefined ): T[]; + /** + * @see _.flatMap + */ + flatMap( + collection: object | null | undefined + ): any[]; + /** * @see _.flatMap */ @@ -4820,6 +4827,7 @@ declare namespace _ { iteratee: object ): boolean[]; } + type T234 = number[][0]; interface LoDashImplicitWrapper { /** @@ -4827,6 +4835,11 @@ declare namespace _ { */ flatMap(this: LoDashImplicitWrapper> | Dictionary> | NumericDictionary> | null | undefined>): LoDashImplicitWrapper; + /** + * @see _.flatMap + */ + flatMap(): LoDashImplicitWrapper; + /** * @see _.flatMap */ @@ -4872,6 +4885,11 @@ declare namespace _ { */ flatMap(this: LoDashExplicitWrapper> | Dictionary> | NumericDictionary> | null | undefined>): LoDashExplicitWrapper; + /** + * @see _.flatMap + */ + flatMap(): LoDashExplicitWrapper; + /** * @see _.flatMap */ diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 3fa2ae6325..36f5860b0e 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -4462,6 +4462,21 @@ namespace TestFlatMap { result = _(objNumericDictionary).chain().flatMap(['a', 42]); result = _(objNumericDictionary).chain().flatMap({a: 42}); } + + { + interface SampleObject { + bar: number; + foo: string[]; + } + const obj: SampleObject = { + bar: 1, + foo: [''], + }; + + const result1: Array = _.flatMap(obj); + const result2: _.LoDashImplicitWrapper> = _(obj).flatMap(); + const result3: _.LoDashExplicitWrapper> = _.chain(obj).flatMap(); + } } // _.flatMapDeep From 564d9f097fd1b963f4f95c23164d74bb3f2737c9 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Tue, 24 Oct 2017 21:36:21 -0400 Subject: [PATCH 06/53] Fixed more functions with the same issue as #20741. Comparators should accept any truthy/falsy value, not just true/false. Functions affected: differenceWith, intersectionBy, intersectionWith, pullAllBy, pullAllwith --- types/lodash/index.d.ts | 248 ++++++++-------- types/lodash/lodash-tests.ts | 530 +++++++++++++++++++++++++++++++++++ 2 files changed, 655 insertions(+), 123 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 6f06f9cd31..6b980ce9b9 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -792,57 +792,57 @@ declare namespace _ { * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); * // => [{ 'x': 2, 'y': 1 }] */ - differenceWith( - array: List | null | undefined, - values?: List, - comparator?: Comparator - ): T[]; + differenceWith( + array: List | null | undefined, + values?: List, + comparator?: Comparator2 + ): T1[]; /** * @see _.differenceWith */ - differenceWith( - array: List | null | undefined, - ...values: Array | Comparator>, - ): T[]; + differenceWith( + array: List | null | undefined, + ...values: Array | Comparator2>, + ): T1[]; } interface LoDashImplicitWrapper { /** * @see _.differenceWith */ - differenceWith( - this: LoDashImplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator - ): LoDashImplicitWrapper; + differenceWith( + this: LoDashImplicitWrapper | null | undefined>, + values?: List, + comparator?: Comparator2 + ): LoDashImplicitWrapper; /** * @see _.differenceWith */ - differenceWith( - this: LoDashImplicitWrapper | null | undefined>, - ...values: Array | Comparator>, - ): LoDashImplicitWrapper; + differenceWith( + this: LoDashImplicitWrapper | null | undefined>, + ...values: Array | Comparator2>, + ): LoDashImplicitWrapper; } interface LoDashExplicitWrapper { /** * @see _.differenceWith */ - differenceWith( - this: LoDashExplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator - ): LoDashExplicitWrapper; + differenceWith( + this: LoDashExplicitWrapper | null | undefined>, + values?: List, + comparator?: Comparator2 + ): LoDashExplicitWrapper; /** * @see _.differenceWith */ - differenceWith( - this: LoDashExplicitWrapper | null | undefined>, - ...values: Array | Comparator>, - ): LoDashExplicitWrapper; + differenceWith( + this: LoDashExplicitWrapper | null | undefined>, + ...values: Array | Comparator2>, + ): LoDashExplicitWrapper; } //_.drop @@ -1591,57 +1591,57 @@ declare namespace _ { * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }] */ - intersectionBy( - array?: List | null | undefined, - values?: List, - iteratee?: ValueIteratee - ): T[]; + intersectionBy( + array?: List | null | undefined, + values?: List, + iteratee?: ValueIteratee + ): T1[]; /** * @see _.intersectionBy */ - intersectionBy( - array?: List | null | undefined, - ...values: Array | ValueIteratee>, - ): T[]; + intersectionBy( + array?: List | null | undefined, + ...values: Array | ValueIteratee>, + ): T1[]; } interface LoDashImplicitWrapper { /** * @see _.intersectionBy */ - intersectionBy( - this: LoDashImplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee - ): LoDashImplicitWrapper; + intersectionBy( + this: LoDashImplicitWrapper | null | undefined>, + values?: List, + iteratee?: ValueIteratee + ): LoDashImplicitWrapper; /** * @see _.intersectionBy */ - intersectionBy( - this: LoDashImplicitWrapper | null | undefined>, - ...values: Array | ValueIteratee>, - ): LoDashImplicitWrapper; + intersectionBy( + this: LoDashImplicitWrapper | null | undefined>, + ...values: Array | ValueIteratee>, + ): LoDashImplicitWrapper; } interface LoDashExplicitWrapper { /** * @see _.intersectionBy */ - intersectionBy( - this: LoDashExplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee - ): LoDashExplicitWrapper; + intersectionBy( + this: LoDashExplicitWrapper | null | undefined>, + values?: List, + iteratee?: ValueIteratee + ): LoDashExplicitWrapper; /** * @see _.intersectionBy */ - intersectionBy( - this: LoDashExplicitWrapper | null | undefined>, - ...values: Array | ValueIteratee>, - ): LoDashExplicitWrapper; + intersectionBy( + this: LoDashExplicitWrapper | null | undefined>, + ...values: Array | ValueIteratee>, + ): LoDashExplicitWrapper; } //_.intersectionWith @@ -1660,61 +1660,62 @@ declare namespace _ { * @example * * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); - * // => [{ 'x': 2, 'y': 1 }] + * _.intersectionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }] */ - intersectionWith( - array: List | null | undefined, - values?: List, - comparator?: Comparator - ): T[]; + intersectionWith( + array: List | null | undefined, + values?: List, + comparator?: Comparator2 + ): T1[]; /** * @see _.differenceWith */ - intersectionWith( - array: List | null | undefined, - ...values: Array | Comparator>, - ): T[]; + intersectionWith( + array: List | null | undefined, + ...values: Array | Comparator2>, + ): T1[]; } interface LoDashImplicitWrapper { /** * @see _.intersectionWith */ - intersectionWith( - this: LoDashImplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator - ): LoDashImplicitWrapper; + intersectionWith( + this: LoDashImplicitWrapper | null | undefined>, + values?: List, + comparator?: Comparator2 + ): LoDashImplicitWrapper; /** * @see _.intersectionWith */ - intersectionWith( - this: LoDashImplicitWrapper | null | undefined>, - ...values: Array | Comparator>, - ): LoDashImplicitWrapper; + intersectionWith( + this: LoDashImplicitWrapper | null | undefined>, + ...values: Array | Comparator2>, + ): LoDashImplicitWrapper; } interface LoDashExplicitWrapper { /** * @see _.intersectionWith */ - intersectionWith( - this: LoDashExplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator - ): LoDashExplicitWrapper; + intersectionWith( + this: LoDashExplicitWrapper | null | undefined>, + values?: List, + comparator?: Comparator2 + ): LoDashExplicitWrapper; /** * @see _.intersectionWith */ - intersectionWith( - this: LoDashExplicitWrapper | null | undefined>, - ...values: Array | Comparator>, - ): LoDashExplicitWrapper; + intersectionWith( + this: LoDashExplicitWrapper | null | undefined>, + ...values: Array | Comparator2>, + ): LoDashExplicitWrapper; } //_.join @@ -2042,30 +2043,30 @@ declare namespace _ { * console.log(array); * // => [{ 'x': 2 }] */ - pullAllBy( - array: T[], - values?: List, - iteratee?: ValueIteratee - ): T[]; + pullAllBy( + array: T1[], + values?: List, + iteratee?: ValueIteratee + ): T1[]; /** * @see _.pullAllBy */ - pullAllBy( - array: List, - values?: List, - iteratee?: ValueIteratee - ): List; + pullAllBy( + array: List, + values?: List, + iteratee?: ValueIteratee + ): List; } interface LoDashImplicitWrapper { /** * @see _.pullAllBy */ - pullAllBy( - this: LoDashImplicitWrapper>, - values?: List, - iteratee?: ValueIteratee + pullAllBy( + this: LoDashImplicitWrapper>, + values?: List, + iteratee?: ValueIteratee ): this; } @@ -2073,10 +2074,10 @@ declare namespace _ { /** * @see _.pullAllBy */ - pullAllBy( - this: LoDashExplicitWrapper>, - values?: List, - iteratee?: ValueIteratee + pullAllBy( + this: LoDashExplicitWrapper>, + values?: List, + iteratee?: ValueIteratee ): this; } @@ -2098,36 +2099,36 @@ declare namespace _ { * @returns {Array} Returns `array`. * @example * - * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; + * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; * - * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); + * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); * console.log(array); - * // => [{ 'x': 2 }] + * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] */ - pullAllWith( - array: T[], - values?: List, - comparator?: Comparator - ): T[]; + pullAllWith( + array: T1[], + values?: List, + comparator?: Comparator2 + ): T1[]; /** * @see _.pullAllWith */ - pullAllWith( - array: List, - values?: List, - comparator?: Comparator - ): List; + pullAllWith( + array: List, + values?: List, + comparator?: Comparator2 + ): List; } interface LoDashImplicitWrapper { /** * @see _.pullAllWith */ - pullAllWith( - this: LoDashImplicitWrapper>, - values?: List, - comparator?: Comparator + pullAllWith( + this: LoDashImplicitWrapper>, + values?: List, + comparator?: Comparator2 ): this; } @@ -2135,10 +2136,10 @@ declare namespace _ { /** * @see _.pullAllWith */ - pullAllWith( - this: LoDashExplicitWrapper>, - values?: List, - comparator?: Comparator + pullAllWith( + this: LoDashExplicitWrapper>, + values?: List, + comparator?: Comparator2 ): this; } @@ -16788,7 +16789,8 @@ declare namespace _ { type ValueIteratee = ((value: T) => any) | string | [string, any] | PartialDeep; type ValueKeyIteratee = ((value: T, key: string) => any) | string | [string, any] | PartialDeep; - type Comparator = (a: T, b: T) => boolean; + type Comparator = (a: T, b: T) => any; + type Comparator2 = (a: T1, b: T2) => any; /** Common interface between Arrays and jQuery objects */ type List = ArrayLike; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 36f5860b0e..6d71b2bada 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -595,6 +595,110 @@ namespace TestDifferenceBy { } } +// _.differenceWith +{ + let array: TResult[] | null | undefined = [] as any; + let list: _.List | null | undefined = [] as any; + let arrayParam: TResult[] = []; + let listParam: _.List = []; + let comparator = (a: TResult, b: TResult) => any; + + { + // $ExpectType TResult[] + _.differenceWith(array); + // $ExpectType TResult[] + _.differenceWith(array, arrayParam); + // $ExpectType TResult[] + _.differenceWith(array, listParam, arrayParam); + // $ExpectType TResult[] + _.differenceWith(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); + + // $ExpectType TResult[] + _.differenceWith(array, arrayParam, comparator); + // $ExpectType TResult[] + _.differenceWith(array, listParam, arrayParam, comparator); + // $ExpectType TResult[] + _.differenceWith(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, comparator); + } + + { + // $ExpectType LoDashImplicitWrapper + _(array).differenceWith(arrayParam); + // $ExpectType LoDashImplicitWrapper + _(array).differenceWith(listParam, arrayParam); + // $ExpectType LoDashImplicitWrapper + _(array).differenceWith(arrayParam, listParam, arrayParam); + // $ExpectType LoDashImplicitWrapper + _(array).differenceWith(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); + + // $ExpectType LoDashImplicitWrapper + _(array).differenceWith(arrayParam, comparator); + // $ExpectType LoDashImplicitWrapper + _(array).differenceWith(listParam, arrayParam, comparator); + // $ExpectType LoDashImplicitWrapper + _(array).differenceWith(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, comparator); + } + + { + // $ExpectType LoDashExplicitWrapper + _.chain(array).differenceWith(arrayParam); + // $ExpectType LoDashExplicitWrapper + _.chain(array).differenceWith(listParam, arrayParam); + // $ExpectType LoDashExplicitWrapper + _.chain(array).differenceWith(arrayParam, listParam, arrayParam); + // $ExpectType LoDashExplicitWrapper + _.chain(array).differenceWith(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); + + // $ExpectType LoDashExplicitWrapper + _.chain(array).differenceWith(arrayParam, comparator); + // $ExpectType LoDashExplicitWrapper + _.chain(array).differenceWith(listParam, arrayParam, comparator); + // $ExpectType LoDashExplicitWrapper + _.chain(array).differenceWith(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, comparator); + } + + { + interface T1 { + a: string; + b: string; + } + interface T2 { + a: string; + b: number; + } + + const t1: T1 = { a: 'a', b: 'b' }; + const t2: T2 | undefined = any; + const comparator = (a: T1, b: T2 | undefined): boolean | undefined => { + return b && a.a === b.a; + }; + + // $ExpectType T1[] + _.differenceWith([t1], [t2], comparator); + // $ExpectType T1[] + _.differenceWith([t1], [t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 | undefined + }); + + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceWith([t2], comparator); + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 | undefined + }); + + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceWith([t2], comparator); + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 | undefined + }); + } +} + // _.drop { let array: TResult[] | null | undefined = [] as any; @@ -1334,6 +1438,191 @@ namespace TestIntersection { } } +// _.intersectionBy +{ + let array: TResult[] = [] as any; + let list: _.List = [] as any; + let arrayParam: TResult[] = [] as any; + let listParam: _.List = [] as any; + + // $ExpectType TResult[] + result = _.intersectionBy(array, list); + // $ExpectType TResult[] + result = _.intersectionBy(list, array, list); + // $ExpectType TResult[] + result = _.intersectionBy(array, list, 'a'); + // $ExpectType TResult[] + result = _.intersectionBy(list, array, list, 'a'); + // $ExpectType TResult[] + result = _.intersectionBy(array, list, { a: 42 }); + // $ExpectType TResult[] + result = _.intersectionBy(list, array, list, { a: 42 }); + // $ExpectType TResult[] + result = _.intersectionBy(array, list, ['a', 42]); + // $ExpectType TResult[] + result = _.intersectionBy(list, array, list, ['a', 42]); + // $ExpectType TResult[] + result = _.intersectionBy(array, list, (value) => { + value; // $ExpectType TResult + }); + // $ExpectType TResult[] + result = _.intersectionBy(list, array, list, (value) => { + value; // $ExpectType TResult + }); + + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(arrayParam); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(listParam, arrayParam); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(list, 'a'); + // $ExpectType LoDashImplicitWrapper + result = _(list).intersectionBy(array, list, 'a'); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(list, { a: 42 }); + // $ExpectType LoDashImplicitWrapper + result = _(list).intersectionBy(array, list, { a: 42 }); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(list, ['a', 42]); + // $ExpectType LoDashImplicitWrapper + result = _(list).intersectionBy(array, list, ['a', 42]); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(list, (value) => { + value; // $ExpectType TResult + }); + // $ExpectType LoDashImplicitWrapper + result = _(list).intersectionBy(array, list, (value) => { + value; // $ExpectType TResult + }); + + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionBy(arrayParam); + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionBy(listParam, arrayParam); + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionBy(list, 'a'); + // $ExpectType LoDashExplicitWrapper + result = _.chain(list).intersectionBy(array, list, 'a'); + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionBy(list, { a: 42 }); + // $ExpectType LoDashExplicitWrapper + result = _.chain(list).intersectionBy(array, list, { a: 42 }); + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionBy(list, ['a', 42]); + // $ExpectType LoDashExplicitWrapper + result = _.chain(list).intersectionBy(array, list, ['a', 42]); + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionBy(list, (value) => { + value; // $ExpectType TResult + }); + // $ExpectType LoDashExplicitWrapper + result = _.chain(list).intersectionBy(array, list, (value) => { + value; // $ExpectType TResult + }); + + interface T1 { + a: string; + b: string; + } + interface T2 { + a: string; + b: number; + } + const t1: T1 = { a: 'a', b: 'b' }; + const t2: T2 = { a: 'a', b: 1 }; + // $ExpectType T1[] + result = _.intersectionBy([t1], [t2], (value) => { + value; // $ExpectType T1 | T2 + }); + // $ExpectType LoDashImplicitWrapper + result = _([t1]).intersectionBy([t2], (value) => { + value; // $ExpectType T1 | T2 + }); + // $ExpectType LoDashExplicitWrapper + result = _.chain([t1]).intersectionBy([t2], (value) => { + value; // $ExpectType T1 | T2 + }); +} + +// _.intersectionWith +{ + let array: TResult[] = [] as any; + let list: _.List = [] as any; + let arrayParam: TResult[] = [] as any; + let listParam: _.List = [] as any; + + // $ExpectType TResult[] + result = _.intersectionWith(array, list); + // $ExpectType TResult[] + result = _.intersectionWith(list, array, list); + // $ExpectType TResult[] + result = _.intersectionWith(array, list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + // $ExpectType TResult[] + result = _.intersectionWith(list, array, list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionWith(arrayParam); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionWith(listParam, arrayParam); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionWith(list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + // $ExpectType LoDashImplicitWrapper + result = _(list).intersectionWith(array, list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionWith(arrayParam); + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionWith(listParam, arrayParam); + // $ExpectType LoDashExplicitWrapper + result = _.chain(array).intersectionWith(list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + // $ExpectType LoDashExplicitWrapper + result = _.chain(list).intersectionWith(array, list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + + interface T1 { + a: string; + b: string; + } + interface T2 { + a: string; + b: number; + } + const t1: T1 = { a: 'a', b: 'b' }; + const t2: T2 = { a: 'a', b: 1 }; + // $ExpectType T1[] + result = _.intersectionWith([t1], [t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 + }); + // $ExpectType LoDashImplicitWrapper + result = _([t1]).intersectionWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 + }); + // $ExpectType LoDashExplicitWrapper + result = _.chain([t1]).intersectionWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 + }); +} + // _.join namespace TestJoin { let array = [1, 2]; @@ -1607,6 +1896,247 @@ namespace TestPullAt { } } +// _.pullAll +{ + let array: TResult[] = any; + let list: _.List = any; + let values: _.List = any; + + // $ExpectType TResult[] + _.pullAll(array); + // $ExpectType TResult[] + _.pullAll(array, values); + // $ExpectType ArrayLike + _.pullAll(list); + // $ExpectType ArrayLike + _.pullAll(list, values); + + // $ExpectType LoDashImplicitWrapper + _(array).pullAll(); + // $ExpectType LoDashImplicitWrapper + _(array).pullAll(values); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAll(); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAll(values); + + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAll(); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAll(values); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAll(); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAll(values); +} + +// _.pullAllBy +{ + let array: TResult[] = any; + let list: _.List = any; + let values: _.List = any; + + // $ExpectType TResult[] + _.pullAllBy(array); + // $ExpectType TResult[] + _.pullAllBy(array, values); + // $ExpectType TResult[] + _.pullAllBy(array, values, 'a'); + // $ExpectType TResult[] + _.pullAllBy(array, values, { a: 42 }); + // $ExpectType TResult[] + _.pullAllBy(array, values, ['a', 42]); + // $ExpectType TResult[] + _.pullAllBy(array, values, (value) => { + value; // $ExpectType TResult + }); + // $ExpectType ArrayLike + _.pullAllBy(list); + // $ExpectType ArrayLike + _.pullAllBy(list, values); + // $ExpectType ArrayLike + _.pullAllBy(list, values, 'a'); + // $ExpectType ArrayLike + _.pullAllBy(list, values, { a: 42 }); + // $ExpectType ArrayLike + _.pullAllBy(list, values, ['a', 42]); + // $ExpectType ArrayLike + _.pullAllBy(list, values, (value) => { + value; // $ExpectType TResult + }); + + // $ExpectType LoDashImplicitWrapper + _(array).pullAllBy(); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllBy(values); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllBy(values, 'a'); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllBy(values, { a: 42 }); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllBy(values, ['a', 42]); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllBy(values, (value) => { + value; // $ExpectType TResult + }); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllBy(); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllBy(values); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllBy(values, 'a'); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllBy(values, { a: 42 }); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllBy(values, ['a', 42]); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllBy(values, (value) => { + value; // $ExpectType TResult + }); + + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllBy(); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllBy(values); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllBy(values, 'a'); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllBy(values, { a: 42 }); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllBy(values, ['a', 42]); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllBy(values, (value) => { + value; // $ExpectType TResult + }); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllBy(); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllBy(values); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllBy(values, 'a'); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllBy(values, { a: 42 }); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllBy(values, ['a', 42]); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllBy(values, (value) => { + value; // $ExpectType TResult + }); + + interface T1 { + a: string; + b: string; + } + interface T2 { + a: string; + b: number; + } + const t1: T1 = { a: 'a', b: 'b' }; + const t2: T2 = { a: 'a', b: 1 }; + // $ExpectType T1[] + result = _.pullAllBy([t1], [t2], (value) => { + value; // $ExpectType T1 | T2 + }); + // $ExpectType LoDashImplicitWrapper + result = _([t1]).pullAllBy([t2], (value) => { + value; // $ExpectType T1 | T2 + }); + // $ExpectType LoDashExplicitWrapper + result = _.chain([t1]).pullAllBy([t2], (value) => { + value; // $ExpectType T1 | T2 + }); +} + +// _.pullAllWith +{ + let array: TResult[] = any; + let list: _.List = any; + let values: _.List = any; + + // $ExpectType TResult[] + _.pullAllWith(array); + // $ExpectType TResult[] + _.pullAllWith(array, values); + // $ExpectType TResult[] + _.pullAllWith(array, values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + // $ExpectType ArrayLike + _.pullAllWith(list); + // $ExpectType ArrayLike + _.pullAllWith(list, values); + // $ExpectType ArrayLike + _.pullAllWith(list, values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + + // $ExpectType LoDashImplicitWrapper + _(array).pullAllWith(); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllWith(values); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllWith(values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllWith(); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllWith(values); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllWith(values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllWith(); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllWith(values); + // $ExpectType LoDashExplicitWrapper + _.chain(array).pullAllWith(values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllWith(); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllWith(values); + // $ExpectType LoDashExplicitWrapper> + _.chain(list).pullAllWith(values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + }); + + interface T1 { + a: string; + b: string; + } + interface T2 { + a: string; + b: number; + } + const t1: T1 = { a: 'a', b: 'b' }; + const t2: T2 = { a: 'a', b: 1 }; + // $ExpectType T1[] + result = _.pullAllWith([t1], [t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 + }); + // $ExpectType LoDashImplicitWrapper + result = _([t1]).pullAllWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 + }); + // $ExpectType LoDashExplicitWrapper + result = _.chain([t1]).pullAllWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 + }); +} + // _.remove namespace TestRemove { let array: TResult[] = []; From ebfac084789a38ac3c09de6285e8365be0dee2b1 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Wed, 25 Oct 2017 17:11:31 -0400 Subject: [PATCH 07/53] Update to TS 2.4 to fix tests --- types/lodash/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 05a83d7d09..0a3b53901d 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -9,7 +9,7 @@ // e-cloud , // Georgii Dolzhykov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.4 /** ### 4.0.0 Changelog (https://github.com/lodash/lodash/wiki/Changelog) From 8839c142f6a29abe674ba0e6787a5657bc564706 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Wed, 25 Oct 2017 21:39:50 -0400 Subject: [PATCH 08/53] Fix lint --- types/lodash/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 0a3b53901d..f39515a4ea 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -1581,7 +1581,7 @@ declare namespace _ { * // => [{ 'x': 1 }] */ intersectionBy( - array?: List | null | undefined, + array?: List | null, values?: List, iteratee?: ValueIteratee ): T1[]; From 6213c4439e0dce1025b0fc454472a1f463ac318c Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Thu, 26 Oct 2017 18:16:32 +0300 Subject: [PATCH 09/53] Fixed sortedIndex iteratee type. --- types/underscore/index.d.ts | 5 ++++- types/underscore/tsconfig.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 2803c89b96..655f14576f 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1058,12 +1058,15 @@ declare module _ { * @param list The sorted list. * @param value The value to determine its index within `list`. * @param iterator Iterator to compute the sort ranking of each value, optional. + * @param context `this` object in `iterator`, optional. * @return The index where `value` should be inserted into `list`. **/ sortedIndex( list: _.List, value: T, - iterator?: (x: T) => TSort, context?: any): number; + iterator?: ((x: T) => TSort) | string, + context?: any + ): number; /** * A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted, diff --git a/types/underscore/tsconfig.json b/types/underscore/tsconfig.json index 549c23e027..a4eeca6fa2 100644 --- a/types/underscore/tsconfig.json +++ b/types/underscore/tsconfig.json @@ -21,4 +21,4 @@ "index.d.ts", "underscore-tests.ts" ] -} \ No newline at end of file +} From 8cf04ecafacc9b7d528d19bbd7c6eed33e45f7a3 Mon Sep 17 00:00:00 2001 From: Jim Cummins Date: Thu, 26 Oct 2017 15:02:41 -0500 Subject: [PATCH 10/53] fix: enzyme -> allow contains fns to accept arrays (react 16) --- types/enzyme/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts index 101215462f..8cc8c07a89 100644 --- a/types/enzyme/index.d.ts +++ b/types/enzyme/index.d.ts @@ -54,22 +54,22 @@ export interface CommonWrapper

{ /** * Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in. */ - contains(node: ReactElement | string): boolean; + contains(node: ReactElement | Array> | string): boolean; /** * Returns whether or not a given react element exists in the shallow render tree. */ - containsMatchingElement(node: ReactElement): boolean; + containsMatchingElement(node: ReactElement | Array>): boolean; /** * Returns whether or not all the given react elements exists in the shallow render tree */ - containsAllMatchingElements(nodes: Array>): boolean; + containsAllMatchingElements(nodes: Array> | Array>>): boolean; /** * Returns whether or not one of the given react elements exists in the shallow render tree. */ - containsAnyMatchingElements(nodes: Array>): boolean; + containsAnyMatchingElements(nodes: Array> | Array>>): boolean; /** * Returns whether or not the current render tree is equal to the given node, based on the expected value. From 579ed18aaac30331e6482347f3cb0c6125cef5bb Mon Sep 17 00:00:00 2001 From: Ed Bishop Date: Fri, 27 Oct 2017 12:46:49 +0100 Subject: [PATCH 11/53] Get results are also writeable --- types/rethinkdb/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/rethinkdb/index.d.ts b/types/rethinkdb/index.d.ts index 983d401b72..4ef00ecb09 100644 --- a/types/rethinkdb/index.d.ts +++ b/types/rethinkdb/index.d.ts @@ -244,7 +244,7 @@ declare module "rethinkdb" { insert(obj: any[], options?: InsertOptions): Operation; insert(obj: any, options?: InsertOptions): Operation; - get(key: string): Operation; + get(key: string): Operation & Writeable; getAll(key: string, index?: Index): Sequence; // without index defaults to primary key getAll(...keys: string[]): Sequence; wait(WaitOptions?: WaitOptions): WaitResult; From 07287254abcd729bc0090582b91816525a47b517 Mon Sep 17 00:00:00 2001 From: Evan Shortiss Date: Fri, 27 Oct 2017 17:51:22 -0700 Subject: [PATCH 12/53] update typings to extend request object. allow import without require --- .../express-formidable-tests.ts | 11 ++++++++--- types/express-formidable/index.d.ts | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/types/express-formidable/express-formidable-tests.ts b/types/express-formidable/express-formidable-tests.ts index 91f9e34519..ddf0c76382 100644 --- a/types/express-formidable/express-formidable-tests.ts +++ b/types/express-formidable/express-formidable-tests.ts @@ -1,9 +1,14 @@ -import express = require("express"); -import expform = require("express-formidable"); +import * as express from "express" +import * as expform from "express-formidable"; const app = express(); -app.use("/form1", expform()); +app.use("/form1", expform(), (req, res, next) => { + console.log(req.fields) + console.log(req.files) + next() +}); + app.use("/form2", expform({ encoding: "utf-8", uploadDir: "./uploads", diff --git a/types/express-formidable/index.d.ts b/types/express-formidable/index.d.ts index 57342521c2..716df6578b 100644 --- a/types/express-formidable/index.d.ts +++ b/types/express-formidable/index.d.ts @@ -3,7 +3,18 @@ // Definitions by: Torkild Dyvik Olsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { RequestHandler } from "express"; +import * as express from "express"; +import { Fields, Files, IncomingForm } from "formidable" + +// Extend the express request object with attached formidable files and fields +declare global { + namespace Express { + interface Request { + fields?: Fields; + files?: Files; + } + } +} interface ExpressFormidableOptions { encoding?: string; @@ -16,6 +27,8 @@ interface ExpressFormidableOptions { multiples?: boolean; } -declare function ExpressFormidable(options?: ExpressFormidableOptions): RequestHandler; +declare function ExpressFormidable(options?: ExpressFormidableOptions): express.RequestHandler; + +declare namespace ExpressFormidable {} export = ExpressFormidable; From 62dfe64143529a7765f2e744b49d11472d082c49 Mon Sep 17 00:00:00 2001 From: Evan Shortiss Date: Fri, 27 Oct 2017 18:03:41 -0700 Subject: [PATCH 13/53] remove unused var --- types/express-formidable/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/express-formidable/index.d.ts b/types/express-formidable/index.d.ts index 716df6578b..dcfef9b55a 100644 --- a/types/express-formidable/index.d.ts +++ b/types/express-formidable/index.d.ts @@ -1,10 +1,10 @@ // Type definitions for express-formidable 1.0.0 // Project: https://github.com/noraesae/express-formidable -// Definitions by: Torkild Dyvik Olsen +// Definitions by: Torkild Dyvik Olsen , Evan Shortiss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as express from "express"; -import { Fields, Files, IncomingForm } from "formidable" +import { Fields, Files } from "formidable" // Extend the express request object with attached formidable files and fields declare global { From c31000f00fd9610e3c76eca75dee667f256f8644 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Sat, 28 Oct 2017 09:58:24 -0400 Subject: [PATCH 14/53] Fixed test errors in TS 2.3 --- types/lodash/index.d.ts | 3 +-- types/lodash/lodash-tests.ts | 12 ------------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index f39515a4ea..b670071e6c 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -9,7 +9,7 @@ // e-cloud , // Georgii Dolzhykov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 2.2 /** ### 4.0.0 Changelog (https://github.com/lodash/lodash/wiki/Changelog) @@ -4753,7 +4753,6 @@ declare namespace _ { iteratee: object ): boolean[]; } - type T234 = number[][0]; interface LoDashImplicitWrapper { /** diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index a72d2f45d7..1cb92c50fa 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -1451,16 +1451,12 @@ namespace TestIntersection { // $ExpectType TResult[] result = _.intersectionBy(array, list, 'a'); // $ExpectType TResult[] - result = _.intersectionBy(list, array, list, 'a'); - // $ExpectType TResult[] result = _.intersectionBy(array, list, { a: 42 }); // $ExpectType TResult[] result = _.intersectionBy(list, array, list, { a: 42 }); // $ExpectType TResult[] result = _.intersectionBy(array, list, ['a', 42]); // $ExpectType TResult[] - result = _.intersectionBy(list, array, list, ['a', 42]); - // $ExpectType TResult[] result = _.intersectionBy(array, list, (value) => { value; // $ExpectType TResult }); @@ -1476,16 +1472,12 @@ namespace TestIntersection { // $ExpectType LoDashImplicitWrapper result = _(array).intersectionBy(list, 'a'); // $ExpectType LoDashImplicitWrapper - result = _(list).intersectionBy(array, list, 'a'); - // $ExpectType LoDashImplicitWrapper result = _(array).intersectionBy(list, { a: 42 }); // $ExpectType LoDashImplicitWrapper result = _(list).intersectionBy(array, list, { a: 42 }); // $ExpectType LoDashImplicitWrapper result = _(array).intersectionBy(list, ['a', 42]); // $ExpectType LoDashImplicitWrapper - result = _(list).intersectionBy(array, list, ['a', 42]); - // $ExpectType LoDashImplicitWrapper result = _(array).intersectionBy(list, (value) => { value; // $ExpectType TResult }); @@ -1501,16 +1493,12 @@ namespace TestIntersection { // $ExpectType LoDashExplicitWrapper result = _.chain(array).intersectionBy(list, 'a'); // $ExpectType LoDashExplicitWrapper - result = _.chain(list).intersectionBy(array, list, 'a'); - // $ExpectType LoDashExplicitWrapper result = _.chain(array).intersectionBy(list, { a: 42 }); // $ExpectType LoDashExplicitWrapper result = _.chain(list).intersectionBy(array, list, { a: 42 }); // $ExpectType LoDashExplicitWrapper result = _.chain(array).intersectionBy(list, ['a', 42]); // $ExpectType LoDashExplicitWrapper - result = _.chain(list).intersectionBy(array, list, ['a', 42]); - // $ExpectType LoDashExplicitWrapper result = _.chain(array).intersectionBy(list, (value) => { value; // $ExpectType TResult }); From 5cf22a50e99eab23b85f38dc8b9cd7e1184158f1 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Sat, 28 Oct 2017 10:05:45 -0400 Subject: [PATCH 15/53] Force iterators and comparators to return a value (disallow void) --- types/lodash/index.d.ts | 162 ++++++++++++++++++----------------- types/lodash/lodash-tests.ts | 83 +++++++++++++++--- 2 files changed, 154 insertions(+), 91 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index b670071e6c..254a411187 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -1134,7 +1134,7 @@ declare namespace _ { */ findIndex( array: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1145,7 +1145,7 @@ declare namespace _ { */ findIndex( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1156,7 +1156,7 @@ declare namespace _ { */ findIndex( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -1182,7 +1182,7 @@ declare namespace _ { */ findLastIndex( array: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1193,7 +1193,7 @@ declare namespace _ { */ findLastIndex( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1204,7 +1204,7 @@ declare namespace _ { */ findLastIndex( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -2977,7 +2977,7 @@ declare namespace _ { */ uniqBy( array: string | null | undefined, - iteratee: StringIterator + iteratee: StringIterator ): string[]; /** @@ -2995,7 +2995,7 @@ declare namespace _ { */ uniqBy( this: LoDashImplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashImplicitWrapper; /** @@ -3013,7 +3013,7 @@ declare namespace _ { */ uniqBy( this: LoDashExplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashExplicitWrapper; /** @@ -3119,7 +3119,7 @@ declare namespace _ { */ sortedUniqBy( array: string | null | undefined, - iteratee: StringIterator + iteratee: StringIterator ): string[]; /** @@ -3137,7 +3137,7 @@ declare namespace _ { */ sortedUniqBy( this: LoDashImplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashImplicitWrapper; /** @@ -3155,7 +3155,7 @@ declare namespace _ { */ sortedUniqBy( this: LoDashExplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashExplicitWrapper; /** @@ -4227,7 +4227,7 @@ declare namespace _ { */ every( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -4235,7 +4235,7 @@ declare namespace _ { */ every( collection: NumericDictionary | null | undefined, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; /** @@ -4243,7 +4243,7 @@ declare namespace _ { */ every( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; } @@ -4253,7 +4253,7 @@ declare namespace _ { */ every( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -4261,7 +4261,7 @@ declare namespace _ { */ every( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; /** @@ -4269,7 +4269,7 @@ declare namespace _ { */ every( this: LoDashImplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; } @@ -4279,7 +4279,7 @@ declare namespace _ { */ every( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -4287,7 +4287,7 @@ declare namespace _ { */ every( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper; /** @@ -4295,7 +4295,7 @@ declare namespace _ { */ every( this: LoDashExplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): LoDashExplicitWrapper; } @@ -4321,7 +4321,7 @@ declare namespace _ { */ filter( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -4337,7 +4337,7 @@ declare namespace _ { */ filter( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): T[]; /** @@ -4353,7 +4353,7 @@ declare namespace _ { */ filter( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): Array; } @@ -4363,7 +4363,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -4379,7 +4379,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashImplicitWrapper; /** @@ -4395,7 +4395,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashImplicitWrapper>; } @@ -4405,7 +4405,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -4421,7 +4421,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -4437,7 +4437,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper>; } @@ -4472,7 +4472,7 @@ declare namespace _ { */ find( collection: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T|undefined; @@ -4490,7 +4490,7 @@ declare namespace _ { */ find( collection: T | null | undefined, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4510,7 +4510,7 @@ declare namespace _ { */ find( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T|undefined; @@ -4528,7 +4528,7 @@ declare namespace _ { */ find( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4548,7 +4548,7 @@ declare namespace _ { */ find( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; @@ -4566,7 +4566,7 @@ declare namespace _ { */ find( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -4592,7 +4592,7 @@ declare namespace _ { */ findLast( collection: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T|undefined; @@ -4610,7 +4610,7 @@ declare namespace _ { */ findLast( collection: T | null | undefined, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4630,7 +4630,7 @@ declare namespace _ { */ findLast( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T | undefined; @@ -4648,7 +4648,7 @@ declare namespace _ { */ findLast( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4668,7 +4668,7 @@ declare namespace _ { */ findLast( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; @@ -4686,7 +4686,7 @@ declare namespace _ { */ findLast( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -5439,7 +5439,7 @@ declare namespace _ { */ groupBy( collection: string | null | undefined, - iteratee?: StringIterator + iteratee?: StringIterator ): Dictionary; /** @@ -5473,7 +5473,7 @@ declare namespace _ { */ groupBy( this: LoDashImplicitWrapper, - iteratee?: StringIterator + iteratee?: StringIterator ): LoDashImplicitWrapper>; /** @@ -5507,7 +5507,7 @@ declare namespace _ { */ groupBy( this: LoDashExplicitWrapper, - iteratee?: StringIterator + iteratee?: StringIterator ): LoDashExplicitWrapper>; /** @@ -6458,7 +6458,7 @@ declare namespace _ { */ reject( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -6466,7 +6466,7 @@ declare namespace _ { */ reject( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): T[]; /** @@ -6474,7 +6474,7 @@ declare namespace _ { */ reject( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): Array; } @@ -6484,7 +6484,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -6492,7 +6492,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashImplicitWrapper; /** @@ -6500,7 +6500,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashImplicitWrapper>; } @@ -6510,7 +6510,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -6518,7 +6518,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -6526,7 +6526,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper>; } @@ -6740,7 +6740,7 @@ declare namespace _ { */ some( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -6748,7 +6748,7 @@ declare namespace _ { */ some( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; /** @@ -6756,7 +6756,7 @@ declare namespace _ { */ some( collection: NumericDictionary | null | undefined, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; } @@ -6766,7 +6766,7 @@ declare namespace _ { */ some( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -6774,7 +6774,7 @@ declare namespace _ { */ some( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; /** @@ -6782,7 +6782,7 @@ declare namespace _ { */ some( this: LoDashImplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; } @@ -6792,7 +6792,7 @@ declare namespace _ { */ some( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -6800,7 +6800,7 @@ declare namespace _ { */ some( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper; /** @@ -6808,7 +6808,7 @@ declare namespace _ { */ some( this: LoDashExplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): LoDashExplicitWrapper; } @@ -6924,7 +6924,7 @@ declare namespace _ { */ orderBy( collection: List | null | undefined, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): T[]; @@ -6942,7 +6942,7 @@ declare namespace _ { */ orderBy( collection: T | null | undefined, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): Array; @@ -6960,7 +6960,7 @@ declare namespace _ { */ orderBy( collection: NumericDictionary | null | undefined, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): T[]; @@ -6980,7 +6980,7 @@ declare namespace _ { */ orderBy( this: LoDashImplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashImplicitWrapper; @@ -6998,7 +6998,7 @@ declare namespace _ { */ orderBy( this: LoDashImplicitWrapper, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashImplicitWrapper>; @@ -7016,7 +7016,7 @@ declare namespace _ { */ orderBy( this: LoDashImplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashImplicitWrapper; @@ -7036,7 +7036,7 @@ declare namespace _ { */ orderBy( this: LoDashExplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashExplicitWrapper; @@ -7054,7 +7054,7 @@ declare namespace _ { */ orderBy( this: LoDashExplicitWrapper, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashExplicitWrapper>; @@ -7072,7 +7072,7 @@ declare namespace _ { */ orderBy( this: LoDashExplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashExplicitWrapper; @@ -16589,14 +16589,17 @@ declare namespace _ { uniqueId(): LoDashExplicitWrapper; } + type NotVoid = {} | null | undefined; type ArrayIterator = (value: T, index: number, collection: T[]) => TResult; type ListIterator = (value: T, index: number, collection: List) => TResult; - type ListIteratee = ListIterator | string | [string, any] | PartialDeep; + type ListIteratee = ListIterator | string | [string, any] | PartialDeep; + type ListIterateeBoolean = ListIterator | string | [string, any] | PartialDeep; type ListIteratorTypeGuard = (value: T, index: number, collection: List) => value is S; // Note: key should be string, not keyof T, because the actual object may contain extra properties that were not specified in the type. type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; - type ObjectIteratee = ObjectIterator | string | [string, any] | PartialDeep; + type ObjectIteratee = ObjectIterator | string | [string, any] | PartialDeep; + type ObjectIterateeBoolean = ObjectIterator | string | [string, any] | PartialDeep; type ObjectIteratorTypeGuard = (value: TObject[keyof TObject], key: string, collection: TObject) => value is S; type DictionaryIterator = ObjectIterator, TResult>; @@ -16604,7 +16607,8 @@ declare namespace _ { type DictionaryIteratorTypeGuard = ObjectIteratorTypeGuard, S>; type NumericDictionaryIterator = (value: T, key: number, collection: NumericDictionary) => TResult; - type NumericDictionaryIteratee = NumericDictionaryIterator | string | [string, any] | PartialDeep; + type NumericDictionaryIteratee = NumericDictionaryIterator | string | [string, any] | PartialDeep; + type NumericDictionaryIterateeBoolean = NumericDictionaryIterator | string | [string, any] | PartialDeep; type StringIterator = (char: string, index: number, string: string) => TResult; @@ -16618,10 +16622,10 @@ declare namespace _ { type MemoVoidArrayIterator = (acc: TResult, curr: T, index: number, arr: T[]) => void; type MemoVoidDictionaryIterator = (acc: TResult, curr: T, key: string, dict: Dictionary) => void; - type ValueIteratee = ((value: T) => any) | string | [string, any] | PartialDeep; - type ValueKeyIteratee = ((value: T, key: string) => any) | string | [string, any] | PartialDeep; - type Comparator = (a: T, b: T) => any; - type Comparator2 = (a: T1, b: T2) => any; + type ValueIteratee = ((value: T) => NotVoid) | string | [string, any] | PartialDeep; + type ValueKeyIteratee = ((value: T, key: string) => NotVoid) | string | [string, any] | PartialDeep; + type Comparator = (a: T, b: T) => boolean | null | undefined; + type Comparator2 = (a: T1, b: T2) => boolean | null | undefined; type PropertyName = string | number; type PropertyPath = Many; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 1cb92c50fa..338d66ced5 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -504,30 +504,37 @@ namespace TestDifferenceBy { // $ExpectType T1[] _.differenceBy([t1], [t2], (value) => { value; // $ExpectType T1 | T2 + return 0; }); // $ExpectType T1[] _.differenceBy([t1], [t2, t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType (T1 | T2)[] _.differenceBy([t1, t2], [t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType T1[] _.differenceBy([t1], [t2], [t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType T1[] _.differenceBy([t1], [t2], [t3], [t4], (value) => { value; // $ExpectType T1 | T2 | T3 | T4 + return 0; }); // $ExpectType T1[] _.differenceBy([t1], [t2], [t3], [t4], [''], (value) => { value; // $ExpectType string | T1 | T2 | T3 | T4 + return 0; }); // $ExpectType T1[] _.differenceBy([t1], [t2], [t3], [t4], [''], [42], (value) => { value; // $ExpectType string | number | T1 | T2 | T3 | T4 + return 0; }); // $ExpectType LoDashImplicitWrapper @@ -535,30 +542,37 @@ namespace TestDifferenceBy { // $ExpectType LoDashImplicitWrapper _([t1]).differenceBy([t2], (value) => { value; // $ExpectType T1 | T2 + return 0; }); // $ExpectType LoDashImplicitWrapper _([t1]).differenceBy([t2, t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType LoDashImplicitWrapper<(T1 | T2)[]> _([t1, t2]).differenceBy([t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType LoDashImplicitWrapper _([t1]).differenceBy([t2], [t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType LoDashImplicitWrapper _([t1]).differenceBy([t2], [t3], [t4], (value) => { value; // $ExpectType T1 | T2 | T3 | T4 + return 0; }); // $ExpectType LoDashImplicitWrapper _([t1]).differenceBy([t2], [t3], [t4], [''], (value) => { value; // $ExpectType string | T1 | T2 | T3 | T4 + return 0; }); // $ExpectType LoDashImplicitWrapper _([t1]).differenceBy([t2], [t3], [t4], [''], [42], (value) => { value; // $ExpectType string | number | T1 | T2 | T3 | T4 + return 0; }); // $ExpectType LoDashExplicitWrapper @@ -566,30 +580,37 @@ namespace TestDifferenceBy { // $ExpectType LoDashExplicitWrapper _.chain([t1]).differenceBy([t2], (value) => { value; // $ExpectType T1 | T2 + return 0; }); // $ExpectType LoDashExplicitWrapper _.chain([t1]).differenceBy([t2, t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType LoDashExplicitWrapper<(T1 | T2)[]> _.chain([t1, t2]).differenceBy([t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType LoDashExplicitWrapper _.chain([t1]).differenceBy([t2], [t3], (value) => { value; // $ExpectType T1 | T2 | T3 + return 0; }); // $ExpectType LoDashExplicitWrapper _.chain([t1]).differenceBy([t2], [t3], [t4], (value) => { value; // $ExpectType T1 | T2 | T3 | T4 + return 0; }); // $ExpectType LoDashExplicitWrapper _.chain([t1]).differenceBy([t2], [t3], [t4], [''], (value) => { value; // $ExpectType string | T1 | T2 | T3 | T4 + return 0; }); // $ExpectType LoDashExplicitWrapper _.chain([t1]).differenceBy([t2], [t3], [t4], [''], [42], (value) => { value; // $ExpectType string | number | T1 | T2 | T3 | T4 + return 0; }); } } @@ -600,7 +621,7 @@ namespace TestDifferenceBy { let list: _.List | null | undefined = [] as any; let arrayParam: TResult[] = []; let listParam: _.List = []; - let comparator = (a: TResult, b: TResult) => any; + let comparator = (a: TResult, b: TResult) => true; { // $ExpectType TResult[] @@ -678,6 +699,7 @@ namespace TestDifferenceBy { _.differenceWith([t1], [t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 | undefined + return true; }); // $ExpectType LoDashImplicitWrapper @@ -686,6 +708,7 @@ namespace TestDifferenceBy { _([t1]).differenceWith([t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 | undefined + return true; }); // $ExpectType LoDashExplicitWrapper @@ -694,6 +717,7 @@ namespace TestDifferenceBy { _.chain([t1]).differenceWith([t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 | undefined + return true; }); } } @@ -1459,10 +1483,12 @@ namespace TestIntersection { // $ExpectType TResult[] result = _.intersectionBy(array, list, (value) => { value; // $ExpectType TResult + return 0; }); // $ExpectType TResult[] result = _.intersectionBy(list, array, list, (value) => { value; // $ExpectType TResult + return 0; }); // $ExpectType LoDashImplicitWrapper @@ -1480,10 +1506,12 @@ namespace TestIntersection { // $ExpectType LoDashImplicitWrapper result = _(array).intersectionBy(list, (value) => { value; // $ExpectType TResult + return ""; }); // $ExpectType LoDashImplicitWrapper result = _(list).intersectionBy(array, list, (value) => { value; // $ExpectType TResult + return 1; }); // $ExpectType LoDashExplicitWrapper @@ -1501,10 +1529,12 @@ namespace TestIntersection { // $ExpectType LoDashExplicitWrapper result = _.chain(array).intersectionBy(list, (value) => { value; // $ExpectType TResult + return false; }); // $ExpectType LoDashExplicitWrapper result = _.chain(list).intersectionBy(array, list, (value) => { value; // $ExpectType TResult + return null; }); interface T1 { @@ -1520,14 +1550,17 @@ namespace TestIntersection { // $ExpectType T1[] result = _.intersectionBy([t1], [t2], (value) => { value; // $ExpectType T1 | T2 + return undefined; }); // $ExpectType LoDashImplicitWrapper result = _([t1]).intersectionBy([t2], (value) => { value; // $ExpectType T1 | T2 + return {}; }); // $ExpectType LoDashExplicitWrapper result = _.chain([t1]).intersectionBy([t2], (value) => { value; // $ExpectType T1 | T2 + return {}; }); } @@ -1546,11 +1579,13 @@ namespace TestIntersection { result = _.intersectionWith(array, list, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType TResult[] result = _.intersectionWith(list, array, list, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashImplicitWrapper @@ -1561,11 +1596,13 @@ namespace TestIntersection { result = _(array).intersectionWith(list, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashImplicitWrapper result = _(list).intersectionWith(array, list, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashExplicitWrapper @@ -1576,11 +1613,13 @@ namespace TestIntersection { result = _.chain(array).intersectionWith(list, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashExplicitWrapper result = _.chain(list).intersectionWith(array, list, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); interface T1 { @@ -1597,16 +1636,19 @@ namespace TestIntersection { result = _.intersectionWith([t1], [t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 + return true; }); // $ExpectType LoDashImplicitWrapper result = _([t1]).intersectionWith([t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 + return true; }); // $ExpectType LoDashExplicitWrapper result = _.chain([t1]).intersectionWith([t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 + return true; }); } @@ -1936,6 +1978,7 @@ namespace TestPullAt { // $ExpectType TResult[] _.pullAllBy(array, values, (value) => { value; // $ExpectType TResult + return []; }); // $ExpectType ArrayLike _.pullAllBy(list); @@ -1950,6 +1993,7 @@ namespace TestPullAt { // $ExpectType ArrayLike _.pullAllBy(list, values, (value) => { value; // $ExpectType TResult + return () => {}; }); // $ExpectType LoDashImplicitWrapper @@ -1965,6 +2009,7 @@ namespace TestPullAt { // $ExpectType LoDashImplicitWrapper _(array).pullAllBy(values, (value) => { value; // $ExpectType TResult + return 0; }); // $ExpectType LoDashImplicitWrapper> _(list).pullAllBy(); @@ -1979,6 +2024,7 @@ namespace TestPullAt { // $ExpectType LoDashImplicitWrapper> _(list).pullAllBy(values, (value) => { value; // $ExpectType TResult + return 0; }); // $ExpectType LoDashExplicitWrapper @@ -1994,6 +2040,7 @@ namespace TestPullAt { // $ExpectType LoDashExplicitWrapper _.chain(array).pullAllBy(values, (value) => { value; // $ExpectType TResult + return 0; }); // $ExpectType LoDashExplicitWrapper> _.chain(list).pullAllBy(); @@ -2008,6 +2055,7 @@ namespace TestPullAt { // $ExpectType LoDashExplicitWrapper> _.chain(list).pullAllBy(values, (value) => { value; // $ExpectType TResult + return 0; }); interface T1 { @@ -2023,14 +2071,17 @@ namespace TestPullAt { // $ExpectType T1[] result = _.pullAllBy([t1], [t2], (value) => { value; // $ExpectType T1 | T2 + return ""; }); // $ExpectType LoDashImplicitWrapper result = _([t1]).pullAllBy([t2], (value) => { value; // $ExpectType T1 | T2 + return ""; }); // $ExpectType LoDashExplicitWrapper result = _.chain([t1]).pullAllBy([t2], (value) => { value; // $ExpectType T1 | T2 + return ""; }); } @@ -2048,6 +2099,7 @@ namespace TestPullAt { _.pullAllWith(array, values, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType ArrayLike _.pullAllWith(list); @@ -2057,6 +2109,7 @@ namespace TestPullAt { _.pullAllWith(list, values, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashImplicitWrapper @@ -2067,6 +2120,7 @@ namespace TestPullAt { _(array).pullAllWith(values, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashImplicitWrapper> _(list).pullAllWith(); @@ -2076,6 +2130,7 @@ namespace TestPullAt { _(list).pullAllWith(values, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashExplicitWrapper @@ -2086,6 +2141,7 @@ namespace TestPullAt { _.chain(array).pullAllWith(values, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); // $ExpectType LoDashExplicitWrapper> _.chain(list).pullAllWith(); @@ -2095,6 +2151,7 @@ namespace TestPullAt { _.chain(list).pullAllWith(values, (a, b) => { a; // $ExpectType TResult b; // $ExpectType TResult + return true; }); interface T1 { @@ -2111,16 +2168,19 @@ namespace TestPullAt { result = _.pullAllWith([t1], [t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 + return true; }); // $ExpectType LoDashImplicitWrapper result = _([t1]).pullAllWith([t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 + return true; }); // $ExpectType LoDashExplicitWrapper result = _.chain([t1]).pullAllWith([t2], (a, b) => { a; // $ExpectType T1 b; // $ExpectType T2 + return true; }); } @@ -6867,12 +6927,11 @@ result = _(foodsOrganic).sortBy('organic', (food) => food.name, namespace TestorderBy { type SampleObject = {a: number; b: string; c: boolean}; - let array: SampleObject[] | null | undefined = [] as any; - let list: _.List | null | undefined = [] as any; - let obj: any = {}; - let numericDictionary: _.NumericDictionary | null | undefined = obj; - let dictionary: _.Dictionary | null | undefined = obj; - let orders: boolean|string|(boolean|string)[] = true as any; + const array: SampleObject[] | null | undefined = any; + const list: _.List | null | undefined = any; + const numericDictionary: _.NumericDictionary | null | undefined = any; + const dictionary: _.Dictionary | null | undefined = any; + const orders: boolean|string|Array = any; { let iteratees: (value: string) => any|((value: string) => any)[] = (value) => 1; @@ -6883,7 +6942,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => 1; + const iteratees: ((value: SampleObject) => _.NotVoid)|string|_.PartialDeep|Array<((value: SampleObject) => _.NotVoid)|string|_.PartialDeep> = any; let result: SampleObject[]; result = _.orderBy(array, iteratees); @@ -6908,7 +6967,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; + const iteratees: ((value: SampleObject) => _.NotVoid)|string|_.PartialDeep|Array<((value: SampleObject) => _.NotVoid)|string|_.PartialDeep> = any; let result: _.LoDashImplicitArrayWrapper; result = _(array).orderBy(iteratees); @@ -6931,7 +6990,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; + const iteratees: ((value: SampleObject) => _.NotVoid)|string|_.PartialDeep|Array<((value: SampleObject) => _.NotVoid)|string|_.PartialDeep> = any; let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().orderBy(iteratees); @@ -13278,8 +13337,8 @@ namespace TestIdentity { } { - let input: {} | null | undefined = any; - _.identity(input); // $ExpectType {} | null | undefined + let input: { a: number; } | null | undefined = any; + _.identity(input); // $ExpectType { a: number; } | null | undefined _.identity(); // $ExpectType undefined } } From 5ed4c19b3cc2e096cf4a8765e021259a2ff071fc Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Sun, 29 Oct 2017 10:08:18 -0400 Subject: [PATCH 16/53] Add type alias for boolean | null | undefined --- types/lodash/index.d.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 254a411187..408e45a266 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -4321,7 +4321,7 @@ declare namespace _ { */ filter( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -4363,7 +4363,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -4405,7 +4405,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -6458,7 +6458,7 @@ declare namespace _ { */ reject( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -6484,7 +6484,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -6510,7 +6510,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -16590,16 +16590,17 @@ declare namespace _ { } type NotVoid = {} | null | undefined; + type Boolish = boolean | null | undefined; type ArrayIterator = (value: T, index: number, collection: T[]) => TResult; type ListIterator = (value: T, index: number, collection: List) => TResult; type ListIteratee = ListIterator | string | [string, any] | PartialDeep; - type ListIterateeBoolean = ListIterator | string | [string, any] | PartialDeep; + type ListIterateeBoolean = ListIterator | string | [string, any] | PartialDeep; type ListIteratorTypeGuard = (value: T, index: number, collection: List) => value is S; // Note: key should be string, not keyof T, because the actual object may contain extra properties that were not specified in the type. type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; type ObjectIteratee = ObjectIterator | string | [string, any] | PartialDeep; - type ObjectIterateeBoolean = ObjectIterator | string | [string, any] | PartialDeep; + type ObjectIterateeBoolean = ObjectIterator | string | [string, any] | PartialDeep; type ObjectIteratorTypeGuard = (value: TObject[keyof TObject], key: string, collection: TObject) => value is S; type DictionaryIterator = ObjectIterator, TResult>; @@ -16608,7 +16609,7 @@ declare namespace _ { type NumericDictionaryIterator = (value: T, key: number, collection: NumericDictionary) => TResult; type NumericDictionaryIteratee = NumericDictionaryIterator | string | [string, any] | PartialDeep; - type NumericDictionaryIterateeBoolean = NumericDictionaryIterator | string | [string, any] | PartialDeep; + type NumericDictionaryIterateeBoolean = NumericDictionaryIterator | string | [string, any] | PartialDeep; type StringIterator = (char: string, index: number, string: string) => TResult; @@ -16624,8 +16625,8 @@ declare namespace _ { type ValueIteratee = ((value: T) => NotVoid) | string | [string, any] | PartialDeep; type ValueKeyIteratee = ((value: T, key: string) => NotVoid) | string | [string, any] | PartialDeep; - type Comparator = (a: T, b: T) => boolean | null | undefined; - type Comparator2 = (a: T1, b: T2) => boolean | null | undefined; + type Comparator = (a: T, b: T) => Boolish; + type Comparator2 = (a: T1, b: T2) => Boolish; type PropertyName = string | number; type PropertyPath = Many; From bde113c7029b291166a78a789683f2fcf110baa5 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 10:51:31 +0900 Subject: [PATCH 17/53] cleanup lint error: no-trailing-whitespace --- types/request/tslint.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/request/tslint.json b/types/request/tslint.json index 75f00111a3..c289a978d2 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -53,7 +53,6 @@ "no-var-keyword": false, "no-var-requires": false, "no-void-expression": false, - "no-trailing-whitespace": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, "one-line": false, From d1806394be5b79eb0c97a0a3afa78945eaf437b5 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 10:53:49 +0900 Subject: [PATCH 18/53] cleanup lint error: dt-header --- types/request/index.d.ts | 7 ++++++- types/request/tslint.json | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 40445d1b05..f714ab2f8c 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -1,6 +1,11 @@ // Type definitions for request 2.0 // Project: https://github.com/request/request -// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor , Joe Skeen , Christopher Currens , Jon Stevens +// Definitions by: Carlos Ballesteros Velasco , +// bonnici , +// Bart van der Schoor , +// Joe Skeen , +// Christopher Currens , +// Jon Stevens // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/request/tslint.json b/types/request/tslint.json index c289a978d2..af66a7ab0e 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -8,7 +8,6 @@ "ban-types": false, "callable-types": false, "comment-format": false, - "dt-header": false, "eofline": false, "export-just-namespace": false, "import-spacing": false, From b00a7ff72ad5f54789ad876e0dcc89958013810e Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 10:54:58 +0900 Subject: [PATCH 19/53] cleanup lint error: trim-file --- types/request/request-tests.ts | 1 - types/request/tslint.json | 1 - 2 files changed, 2 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 093a7b2b5b..ed2f05b132 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -1,4 +1,3 @@ - import request = require('request'); import http = require('http'); import stream = require('stream'); diff --git a/types/request/tslint.json b/types/request/tslint.json index af66a7ab0e..287b4ac437 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -69,7 +69,6 @@ "space-before-function-paren": false, "space-within-parens": false, "strict-export-declare-modifiers": false, - "trim-file": false, "triple-equals": false, "typedef-whitespace": false, "unified-signatures": false, From 2dde57da141f9794187c148b8a2e56ca9c7af145 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 10:57:56 +0900 Subject: [PATCH 20/53] cleanup lint error: comment-format --- types/request/index.d.ts | 4 ++-- types/request/request-tests.ts | 22 +++++++++++----------- types/request/tslint.json | 1 - 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index f714ab2f8c..4a67d198d6 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -240,8 +240,8 @@ declare namespace request { writable: boolean; getAgent(): http.Agent; - //start(): void; - //abort(): void; + // start(): void; + // abort(): void; pipeDest(dest: any): void; setHeader(name: string, value: string, clobber?: boolean): Request; setHeaders(headers: Headers): Request; diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index ed2f05b132..843ec4920e 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -32,12 +32,12 @@ var bodyArr: request.RequestPart[] = [{ body: value }]; -//Defaults tests +// Defaults tests (() => { const githubUrl = 'https://github.com'; const defaultJarRequest = request.defaults({ jar: true }); defaultJarRequest.get(githubUrl); - //defaultJarRequest(); //this line doesn't compile (and shouldn't) + // defaultJarRequest(); //this line doesn't compile (and shouldn't) const defaultUrlRequest = request.defaults({ url: githubUrl }); defaultUrlRequest(); defaultUrlRequest.get(); @@ -138,8 +138,8 @@ opt.uri = str; // --- --- --- --- --- --- --- --- --- --- --- --- agent = req.getAgent(); -//req.start(); -//req.abort(); +// req.start(); +// req.abort(); req.pipeDest(dest); req = req.setHeader(str, str); req = req.setHeader(str, str, bool); @@ -245,7 +245,7 @@ request }) .pipe(request.put('http://another.com/another.png')); -//The following examples from https://github.com/request/request +// The following examples from https://github.com/request/request request('http://www.google.com', function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body); // Show the HTML for the Google homepage. @@ -571,13 +571,13 @@ request({ } }); -//requests using baseRequest() will set the 'x-token' header +// requests using baseRequest() will set the 'x-token' header var baseRequest = request.defaults({ headers: {'x-token': 'my-token'} }); -//requests using specialRequest() will include the 'x-token' header set in -//baseRequest and will also include the 'special' header +// requests using specialRequest() will include the 'x-token' header set in +// baseRequest and will also include the 'special' header var specialRequest = baseRequest.defaults({ headers: {special: 'special value'} }); @@ -666,10 +666,10 @@ request({url: url, jar: j}, function () { request('http://images.google.com'); }); -//TODO: add definitions for tough-cookie-filestore -//var FileCookieStore = require('tough-cookie-filestore'); +// TODO: add definitions for tough-cookie-filestore +// var FileCookieStore = require('tough-cookie-filestore'); // NOTE - currently the 'cookies.json' file must already exist! -//var j = request.jar(new FileCookieStore('cookies.json')); +// var j = request.jar(new FileCookieStore('cookies.json')); requestWithJar = request.defaults({ jar : j }) request('http://www.google.com', function() { request('http://images.google.com'); diff --git a/types/request/tslint.json b/types/request/tslint.json index 287b4ac437..3ce98c0314 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -7,7 +7,6 @@ "ban-comma-operator": false, "ban-types": false, "callable-types": false, - "comment-format": false, "eofline": false, "export-just-namespace": false, "import-spacing": false, From 3c49d1b237b59f52397d90da737ea75d0eb643b4 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:03:19 +0900 Subject: [PATCH 21/53] cleanup lint error: no-padding --- types/request/index.d.ts | 11 ++++------- types/request/request-tests.ts | 12 +++--------- types/request/tslint.json | 1 - 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 4a67d198d6..6455c5752f 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -22,10 +22,8 @@ import FormData = require('form-data'); import { Url } from 'url'; declare namespace request { - export interface RequestAPI { - + export interface RequestAPI + { defaults(options: TOptions): RequestAPI; defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi; @@ -70,9 +68,8 @@ declare namespace request { } interface DefaultUriUrlRequestApi extends RequestAPI { - + TOptions extends CoreOptions, + TUriUrlOptions> extends RequestAPI { defaults(options: TOptions): DefaultUriUrlRequestApi; (callback?: RequestCallback): TRequest; diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 843ec4920e..f3d3e43a66 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -89,21 +89,15 @@ strOrTrueOrUndef = oauth.body_hash; var options: request.Options = { url: str, uri: str, - callback: (error: any, response: any, body: any) => { - - }, + callback: (error: any, response: any, body: any) => {}, jar: value, form: obj, oauth: value, aws: aws, qs: obj, json: value, - jsonReviver: (key: string, value: any) => { - - }, - jsonReplacer: (key: string, value: any) => { - - }, + jsonReviver: (key: string, value: any) => {}, + jsonReplacer: (key: string, value: any) => {}, multipart: value, agent: new http.Agent(), agentOptions: value, diff --git a/types/request/tslint.json b/types/request/tslint.json index 3ce98c0314..b69c5ab822 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -33,7 +33,6 @@ "no-misused-new": false, "no-namespace": false, "no-object-literal-type-assertion": false, - "no-padding": false, "no-redundant-jsdoc": false, "no-redundant-jsdoc-2": false, "no-redundant-undefined": false, From a3adeb702e93330d9e58ede06a537099dd68486e Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:09:29 +0900 Subject: [PATCH 22/53] Cleanup lint error: only-arrow-functions --- types/request/request-tests.ts | 68 +++++++++++++++++----------------- types/request/tslint.json | 1 - 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index f3d3e43a66..15664c98fc 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -234,13 +234,13 @@ r.post(options); request .get('http://example.com/example.png') -.on('response', function(response: any) { +.on('response', (response: any) => { // check response }) .pipe(request.put('http://another.com/another.png')); // The following examples from https://github.com/request/request -request('http://www.google.com', function (error, response, body) { +request('http://www.google.com', (error, response, body) => { if (!error && response.statusCode == 200) { console.log(body); // Show the HTML for the Google homepage. } @@ -254,7 +254,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img request .get('http://google.com/img.png') - .on('response', function(response: any) { + .on('response', (response: any) => { console.log(response.statusCode); // 200 console.log(response.headers['content-type']); // 'image/png' }) @@ -262,12 +262,12 @@ request request .get('http://mysite.com/doodle.png') - .on('error', function(err: any) { + .on('error', (err: any) => { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); -http.createServer(function (req, resp) { +http.createServer((req, resp) => { if (req.url === '/doodle.png') { if (req.method === 'PUT') { req.pipe(request.put('http://mysite.com/doodle.png')); @@ -277,7 +277,7 @@ http.createServer(function (req, resp) { } }); -http.createServer(function (req, resp) { +http.createServer((req, resp) => { if (req.url === '/doodle.png') { var x = request('http://mysite.com/doodle.png'); req.pipe(x); @@ -285,11 +285,11 @@ http.createServer(function (req, resp) { } }); -http.createServer(function (req, resp) { +http.createServer((req, resp) => { req.pipe(request('http://mysite.com/doodle.png')).pipe(resp); }); -http.createServer(function (req, resp) { +http.createServer((req, resp) => { if (req.url === '/doodle.png') { r.get('http://google.com/doodle.png').pipe(resp); } @@ -299,7 +299,7 @@ request.post('http://service.com/upload', {form:{key:'value'}}); // or request.post('http://service.com/upload').form({key:'value'}); // or -request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }); +request.post({url:'http://service.com/upload', form: {key:'value'}}, (err,httpResponse,body) => { /* ... */ }); var data = { // Pass a simple key-value pair @@ -353,7 +353,7 @@ request({ ] } }, - function (error, response, body) { + (error, response, body) => { if (error) { return console.error('upload failed:', error); } @@ -373,7 +373,7 @@ request({ { body: fs.createReadStream('image.png') } ] }, - function (error, response, body) { + (error, response, body) => { if (error) { return console.error('upload failed:', error); } @@ -408,7 +408,7 @@ var username = 'username', password = 'password', url = 'http://' + username + ':' + password + '@some.server.com'; -request({url: url}, function (error, response, body) { +request({url: url}, (error, response, body) => { // Do more stuff with 'body' here }); @@ -442,7 +442,7 @@ oauth = } , url = 'https://api.twitter.com/oauth/request_token' ; -request.post({url:url, oauth:oauth}, function (e, r, body) { +request.post({url:url, oauth:oauth}, (e, r, body) => { // Ideally, you would take the body in the response // and construct a URL that a user clicks on (like a sign in button). // The verifier is only available in the response after a user has @@ -466,7 +466,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { } , url = 'https://api.twitter.com/oauth/access_token' ; - request.post({url:url, oauth:oauth}, function (e, r, body) { + request.post({url:url, oauth:oauth}, (e, r, body) => { // ready to make signed requests on behalf of the user var perm_data: any = qs.parse(body); var oauth = @@ -480,7 +480,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { screen_name: perm_data.screen_name, user_id: perm_data.user_id }; - request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { + request.get({url:url, oauth:oauth, qs:query, json:true}, (e, r, user) => { console.log(user); }); }); @@ -577,7 +577,7 @@ var specialRequest = baseRequest.defaults({ }); const urlRequest = specialRequest.defaults({url: 'https://github.com'}); -urlRequest({}, function(error, response, body) {console.log(body);}); +urlRequest({}, (error, response, body) => {console.log(body);}); request.put(url); request.patch(url); @@ -590,7 +590,7 @@ request.cookie('key1=value1'); request.jar(); request.debug = true; -request.get('http://10.255.255.1', {timeout: 1500}, function(err) { +request.get('http://10.255.255.1', {timeout: 1500}, (err) => { console.log(err.code === 'ETIMEDOUT'); // Set to `true` if the timeout was a connection timeout, `false` or // `undefined` otherwise. @@ -609,7 +609,7 @@ var rand = Math.floor(Math.random()*100000000).toString(); , { body: 'I am an attachment' } ] } - , function (error, response, body) { + , (error, response, body) => { if(response.statusCode == 201){ console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) } else { @@ -624,31 +624,31 @@ request( , uri: 'http://www.google.com' , gzip: true } - , function (error, response, body) { + , (error, response, body) => { // body is the decompressed response body console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) console.log('the decoded data is: ' + body) } - ).on('data', function(data: any) { + ).on('data', (data: any) => { // decompressed data as it is received console.log('decoded chunk: ' + data) }) - .on('response', function(response: http.IncomingMessage) { + .on('response', (response: http.IncomingMessage) => { // unmodified http.IncomingMessage object - response.on('data', function(data: any[]) { + response.on('data', (data: any[]) => { // compressed data as it is received console.log('received ' + data.length + ' bytes of compressed data') }) }); var requestWithJar = request.defaults({jar: true}) -requestWithJar('http://www.google.com', function () { +requestWithJar('http://www.google.com', () => { requestWithJar('http://images.google.com'); }); var j = request.jar() requestWithJar = request.defaults({jar:j}) -requestWithJar('http://www.google.com', function () { +requestWithJar('http://www.google.com', () => { requestWithJar('http://images.google.com'); }); @@ -656,7 +656,7 @@ var j = request.jar(); cookie = request.cookie('key1=value1'); var url = 'http://www.google.com'; j.setCookie(cookie, url); -request({url: url, jar: j}, function () { +request({url: url, jar: j}, () => { request('http://images.google.com'); }); @@ -665,12 +665,12 @@ request({url: url, jar: j}, function () { // NOTE - currently the 'cookies.json' file must already exist! // var j = request.jar(new FileCookieStore('cookies.json')); requestWithJar = request.defaults({ jar : j }) -request('http://www.google.com', function() { +request('http://www.google.com', () => { request('http://images.google.com'); }); var j = request.jar() -request({url: 'http://www.google.com', jar: j}, function () { +request({url: 'http://www.google.com', jar: j}, () => { var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." var cookies = j.getCookies(url); // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] @@ -682,11 +682,11 @@ request( , gzip: true } ) - .on('request', function(req: http.ClientRequest) { }) - .on('response', function(resp: http.IncomingMessage) { }) - .on('data', function(data: Buffer | string) { }) - .on('error', function(e: Error) { }) - .on('complete', function(resp: http.IncomingMessage, body?: string | Buffer) { }); + .on('request', (req: http.ClientRequest) => { }) + .on('response', (resp: http.IncomingMessage) => { }) + .on('data', (data: Buffer | string) => { }) + .on('error', (e: Error) => { }) + .on('complete', (resp: http.IncomingMessage, body?: string | Buffer) => { }); // options.url / options.uri can be the Url object request.get({ @@ -713,11 +713,11 @@ requestWithOptionalUri({ url: urlModule.parse('http://example.com') }); requestWithOptionalUri('http://example.com'); -requestWithOptionalUri(function() {}); +requestWithOptionalUri(() => {}); requestWithOptionalUri.get(); -requestWithOptionalUri.get(function() {}); +requestWithOptionalUri.get(() => {}); requestWithOptionalUri.get('http://example.com'); diff --git a/types/request/tslint.json b/types/request/tslint.json index b69c5ab822..a37883fcfa 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -54,7 +54,6 @@ "object-literal-shorthand": false, "one-line": false, "one-variable-per-declaration": false, - "only-arrow-functions": false, "prefer-conditional-expression": false, "prefer-const": false, "prefer-declare-function": false, From 0339b28f8047e7cf5753422e381e499871f73646 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:13:49 +0900 Subject: [PATCH 23/53] cleanup lint error: one-line --- types/request/index.d.ts | 3 +-- types/request/request-tests.ts | 45 +++++++++++++++++----------------- types/request/tslint.json | 1 - 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 6455c5752f..dbe65da3a5 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -22,8 +22,7 @@ import FormData = require('form-data'); import { Url } from 'url'; declare namespace request { - export interface RequestAPI - { + export interface RequestAPI { defaults(options: TOptions): RequestAPI; defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi; diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 15664c98fc..7f57dc8946 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -434,14 +434,14 @@ request(options, callback); import qs = require('querystring'); const CONSUMER_KEY = 'key'; const CONSUMER_SECRET = 'secret'; -oauth = - { callback: 'http://mysite.com/callback/' - , consumer_key: CONSUMER_KEY - , consumer_secret: CONSUMER_SECRET - , transport_method: 'header' +oauth = { + callback: 'http://mysite.com/callback/', + consumer_key: CONSUMER_KEY, + consumer_secret: CONSUMER_SECRET, + transport_method: 'header' } - , url = 'https://api.twitter.com/oauth/request_token' - ; + , url = 'https://api.twitter.com/oauth/request_token'; + request.post({url:url, oauth:oauth}, (e, r, body) => { // Ideally, you would take the body in the response // and construct a URL that a user clicks on (like a sign in button). @@ -457,24 +457,23 @@ request.post({url:url, oauth:oauth}, (e, r, body) => { // step 3 // after the user is redirected back to your server var auth_data: any = qs.parse(body) - , oauth = - { consumer_key: CONSUMER_KEY - , consumer_secret: CONSUMER_SECRET - , token: auth_data.oauth_token - , token_secret: req_data.oauth_token_secret as string - , verifier: auth_data.oauth_verifier - } - , url = 'https://api.twitter.com/oauth/access_token' - ; + , oauth = { + consumer_key: CONSUMER_KEY, + consumer_secret: CONSUMER_SECRET, + token: auth_data.oauth_token, + token_secret: req_data.oauth_token_secret as string, + verifier: auth_data.oauth_verifier + }, url = 'https://api.twitter.com/oauth/access_token'; + request.post({url:url, oauth:oauth}, (e, r, body) => { // ready to make signed requests on behalf of the user var perm_data: any = qs.parse(body); - var oauth = - { consumer_key: CONSUMER_KEY - , consumer_secret: CONSUMER_SECRET - , token: perm_data.oauth_token - , token_secret: perm_data.oauth_token_secret - }; + var oauth = { + consumer_key: CONSUMER_KEY, + consumer_secret: CONSUMER_SECRET, + token: perm_data.oauth_token, + token_secret: perm_data.oauth_token_secret + }; var url = 'https://api.twitter.com/1.1/users/show.json'; var query = { screen_name: perm_data.screen_name, @@ -610,7 +609,7 @@ var rand = Math.floor(Math.random()*100000000).toString(); ] } , (error, response, body) => { - if(response.statusCode == 201){ + if(response.statusCode == 201) { console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) } else { console.log('error: '+ response.statusCode) diff --git a/types/request/tslint.json b/types/request/tslint.json index a37883fcfa..21ab8a214b 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -52,7 +52,6 @@ "no-void-expression": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, - "one-line": false, "one-variable-per-declaration": false, "prefer-conditional-expression": false, "prefer-const": false, From 8d2da56ea51e335f0247be40f02a121750aced02 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:15:24 +0900 Subject: [PATCH 24/53] cleanup lint error: arrow-return-shorthand --- types/request/tslint.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/request/tslint.json b/types/request/tslint.json index 21ab8a214b..8f9210f781 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -3,7 +3,6 @@ "rules": { "adjacent-overload-signatures": false, "array-type": false, - "arrow-return-shorthand": false, "ban-comma-operator": false, "ban-types": false, "callable-types": false, From a2e8bfda4ea4ff040f8f589f3eb17e1b048ff2a6 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:16:35 +0900 Subject: [PATCH 25/53] cleanup lint error: ban-comma-operator --- types/request/request-tests.ts | 4 ++-- types/request/tslint.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 7f57dc8946..c6df4714f5 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -439,8 +439,8 @@ oauth = { consumer_key: CONSUMER_KEY, consumer_secret: CONSUMER_SECRET, transport_method: 'header' - } - , url = 'https://api.twitter.com/oauth/request_token'; +}; +url = 'https://api.twitter.com/oauth/request_token'; request.post({url:url, oauth:oauth}, (e, r, body) => { // Ideally, you would take the body in the response diff --git a/types/request/tslint.json b/types/request/tslint.json index 8f9210f781..013ddb155a 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -3,7 +3,6 @@ "rules": { "adjacent-overload-signatures": false, "array-type": false, - "ban-comma-operator": false, "ban-types": false, "callable-types": false, "eofline": false, From 7439f6d08fd66f54090d7e9499d54959f9fb57da Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:20:34 +0900 Subject: [PATCH 26/53] cleanup lint errors: whitespace, typedef-whitespace, space-within-parens, space-before-function-paren --- types/request/request-tests.ts | 26 +++++++++++++------------- types/request/tslint.json | 6 +----- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index c6df4714f5..54cd9c8a7a 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -295,11 +295,11 @@ http.createServer((req, resp) => { } }); -request.post('http://service.com/upload', {form:{key:'value'}}); +request.post('http://service.com/upload', {form: {key: 'value'}}); // or -request.post('http://service.com/upload').form({key:'value'}); +request.post('http://service.com/upload').form({key: 'value'}); // or -request.post({url:'http://service.com/upload', form: {key:'value'}}, (err,httpResponse,body) => { /* ... */ }); +request.post({url: 'http://service.com/upload', form: {key: 'value'}}, (err, httpResponse, body) => { /* ... */ }); var data = { // Pass a simple key-value pair @@ -324,7 +324,7 @@ var data = { } } }; -request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { +request.post({url: 'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { if (err) { return console.error('upload failed:', err); } @@ -442,7 +442,7 @@ oauth = { }; url = 'https://api.twitter.com/oauth/request_token'; -request.post({url:url, oauth:oauth}, (e, r, body) => { +request.post({url: url, oauth: oauth}, (e, r, body) => { // Ideally, you would take the body in the response // and construct a URL that a user clicks on (like a sign in button). // The verifier is only available in the response after a user has @@ -465,7 +465,7 @@ request.post({url:url, oauth:oauth}, (e, r, body) => { verifier: auth_data.oauth_verifier }, url = 'https://api.twitter.com/oauth/access_token'; - request.post({url:url, oauth:oauth}, (e, r, body) => { + request.post({url: url, oauth: oauth}, (e, r, body) => { // ready to make signed requests on behalf of the user var perm_data: any = qs.parse(body); var oauth = { @@ -479,7 +479,7 @@ request.post({url:url, oauth:oauth}, (e, r, body) => { screen_name: perm_data.screen_name, user_id: perm_data.user_id }; - request.get({url:url, oauth:oauth, qs:query, json:true}, (e, r, user) => { + request.get({url: url, oauth: oauth, qs: query, json: true}, (e, r, user) => { console.log(user); }); }); @@ -576,7 +576,7 @@ var specialRequest = baseRequest.defaults({ }); const urlRequest = specialRequest.defaults({url: 'https://github.com'}); -urlRequest({}, (error, response, body) => {console.log(body);}); +urlRequest({}, (error, response, body) => { console.log(body); }); request.put(url); request.patch(url); @@ -597,7 +597,7 @@ request.get('http://10.255.255.1', {timeout: 1500}, (err) => { process.exit(0); }); -var rand = Math.floor(Math.random()*100000000).toString(); +var rand = Math.floor(Math.random() * 100000000).toString(); request( { method: 'PUT' , uri: 'http://mikeal.iriscouch.com/testjs/' + rand @@ -609,10 +609,10 @@ var rand = Math.floor(Math.random()*100000000).toString(); ] } , (error, response, body) => { - if(response.statusCode == 201) { - console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + if (response.statusCode == 201) { + console.log('document saved as: http://mikeal.iriscouch.com/testjs/' + rand) } else { - console.log('error: '+ response.statusCode) + console.log('error: ' + response.statusCode) console.log(body) } } @@ -646,7 +646,7 @@ requestWithJar('http://www.google.com', () => { }); var j = request.jar() -requestWithJar = request.defaults({jar:j}) +requestWithJar = request.defaults({jar: j}) requestWithJar('http://www.google.com', () => { requestWithJar('http://images.google.com'); }); diff --git a/types/request/tslint.json b/types/request/tslint.json index 013ddb155a..12fdeef86a 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -60,13 +60,9 @@ "prefer-template": false, "radix": false, "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, "strict-export-declare-modifiers": false, "triple-equals": false, - "typedef-whitespace": false, "unified-signatures": false, - "void-return": false, - "whitespace": false + "void-return": false } } From fd9dffdd7c280d2071b897c09ffb477bd7fe8024 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:23:03 +0900 Subject: [PATCH 27/53] cleanup lint error: semicolon --- types/request/index.d.ts | 12 ++++++------ types/request/request-tests.ts | 26 +++++++++++++------------- types/request/tslint.json | 1 - 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index dbe65da3a5..41fcdd1b0f 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -180,7 +180,7 @@ declare namespace request { export type ResponseRequest = CoreOptions & { uri: Url; - } + }; export interface RequestResponse extends http.IncomingMessage { request: ResponseRequest; @@ -210,7 +210,7 @@ declare namespace request { postData?: { mimeType?: string; params?: NameValuePair[]; - } + }; } export interface NameValuePair { @@ -294,7 +294,7 @@ declare namespace request { token_secret?: string; transport_method?: 'body' | 'header' | 'query'; verifier?: string; - body_hash?: true | string + body_hash?: true | string; } export interface HawkOptions { @@ -307,9 +307,9 @@ declare namespace request { } export interface CookieJar { - setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void - getCookieString(uri: string | url.Url): string - getCookies(uri: string | url.Url): Cookie[] + setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void; + getCookieString(uri: string | url.Url): string; + getCookies(uri: string | url.Url): Cookie[]; } export interface CookieValue { diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 54cd9c8a7a..edf6f4b9e7 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -610,10 +610,10 @@ var rand = Math.floor(Math.random() * 100000000).toString(); } , (error, response, body) => { if (response.statusCode == 201) { - console.log('document saved as: http://mikeal.iriscouch.com/testjs/' + rand) + console.log('document saved as: http://mikeal.iriscouch.com/testjs/' + rand); } else { - console.log('error: ' + response.statusCode) - console.log(body) + console.log('error: ' + response.statusCode); + console.log(body); } } ); @@ -625,28 +625,28 @@ request( } , (error, response, body) => { // body is the decompressed response body - console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) - console.log('the decoded data is: ' + body) + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')); + console.log('the decoded data is: ' + body); } ).on('data', (data: any) => { // decompressed data as it is received - console.log('decoded chunk: ' + data) + console.log('decoded chunk: ' + data); }) .on('response', (response: http.IncomingMessage) => { // unmodified http.IncomingMessage object response.on('data', (data: any[]) => { // compressed data as it is received - console.log('received ' + data.length + ' bytes of compressed data') - }) + console.log('received ' + data.length + ' bytes of compressed data'); + }); }); -var requestWithJar = request.defaults({jar: true}) +var requestWithJar = request.defaults({jar: true}); requestWithJar('http://www.google.com', () => { requestWithJar('http://images.google.com'); }); -var j = request.jar() -requestWithJar = request.defaults({jar: j}) +var j = request.jar(); +requestWithJar = request.defaults({jar: j}); requestWithJar('http://www.google.com', () => { requestWithJar('http://images.google.com'); }); @@ -663,12 +663,12 @@ request({url: url, jar: j}, () => { // var FileCookieStore = require('tough-cookie-filestore'); // NOTE - currently the 'cookies.json' file must already exist! // var j = request.jar(new FileCookieStore('cookies.json')); -requestWithJar = request.defaults({ jar : j }) +requestWithJar = request.defaults({ jar : j }); request('http://www.google.com', () => { request('http://images.google.com'); }); -var j = request.jar() +var j = request.jar(); request({url: 'http://www.google.com', jar: j}, () => { var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." var cookies = j.getCookies(url); diff --git a/types/request/tslint.json b/types/request/tslint.json index 12fdeef86a..2ae43c1910 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -59,7 +59,6 @@ "prefer-switch": false, "prefer-template": false, "radix": false, - "semicolon": false, "strict-export-declare-modifiers": false, "triple-equals": false, "unified-signatures": false, From cf4b4fd2ba94d275cf3579f7dc419f8ef59afc9f Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:41:23 +0900 Subject: [PATCH 28/53] cleanup ignore errors --- types/request/tslint.json | 45 +-------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/types/request/tslint.json b/types/request/tslint.json index 2ae43c1910..34c2b940f3 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -1,67 +1,24 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, "array-type": false, "ban-types": false, "callable-types": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, "no-var-keyword": false, "no-var-requires": false, "no-void-expression": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, "one-variable-per-declaration": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, "prefer-switch": false, "prefer-template": false, - "radix": false, "strict-export-declare-modifiers": false, "triple-equals": false, - "unified-signatures": false, - "void-return": false + "unified-signatures": false } } From 0a487b74a22e90d37d181b65b420db9de398d24e Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:43:07 +0900 Subject: [PATCH 29/53] cleanup lint error: array-type --- types/request/index.d.ts | 4 ++-- types/request/tslint.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 41fcdd1b0f..6162f92fd8 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -220,10 +220,10 @@ declare namespace request { export interface Multipart { chunked?: boolean; - data?: { + data?: Array<{ 'content-type'?: string, body: string - }[]; + }>; } export interface RequestPart { diff --git a/types/request/tslint.json b/types/request/tslint.json index 34c2b940f3..f15db70fa2 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "array-type": false, "ban-types": false, "callable-types": false, "no-consecutive-blank-lines": false, From 6cffeea86458739707f7136e6144da56c6132649 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:46:03 +0900 Subject: [PATCH 30/53] cleanup lint error: prefer-switch --- types/request/request-tests.ts | 11 +++++++---- types/request/tslint.json | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index edf6f4b9e7..b7fb521ae4 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -269,10 +269,13 @@ request http.createServer((req, resp) => { if (req.url === '/doodle.png') { - if (req.method === 'PUT') { - req.pipe(request.put('http://mysite.com/doodle.png')); - } else if (req.method === 'GET' || req.method === 'HEAD') { - request.get('http://mysite.com/doodle.png').pipe(resp); + switch (req.method) { + case 'PUT': + req.pipe(request.put('http://mysite.com/doodle.png')); + break; + case 'GET': + case 'HEAD': + request.get('http://mysite.com/doodle.png').pipe(resp); } } }); diff --git a/types/request/tslint.json b/types/request/tslint.json index f15db70fa2..cf15efe562 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -14,7 +14,6 @@ "object-literal-shorthand": false, "one-variable-per-declaration": false, "prefer-const": false, - "prefer-switch": false, "prefer-template": false, "strict-export-declare-modifiers": false, "triple-equals": false, From c775fd5830583690aa86420c6d65166a1829d78a Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:49:50 +0900 Subject: [PATCH 31/53] cleanup lint error: no-void-expression --- types/request/request-tests.ts | 9 ++++++--- types/request/tslint.json | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index b7fb521ae4..c8aa9336b7 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -329,7 +329,8 @@ var data = { }; request.post({url: 'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { if (err) { - return console.error('upload failed:', err); + console.error('upload failed:', err); + return; } console.log('Upload successful! Server responded with:', body); }); @@ -358,7 +359,8 @@ request({ }, (error, response, body) => { if (error) { - return console.error('upload failed:', error); + console.error('upload failed:', error); + return; } console.log('Upload successful! Server responded with:', body); }); @@ -378,7 +380,8 @@ request({ }, (error, response, body) => { if (error) { - return console.error('upload failed:', error); + console.error('upload failed:', error); + return; } console.log('Upload successful! Server responded with:', body); }); diff --git a/types/request/tslint.json b/types/request/tslint.json index cf15efe562..c893b6b870 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -9,7 +9,6 @@ "no-misused-new": false, "no-var-keyword": false, "no-var-requires": false, - "no-void-expression": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, "one-variable-per-declaration": false, From 9e6d73176fc6fc27f3401e66fcb205c22e2f4bfe Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:54:20 +0900 Subject: [PATCH 32/53] cleanup lint error: one-variable-per-declaration --- types/request/request-tests.ts | 27 ++++++++++++++------------- types/request/tslint.json | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index c8aa9336b7..c4eb23f4a9 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -410,9 +410,9 @@ request.get('http://some.server.com/', { } }); -var username = 'username', - password = 'password', - url = 'http://' + username + ':' + password + '@some.server.com'; +let username = 'username'; +let password = 'password'; +var url = 'http://' + username + ':' + password + '@some.server.com'; request({url: url}, (error, response, body) => { // Do more stuff with 'body' here @@ -462,14 +462,15 @@ request.post({url: url, oauth: oauth}, (e, r, body) => { // step 3 // after the user is redirected back to your server - var auth_data: any = qs.parse(body) - , oauth = { + var auth_data: any = qs.parse(body); + var oauth = { consumer_key: CONSUMER_KEY, consumer_secret: CONSUMER_SECRET, token: auth_data.oauth_token, token_secret: req_data.oauth_token_secret as string, verifier: auth_data.oauth_verifier - }, url = 'https://api.twitter.com/oauth/access_token'; + }; + var url = 'https://api.twitter.com/oauth/access_token'; request.post({url: url, oauth: oauth}, (e, r, body) => { // ready to make signed requests on behalf of the user @@ -491,10 +492,10 @@ request.post({url: url, oauth: oauth}, (e, r, body) => { }); }); -var path = require('path') - , certFile = path.resolve(__dirname, 'ssl/client.crt') - , keyFile = path.resolve(__dirname, 'ssl/client.key') - , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); +var path = require('path'); +var certFile = path.resolve(__dirname, 'ssl/client.crt'); +var keyFile = path.resolve(__dirname, 'ssl/client.key'); +var caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); options = { url: 'https://api.some-server.com/', @@ -506,9 +507,9 @@ options = { request.get(options); -var path = require('path') - , certFile = path.resolve(__dirname, 'ssl/client.crt') - , keyFile = path.resolve(__dirname, 'ssl/client.key'); +var path = require('path'); +var certFile = path.resolve(__dirname, 'ssl/client.crt'); +var keyFile = path.resolve(__dirname, 'ssl/client.key'); options = { url: 'https://api.some-server.com/', diff --git a/types/request/tslint.json b/types/request/tslint.json index c893b6b870..70d8cfc55c 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -11,7 +11,6 @@ "no-var-requires": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, - "one-variable-per-declaration": false, "prefer-const": false, "prefer-template": false, "strict-export-declare-modifiers": false, From 63cf38db03218e79c23ae3d036da45d667b8494b Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 11:55:47 +0900 Subject: [PATCH 33/53] cleanup lint error: no-var-requires --- types/request/request-tests.ts | 3 +-- types/request/tslint.json | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index c4eb23f4a9..87305be7c7 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -4,6 +4,7 @@ import stream = require('stream'); import urlModule = require('url'); import fs = require('fs'); import FormData = require('form-data'); +import path = require('path'); var value: any; var str: string; @@ -492,7 +493,6 @@ request.post({url: url, oauth: oauth}, (e, r, body) => { }); }); -var path = require('path'); var certFile = path.resolve(__dirname, 'ssl/client.crt'); var keyFile = path.resolve(__dirname, 'ssl/client.key'); var caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); @@ -507,7 +507,6 @@ options = { request.get(options); -var path = require('path'); var certFile = path.resolve(__dirname, 'ssl/client.crt'); var keyFile = path.resolve(__dirname, 'ssl/client.key'); diff --git a/types/request/tslint.json b/types/request/tslint.json index 70d8cfc55c..2fa77ee874 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -8,7 +8,6 @@ "no-inferrable-types": false, "no-misused-new": false, "no-var-keyword": false, - "no-var-requires": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, "prefer-const": false, From 964a5b5515062c83d60cb91726422dcaa7594e88 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 12:13:40 +0900 Subject: [PATCH 34/53] cleanup lint error: prefer-template --- types/request/request-tests.ts | 7 +++---- types/request/tslint.json | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 87305be7c7..ef47ebeb3d 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -413,7 +413,7 @@ request.get('http://some.server.com/', { let username = 'username'; let password = 'password'; -var url = 'http://' + username + ':' + password + '@some.server.com'; +var url = `http://'${username}:${password}'@some.server.com`; request({url: url}, (error, response, body) => { // Do more stuff with 'body' here @@ -457,8 +457,7 @@ request.post({url: url, oauth: oauth}, (e, r, body) => { // step 2 var req_data = qs.parse(body); - var uri = 'https://api.twitter.com/oauth/authenticate' - + '?' + qs.stringify({oauth_token: req_data.oauth_token}); + var uri = `https://api.twitter.com/oauth/authenticate?${qs.stringify({oauth_token: req_data.oauth_token})}`; // redirect the user to the authorize uri // step 3 @@ -642,7 +641,7 @@ request( // unmodified http.IncomingMessage object response.on('data', (data: any[]) => { // compressed data as it is received - console.log('received ' + data.length + ' bytes of compressed data'); + console.log(`received ${data.length} bytes of compressed data`); }); }); diff --git a/types/request/tslint.json b/types/request/tslint.json index 2fa77ee874..26b488e3d9 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -11,7 +11,6 @@ "object-literal-key-quotes": false, "object-literal-shorthand": false, "prefer-const": false, - "prefer-template": false, "strict-export-declare-modifiers": false, "triple-equals": false, "unified-signatures": false From 0e3e3e4c81e5a57d5f0620ebe970c0cbc75e6a7f Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 12:20:55 +0900 Subject: [PATCH 35/53] cleanup lint error: triple-equals --- types/request/request-tests.ts | 6 +++--- types/request/tslint.json | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index ef47ebeb3d..8053f874ee 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -242,7 +242,7 @@ request // The following examples from https://github.com/request/request request('http://www.google.com', (error, response, body) => { - if (!error && response.statusCode == 200) { + if (!error && response.statusCode === 200) { console.log(body); // Show the HTML for the Google homepage. } }); @@ -427,7 +427,7 @@ options = { }; function callback(error: any, response: http.IncomingMessage, body: string) { - if (!error && response.statusCode == 200) { + if (!error && response.statusCode === 200) { var info = JSON.parse(body); console.log(info.stargazers_count + " Stars"); console.log(info.forks_count + " Forks"); @@ -614,7 +614,7 @@ var rand = Math.floor(Math.random() * 100000000).toString(); ] } , (error, response, body) => { - if (response.statusCode == 201) { + if (response.statusCode === 201) { console.log('document saved as: http://mikeal.iriscouch.com/testjs/' + rand); } else { console.log('error: ' + response.statusCode); diff --git a/types/request/tslint.json b/types/request/tslint.json index 26b488e3d9..8a08c7137a 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -12,7 +12,6 @@ "object-literal-shorthand": false, "prefer-const": false, "strict-export-declare-modifiers": false, - "triple-equals": false, "unified-signatures": false } } From fb7564f1c09130fc056318913ed54f727af4726a Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 12:22:26 +0900 Subject: [PATCH 36/53] cleanup lint error: no-consecutive-blank-lines --- types/request/request-tests.ts | 2 -- types/request/tslint.json | 1 - 2 files changed, 3 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 8053f874ee..761ef45ebb 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -48,7 +48,6 @@ var bodyArr: request.RequestPart[] = [{ defaultBodyRequest.put(); })(); - // --- --- --- --- --- --- --- --- --- --- --- --- obj = req.toJSON(); @@ -537,7 +536,6 @@ request.get({ } }); - request({ // will be ignored method: 'GET', diff --git a/types/request/tslint.json b/types/request/tslint.json index 8a08c7137a..b3f1287bb8 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -3,7 +3,6 @@ "rules": { "ban-types": false, "callable-types": false, - "no-consecutive-blank-lines": false, "no-duplicate-variable": false, "no-inferrable-types": false, "no-misused-new": false, From ee5526f8620930643294c9f5a08e4e5675a307c7 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 12:25:29 +0900 Subject: [PATCH 37/53] cleanup lint error: callable-types --- types/request/index.d.ts | 4 +--- types/request/tslint.json | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 6162f92fd8..20ad40e64e 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -174,9 +174,7 @@ declare namespace request { export type OptionsWithUrl = UrlOptions & CoreOptions; export type Options = OptionsWithUri | OptionsWithUrl; - export interface RequestCallback { - (error: any, response: RequestResponse, body: any): void; - } + export type RequestCallback = (error: any, response: RequestResponse, body: any) => void; export type ResponseRequest = CoreOptions & { uri: Url; diff --git a/types/request/tslint.json b/types/request/tslint.json index b3f1287bb8..91824c6ac1 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -2,7 +2,6 @@ "extends": "dtslint/dt.json", "rules": { "ban-types": false, - "callable-types": false, "no-duplicate-variable": false, "no-inferrable-types": false, "no-misused-new": false, From fd1c81d5df844a54fffce582b754ba871b50a8e1 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 30 Oct 2017 12:31:52 +0900 Subject: [PATCH 38/53] cleanup lint error: object-literal-key-quotes --- types/request/request-tests.ts | 22 +++++++++++----------- types/request/tslint.json | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 761ef45ebb..d2c308ed75 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -351,7 +351,7 @@ request({ data: [ { 'content-type': 'application/json', - body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, content_type: 'text/plain' }}}) }, { body: 'I am an attachment' } ] @@ -372,7 +372,7 @@ request({ multipart: [ { headers: { 'content-type': 'application/json' }, - body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, content_type: 'text/plain' }}}) }, { body: 'I am an attachment' }, { body: fs.createReadStream('image.png') } @@ -389,24 +389,24 @@ request({ request.get('http://some.server.com/').auth('username', 'password', false); // or request.get('http://some.server.com/', { - 'auth': { - 'user': 'username', - 'pass': 'password', - 'sendImmediately': false + auth: { + user: 'username', + pass: 'password', + sendImmediately: false } }); // or request.get('http://some.server.com/').auth('foo', 'bar', true, 'bearerToken'); // or request.get('http://some.server.com/', { - 'auth': { - 'bearer': 'bearerToken' + auth: { + bearer: 'bearerToken' } }); // or request.get('http://some.server.com/', { - 'auth': { - 'bearer': () => 'bearerToken' + auth: { + bearer: () => 'bearerToken' } }); @@ -606,7 +606,7 @@ var rand = Math.floor(Math.random() * 100000000).toString(); , uri: 'http://mikeal.iriscouch.com/testjs/' + rand , multipart: [ { headers: { 'content-type': 'application/json' } - , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, content_type: 'text/plain' }}}) } , { body: 'I am an attachment' } ] diff --git a/types/request/tslint.json b/types/request/tslint.json index 91824c6ac1..7f1cf14897 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -6,7 +6,6 @@ "no-inferrable-types": false, "no-misused-new": false, "no-var-keyword": false, - "object-literal-key-quotes": false, "object-literal-shorthand": false, "prefer-const": false, "strict-export-declare-modifiers": false, From 3247c06c5835654995f73b5f98cbc5e3e0da3e8c Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Mon, 30 Oct 2017 14:01:04 +0300 Subject: [PATCH 39/53] Added types for lil-uuid --- types/lil-uuid/index.d.ts | 19 +++++++++++++++++++ types/lil-uuid/lil-uuid-tests.ts | 4 ++++ types/lil-uuid/tsconfig.json | 23 +++++++++++++++++++++++ types/lil-uuid/tslint.json | 1 + 4 files changed, 47 insertions(+) create mode 100644 types/lil-uuid/index.d.ts create mode 100644 types/lil-uuid/lil-uuid-tests.ts create mode 100644 types/lil-uuid/tsconfig.json create mode 100644 types/lil-uuid/tslint.json diff --git a/types/lil-uuid/index.d.ts b/types/lil-uuid/index.d.ts new file mode 100644 index 0000000000..fb0a783142 --- /dev/null +++ b/types/lil-uuid/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for lil-uuid 0.1 +// Project: https://github.com/lil-js/uuid +// Definitions by: Pr1st0n +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Generate a random UUID + * + * @returns UUID string. + */ +export function uuid(): string; + +/** + * Check if a given string has a valid UUID format. It supports multiple version (3, 4 and 5). + * + * @param uuid UUID string. + * @returns True if string is valid UUID, false otherwise. + */ +export function isUUID(uuid: string): boolean; diff --git a/types/lil-uuid/lil-uuid-tests.ts b/types/lil-uuid/lil-uuid-tests.ts new file mode 100644 index 0000000000..8b39216e67 --- /dev/null +++ b/types/lil-uuid/lil-uuid-tests.ts @@ -0,0 +1,4 @@ +import * as lil from 'lil-uuid'; + +lil.uuid(); +lil.isUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479'); diff --git a/types/lil-uuid/tsconfig.json b/types/lil-uuid/tsconfig.json new file mode 100644 index 0000000000..889bd07cca --- /dev/null +++ b/types/lil-uuid/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lil-uuid-tests.ts" + ] +} diff --git a/types/lil-uuid/tslint.json b/types/lil-uuid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/lil-uuid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 27fbaeb543e330df20447038034a5194e8e8ae21 Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Mon, 30 Oct 2017 14:51:32 +0300 Subject: [PATCH 40/53] Removed accidentally added typings. --- types/lil-uuid/index.d.ts | 19 ------------------- types/lil-uuid/lil-uuid-tests.ts | 4 ---- types/lil-uuid/tsconfig.json | 23 ----------------------- types/lil-uuid/tslint.json | 1 - 4 files changed, 47 deletions(-) delete mode 100644 types/lil-uuid/index.d.ts delete mode 100644 types/lil-uuid/lil-uuid-tests.ts delete mode 100644 types/lil-uuid/tsconfig.json delete mode 100644 types/lil-uuid/tslint.json diff --git a/types/lil-uuid/index.d.ts b/types/lil-uuid/index.d.ts deleted file mode 100644 index fb0a783142..0000000000 --- a/types/lil-uuid/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Type definitions for lil-uuid 0.1 -// Project: https://github.com/lil-js/uuid -// Definitions by: Pr1st0n -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/** - * Generate a random UUID - * - * @returns UUID string. - */ -export function uuid(): string; - -/** - * Check if a given string has a valid UUID format. It supports multiple version (3, 4 and 5). - * - * @param uuid UUID string. - * @returns True if string is valid UUID, false otherwise. - */ -export function isUUID(uuid: string): boolean; diff --git a/types/lil-uuid/lil-uuid-tests.ts b/types/lil-uuid/lil-uuid-tests.ts deleted file mode 100644 index 8b39216e67..0000000000 --- a/types/lil-uuid/lil-uuid-tests.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as lil from 'lil-uuid'; - -lil.uuid(); -lil.isUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479'); diff --git a/types/lil-uuid/tsconfig.json b/types/lil-uuid/tsconfig.json deleted file mode 100644 index 889bd07cca..0000000000 --- a/types/lil-uuid/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "lil-uuid-tests.ts" - ] -} diff --git a/types/lil-uuid/tslint.json b/types/lil-uuid/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/lil-uuid/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From 62d3afb1e94602bf16d7b0b48da95a3c3f8cd2cf Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Mon, 30 Oct 2017 19:50:58 -0400 Subject: [PATCH 41/53] Use boolean instead of Boolish --- types/lodash/index.d.ts | 23 +++++++++++------------ types/lodash/lodash-tests.ts | 9 --------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 408e45a266..12e4b0c584 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -4321,7 +4321,7 @@ declare namespace _ { */ filter( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -4363,7 +4363,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -4405,7 +4405,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -6458,7 +6458,7 @@ declare namespace _ { */ reject( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -6484,7 +6484,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -6510,7 +6510,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -16590,17 +16590,16 @@ declare namespace _ { } type NotVoid = {} | null | undefined; - type Boolish = boolean | null | undefined; type ArrayIterator = (value: T, index: number, collection: T[]) => TResult; type ListIterator = (value: T, index: number, collection: List) => TResult; type ListIteratee = ListIterator | string | [string, any] | PartialDeep; - type ListIterateeBoolean = ListIterator | string | [string, any] | PartialDeep; + type ListIterateeBoolean = ListIterator | string | [string, any] | PartialDeep; type ListIteratorTypeGuard = (value: T, index: number, collection: List) => value is S; // Note: key should be string, not keyof T, because the actual object may contain extra properties that were not specified in the type. type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; type ObjectIteratee = ObjectIterator | string | [string, any] | PartialDeep; - type ObjectIterateeBoolean = ObjectIterator | string | [string, any] | PartialDeep; + type ObjectIterateeBoolean = ObjectIterator | string | [string, any] | PartialDeep; type ObjectIteratorTypeGuard = (value: TObject[keyof TObject], key: string, collection: TObject) => value is S; type DictionaryIterator = ObjectIterator, TResult>; @@ -16609,7 +16608,7 @@ declare namespace _ { type NumericDictionaryIterator = (value: T, key: number, collection: NumericDictionary) => TResult; type NumericDictionaryIteratee = NumericDictionaryIterator | string | [string, any] | PartialDeep; - type NumericDictionaryIterateeBoolean = NumericDictionaryIterator | string | [string, any] | PartialDeep; + type NumericDictionaryIterateeBoolean = NumericDictionaryIterator | string | [string, any] | PartialDeep; type StringIterator = (char: string, index: number, string: string) => TResult; @@ -16625,8 +16624,8 @@ declare namespace _ { type ValueIteratee = ((value: T) => NotVoid) | string | [string, any] | PartialDeep; type ValueKeyIteratee = ((value: T, key: string) => NotVoid) | string | [string, any] | PartialDeep; - type Comparator = (a: T, b: T) => Boolish; - type Comparator2 = (a: T1, b: T2) => Boolish; + type Comparator = (a: T, b: T) => boolean; + type Comparator2 = (a: T1, b: T2) => boolean; type PropertyName = string | number; type PropertyPath = Many; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 338d66ced5..a108df685e 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -689,12 +689,7 @@ namespace TestDifferenceBy { const t1: T1 = { a: 'a', b: 'b' }; const t2: T2 | undefined = any; - const comparator = (a: T1, b: T2 | undefined): boolean | undefined => { - return b && a.a === b.a; - }; - // $ExpectType T1[] - _.differenceWith([t1], [t2], comparator); // $ExpectType T1[] _.differenceWith([t1], [t2], (a, b) => { a; // $ExpectType T1 @@ -702,8 +697,6 @@ namespace TestDifferenceBy { return true; }); - // $ExpectType LoDashImplicitWrapper - _([t1]).differenceWith([t2], comparator); // $ExpectType LoDashImplicitWrapper _([t1]).differenceWith([t2], (a, b) => { a; // $ExpectType T1 @@ -711,8 +704,6 @@ namespace TestDifferenceBy { return true; }); - // $ExpectType LoDashExplicitWrapper - _.chain([t1]).differenceWith([t2], comparator); // $ExpectType LoDashExplicitWrapper _.chain([t1]).differenceWith([t2], (a, b) => { a; // $ExpectType T1 From e26351b49f9788a8c6466f992e9cb9483f32069b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=BCrmann?= Date: Tue, 31 Oct 2017 13:19:46 +0100 Subject: [PATCH 42/53] Ramda: Enable return type polymorphism for min/max --- types/ramda/index.d.ts | 8 ++++---- types/ramda/ramda-tests.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index f0c95c7a8c..58994ef28a 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -974,8 +974,8 @@ declare namespace R { /** * Returns the larger of its two arguments. */ - max(a: Ord, b: Ord): Ord; - max(a: Ord): (b: Ord) => Ord; + max(a: T, b: T): T; + max(a: T): (b: T) => T; /** * Takes a function and two values, and returns whichever value produces @@ -1077,8 +1077,8 @@ declare namespace R { /** * Returns the smaller of its two arguments. */ - min(a: Ord, b: Ord): Ord; - min(a: Ord): (b: Ord) => Ord; + min(a: T, b: T): T; + min(a: T): (b: T) => T; /** * Takes a function and two values, and returns whichever value produces diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 2ce8bae2ca..7b8de33aa6 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -1982,8 +1982,8 @@ class Rectangle { }; () => { - const x: R.Ord = R.max(7, 3); // => 7 - const y: R.Ord = R.max("a", "z"); // => 'z' + const x: number = R.max(7, 3); // => 7 + const y: string = R.max("a", "z"); // => 'z' }; () => { @@ -2013,8 +2013,8 @@ class Rectangle { }; () => { - const x: R.Ord = R.min(9, 3); // => 3 - const y: R.Ord = R.min("a", "z"); // => 'a' + const x: number = R.min(9, 3); // => 3 + const y: string = R.min("a", "z"); // => 'a' }; () => { From 13d697eefa2ba8b9f78923b7fac9039272c8244d Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Wed, 1 Nov 2017 07:05:17 -0400 Subject: [PATCH 43/53] Force lists to have the same type if iteratee/comparator is not specified --- types/lodash/index.d.ts | 427 +++++++++++++++++++++++++++-------- types/lodash/lodash-tests.ts | 156 ++++++------- 2 files changed, 417 insertions(+), 166 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 12e4b0c584..d666919403 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -582,8 +582,8 @@ declare namespace _ { */ differenceBy( array: List | null | undefined, - values?: List, - iteratee?: ValueIteratee + values: List, + iteratee: ValueIteratee ): T1[]; /** @@ -593,7 +593,7 @@ declare namespace _ { array: List | null | undefined, values1: List, values2: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): T1[]; /** @@ -604,7 +604,7 @@ declare namespace _ { values1: List, values2: List, values3: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): T1[]; /** @@ -616,7 +616,7 @@ declare namespace _ { values2: List, values3: List, values4: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): T1[]; /** @@ -629,7 +629,20 @@ declare namespace _ { values3: List, values4: List, values5: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee + ): T1[]; + + /** + * @see _.differenceBy + */ + differenceBy( + array: List | null | undefined, + values1: List, + values2: List, + values3: List, + values4: List, + values5: List, + ...values: Array | ValueIteratee> ): T1[]; /** @@ -637,7 +650,7 @@ declare namespace _ { */ differenceBy( array: List | null | undefined, - ...values: any[] + ...values: Array> ): T[]; } @@ -647,8 +660,8 @@ declare namespace _ { */ differenceBy( this: LoDashImplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee + values: List, + iteratee: ValueIteratee ): LoDashImplicitWrapper; /** @@ -658,7 +671,7 @@ declare namespace _ { this: LoDashImplicitWrapper | null | undefined>, values1: List, values2: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): LoDashImplicitWrapper; /** @@ -669,7 +682,7 @@ declare namespace _ { values1: List, values2: List, values3: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): LoDashImplicitWrapper; /** @@ -681,7 +694,7 @@ declare namespace _ { values2: List, values3: List, values4: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): LoDashImplicitWrapper; /** @@ -694,7 +707,20 @@ declare namespace _ { values3: List, values4: List, values5: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee + ): LoDashImplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + values4: List, + values5: List, + ...values: Array | ValueIteratee> ): LoDashImplicitWrapper; /** @@ -702,7 +728,7 @@ declare namespace _ { */ differenceBy( this: LoDashImplicitWrapper | null | undefined>, - ...values: any[] + ...values: Array> ): LoDashImplicitWrapper; } @@ -712,8 +738,8 @@ declare namespace _ { */ differenceBy( this: LoDashExplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee + values: List, + iteratee: ValueIteratee ): LoDashExplicitWrapper; /** @@ -723,7 +749,7 @@ declare namespace _ { this: LoDashExplicitWrapper | null | undefined>, values1: List, values2: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): LoDashExplicitWrapper; /** @@ -734,7 +760,7 @@ declare namespace _ { values1: List, values2: List, values3: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): LoDashExplicitWrapper; /** @@ -746,7 +772,7 @@ declare namespace _ { values2: List, values3: List, values4: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee ): LoDashExplicitWrapper; /** @@ -759,7 +785,20 @@ declare namespace _ { values3: List, values4: List, values5: List, - iteratee?: ValueIteratee + iteratee: ValueIteratee + ): LoDashExplicitWrapper; + + /** + * @see _.differenceBy + */ + differenceBy( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + values3: List, + values4: List, + values5: List, + ...values: Array | ValueIteratee> ): LoDashExplicitWrapper; /** @@ -767,7 +806,7 @@ declare namespace _ { */ differenceBy( this: LoDashExplicitWrapper | null | undefined>, - ...values: any[] + ...values: Array> ): LoDashExplicitWrapper; } @@ -791,17 +830,37 @@ declare namespace _ { */ differenceWith( array: List | null | undefined, - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): T1[]; /** * @see _.differenceWith */ - differenceWith( + differenceWith( array: List | null | undefined, - ...values: Array | Comparator2>, + values1: List, + values2: List, + comparator: Comparator2 ): T1[]; + + /** + * @see _.differenceWith + */ + differenceWith( + array: List | null | undefined, + values1: List, + values2: List, + ...values: Array | Comparator2> + ): T1[]; + + /** + * @see _.differenceWith + */ + differenceWith( + array: List | null | undefined, + ...values: Array> + ): T[]; } interface LoDashImplicitWrapper { @@ -810,17 +869,37 @@ declare namespace _ { */ differenceWith( this: LoDashImplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): LoDashImplicitWrapper; /** * @see _.differenceWith */ - differenceWith( + differenceWith( this: LoDashImplicitWrapper | null | undefined>, - ...values: Array | Comparator2>, + values1: List, + values2: List, + comparator: Comparator2 ): LoDashImplicitWrapper; + + /** + * @see _.differenceWith + */ + differenceWith( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + ...values: Array | Comparator2> + ): LoDashImplicitWrapper; + + /** + * @see _.differenceWith + */ + differenceWith( + this: LoDashImplicitWrapper | null | undefined>, + ...values: Array> + ): LoDashImplicitWrapper; } interface LoDashExplicitWrapper { @@ -829,17 +908,37 @@ declare namespace _ { */ differenceWith( this: LoDashExplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): LoDashExplicitWrapper; /** * @see _.differenceWith */ - differenceWith( + differenceWith( this: LoDashExplicitWrapper | null | undefined>, - ...values: Array | Comparator2>, + values1: List, + values2: List, + comparator: Comparator2 ): LoDashExplicitWrapper; + + /** + * @see _.differenceWith + */ + differenceWith( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + ...values: Array | Comparator2> + ): LoDashExplicitWrapper; + + /** + * @see _.differenceWith + */ + differenceWith( + this: LoDashExplicitWrapper | null | undefined>, + ...values: Array> + ): LoDashExplicitWrapper; } //_.drop @@ -1581,18 +1680,38 @@ declare namespace _ { * // => [{ 'x': 1 }] */ intersectionBy( - array?: List | null, - values?: List, - iteratee?: ValueIteratee + array: List | null, + values: List, + iteratee: ValueIteratee ): T1[]; /** * @see _.intersectionBy */ - intersectionBy( - array: List | null | undefined, - ...values: Array | ValueIteratee>, + intersectionBy( + array: List | null, + values1: List, + values2: List, + iteratee: ValueIteratee ): T1[]; + + /** + * @see _.intersectionBy + */ + intersectionBy( + array: List | null | undefined, + values1: List, + values2: List, + ...values: Array | ValueIteratee> + ): T1[]; + + /** + * @see _.intersectionBy + */ + intersectionBy( + array?: List | null | undefined, + ...values: Array> + ): T[]; } interface LoDashImplicitWrapper { @@ -1601,17 +1720,37 @@ declare namespace _ { */ intersectionBy( this: LoDashImplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee + values: List, + iteratee: ValueIteratee ): LoDashImplicitWrapper; /** * @see _.intersectionBy */ - intersectionBy( + intersectionBy( this: LoDashImplicitWrapper | null | undefined>, - ...values: Array | ValueIteratee>, + values1: List, + values2: List, + iteratee: ValueIteratee ): LoDashImplicitWrapper; + + /** + * @see _.intersectionBy + */ + intersectionBy( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + ...values: Array | ValueIteratee> + ): LoDashImplicitWrapper; + + /** + * @see _.intersectionBy + */ + intersectionBy( + this: LoDashImplicitWrapper | null | undefined>, + ...values: Array> + ): LoDashImplicitWrapper; } interface LoDashExplicitWrapper { @@ -1620,17 +1759,37 @@ declare namespace _ { */ intersectionBy( this: LoDashExplicitWrapper | null | undefined>, - values?: List, - iteratee?: ValueIteratee + values: List, + iteratee: ValueIteratee ): LoDashExplicitWrapper; /** * @see _.intersectionBy */ - intersectionBy( + intersectionBy( this: LoDashExplicitWrapper | null | undefined>, - ...values: Array | ValueIteratee>, + values1: List, + values2: List, + iteratee: ValueIteratee ): LoDashExplicitWrapper; + + /** + * @see _.intersectionBy + */ + intersectionBy( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + ...values: Array | ValueIteratee> + ): LoDashExplicitWrapper; + + /** + * @see _.intersectionBy + */ + intersectionBy( + this: LoDashExplicitWrapper | null | undefined>, + ...values: Array> + ): LoDashExplicitWrapper; } //_.intersectionWith @@ -1654,17 +1813,37 @@ declare namespace _ { */ intersectionWith( array: List | null | undefined, - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): T1[]; /** - * @see _.differenceWith + * @see _.intersectionWith */ - intersectionWith( + intersectionWith( array: List | null | undefined, - ...values: Array | Comparator2>, + values1: List, + values2: List, + comparator: Comparator2 ): T1[]; + + /** + * @see _.intersectionWith + */ + intersectionWith( + array: List | null | undefined, + values1: List, + values2: List, + ...values: Array | Comparator2> + ): T1[]; + + /** + * @see _.intersectionWith + */ + intersectionWith( + array?: List | null | undefined, + ...values: Array> + ): T[]; } interface LoDashImplicitWrapper { @@ -1673,17 +1852,37 @@ declare namespace _ { */ intersectionWith( this: LoDashImplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): LoDashImplicitWrapper; /** * @see _.intersectionWith */ - intersectionWith( + intersectionWith( this: LoDashImplicitWrapper | null | undefined>, - ...values: Array | Comparator2>, + values1: List, + values2: List, + comparator: Comparator2 ): LoDashImplicitWrapper; + + /** + * @see _.intersectionWith + */ + intersectionWith( + this: LoDashImplicitWrapper | null | undefined>, + values1: List, + values2: List, + ...values: Array | Comparator2>, + ): LoDashImplicitWrapper; + + /** + * @see _.intersectionWith + */ + intersectionWith( + this: LoDashImplicitWrapper | null | undefined>, + ...values: Array> + ): LoDashImplicitWrapper; } interface LoDashExplicitWrapper { @@ -1692,17 +1891,37 @@ declare namespace _ { */ intersectionWith( this: LoDashExplicitWrapper | null | undefined>, - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): LoDashExplicitWrapper; /** * @see _.intersectionWith */ - intersectionWith( + intersectionWith( this: LoDashExplicitWrapper | null | undefined>, - ...values: Array | Comparator2>, + values1: List, + values2: List, + comparator: Comparator2 ): LoDashExplicitWrapper; + + /** + * @see _.intersectionWith + */ + intersectionWith( + this: LoDashExplicitWrapper | null | undefined>, + values1: List, + values2: List, + ...values: Array | Comparator2>, + ): LoDashExplicitWrapper; + + /** + * @see _.intersectionWith + */ + intersectionWith( + this: LoDashExplicitWrapper | null | undefined>, + ...values: Array> + ): LoDashExplicitWrapper; } //_.join @@ -2025,10 +2244,28 @@ declare namespace _ { * console.log(array); * // => [{ 'x': 2 }] */ + pullAllBy( + array: T[], + values?: List, + iteratee?: ValueIteratee + ): T[]; + + /** + * @see _.pullAllBy + */ + pullAllBy( + array: List, + values?: List, + iteratee?: ValueIteratee + ): List; + + /** + * @see _.pullAllBy + */ pullAllBy( array: T1[], - values?: List, - iteratee?: ValueIteratee + values: List, + iteratee: ValueIteratee ): T1[]; /** @@ -2036,30 +2273,28 @@ declare namespace _ { */ pullAllBy( array: List, - values?: List, - iteratee?: ValueIteratee + values: List, + iteratee: ValueIteratee ): List; } - interface LoDashImplicitWrapper { + interface LoDashWrapper { /** * @see _.pullAllBy */ - pullAllBy( - this: LoDashImplicitWrapper>, - values?: List, - iteratee?: ValueIteratee + pullAllBy( + this: LoDashWrapper>, + values?: List, + iteratee?: ValueIteratee ): this; - } - interface LoDashExplicitWrapper { /** * @see _.pullAllBy */ pullAllBy( - this: LoDashExplicitWrapper>, - values?: List, - iteratee?: ValueIteratee + this: LoDashWrapper>, + values: List, + iteratee: ValueIteratee ): this; } @@ -2085,10 +2320,28 @@ declare namespace _ { * console.log(array); * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] */ + pullAllWith( + array: T[], + values?: List, + comparator?: Comparator + ): T[]; + + /** + * @see _.pullAllWith + */ + pullAllWith( + array: List, + values?: List, + comparator?: Comparator + ): List; + + /** + * @see _.pullAllWith + */ pullAllWith( array: T1[], - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): T1[]; /** @@ -2096,30 +2349,28 @@ declare namespace _ { */ pullAllWith( array: List, - values?: List, - comparator?: Comparator2 + values: List, + comparator: Comparator2 ): List; } - interface LoDashImplicitWrapper { + interface LoDashWrapper { /** * @see _.pullAllWith */ - pullAllWith( - this: LoDashImplicitWrapper>, - values?: List, - comparator?: Comparator2 + pullAllWith( + this: LoDashWrapper>, + values?: List, + comparator?: Comparator ): this; - } - interface LoDashExplicitWrapper { /** * @see _.pullAllWith */ pullAllWith( - this: LoDashExplicitWrapper>, - values?: List, - comparator?: Comparator2 + this: LoDashWrapper>, + values: List, + comparator: Comparator2 ): this; } diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index a108df685e..257fc27c16 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -305,26 +305,26 @@ namespace TestDifferenceBy { result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam); result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); - result = _.differenceBy(array, arrayParam, iteratee); - result = _.differenceBy(array, listParam, arrayParam, iteratee); - result = _.differenceBy(array, arrayParam, listParam, arrayParam, iteratee); - result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, iteratee); - result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); - result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); + result = _.differenceBy(array, arrayParam, iteratee); + result = _.differenceBy(array, listParam, arrayParam, iteratee); + result = _.differenceBy(array, arrayParam, listParam, arrayParam, iteratee); + result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, iteratee); + result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); + result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); - result = _.differenceBy(array, arrayParam, 'a'); - result = _.differenceBy(array, listParam, arrayParam, 'a'); - result = _.differenceBy(array, arrayParam, listParam, arrayParam, 'a'); - result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, 'a'); - result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); - result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); + result = _.differenceBy(array, arrayParam, 'a'); + result = _.differenceBy(array, listParam, arrayParam, 'a'); + result = _.differenceBy(array, arrayParam, listParam, arrayParam, 'a'); + result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, 'a'); + result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); + result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); result = _.differenceBy(array, arrayParam, {a: 1}); result = _.differenceBy(array, listParam, arrayParam, {a: 1}); result = _.differenceBy(array, arrayParam, listParam, arrayParam, {a: 1}); result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _.differenceBy(array, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); - result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); + result = _.differenceBy(array, listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _.differenceBy(list); result = _.differenceBy(list, listParam); @@ -334,26 +334,26 @@ namespace TestDifferenceBy { result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam); result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); - result = _.differenceBy(list, listParam, iteratee); - result = _.differenceBy(list, arrayParam, listParam, iteratee); - result = _.differenceBy(list, listParam, arrayParam, listParam, iteratee); - result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, iteratee); - result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); - result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); + result = _.differenceBy(list, listParam, iteratee); + result = _.differenceBy(list, arrayParam, listParam, iteratee); + result = _.differenceBy(list, listParam, arrayParam, listParam, iteratee); + result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, iteratee); + result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); + result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); - result = _.differenceBy(list, listParam, 'a'); - result = _.differenceBy(list, arrayParam, listParam, 'a'); - result = _.differenceBy(list, listParam, arrayParam, listParam, 'a'); - result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, 'a'); - result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); - result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); + result = _.differenceBy(list, listParam, 'a'); + result = _.differenceBy(list, arrayParam, listParam, 'a'); + result = _.differenceBy(list, listParam, arrayParam, listParam, 'a'); + result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, 'a'); + result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); + result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); result = _.differenceBy(list, listParam, {a: 1}); result = _.differenceBy(list, arrayParam, listParam, {a: 1}); result = _.differenceBy(list, listParam, arrayParam, listParam, {a: 1}); result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, {a: 1}); result = _.differenceBy(list, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); - result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); + result = _.differenceBy(list, arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); } { @@ -366,26 +366,26 @@ namespace TestDifferenceBy { result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam); result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); - result = _(array).differenceBy(arrayParam, iteratee); - result = _(array).differenceBy(listParam, arrayParam, iteratee); - result = _(array).differenceBy(arrayParam, listParam, arrayParam, iteratee); - result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, iteratee); - result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); - result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); + result = _(array).differenceBy(arrayParam, iteratee); + result = _(array).differenceBy(listParam, arrayParam, iteratee); + result = _(array).differenceBy(arrayParam, listParam, arrayParam, iteratee); + result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, iteratee); + result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); + result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); - result = _(array).differenceBy(arrayParam, 'a'); - result = _(array).differenceBy(listParam, arrayParam, 'a'); - result = _(array).differenceBy(arrayParam, listParam, arrayParam, 'a'); - result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, 'a'); - result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); - result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); + result = _(array).differenceBy(arrayParam, 'a'); + result = _(array).differenceBy(listParam, arrayParam, 'a'); + result = _(array).differenceBy(arrayParam, listParam, arrayParam, 'a'); + result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, 'a'); + result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); + result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); result = _(array).differenceBy(arrayParam, {a: 1}); result = _(array).differenceBy(listParam, arrayParam, {a: 1}); result = _(array).differenceBy(arrayParam, listParam, arrayParam, {a: 1}); result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _(array).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); - result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); + result = _(array).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _(list).differenceBy(listParam); result = _(list).differenceBy(arrayParam, listParam); @@ -394,26 +394,26 @@ namespace TestDifferenceBy { result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam); result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); - result = _(list).differenceBy(listParam, iteratee); - result = _(list).differenceBy(arrayParam, listParam, iteratee); - result = _(list).differenceBy(listParam, arrayParam, listParam, iteratee); - result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, iteratee); - result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, iteratee); - result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); + result = _(list).differenceBy(listParam, iteratee); + result = _(list).differenceBy(arrayParam, listParam, iteratee); + result = _(list).differenceBy(listParam, arrayParam, listParam, iteratee); + result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, iteratee); + result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, iteratee); + result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); - result = _(list).differenceBy(listParam, 'a'); - result = _(list).differenceBy(arrayParam, listParam, 'a'); - result = _(list).differenceBy(listParam, arrayParam, listParam, 'a'); - result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, 'a'); - result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, 'a'); - result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); + result = _(list).differenceBy(listParam, 'a'); + result = _(list).differenceBy(arrayParam, listParam, 'a'); + result = _(list).differenceBy(listParam, arrayParam, listParam, 'a'); + result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, 'a'); + result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, 'a'); + result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); result = _(list).differenceBy(listParam, {a: 1}); result = _(list).differenceBy(arrayParam, listParam, {a: 1}); result = _(list).differenceBy(listParam, arrayParam, listParam, {a: 1}); result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, {a: 1}); result = _(list).differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); - result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); + result = _(list).differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); } { @@ -426,26 +426,26 @@ namespace TestDifferenceBy { result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam); result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam); - result = _(array).chain().differenceBy(arrayParam, iteratee); - result = _(array).chain().differenceBy(listParam, arrayParam, iteratee); - result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, iteratee); - result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, iteratee); - result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); - result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); + result = _(array).chain().differenceBy(arrayParam, iteratee); + result = _(array).chain().differenceBy(listParam, arrayParam, iteratee); + result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, iteratee); + result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, iteratee); + result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); + result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, iteratee); - result = _(array).chain().differenceBy(arrayParam, 'a'); - result = _(array).chain().differenceBy(listParam, arrayParam, 'a'); - result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, 'a'); - result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, 'a'); - result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); - result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); + result = _(array).chain().differenceBy(arrayParam, 'a'); + result = _(array).chain().differenceBy(listParam, arrayParam, 'a'); + result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, 'a'); + result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, 'a'); + result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); + result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, 'a'); result = _(array).chain().differenceBy(arrayParam, {a: 1}); result = _(array).chain().differenceBy(listParam, arrayParam, {a: 1}); result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, {a: 1}); result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _(array).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); - result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); + result = _(array).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, arrayParam, {a: 1}); result = _(list).chain().differenceBy(listParam); result = _(list).chain().differenceBy(arrayParam, listParam); @@ -454,26 +454,26 @@ namespace TestDifferenceBy { result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam); result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam); - result = _(list).chain().differenceBy(listParam, iteratee); - result = _(list).chain().differenceBy(arrayParam, listParam, iteratee); - result = _(list).chain().differenceBy(listParam, arrayParam, listParam, iteratee); - result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, iteratee); - result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, iteratee); - result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); + result = _(list).chain().differenceBy(listParam, iteratee); + result = _(list).chain().differenceBy(arrayParam, listParam, iteratee); + result = _(list).chain().differenceBy(listParam, arrayParam, listParam, iteratee); + result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, iteratee); + result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, iteratee); + result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, iteratee); - result = _(list).chain().differenceBy(listParam, 'a'); - result = _(list).chain().differenceBy(arrayParam, listParam, 'a'); - result = _(list).chain().differenceBy(listParam, arrayParam, listParam, 'a'); - result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, 'a'); - result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, 'a'); - result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); + result = _(list).chain().differenceBy(listParam, 'a'); + result = _(list).chain().differenceBy(arrayParam, listParam, 'a'); + result = _(list).chain().differenceBy(listParam, arrayParam, listParam, 'a'); + result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, 'a'); + result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, 'a'); + result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, 'a'); result = _(list).chain().differenceBy(listParam, {a: 1}); result = _(list).chain().differenceBy(arrayParam, listParam, {a: 1}); result = _(list).chain().differenceBy(listParam, arrayParam, listParam, {a: 1}); result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, {a: 1}); result = _(list).chain().differenceBy(listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); - result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); + result = _(list).chain().differenceBy(arrayParam, listParam, arrayParam, listParam, arrayParam, listParam, {a: 1}); } { From b416b57ef56d950b8123d3291b12cc38163d6bb4 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Thu, 2 Nov 2017 20:39:21 -0400 Subject: [PATCH 44/53] Fix lint --- types/lodash/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index d666919403..36cd3284e1 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -1709,7 +1709,7 @@ declare namespace _ { * @see _.intersectionBy */ intersectionBy( - array?: List | null | undefined, + array?: List | null, ...values: Array> ): T[]; } @@ -1841,7 +1841,7 @@ declare namespace _ { * @see _.intersectionWith */ intersectionWith( - array?: List | null | undefined, + array?: List | null, ...values: Array> ): T[]; } From 5d0ec0027d4dd13a476fbcffa12e2d01b96980a3 Mon Sep 17 00:00:00 2001 From: Ricardo Portugal Date: Sat, 4 Nov 2017 18:13:02 +0000 Subject: [PATCH 45/53] add extensions to ExecutionResult --- types/graphql/execution/execute.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/graphql/execution/execute.d.ts b/types/graphql/execution/execute.d.ts index 6d02b82124..d63a7f93a7 100644 --- a/types/graphql/execution/execute.d.ts +++ b/types/graphql/execution/execute.d.ts @@ -33,6 +33,7 @@ export interface ExecutionContext { */ export interface ExecutionResult { data?: { [key: string]: any }; + extensions?: { [key: string]: any }; errors?: GraphQLError[]; } From c15de95e10e559e080dec72698a414c89fbdd6aa Mon Sep 17 00:00:00 2001 From: Ricardo Portugal Date: Sat, 4 Nov 2017 18:22:42 +0000 Subject: [PATCH 46/53] comment --- types/graphql/execution/execute.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/graphql/execution/execute.d.ts b/types/graphql/execution/execute.d.ts index d63a7f93a7..c8ee7d9215 100644 --- a/types/graphql/execution/execute.d.ts +++ b/types/graphql/execution/execute.d.ts @@ -28,7 +28,8 @@ export interface ExecutionContext { /** * The result of execution. `data` is the result of executing the - * query, `errors` is null if no errors occurred, and is a + * query, `extensions` represents additional metadata, `errors` is + * null if no errors occurred, and is a * non-empty array if an error occurred. */ export interface ExecutionResult { From 0e09de1997f1dc5382699c4b01d7bde92435717f Mon Sep 17 00:00:00 2001 From: Ricardo Portugal Date: Sat, 4 Nov 2017 18:29:20 +0000 Subject: [PATCH 47/53] add rportugal to "Definitions by" --- 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 b65245a33e..74d9224242 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -8,6 +8,7 @@ // Mikhail Novikov // Ivan Goncharov // Hagai Cohen +// Ricardo Portugal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 01be23749e8cfd546b1a68b0e4edf501a254cddc Mon Sep 17 00:00:00 2001 From: Gregor Yushinov Date: Sun, 5 Nov 2017 02:49:22 +0100 Subject: [PATCH 48/53] One can set connection options on the object's root level now All options which usually have been passed in the db/auth/server/replset object can now be set directly in the connection options. If you don't do so you get hints in the debug console. For reference see: https://github.com/Automattic/mongoose/blob/master/lib/drivers/node-mongodb-native/connection.js#L272 --- types/mongoose/index.d.ts | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 261b8ade84..7e45ea835a 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -364,6 +364,49 @@ declare module "mongoose" { pass?: string; /** options for authentication (see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate) */ auth?: any; + /** Use ssl connection (needs to have a mongod server with ssl support) (default: true) */ + ssl?: boolean; + /** Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. */ + sslValidate?: object; + /** Reconnect on error (default: true) */ + poolSize?: number; + /** Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) */ + autoReconnect?: boolean; + /** TCP KeepAlive on the socket with a X ms delay before start (default: 0). */ + keepAlive?: number; + /** TCP Connection timeout setting (default: 0) */ + connectTimeoutMS?: number; + /** TCP Socket timeout setting (default: 0) */ + socketTimeoutMS?: number; + /** If the database authentication is dependent on another databaseName. */ + authSource?: string; + /** Attempt to reconnect #times (default: 30) */ + retries?: number; + /** Will wait # milliseconds between retries (default: 1000) */ + reconnectWait?: number; + /** The name of the replicaset to connect to. */ + replicaSet?: string; + /** The current value of the parameter native_parser */ + nativeParser?: boolean; + /** Auth mechanism */ + authMechanism?: any; + /** Specify a journal write concern (default: false). */ + journal?: boolean; + /** The write concern */ + w?: number|string; + /** The write concern timeout. */ + wTimeoutMS?: number; + /** The ReadPreference mode as listed here: http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html */ + readPreference?: string; + /** An object representing read preference tags, see: http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html */ + readPreferencetags?: object; + + // TODO + safe?: any; + fsync?: any; + rs_name?: any; + slaveOk?: any; + authdb?: any; } /** See the node-mongodb-native driver instance for options that it understands. */ From 774fe888b682eaf770e04e72eb07bdac4576d589 Mon Sep 17 00:00:00 2001 From: Ian Phillips Date: Fri, 10 Nov 2017 13:23:34 -0800 Subject: [PATCH 49/53] Add a test for Backbone.Collection.clone() --- types/backbone/backbone-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/backbone/backbone-tests.ts b/types/backbone/backbone-tests.ts index c074ac57e5..967ae5d52d 100644 --- a/types/backbone/backbone-tests.ts +++ b/types/backbone/backbone-tests.ts @@ -178,6 +178,8 @@ function test_collection() { var alphabetical = books.sortBy((book: Book): number => null); + var copy = books.clone(); + let one: Book; let models: Book[]; let bool: boolean; From 21d091f2d82843854d8c4714a02e3b973cda33d7 Mon Sep 17 00:00:00 2001 From: Ian Phillips Date: Fri, 10 Nov 2017 14:23:33 -0800 Subject: [PATCH 50/53] Change return type of Backbone.Collection.clone() to "this" --- types/backbone/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/backbone/index.d.ts b/types/backbone/index.d.ts index e2abd94568..e6c73680ed 100644 --- a/types/backbone/index.d.ts +++ b/types/backbone/index.d.ts @@ -229,7 +229,7 @@ declare namespace Backbone { **/ get(id: number|string|Model): TModel; has(key: number|string|Model): boolean; - clone(): Collection; + clone(): this; create(attributes: any, options?: ModelSaveOptions): TModel; pluck(attribute: string): any[]; push(model: TModel, options?: AddOptions): TModel; From e128fc0753d17241c49aa6569293900a2f5af05c Mon Sep 17 00:00:00 2001 From: Andrey Lalev Date: Sat, 11 Nov 2017 08:12:01 +0200 Subject: [PATCH 51/53] Create definitions for find@0.2 --- types/find/find-tests.ts | 32 +++++++++++ types/find/index.d.ts | 116 +++++++++++++++++++++++++++++++++++++++ types/find/tsconfig.json | 23 ++++++++ types/find/tslint.json | 1 + 4 files changed, 172 insertions(+) create mode 100644 types/find/find-tests.ts create mode 100644 types/find/index.d.ts create mode 100644 types/find/tsconfig.json create mode 100644 types/find/tslint.json diff --git a/types/find/find-tests.ts b/types/find/find-tests.ts new file mode 100644 index 0000000000..c6c1cd04f5 --- /dev/null +++ b/types/find/find-tests.ts @@ -0,0 +1,32 @@ +import * as find from "find"; + +const stringPattern = ".d.ts"; +const regexPattern = /ts(config|lint)\.json/; +const rootDir = "."; + +const emptyCb = (): void => { }; +const errorCb = (err: Error): void => { }; +const stringArrayCallback = (paths: string[]): void => { }; +const singleStringCb = (paths: string): void => { }; + +find.file(rootDir, (dirs: string[]): void => { }).error(emptyCb); // $ExpectType void +find.file(rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void +find.file(stringPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void +find.file(regexPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void +find.fileSync(rootDir); // $ExpectType string[] +find.fileSync(stringPattern, rootDir); // $ExpectType string[] +find.fileSync(regexPattern, rootDir); // $ExpectType string[] +find.eachFile(rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream +find.eachFile(stringPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream +find.eachFile(regexPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream + +find.dir(stringPattern, rootDir, (dirs: string[]): void => { }).error(emptyCb); // $ExpectType void +find.dir(stringPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void +find.dir(regexPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void +find.dir(rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void +find.dirSync(rootDir); // $ExpectType string[] +find.dirSync(stringPattern, rootDir); // $ExpectType string[] +find.dirSync(regexPattern, rootDir); // $ExpectType string[] +find.eachDir(rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream +find.eachDir(stringPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream +find.eachDir(regexPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream diff --git a/types/find/index.d.ts b/types/find/index.d.ts new file mode 100644 index 0000000000..61166669db --- /dev/null +++ b/types/find/index.d.ts @@ -0,0 +1,116 @@ +// Type definitions for find 0.2 +// Project: https://github.com/yuanchuan/find#readme +// Definitions by: Andrey Lalev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface AsyncFindStream { + /** + * Handling errors in asynchronous interfaces. + * @param callback The callback that is called upon an error + */ + error(callback: (() => void) | ((err: Error) => void)): void; +} + +export interface FindEachStream { + /** + * Handling errors in asynchronous interfaces. + * @param callback The callback that is called upon an error + */ + error(callback: (() => void) | ((err: Error) => void)): FindEachStream; + + /** + * Detect end in find.eachfile and find.eachdir. + * @param callback The callback called at the end of find.eachfile and find.eachdir + */ + end(callback: () => void): FindEachStream; +} + +/** + * Find all files in a given directory asynchronously. + * @param root The root directory + * @param callback A callback that accepts an array of the found files + */ +export function file(root: string, callback: (files: string[]) => void): AsyncFindStream; + +/** + * Find all files that match a glob pattern in a given directory asynchronously. + * @param pattern The pattern to filter the files with + * @param root The root directory + * @param callback A callback that accepts an array of the found files + */ +export function file(pattern: string | RegExp, root: string, callback: (files: string[]) => void): AsyncFindStream; + +/** + * Find all files in a given directory asynchronously. + * @param root The root directory + * @param callback A callback that accepts each file separately + */ +export function eachFile(root: string, callback: (file: string) => void): FindEachStream; + +/** + * Find all files that match a glob pattern in a given directory asynchronously. + * @param pattern The pattern to filter the files with + * @param root The root directory + * @param callback A callback that accepts an array of the found files + */ +export function eachFile(pattern: string | RegExp, root: string, callback: (file: string) => void): FindEachStream; + +/** + * Find all files in a given directory synchronously. + * @param root The root directory + * @returns The files that have been found + */ +export function fileSync(root: string): string[]; + +/** + * Find all files that match a glob pattern in a given directory synchronously. + * @param pattern The pattern to filter the files with + * @param root The root directory + * @returns The files that have been found + */ +export function fileSync(pattern: string | RegExp, root: string): string[]; + +/** + * Find all directories in a given directory asynchronously. + * @param root The root directory + * @param callback A callback that accepts an array of the found directories + */ +export function dir(root: string, callback: (directories: string[]) => void): AsyncFindStream; + +/** + * Find all directories that match a glob pattern in a given directory asynchronously. + * @param pattern The pattern to filter the directories with + * @param root The root directory + * @param callback A callback that accepts an array of the found directories + */ +export function dir(pattern: RegExp | string, root: string, callback: (directories: string[]) => void): AsyncFindStream; + +/** + * Find all directories in a given directory synchronously. + * @param root The root directory + * @returns The directories that have been found + */ +export function dirSync(root: string): string[]; + +/** + * Find all directories that match a glob pattern in a given directory synchronously. + * @param pattern The pattern to filter the directories with + * @param root The root directory + * @returns The directories that have been found + */ +export function dirSync(pattern: string | RegExp, root: string): string[]; + +/** + * Find all directories in a given directory asynchronously. + * @param root The root directory + * @param callback A callback that accepts each of the found directories separately + */ +export function eachDir(root: string, callback: (directory: string) => void): FindEachStream; + +/** + * Find all directories that match a glob pattern in a given directory asynchronously. + * @param pattern The pattern to filter the directories with + * @param root The root directory + * @param callback A callback that accepts each of the found directories separately + */ +export function eachDir(pattern: string | RegExp, root: string, callback: (directory: string) => void): FindEachStream; diff --git a/types/find/tsconfig.json b/types/find/tsconfig.json new file mode 100644 index 0000000000..e231e78ff5 --- /dev/null +++ b/types/find/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "find-tests.ts" + ] +} diff --git a/types/find/tslint.json b/types/find/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/find/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From a2a63ece84e7c823ad3a548cda56557ef020a602 Mon Sep 17 00:00:00 2001 From: Andrey Lalev Date: Sat, 11 Nov 2017 08:42:24 +0200 Subject: [PATCH 52/53] Add types for gulp-clean-dest@0.2 --- .../gulp-clean-dest/gulp-clean-dest-tests.ts | 10 +++++++ types/gulp-clean-dest/index.d.ts | 29 +++++++++++++++++++ types/gulp-clean-dest/tsconfig.json | 23 +++++++++++++++ types/gulp-clean-dest/tslint.json | 1 + 4 files changed, 63 insertions(+) create mode 100644 types/gulp-clean-dest/gulp-clean-dest-tests.ts create mode 100644 types/gulp-clean-dest/index.d.ts create mode 100644 types/gulp-clean-dest/tsconfig.json create mode 100644 types/gulp-clean-dest/tslint.json diff --git a/types/gulp-clean-dest/gulp-clean-dest-tests.ts b/types/gulp-clean-dest/gulp-clean-dest-tests.ts new file mode 100644 index 0000000000..22a14f7487 --- /dev/null +++ b/types/gulp-clean-dest/gulp-clean-dest-tests.ts @@ -0,0 +1,10 @@ +import cleanDest = require("gulp-clean-dest"); + +const someDir = "."; + +// $ExpectType ReadWriteStream +cleanDest(someDir); +cleanDest(someDir, {}); +cleanDest(someDir, { cwd: someDir }); +cleanDest(someDir, { extension: ".ts" }); +cleanDest(someDir, { cwd: someDir, extension: ".ts" }); diff --git a/types/gulp-clean-dest/index.d.ts b/types/gulp-clean-dest/index.d.ts new file mode 100644 index 0000000000..bbb33abad0 --- /dev/null +++ b/types/gulp-clean-dest/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for gulp-clean-dest 0.2 +// Project: https://github.com/clark800/gulp-clean-dest +// Definitions by: Andrey Lalev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace gulpCleanDest { + interface Options { + /** + * The working directory the folder is relative to. + */ + cwd?: string; + + /** + * Extension of the destination files. Useful if it differs from the original. + */ + extension?: string; + } +} + +/** + * Removes files from the dest directory prior to building. + * @param destination The name of the dest directory + * @param options Options for the cleaning process + */ +declare function gulpCleanDest(destination: string, options?: gulpCleanDest.Options): NodeJS.ReadWriteStream; + +export = gulpCleanDest; diff --git a/types/gulp-clean-dest/tsconfig.json b/types/gulp-clean-dest/tsconfig.json new file mode 100644 index 0000000000..777c860568 --- /dev/null +++ b/types/gulp-clean-dest/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gulp-clean-dest-tests.ts" + ] +} diff --git a/types/gulp-clean-dest/tslint.json b/types/gulp-clean-dest/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/gulp-clean-dest/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 02fc61f4ad54e74bbc70fc8d00d0e139cb5a6ba7 Mon Sep 17 00:00:00 2001 From: Evan Shortiss Date: Fri, 10 Nov 2017 23:46:57 -0800 Subject: [PATCH 53/53] adress reviewer notes --- .../express-formidable-tests.ts | 10 +-- types/express-formidable/index.d.ts | 4 +- types/express-formidable/tsconfig.json | 2 +- types/express-formidable/tslint.json | 78 +------------------ 4 files changed, 9 insertions(+), 85 deletions(-) diff --git a/types/express-formidable/express-formidable-tests.ts b/types/express-formidable/express-formidable-tests.ts index ddf0c76382..f508f0be95 100644 --- a/types/express-formidable/express-formidable-tests.ts +++ b/types/express-formidable/express-formidable-tests.ts @@ -1,12 +1,12 @@ -import * as express from "express" -import * as expform from "express-formidable"; +import express = require("express"); +import expform = require("express-formidable"); const app = express(); app.use("/form1", expform(), (req, res, next) => { - console.log(req.fields) - console.log(req.files) - next() + console.log(req.fields); + console.log(req.files); + next(); }); app.use("/form2", expform({ diff --git a/types/express-formidable/index.d.ts b/types/express-formidable/index.d.ts index dcfef9b55a..e7c0402119 100644 --- a/types/express-formidable/index.d.ts +++ b/types/express-formidable/index.d.ts @@ -1,10 +1,10 @@ -// Type definitions for express-formidable 1.0.0 +// Type definitions for express-formidable 1.0 // Project: https://github.com/noraesae/express-formidable // Definitions by: Torkild Dyvik Olsen , Evan Shortiss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as express from "express"; -import { Fields, Files } from "formidable" +import { Fields, Files } from "formidable"; // Extend the express request object with attached formidable files and fields declare global { diff --git a/types/express-formidable/tsconfig.json b/types/express-formidable/tsconfig.json index 9deeebd96f..45a7b6c12b 100644 --- a/types/express-formidable/tsconfig.json +++ b/types/express-formidable/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "express-formidable-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/express-formidable/tslint.json b/types/express-formidable/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/express-formidable/tslint.json +++ b/types/express-formidable/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" }