diff --git a/types/backbone/backbone-tests.ts b/types/backbone/backbone-tests.ts index 7bf31f0a7b..1772ec5b89 100644 --- a/types/backbone/backbone-tests.ts +++ b/types/backbone/backbone-tests.ts @@ -180,6 +180,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; diff --git a/types/backbone/index.d.ts b/types/backbone/index.d.ts index 6475ba1e4a..04f3024e98 100644 --- a/types/backbone/index.d.ts +++ b/types/backbone/index.d.ts @@ -235,6 +235,7 @@ declare namespace Backbone { **/ get(id: number|string|Model): TModel; has(key: number|string|Model): boolean; + clone(): this; create(attributes: any, options?: ModelSaveOptions): TModel; pluck(attribute: string): any[]; push(model: TModel, options?: AddOptions): TModel; diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts index 2b679d5f7b..bfd714fd22 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. diff --git a/types/express-formidable/express-formidable-tests.ts b/types/express-formidable/express-formidable-tests.ts index 91f9e34519..f508f0be95 100644 --- a/types/express-formidable/express-formidable-tests.ts +++ b/types/express-formidable/express-formidable-tests.ts @@ -3,7 +3,12 @@ import expform = require("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 f2228d2b0f..75a34d0350 100644 --- a/types/express-formidable/index.d.ts +++ b/types/express-formidable/index.d.ts @@ -1,10 +1,21 @@ -// 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 +// Definitions by: Torkild Dyvik Olsen , Evan Shortiss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import { RequestHandler } from "express"; +import * as express from "express"; +import { Fields, Files } 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; @@ -17,6 +28,8 @@ interface ExpressFormidableOptions { multiples?: boolean; } -declare function ExpressFormidable(options?: ExpressFormidableOptions): RequestHandler; +declare function ExpressFormidable(options?: ExpressFormidableOptions): express.RequestHandler; + +declare namespace ExpressFormidable {} export = ExpressFormidable; 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" } 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" } diff --git a/types/graphql/execution/execute.d.ts b/types/graphql/execution/execute.d.ts index 6d02b82124..c8ee7d9215 100644 --- a/types/graphql/execution/execute.d.ts +++ b/types/graphql/execution/execute.d.ts @@ -28,11 +28,13 @@ 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 { data?: { [key: string]: any }; + extensions?: { [key: string]: any }; errors?: GraphQLError[]; } 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 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" } diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 22cecf47e8..f038846d22 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -581,64 +581,77 @@ 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, + values3: List, + values4: List, + values5: List, + ...values: Array | 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: Array> ): T[]; } @@ -646,64 +659,77 @@ 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, + values3: List, + values4: List, + values5: List, + ...values: Array | 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: Array> ): LoDashImplicitWrapper; } @@ -711,64 +737,77 @@ 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, + values3: List, + values4: List, + values5: List, + ...values: Array | 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: Array> ): LoDashExplicitWrapper; } @@ -790,18 +829,38 @@ 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, + 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 | Comparator>, + ...values: Array> ): T[]; } @@ -809,18 +868,38 @@ declare namespace _ { /** * @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>, + 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 | Comparator>, + ...values: Array> ): LoDashImplicitWrapper; } @@ -828,18 +907,38 @@ declare namespace _ { /** * @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>, + 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 | Comparator>, + ...values: Array> ): LoDashExplicitWrapper; } @@ -1135,7 +1234,7 @@ declare namespace _ { */ findIndex( array: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1146,7 +1245,7 @@ declare namespace _ { */ findIndex( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1157,7 +1256,7 @@ declare namespace _ { */ findIndex( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -1183,7 +1282,7 @@ declare namespace _ { */ findLastIndex( array: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1194,7 +1293,7 @@ declare namespace _ { */ findLastIndex( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): number; } @@ -1205,7 +1304,7 @@ declare namespace _ { */ findLastIndex( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -1581,18 +1680,38 @@ 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, + values: List, + iteratee: ValueIteratee + ): T1[]; + + /** + * @see _.intersectionBy + */ + 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 | ValueIteratee>, + array?: List | null, + ...values: Array> ): T[]; } @@ -1600,18 +1719,38 @@ declare namespace _ { /** * @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>, + 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 | ValueIteratee>, + ...values: Array> ): LoDashImplicitWrapper; } @@ -1619,18 +1758,38 @@ declare namespace _ { /** * @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>, + 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 | ValueIteratee>, + ...values: Array> ): LoDashExplicitWrapper; } @@ -1648,22 +1807,43 @@ 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 + * @see _.intersectionWith + */ + intersectionWith( + array: List | null | undefined, + 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 | Comparator>, + array?: List | null, + ...values: Array> ): T[]; } @@ -1671,18 +1851,38 @@ declare namespace _ { /** * @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>, + 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 | Comparator>, + ...values: Array> ): LoDashImplicitWrapper; } @@ -1690,18 +1890,38 @@ declare namespace _ { /** * @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>, + 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 | Comparator>, + ...values: Array> ): LoDashExplicitWrapper; } @@ -2039,27 +2259,43 @@ declare namespace _ { values?: List, iteratee?: ValueIteratee ): List; + + /** + * @see _.pullAllBy + */ + pullAllBy( + array: T1[], + values: List, + iteratee: ValueIteratee + ): T1[]; + + /** + * @see _.pullAllBy + */ + pullAllBy( + array: List, + values: List, + iteratee: ValueIteratee + ): List; } - interface LoDashImplicitWrapper { + interface LoDashWrapper { /** * @see _.pullAllBy */ pullAllBy( - this: LoDashImplicitWrapper>, + this: LoDashWrapper>, values?: List, iteratee?: ValueIteratee ): this; - } - interface LoDashExplicitWrapper { /** * @see _.pullAllBy */ - pullAllBy( - this: LoDashExplicitWrapper>, - values?: List, - iteratee?: ValueIteratee + pullAllBy( + this: LoDashWrapper>, + values: List, + iteratee: ValueIteratee ): this; } @@ -2079,11 +2315,11 @@ declare namespace _ { * @returns 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[], @@ -2099,27 +2335,43 @@ declare namespace _ { values?: List, comparator?: Comparator ): List; + + /** + * @see _.pullAllWith + */ + pullAllWith( + array: T1[], + values: List, + comparator: Comparator2 + ): T1[]; + + /** + * @see _.pullAllWith + */ + pullAllWith( + array: List, + values: List, + comparator: Comparator2 + ): List; } - interface LoDashImplicitWrapper { + interface LoDashWrapper { /** * @see _.pullAllWith */ pullAllWith( - this: LoDashImplicitWrapper>, + this: LoDashWrapper>, values?: List, comparator?: Comparator ): this; - } - interface LoDashExplicitWrapper { /** * @see _.pullAllWith */ - pullAllWith( - this: LoDashExplicitWrapper>, - values?: List, - comparator?: Comparator + pullAllWith( + this: LoDashWrapper>, + values: List, + comparator: Comparator2 ): this; } @@ -2977,7 +3229,7 @@ declare namespace _ { */ uniqBy( array: string | null | undefined, - iteratee: StringIterator + iteratee: StringIterator ): string[]; /** @@ -2995,7 +3247,7 @@ declare namespace _ { */ uniqBy( this: LoDashImplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashImplicitWrapper; /** @@ -3013,7 +3265,7 @@ declare namespace _ { */ uniqBy( this: LoDashExplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashExplicitWrapper; /** @@ -3119,7 +3371,7 @@ declare namespace _ { */ sortedUniqBy( array: string | null | undefined, - iteratee: StringIterator + iteratee: StringIterator ): string[]; /** @@ -3137,7 +3389,7 @@ declare namespace _ { */ sortedUniqBy( this: LoDashImplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashImplicitWrapper; /** @@ -3155,7 +3407,7 @@ declare namespace _ { */ sortedUniqBy( this: LoDashExplicitWrapper, - iteratee: StringIterator + iteratee: StringIterator ): LoDashExplicitWrapper; /** @@ -4227,7 +4479,7 @@ declare namespace _ { */ every( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -4235,7 +4487,7 @@ declare namespace _ { */ every( collection: NumericDictionary | null | undefined, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; /** @@ -4243,7 +4495,7 @@ declare namespace _ { */ every( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; } @@ -4253,7 +4505,7 @@ declare namespace _ { */ every( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -4261,7 +4513,7 @@ declare namespace _ { */ every( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; /** @@ -4269,7 +4521,7 @@ declare namespace _ { */ every( this: LoDashImplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; } @@ -4279,7 +4531,7 @@ declare namespace _ { */ every( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -4287,7 +4539,7 @@ declare namespace _ { */ every( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper; /** @@ -4295,7 +4547,7 @@ declare namespace _ { */ every( this: LoDashExplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): LoDashExplicitWrapper; } @@ -4321,7 +4573,7 @@ declare namespace _ { */ filter( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -4337,7 +4589,7 @@ declare namespace _ { */ filter( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): T[]; /** @@ -4353,7 +4605,7 @@ declare namespace _ { */ filter( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): Array; } @@ -4363,7 +4615,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -4379,7 +4631,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashImplicitWrapper; /** @@ -4395,7 +4647,7 @@ declare namespace _ { */ filter( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashImplicitWrapper>; } @@ -4405,7 +4657,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -4421,7 +4673,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -4437,7 +4689,7 @@ declare namespace _ { */ filter( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper>; } @@ -4472,7 +4724,7 @@ declare namespace _ { */ find( collection: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T|undefined; @@ -4490,7 +4742,7 @@ declare namespace _ { */ find( collection: T | null | undefined, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4510,7 +4762,7 @@ declare namespace _ { */ find( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T|undefined; @@ -4528,7 +4780,7 @@ declare namespace _ { */ find( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4548,7 +4800,7 @@ declare namespace _ { */ find( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; @@ -4566,7 +4818,7 @@ declare namespace _ { */ find( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -4592,7 +4844,7 @@ declare namespace _ { */ findLast( collection: List | null | undefined, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T|undefined; @@ -4610,7 +4862,7 @@ declare namespace _ { */ findLast( collection: T | null | undefined, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4630,7 +4882,7 @@ declare namespace _ { */ findLast( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): T | undefined; @@ -4648,7 +4900,7 @@ declare namespace _ { */ findLast( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): T[keyof T]|undefined; } @@ -4668,7 +4920,7 @@ declare namespace _ { */ findLast( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee, + predicate?: ListIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; @@ -4686,7 +4938,7 @@ declare namespace _ { */ findLast( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee, + predicate?: ObjectIterateeBoolean, fromIndex?: number ): LoDashExplicitWrapper; } @@ -4706,6 +4958,13 @@ declare namespace _ { collection: List> | Dictionary> | NumericDictionary> | null | undefined ): T[]; + /** + * @see _.flatMap + */ + flatMap( + collection: object | null | undefined + ): any[]; + /** * @see _.flatMap */ @@ -4753,6 +5012,11 @@ declare namespace _ { */ flatMap(this: LoDashImplicitWrapper> | Dictionary> | NumericDictionary> | null | undefined>): LoDashImplicitWrapper; + /** + * @see _.flatMap + */ + flatMap(): LoDashImplicitWrapper; + /** * @see _.flatMap */ @@ -4798,6 +5062,11 @@ declare namespace _ { */ flatMap(this: LoDashExplicitWrapper> | Dictionary> | NumericDictionary> | null | undefined>): LoDashExplicitWrapper; + /** + * @see _.flatMap + */ + flatMap(): LoDashExplicitWrapper; + /** * @see _.flatMap */ @@ -5422,7 +5691,7 @@ declare namespace _ { */ groupBy( collection: string | null | undefined, - iteratee?: StringIterator + iteratee?: StringIterator ): Dictionary; /** @@ -5456,7 +5725,7 @@ declare namespace _ { */ groupBy( this: LoDashImplicitWrapper, - iteratee?: StringIterator + iteratee?: StringIterator ): LoDashImplicitWrapper>; /** @@ -5490,7 +5759,7 @@ declare namespace _ { */ groupBy( this: LoDashExplicitWrapper, - iteratee?: StringIterator + iteratee?: StringIterator ): LoDashExplicitWrapper>; /** @@ -6441,7 +6710,7 @@ declare namespace _ { */ reject( collection: string | null | undefined, - predicate?: StringIterator + predicate?: StringIterator ): string[]; /** @@ -6449,7 +6718,7 @@ declare namespace _ { */ reject( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): T[]; /** @@ -6457,7 +6726,7 @@ declare namespace _ { */ reject( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): Array; } @@ -6467,7 +6736,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashImplicitWrapper; /** @@ -6475,7 +6744,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashImplicitWrapper; /** @@ -6483,7 +6752,7 @@ declare namespace _ { */ reject( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashImplicitWrapper>; } @@ -6493,7 +6762,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper, - predicate?: StringIterator + predicate?: StringIterator ): LoDashExplicitWrapper; /** @@ -6501,7 +6770,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -6509,7 +6778,7 @@ declare namespace _ { */ reject( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper>; } @@ -6723,7 +6992,7 @@ declare namespace _ { */ some( collection: List | null | undefined, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -6731,7 +7000,7 @@ declare namespace _ { */ some( collection: T | null | undefined, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; /** @@ -6739,7 +7008,7 @@ declare namespace _ { */ some( collection: NumericDictionary | null | undefined, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; } @@ -6749,7 +7018,7 @@ declare namespace _ { */ some( this: LoDashImplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): boolean; /** @@ -6757,7 +7026,7 @@ declare namespace _ { */ some( this: LoDashImplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): boolean; /** @@ -6765,7 +7034,7 @@ declare namespace _ { */ some( this: LoDashImplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): boolean; } @@ -6775,7 +7044,7 @@ declare namespace _ { */ some( this: LoDashExplicitWrapper | null | undefined>, - predicate?: ListIteratee + predicate?: ListIterateeBoolean ): LoDashExplicitWrapper; /** @@ -6783,7 +7052,7 @@ declare namespace _ { */ some( this: LoDashExplicitWrapper, - predicate?: ObjectIteratee + predicate?: ObjectIterateeBoolean ): LoDashExplicitWrapper; /** @@ -6791,7 +7060,7 @@ declare namespace _ { */ some( this: LoDashExplicitWrapper | null | undefined>, - predicate?: NumericDictionaryIteratee + predicate?: NumericDictionaryIterateeBoolean ): LoDashExplicitWrapper; } @@ -6907,7 +7176,7 @@ declare namespace _ { */ orderBy( collection: List | null | undefined, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): T[]; @@ -6925,7 +7194,7 @@ declare namespace _ { */ orderBy( collection: T | null | undefined, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): Array; @@ -6943,7 +7212,7 @@ declare namespace _ { */ orderBy( collection: NumericDictionary | null | undefined, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): T[]; @@ -6963,7 +7232,7 @@ declare namespace _ { */ orderBy( this: LoDashImplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashImplicitWrapper; @@ -6981,7 +7250,7 @@ declare namespace _ { */ orderBy( this: LoDashImplicitWrapper, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashImplicitWrapper>; @@ -6999,7 +7268,7 @@ declare namespace _ { */ orderBy( this: LoDashImplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashImplicitWrapper; @@ -7019,7 +7288,7 @@ declare namespace _ { */ orderBy( this: LoDashExplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashExplicitWrapper; @@ -7037,7 +7306,7 @@ declare namespace _ { */ orderBy( this: LoDashExplicitWrapper, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashExplicitWrapper>; @@ -7055,7 +7324,7 @@ declare namespace _ { */ orderBy( this: LoDashExplicitWrapper | null | undefined>, - iteratees?: Many>, + iteratees?: Many>, orders?: Many ): LoDashExplicitWrapper; @@ -16742,14 +17011,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>; @@ -16757,7 +17029,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; @@ -16771,9 +17044,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 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; + type Comparator2 = (a: T1, b: T2) => boolean; type PropertyName = string | number | symbol; type PropertyPath = Many; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 05d0db4e27..e40569204d 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -297,6 +297,7 @@ namespace TestDifferenceBy { { let result: TResult[]; + result = _.differenceBy(array); result = _.differenceBy(array, arrayParam); result = _.differenceBy(array, listParam, arrayParam); result = _.differenceBy(array, arrayParam, listParam, arrayParam); @@ -304,27 +305,28 @@ 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); result = _.differenceBy(list, arrayParam, listParam); result = _.differenceBy(list, listParam, arrayParam, listParam); @@ -332,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}); } { @@ -364,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); @@ -392,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}); } { @@ -424,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); @@ -452,26 +454,262 @@ 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}); + } + + { + 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 + 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 + _([t1]).differenceBy([t2], 'name'); + // $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 + _.chain([t1]).differenceBy([t2], 'name'); + // $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; + }); + } +} + +// _.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) => true; + + { + // $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; + + // $ExpectType T1[] + _.differenceWith([t1], [t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 | undefined + return true; + }); + + // $ExpectType LoDashImplicitWrapper + _([t1]).differenceWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 | undefined + return true; + }); + + // $ExpectType LoDashExplicitWrapper + _.chain([t1]).differenceWith([t2], (a, b) => { + a; // $ExpectType T1 + b; // $ExpectType T2 | undefined + return true; + }); } } @@ -1214,6 +1452,197 @@ 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(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(array, list, (value) => { + value; // $ExpectType TResult + return 0; + }); + // $ExpectType TResult[] + result = _.intersectionBy(list, array, list, (value) => { + value; // $ExpectType TResult + return 0; + }); + + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(arrayParam); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(listParam, arrayParam); + // $ExpectType LoDashImplicitWrapper + result = _(array).intersectionBy(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 = _(array).intersectionBy(list, (value) => { + value; // $ExpectType TResult + return ""; + }); + // $ExpectType LoDashImplicitWrapper + result = _(list).intersectionBy(array, list, (value) => { + value; // $ExpectType TResult + return 1; + }); + + // $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(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(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 { + 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 + 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 {}; + }); +} + +// _.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 + return true; + }); + // $ExpectType TResult[] + result = _.intersectionWith(list, array, list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + return true; + }); + + // $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 + return true; + }); + // $ExpectType LoDashImplicitWrapper + result = _(list).intersectionWith(array, list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + return true; + }); + + // $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 + return true; + }); + // $ExpectType LoDashExplicitWrapper + result = _.chain(list).intersectionWith(array, list, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + return true; + }); + + 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 + 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; + }); +} + // _.join namespace TestJoin { let array = [1, 2]; @@ -1487,6 +1916,265 @@ 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 + return []; + }); + // $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 + return () => {}; + }); + + // $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 + return 0; + }); + // $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 + return 0; + }); + + // $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 + return 0; + }); + // $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 + return 0; + }); + + 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 + 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 ""; + }); +} + +// _.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 + return true; + }); + // $ExpectType ArrayLike + _.pullAllWith(list); + // $ExpectType ArrayLike + _.pullAllWith(list, values); + // $ExpectType ArrayLike + _.pullAllWith(list, values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + return true; + }); + + // $ExpectType LoDashImplicitWrapper + _(array).pullAllWith(); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllWith(values); + // $ExpectType LoDashImplicitWrapper + _(array).pullAllWith(values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + return true; + }); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllWith(); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllWith(values); + // $ExpectType LoDashImplicitWrapper> + _(list).pullAllWith(values, (a, b) => { + a; // $ExpectType TResult + b; // $ExpectType TResult + return true; + }); + + // $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 + return true; + }); + // $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 + return true; + }); + + 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 + 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; + }); +} + // _.remove namespace TestRemove { let array: TResult[] = []; @@ -4321,6 +5009,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 @@ -6215,12 +6918,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; @@ -6231,7 +6933,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); @@ -6256,7 +6958,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); @@ -6279,7 +6981,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); @@ -12637,8 +13339,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 } } 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. */ diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 5875b4ef50..0c309578f8 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -981,8 +981,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 @@ -1084,8 +1084,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 ddaf6d95b1..0ee496a6aa 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -1986,8 +1986,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' }; () => { @@ -2017,8 +2017,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' }; () => { diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 40445d1b05..20ad40e64e 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 @@ -17,10 +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; @@ -65,9 +67,8 @@ declare namespace request { } interface DefaultUriUrlRequestApi extends RequestAPI { - + TOptions extends CoreOptions, + TUriUrlOptions> extends RequestAPI { defaults(options: TOptions): DefaultUriUrlRequestApi; (callback?: RequestCallback): TRequest; @@ -173,13 +174,11 @@ 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; - } + }; export interface RequestResponse extends http.IncomingMessage { request: ResponseRequest; @@ -209,7 +208,7 @@ declare namespace request { postData?: { mimeType?: string; params?: NameValuePair[]; - } + }; } export interface NameValuePair { @@ -219,10 +218,10 @@ declare namespace request { export interface Multipart { chunked?: boolean; - data?: { + data?: Array<{ 'content-type'?: string, body: string - }[]; + }>; } export interface RequestPart { @@ -235,8 +234,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; @@ -293,7 +292,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 { @@ -306,9 +305,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 093a7b2b5b..d2c308ed75 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -1,10 +1,10 @@ - import request = require('request'); import http = require('http'); 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; @@ -33,12 +33,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(); @@ -48,7 +48,6 @@ var bodyArr: request.RequestPart[] = [{ defaultBodyRequest.put(); })(); - // --- --- --- --- --- --- --- --- --- --- --- --- obj = req.toJSON(); @@ -90,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, @@ -139,8 +132,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); @@ -241,14 +234,14 @@ 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) { - if (!error && response.statusCode == 200) { +// The following examples from https://github.com/request/request +request('http://www.google.com', (error, response, body) => { + if (!error && response.statusCode === 200) { console.log(body); // Show the HTML for the Google homepage. } }); @@ -261,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' }) @@ -269,22 +262,25 @@ 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')); - } 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); } } }); -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); @@ -292,21 +288,21 @@ 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); } }); -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'}}, 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 @@ -331,9 +327,10 @@ 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); + console.error('upload failed:', err); + return; } console.log('Upload successful! Server responded with:', body); }); @@ -354,15 +351,16 @@ 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' } ] } }, - function (error, response, body) { + (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); }); @@ -374,15 +372,16 @@ 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') } ] }, - function (error, response, body) { + (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); }); @@ -390,32 +389,32 @@ 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' } }); -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}, function (error, response, body) { +request({url: url}, (error, response, body) => { // Do more stuff with 'body' here }); @@ -427,7 +426,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"); @@ -441,15 +440,15 @@ 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' - } - , url = 'https://api.twitter.com/oauth/request_token' - ; -request.post({url:url, oauth:oauth}, function (e, r, body) { +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'; + +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 @@ -457,46 +456,44 @@ request.post({url:url, oauth:oauth}, function (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 // 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' - ; - request.post({url:url, oauth:oauth}, function (e, r, body) { + 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 + }; + 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 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, 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); }); }); }); -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 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/', @@ -508,9 +505,8 @@ options = { request.get(options); -var path = require('path') - , certFile = path.resolve(__dirname, 'ssl/client.crt') - , keyFile = path.resolve(__dirname, 'ssl/client.key'); +var certFile = path.resolve(__dirname, 'ssl/client.crt'); +var keyFile = path.resolve(__dirname, 'ssl/client.key'); options = { url: 'https://api.some-server.com/', @@ -540,7 +536,6 @@ request.get({ } }); - request({ // will be ignored method: 'GET', @@ -572,19 +567,19 @@ 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'} }); 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); @@ -597,7 +592,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. @@ -605,23 +600,23 @@ request.get('http://10.255.255.1', {timeout: 1500}, function(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 , 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' } ] } - , function (error, response, body) { - if(response.statusCode == 201){ - console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + , (error, response, body) => { + if (response.statusCode === 201) { + 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); } } ); @@ -631,31 +626,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) + 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) + 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') - }) + console.log(`received ${data.length} bytes of compressed data`); + }); }); -var requestWithJar = request.defaults({jar: true}) -requestWithJar('http://www.google.com', function () { +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}) -requestWithJar('http://www.google.com', function () { +var j = request.jar(); +requestWithJar = request.defaults({jar: j}); +requestWithJar('http://www.google.com', () => { requestWithJar('http://images.google.com'); }); @@ -663,21 +658,21 @@ 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'); }); -//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')); -requestWithJar = request.defaults({ jar : j }) -request('http://www.google.com', function() { +// var j = request.jar(new FileCookieStore('cookies.json')); +requestWithJar = request.defaults({ jar : j }); +request('http://www.google.com', () => { request('http://images.google.com'); }); -var j = request.jar() -request({url: 'http://www.google.com', jar: j}, function () { +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); // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] @@ -689,11 +684,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({ @@ -720,11 +715,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 75f00111a3..7f1cf14897 100644 --- a/types/request/tslint.json +++ b/types/request/tslint.json @@ -1,81 +1,14 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-comma-operator": 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-switch": 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 + "unified-signatures": false } } 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; diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8ef77dff02..76e94bfb3c 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 +}