From 9081e075b730c9948b643a6c38d6deb18cb0ebdd Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 23 May 2016 17:25:06 -0700 Subject: [PATCH 01/18] Fix extend erro for `NodeBuffer` With change https://github.com/Microsoft/TypeScript/pull/8515, `Uint8Array.fill` method now returns `this`. Fixing definition of `NodeBuffer` to maintain extends relationship with `Uint8Array` --- node/node-4.d.ts | 2 +- node/node.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/node-4.d.ts b/node/node-4.d.ts index a9d4709a91..0cd3c54a17 100644 --- a/node/node-4.d.ts +++ b/node/node-4.d.ts @@ -465,7 +465,7 @@ interface NodeBuffer extends Uint8Array { writeFloatBE(value: number, offset: number, noAssert?: boolean): number; writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): Buffer; + fill(value: any, offset?: number, end?: number): this; // TODO: encoding param indexOf(value: string | number | Buffer, byteOffset?: number): number; // TODO: entries diff --git a/node/node.d.ts b/node/node.d.ts index 8c30f25809..42621d50c4 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -465,7 +465,7 @@ interface NodeBuffer extends Uint8Array { writeFloatBE(value: number, offset: number, noAssert?: boolean): number; writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): Buffer; + fill(value: any, offset?: number, end?: number): this; // TODO: encoding param indexOf(value: string | number | Buffer, byteOffset?: number): number; // TODO: entries From 94b221dd73f1ed85741ac114bbbea9f36c16a59a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 23 May 2016 17:27:55 -0700 Subject: [PATCH 02/18] Remove unreachable code --- node/node-0.11-tests.ts | 3 ++- node/node-0.12-tests.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/node/node-0.11-tests.ts b/node/node-0.11-tests.ts index 8609639a8c..66c0c9ec7c 100644 --- a/node/node-0.11-tests.ts +++ b/node/node-0.11-tests.ts @@ -24,7 +24,8 @@ assert.notStrictEqual(2, "2", "uses === comparator"); assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT"); assert.doesNotThrow(() => { - if (false) { throw "a hammer at your face"; } + const b = false; + if (b) { throw "a hammer at your face"; } }, undefined, "What the...*crunch*"); //////////////////////////////////////////////////// diff --git a/node/node-0.12-tests.ts b/node/node-0.12-tests.ts index 2560181896..989b69dab0 100644 --- a/node/node-0.12-tests.ts +++ b/node/node-0.12-tests.ts @@ -26,7 +26,8 @@ assert.notStrictEqual(2, "2", "uses === comparator"); assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT"); assert.doesNotThrow(() => { - if (false) { throw "a hammer at your face"; } + const b = false; + if (b) { throw "a hammer at your face"; } }, undefined, "What the...*crunch*"); //////////////////////////////////////////////////// From 9fb3c230e09653f0038cf5a600f9b273f2bf17b7 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 24 May 2016 15:48:47 +0200 Subject: [PATCH 03/18] Add core.version (#9383) See https://github.com/zloirock/core-js/blob/v2.4.0/modules/_core.js#L1 See https://github.com/zloirock/core-js/blob/v2.4.0/library/modules/_core.js#L1 --- core-js/core-js-tests.ts | 2 ++ core-js/core-js.d.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core-js/core-js-tests.ts b/core-js/core-js-tests.ts index bc690d434c..965acc6855 100644 --- a/core-js/core-js-tests.ts +++ b/core-js/core-js-tests.ts @@ -500,3 +500,5 @@ s = s.unescapeHTML(); // ############################################################################################# promiseOfVoid = delay(i); + +console.log('core-js version number:', core.version); diff --git a/core-js/core-js.d.ts b/core-js/core-js.d.ts index 16441df233..2c1fa4bd99 100644 --- a/core-js/core-js.d.ts +++ b/core-js/core-js.d.ts @@ -1266,6 +1266,8 @@ interface String { declare function delay(msec: number): Promise; declare namespace core { + var version: string; + namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; function construct(target: Function, argumentsList: ArrayLike): any; From 8a851abfad7b2dafbf53ec1ee31d1adb899164ea Mon Sep 17 00:00:00 2001 From: Pei-Tang Huang Date: Tue, 24 May 2016 21:50:36 +0800 Subject: [PATCH 04/18] Html2canvas 0.5 (#9293) * Merge function with optional argument. * Align function to 0.5.0 (by replacing callback by Promise.) * Declare module for easier import. * Format. * Update version and author information. * Use ES6 Promise directly. Since DefinitelyTyped recommend compilation with `--target es6` and `--noImplicitAny` options. * Revert "Use ES6 Promise directly." Projects targeting es5 wouldn't compile due to the leak of ES6 Promise. This reverts commit 7d022d153c0601384d920671a3150fa7bcacd166. * Fixed header format. --- html2canvas/html2canvas.d.ts | 38 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/html2canvas/html2canvas.d.ts b/html2canvas/html2canvas.d.ts index 1d5fd82fe7..e1fcbc7a1b 100644 --- a/html2canvas/html2canvas.d.ts +++ b/html2canvas/html2canvas.d.ts @@ -1,6 +1,6 @@ -// Type definitions for html2canvas.js v0.4.1 +// Type definitions for html2canvas.js v0.5.0-bata.4 // Project: https://github.com/niklasvh/html2canvas -// Definitions by: Richard Hepburn +// Definitions by: Richard Hepburn , Pei-Tang Huang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -36,26 +36,14 @@ declare namespace Html2Canvas { /** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */ useCORS?: boolean; - + /** Use svg powered rendering where available (FF11+). */ svgRendering?: boolean; - - /** Callback providing the rendered canvas element after rendering */ - onrendered?(canvas: HTMLCanvasElement): void; } } interface Html2CanvasStatic { - /** - * Renders an HTML element to a canvas so that a screenshot can be generated. - * - * The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, - * but builds the screenshot based on the information available on the page. - * - * @param {HTMLElement} element The HTML element which will be rendered to the canvas. Use the root element to render the entire window. - */ - (element: HTMLElement): void; /** * Renders an HTML element to a canvas so that a screenshot can be generated. * @@ -65,7 +53,25 @@ interface Html2CanvasStatic { * @param {HTMLElement} element The HTML element which will be rendered to the canvas. Use the root element to render the entire window. * @param {Html2CanvasOptions} options The options object that controls how the element will be rendered. */ - (element: HTMLElement, options: Html2Canvas.Html2CanvasOptions): void; + (element: HTMLElement, options?: Html2Canvas.Html2CanvasOptions): Html2CanvasPromise; +} + +// FIXME: +// Find out a way to dependent on real Promise interface. +// And remove following custome Promise interface. +interface Html2CanvasThenable { + then(onFulfilled?: (value: R) => U | Html2CanvasThenable, onRejected?: (error: any) => U | Html2CanvasThenable): Html2CanvasThenable; + then(onFulfilled?: (value: R) => U | Html2CanvasThenable, onRejected?: (error: any) => void): Html2CanvasThenable; +} + +interface Html2CanvasPromise extends Html2CanvasThenable { + then(onFulfilled?: (value: R) => U | Html2CanvasThenable, onRejected?: (error: any) => U | Html2CanvasThenable): Html2CanvasPromise; + then(onFulfilled?: (value: R) => U | Html2CanvasThenable, onRejected?: (error: any) => void): Html2CanvasPromise; + catch(onRejected?: (error: any) => U | Html2CanvasThenable): Html2CanvasPromise; +} + +declare module 'html2canvas' { + export = html2canvas; } declare var html2canvas: Html2CanvasStatic; From 1751c28d19510f44b61abad6e219b2b82e0cba30 Mon Sep 17 00:00:00 2001 From: Telshin Date: Tue, 24 May 2016 06:52:21 -0700 Subject: [PATCH 05/18] React-GA typing files (#9397) --- react-ga/react-ga-tests.tsx | 53 +++++++++++++++++++++++++++++++++++++ react-ga/react-ga.d.ts | 27 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 react-ga/react-ga-tests.tsx create mode 100644 react-ga/react-ga.d.ts diff --git a/react-ga/react-ga-tests.tsx b/react-ga/react-ga-tests.tsx new file mode 100644 index 0000000000..2248665dd9 --- /dev/null +++ b/react-ga/react-ga-tests.tsx @@ -0,0 +1,53 @@ +/// +/// + +describe("Testing react-ga initialize object", () => { + it("Able to initialize react-ga object", () => { + let ga = __reactGA; + ga.initialize("UA-65432-1"); + }); + it("Able to initailize react-ga object", () => { + let ga = __reactGA; + + let options: __reactGA.InitializeOptions = { + debug: true, + } + + ga.initialize("UA-65432-1", options); + }); +}); + +describe("Testing react-ga pageview calls", () => { + it("Able to make pageview calls", () => { + let ga = __reactGA; + ga.initialize("UA-65432-1"); + + ga.pageview("http://telshin.com"); + }); +}); + +describe("Testing react-ga modal calls", () => { + it("Able to make modal calls", () => { + let ga = __reactGA; + ga.initialize("UA-65432-1"); + + ga.modalview("Test modal"); + }); +}); + +describe("Testing react-ga event calls", () => { + it("Able to make event calls", () => { + let ga = __reactGA; + ga.initialize("UA-65432-1"); + + let options: __reactGA.EventArgs = { + category: "Test", + action: "CI", + label: "Running Jasmine tests for react-ga typscript library", + value: 4, + nonInteraction: true, + } + + ga.event(options); + }); +}); \ No newline at end of file diff --git a/react-ga/react-ga.d.ts b/react-ga/react-ga.d.ts new file mode 100644 index 0000000000..3a80651dc1 --- /dev/null +++ b/react-ga/react-ga.d.ts @@ -0,0 +1,27 @@ +// Type definitions for react-fa v1.4.1 +// Project: https://github.com/react-ga/react-ga +// Definitions by: Tim Aldridge +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace __reactGA { + export interface EventArgs { + category: string; + action: string; + label?: string; + value?: number; + nonInteraction?: boolean; + } + + export interface InitializeOptions { + debug?: boolean; + } + + export function initialize(trackingCode: string, options?: InitializeOptions): void; + export function pageview(path: string): void; + export function modalview(name: string): void; + export function event(args: EventArgs): void; +} + +declare module 'react-ga' { + export = __reactGA; +} From 5f9cf2d84c5b8e1df2f51202900ef081ea2b0f16 Mon Sep 17 00:00:00 2001 From: cjbarth Date: Tue, 24 May 2016 09:53:46 -0400 Subject: [PATCH 06/18] Update Options.ca to use same type as NodeJs (#9399) ca: A string, Buffer or array of strings or Buffers of trusted certificates in PEM format. --- request/request.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request/request.d.ts b/request/request.d.ts index aaeba2caca..547ee625de 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -110,7 +110,7 @@ declare module 'request' { key?: Buffer; cert?: Buffer; passphrase?: string; - ca?: Buffer; + ca?: string | Buffer | string[] | Buffer[]; har?: HttpArchiveRequest; useQuerystring?: boolean; } From d456e7ccb07a53c47bdd63957e8785402c19c579 Mon Sep 17 00:00:00 2001 From: Sean Kelley Date: Tue, 24 May 2016 06:56:08 -0700 Subject: [PATCH 07/18] Inferrable _.assign*, _.extend*, _.defaults (#9388) * Change the signatures of the _.assign* functions to use intersection types, following 4e4ffc7e. * Redefine _.extend and _.extendWith from scratch by copy-paste-renaming _.assignIn and _.assignInWith (respectively). * Uncomment lodash/extendWith module since it exists now. * Redefine _.defaults using 6ff5a95d0 as a template. * Flip the order of _.defaults intersected types so earlier arguments take precedence when a field is mentioned multiple times. Also fix an extraneous type parameter on an _.assign overload. * Rewrite most of the tests to remove the TResult parameter where appropriate. Add extendWith tests separate from extend tests. * Fix bug with _.defaults where the explicit wrapper variant would return an implicit wrapper. * Update lodash tests to remove a bunch of now-unnecessary type specification. --- lodash/lodash-tests.ts | 695 ++++++++++++++++++++++----------------- lodash/lodash.d.ts | 713 ++++++++++++++++++++++++----------------- 2 files changed, 823 insertions(+), 585 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2d5f5b50f3..7c63f5be44 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -8014,12 +8014,12 @@ namespace TestRandom { // _.assign namespace TestAssign { - interface Obj {a: string}; - interface S1 {a: number}; - interface S2 {b: number}; - interface S3 {c: number}; - interface S4 {d: number}; - interface S5 {e: number}; + interface Obj { a: string }; + interface S1 { a: number }; + interface S2 { b: number }; + interface S3 { c: number }; + interface S4 { d: number }; + interface S5 { e: number }; let obj: Obj; let s1: S1; @@ -8033,37 +8033,37 @@ namespace TestAssign { { let result: Obj; - result = _.assign(obj); + result = _.assign(obj); } { - let result: {a: number}; + let result: { a: number }; - result = _.assign(obj, s1); + result = _.assign(obj, s1); } { - let result: {a: number, b: number}; + let result: { a: number, b: number }; - result = _.assign(obj, s1, s2); + result = _.assign(obj, s1, s2); } { - let result: {a: number, b: number, c: number}; + let result: { a: number, b: number, c: number }; - result = _.assign(obj, s1, s2, s3); + result = _.assign(obj, s1, s2, s3); } { - let result: {a: number, b: number, c: number, d: number}; + let result: { a: number, b: number, c: number, d: number }; - result = _.assign(obj, s1, s2, s3, s4); + result = _.assign(obj, s1, s2, s3, s4); } { - let result: {a: number, b: number, c: number, d: number, e: number}; + let result: { a: number, b: number, c: number, d: number, e: number }; - result = _.assign(obj, s1, s2, s3, s4, s5); + result = _.assign<{ a: number, b: number, c: number, d: number, e: number }>(obj, s1, s2, s3, s4, s5); } { @@ -8073,33 +8073,33 @@ namespace TestAssign { } { - let result: _.LoDashImplicitObjectWrapper<{a: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number }>; - result = _(obj).assign(s1); + result = _(obj).assign(s1); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number }>; - result = _(obj).assign(s1, s2); + result = _(obj).assign(s1, s2); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number }>; - result = _(obj).assign(s1, s2, s3); + result = _(obj).assign(s1, s2, s3); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; - result = _(obj).assign(s1, s2, s3, s4); + result = _(obj).assign(s1, s2, s3, s4); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; - result = _(obj).assign<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5); + result = _(obj).assign<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); } { @@ -8109,44 +8109,44 @@ namespace TestAssign { } { - let result: _.LoDashExplicitObjectWrapper<{a: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number }>; - result = _(obj).chain().assign(s1); + result = _(obj).chain().assign(s1); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number }>; - result = _(obj).chain().assign(s1, s2); + result = _(obj).chain().assign(s1, s2); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number }>; - result = _(obj).chain().assign(s1, s2, s3); + result = _(obj).chain().assign(s1, s2, s3); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; - result = _(obj).chain().assign(s1, s2, s3, s4); + result = _(obj).chain().assign(s1, s2, s3, s4); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; - result = _(obj).chain().assign<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5); + result = _(obj).chain().assign<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); } } // _.assignWith namespace TestAssignWith { - interface Obj {a: string}; - interface S1 {a: number}; - interface S2 {b: number}; - interface S3 {c: number}; - interface S4 {d: number}; - interface S5 {e: number}; + interface Obj { a: string }; + interface S1 { a: number }; + interface S2 { b: number }; + interface S3 { c: number }; + interface S4 { d: number }; + interface S5 { e: number }; let obj: Obj; let s1: S1; @@ -8160,32 +8160,32 @@ namespace TestAssignWith { { let result: Obj; - result = _.assignWith(obj); + result = _.assignWith(obj); } { - let result: {a: number}; - result = _.assignWith(obj, s1, customizer); + let result: { a: number }; + result = _.assignWith(obj, s1, customizer); } { - let result: {a: number, b: number}; - result = _.assignWith(obj, s1, s2, customizer); + let result: { a: number, b: number }; + result = _.assignWith(obj, s1, s2, customizer); } { - let result: {a: number, b: number, c: number}; - result = _.assignWith(obj, s1, s2, s3, customizer); + let result: { a: number, b: number, c: number }; + result = _.assignWith(obj, s1, s2, s3, customizer); } { - let result: {a: number, b: number, c: number, d: number}; - result = _.assignWith(obj, s1, s2, s3, s4, customizer); + let result: { a: number, b: number, c: number, d: number }; + result = _.assignWith(obj, s1, s2, s3, s4, customizer); } { - let result: {a: number, b: number, c: number, d: number, e: number}; - result = _.assignWith(obj, s1, s2, s3, s4, s5, customizer); + let result: { a: number, b: number, c: number, d: number, e: number }; + result = _.assignWith<{ a: number, b: number, c: number, d: number, e: number }>(obj, s1, s2, s3, s4, s5, customizer); } { @@ -8195,28 +8195,28 @@ namespace TestAssignWith { } { - let result: _.LoDashImplicitObjectWrapper<{a: number}>; - result = _(obj).assignWith(s1, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number }>; + result = _(obj).assignWith(s1, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number}>; - result = _(obj).assignWith(s1, s2, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number }>; + result = _(obj).assignWith(s1, s2, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number}>; - result = _(obj).assignWith(s1, s2, s3, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number }>; + result = _(obj).assignWith(s1, s2, s3, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; - result = _(obj).assignWith(s1, s2, s3, s4, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; + result = _(obj).assignWith(s1, s2, s3, s4, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; - result = _(obj).assignWith<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; + result = _(obj).assignWith<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5, customizer); } { @@ -8226,39 +8226,39 @@ namespace TestAssignWith { } { - let result: _.LoDashExplicitObjectWrapper<{a: number}>; - result = _(obj).chain().assignWith(s1, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number }>; + result = _(obj).chain().assignWith(s1, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number}>; - result = _(obj).chain().assignWith(s1, s2, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number }>; + result = _(obj).chain().assignWith(s1, s2, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number}>; - result = _(obj).chain().assignWith(s1, s2, s3, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number }>; + result = _(obj).chain().assignWith(s1, s2, s3, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; - result = _(obj).chain().assignWith(s1, s2, s3, s4, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; + result = _(obj).chain().assignWith(s1, s2, s3, s4, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; - result = _(obj).chain().assignWith<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; + result = _(obj).chain().assignWith<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5, customizer); } } // _.assignIn namespace TestAssignIn { - interface Obj {a: string}; - interface S1 {a: number}; - interface S2 {b: number}; - interface S3 {c: number}; - interface S4 {d: number}; - interface S5 {e: number}; + interface Obj { a: string }; + interface S1 { a: number }; + interface S2 { b: number }; + interface S3 { c: number }; + interface S4 { d: number }; + interface S5 { e: number }; let obj: Obj; let s1: S1; @@ -8272,37 +8272,37 @@ namespace TestAssignIn { { let result: Obj; - result = _.assignIn(obj); + result = _.assignIn(obj); } { - let result: {a: number}; + let result: { a: number }; - result = _.assignIn(obj, s1); + result = _.assignIn(obj, s1); } { - let result: {a: number, b: number}; + let result: { a: number, b: number }; - result = _.assignIn(obj, s1, s2); + result = _.assignIn(obj, s1, s2); } { - let result: {a: number, b: number, c: number}; + let result: { a: number, b: number, c: number }; - result = _.assignIn(obj, s1, s2, s3); + result = _.assignIn(obj, s1, s2, s3); } { - let result: {a: number, b: number, c: number, d: number}; + let result: { a: number, b: number, c: number, d: number }; - result = _.assignIn(obj, s1, s2, s3, s4); + result = _.assignIn(obj, s1, s2, s3, s4); } { - let result: {a: number, b: number, c: number, d: number, e: number}; + let result: { a: number, b: number, c: number, d: number, e: number }; - result = _.assignIn(obj, s1, s2, s3, s4, s5); + result = _.assignIn<{ a: number, b: number, c: number, d: number, e: number }>(obj, s1, s2, s3, s4, s5); } { @@ -8312,33 +8312,33 @@ namespace TestAssignIn { } { - let result: _.LoDashImplicitObjectWrapper<{a: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number }>; - result = _(obj).assignIn(s1); + result = _(obj).assignIn(s1); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number }>; - result = _(obj).assignIn(s1, s2); + result = _(obj).assignIn(s1, s2); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number }>; - result = _(obj).assignIn(s1, s2, s3); + result = _(obj).assignIn(s1, s2, s3); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; - result = _(obj).assignIn(s1, s2, s3, s4); + result = _(obj).assignIn(s1, s2, s3, s4); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; - result = _(obj).assignIn<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5); + result = _(obj).assignIn<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); } { @@ -8348,44 +8348,44 @@ namespace TestAssignIn { } { - let result: _.LoDashExplicitObjectWrapper<{a: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number }>; - result = _(obj).chain().assignIn(s1); + result = _(obj).chain().assignIn(s1); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number }>; - result = _(obj).chain().assignIn(s1, s2); + result = _(obj).chain().assignIn(s1, s2); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number }>; - result = _(obj).chain().assignIn(s1, s2, s3); + result = _(obj).chain().assignIn(s1, s2, s3); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; - result = _(obj).chain().assignIn(s1, s2, s3, s4); + result = _(obj).chain().assignIn(s1, s2, s3, s4); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; - result = _(obj).chain().assignIn<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5); + result = _(obj).chain().assignIn<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); } } // _.assignInWith namespace TestAssignInWith { - interface Obj {a: string}; - interface S1 {a: number}; - interface S2 {b: number}; - interface S3 {c: number}; - interface S4 {d: number}; - interface S5 {e: number}; + interface Obj { a: string }; + interface S1 { a: number }; + interface S2 { b: number }; + interface S3 { c: number }; + interface S4 { d: number }; + interface S5 { e: number }; let obj: Obj; let s1: S1; @@ -8399,32 +8399,32 @@ namespace TestAssignInWith { { let result: Obj; - result = _.assignInWith(obj); + result = _.assignInWith(obj); } { - let result: {a: number}; - result = _.assignInWith(obj, s1, customizer); + let result: { a: number }; + result = _.assignInWith(obj, s1, customizer); } { - let result: {a: number, b: number}; - result = _.assignInWith(obj, s1, s2, customizer); + let result: { a: number, b: number }; + result = _.assignInWith(obj, s1, s2, customizer); } { - let result: {a: number, b: number, c: number}; - result = _.assignInWith(obj, s1, s2, s3, customizer); + let result: { a: number, b: number, c: number }; + result = _.assignInWith(obj, s1, s2, s3, customizer); } { - let result: {a: number, b: number, c: number, d: number}; - result = _.assignInWith(obj, s1, s2, s3, s4, customizer); + let result: { a: number, b: number, c: number, d: number }; + result = _.assignInWith(obj, s1, s2, s3, s4, customizer); } { - let result: {a: number, b: number, c: number, d: number, e: number}; - result = _.assignInWith(obj, s1, s2, s3, s4, s5, customizer); + let result: { a: number, b: number, c: number, d: number, e: number }; + result = _.assignInWith<{ a: number, b: number, c: number, d: number, e: number }>(obj, s1, s2, s3, s4, s5, customizer); } { @@ -8434,28 +8434,28 @@ namespace TestAssignInWith { } { - let result: _.LoDashImplicitObjectWrapper<{a: number}>; - result = _(obj).assignInWith(s1, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number }>; + result = _(obj).assignInWith(s1, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number}>; - result = _(obj).assignInWith(s1, s2, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number }>; + result = _(obj).assignInWith(s1, s2, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number}>; - result = _(obj).assignInWith(s1, s2, s3, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number }>; + result = _(obj).assignInWith(s1, s2, s3, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; - result = _(obj).assignInWith(s1, s2, s3, s4, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; + result = _(obj).assignInWith(s1, s2, s3, s4, customizer); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; - result = _(obj).assignInWith<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5, customizer); + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; + result = _(obj).assignInWith<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5, customizer); } { @@ -8465,28 +8465,28 @@ namespace TestAssignInWith { } { - let result: _.LoDashExplicitObjectWrapper<{a: number}>; - result = _(obj).chain().assignInWith(s1, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number }>; + result = _(obj).chain().assignInWith(s1, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number}>; - result = _(obj).chain().assignInWith(s1, s2, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number }>; + result = _(obj).chain().assignInWith(s1, s2, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number}>; - result = _(obj).chain().assignInWith(s1, s2, s3, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number }>; + result = _(obj).chain().assignInWith(s1, s2, s3, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; - result = _(obj).chain().assignInWith(s1, s2, s3, s4, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; + result = _(obj).chain().assignInWith(s1, s2, s3, s4, customizer); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; - result = _(obj).chain().assignInWith<{a: number, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5, customizer); + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; + result = _(obj).chain().assignInWith<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5, customizer); } } @@ -8520,151 +8520,153 @@ namespace TestCreate { } } + // _.defaults namespace TestDefaults { - interface Obj {a: string}; - interface S1 {a: number}; - interface S2 {b: number}; - interface S3 {c: number}; - interface S4 {d: number}; - interface S5 {e: number}; + interface Obj { a: string }; + interface S1 { a: number }; + interface S2 { b: number }; + interface S3 { c: number }; + interface S4 { d: number }; + interface S5 { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; + let obj: Obj; + let s1: S1; + let s2: S2; + let s3: S3; + let s4: S4; + let s5: S5; - { - let result: Obj; + { + let result: Obj; - result = _.defaults(obj); - } + result = _.defaults(obj); + } - { - let result: {a: string}; + { + let result: { a: string }; - result = _.defaults(obj, s1); - } + result = _.defaults(obj, s1); + } - { - let result: {a: string, b: number}; + { + let result: { a: string, b: number }; - result = _.defaults(obj, s1, s2); - } + result = _.defaults(obj, s1, s2); + } - { - let result: {a: string, b: number, c: number}; + { + let result: { a: string, b: number, c: number }; - result = _.defaults(obj, s1, s2, s3); - } + result = _.defaults(obj, s1, s2, s3); + } - { - let result: {a: string, b: number, c: number, d: number}; + { + let result: { a: string, b: number, c: number, d: number }; - result = _.defaults(obj, s1, s2, s3, s4); - } + result = _.defaults(obj, s1, s2, s3, s4); + } - { - let result: {a: string, b: number, c: number, d: number, e: number}; + { + let result: { a: string, b: number, c: number, d: number, e: number }; - result = _.defaults(obj, s1, s2, s3, s4, s5); - } + result = _.defaults<{ a: string, b: number, c: number, d: number, e: number }>(obj, s1, s2, s3, s4, s5); + } - { - let result: _.LoDashImplicitObjectWrapper; + { + let result: _.LoDashImplicitObjectWrapper; - result = _(obj).defaults(); - } + result = _(obj).defaults(); + } - { - let result: _.LoDashImplicitObjectWrapper<{a: string}>; + { + let result: _.LoDashImplicitObjectWrapper<{ a: string }>; - result = _(obj).defaults(s1); - } + result = _(obj).defaults(s1); + } - { - let result: _.LoDashImplicitObjectWrapper<{a: string, b: number}>; + { + let result: _.LoDashImplicitObjectWrapper<{ a: string, b: number }>; - result = _(obj).defaults(s1, s2); - } + result = _(obj).defaults(s1, s2); + } - { - let result: _.LoDashImplicitObjectWrapper<{a: string, b: number, c: number}>; + { + let result: _.LoDashImplicitObjectWrapper<{ a: string, b: number, c: number }>; - result = _(obj).defaults(s1, s2, s3); - } + result = _(obj).defaults(s1, s2, s3); + } - { - let result: _.LoDashImplicitObjectWrapper<{a: string, b: number, c: number, d: number}>; + { + let result: _.LoDashImplicitObjectWrapper<{ a: string, b: number, c: number, d: number }>; - result = _(obj).defaults(s1, s2, s3, s4); - } + result = _(obj).defaults(s1, s2, s3, s4); + } - { - let result: _.LoDashImplicitObjectWrapper<{a: string, b: number, c: number, d: number, e: number}>; + { + let result: _.LoDashImplicitObjectWrapper<{ a: string, b: number, c: number, d: number, e: number }>; - result = _(obj).defaults<{a: string, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5); - } + result = _(obj).defaults<{ a: string, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); + } - { - let result: _.LoDashExplicitObjectWrapper; + { + let result: _.LoDashExplicitObjectWrapper; - result = _(obj).chain().defaults(); - } + result = _(obj).chain().defaults(); + } - { - let result: _.LoDashExplicitObjectWrapper<{a: string}>; + { + let result: _.LoDashExplicitObjectWrapper<{ a: string }>; - result = _(obj).chain().defaults(s1); - } + result = _(obj).chain().defaults(s1); + } - { - let result: _.LoDashExplicitObjectWrapper<{a: string, b: number}>; + { + let result: _.LoDashExplicitObjectWrapper<{ a: string, b: number }>; - result = _(obj).chain().defaults(s1, s2); - } + result = _(obj).chain().defaults(s1, s2); + } - { - let result: _.LoDashExplicitObjectWrapper<{a: string, b: number, c: number}>; + { + let result: _.LoDashExplicitObjectWrapper<{ a: string, b: number, c: number }>; - result = _(obj).chain().defaults(s1, s2, s3); - } + result = _(obj).chain().defaults(s1, s2, s3); + } - { - let result: _.LoDashExplicitObjectWrapper<{a: string, b: number, c: number, d: number}>; + { + let result: _.LoDashExplicitObjectWrapper<{ a: string, b: number, c: number, d: number }>; - result = _(obj).chain().defaults(s1, s2, s3, s4); - } + result = _(obj).chain().defaults(s1, s2, s3, s4); + } - { - let result: _.LoDashExplicitObjectWrapper<{a: string, b: number, c: number, d: number, e: number}>; + { + let result: _.LoDashExplicitObjectWrapper<{ a: string, b: number, c: number, d: number, e: number }>; - result = _(obj).chain().defaults<{a: string, b: number, c: number, d: number, e: number}>(s1, s2, s3, s4, s5); - } + result = _(obj).chain().defaults<{ a: string, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); + } } //_.defaultsDeep interface DefaultsDeepResult { - user: { - name: string; - age: number; - } + user: { + name: string; + age: number; + } } -var TestDefaultsDeepObject = {'user': {'name': 'barney'}}; -var TestDefaultsDeepSource = {'user': {'name': 'fred', 'age': 36}}; +var TestDefaultsDeepObject = { 'user': { 'name': 'barney' } }; +var TestDefaultsDeepSource = { 'user': { 'name': 'fred', 'age': 36 } }; result = _.defaultsDeep(TestDefaultsDeepObject, TestDefaultsDeepSource); result = _(TestDefaultsDeepObject).defaultsDeep(TestDefaultsDeepSource).value(); + // _.extend namespace TestExtend { - type Obj = {a: string}; - type S1 = {a: number}; - type S2 = {b: number}; - type S3 = {c: number}; - type S4 = {d: number}; - type S5 = {e: number}; + type Obj = { a: string }; + type S1 = { a: number }; + type S2 = { b: number }; + type S3 = { c: number }; + type S4 = { d: number }; + type S5 = { e: number }; let obj: Obj; let s1: S1; @@ -8678,42 +8680,37 @@ namespace TestExtend { { let result: Obj; - result = _.extend(obj); + result = _.extend(obj); } { - let result: {a: number}; + let result: { a: number }; - result = _.extend(obj, s1); - result = _.extend(obj, s1, customizer); + result = _.extend(obj, s1); } { - let result: {a: number, b: number}; + let result: { a: number, b: number }; - result = _.extend(obj, s1, s2); - result = _.extend(obj, s1, s2, customizer); + result = _.extend(obj, s1, s2); } { - let result: {a: number, b: number, c: number}; + let result: { a: number, b: number, c: number }; - result = _.extend(obj, s1, s2, s3); - result = _.extend(obj, s1, s2, s3, customizer); + result = _.extend(obj, s1, s2, s3); } { - let result: {a: number, b: number, c: number, d: number}; + let result: { a: number, b: number, c: number, d: number }; - result = _.extend(obj, s1, s2, s3, s4); - result = _.extend(obj, s1, s2, s3, s4, customizer); + result = _.extend(obj, s1, s2, s3, s4); } { - let result: {a: number, b: number, c: number, d: number, e: number}; + let result: { a: number, b: number, c: number, d: number, e: number }; - result = _.extend(obj, s1, s2, s3, s4, s5); - result = _.extend(obj, s1, s2, s3, s4, s5, customizer); + result = _.extend<{ a: number, b: number, c: number, d: number, e: number }>(obj, s1, s2, s3, s4, s5); } { @@ -8723,38 +8720,33 @@ namespace TestExtend { } { - let result: _.LoDashImplicitObjectWrapper<{a: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number }>; - result = _(obj).extend(s1); - result = _(obj).extend(s1, customizer); + result = _(obj).extend(s1); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number }>; - result = _(obj).extend(s1, s2); - result = _(obj).extend(s1, s2, customizer); + result = _(obj).extend(s1, s2); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number }>; - result = _(obj).extend(s1, s2, s3); - result = _(obj).extend(s1, s2, s3, customizer); + result = _(obj).extend(s1, s2, s3); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; - result = _(obj).extend(s1, s2, s3, s4); - result = _(obj).extend(s1, s2, s3, s4, customizer); + result = _(obj).extend(s1, s2, s3, s4); } { - let result: _.LoDashImplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; - result = _(obj).extend(s1, s2, s3, s4, s5); - result = _(obj).extend(s1, s2, s3, s4, s5, customizer); + result = _(obj).extend<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); } { @@ -8764,38 +8756,161 @@ namespace TestExtend { } { - let result: _.LoDashExplicitObjectWrapper<{a: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number }>; - result = _(obj).chain().extend(s1); - result = _(obj).chain().extend(s1, customizer); + result = _(obj).chain().extend(s1); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number }>; - result = _(obj).chain().extend(s1, s2); - result = _(obj).chain().extend(s1, s2, customizer); + result = _(obj).chain().extend(s1, s2); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number }>; - result = _(obj).chain().extend(s1, s2, s3); - result = _(obj).chain().extend(s1, s2, s3, customizer); + result = _(obj).chain().extend(s1, s2, s3); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; - result = _(obj).chain().extend(s1, s2, s3, s4); - result = _(obj).chain().extend(s1, s2, s3, s4, customizer); + result = _(obj).chain().extend(s1, s2, s3, s4); } { - let result: _.LoDashExplicitObjectWrapper<{a: number, b: number, c: number, d: number, e: number}>; + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; - result = _(obj).chain().extend(s1, s2, s3, s4, s5); - result = _(obj).chain().extend(s1, s2, s3, s4, s5, customizer); + result = _(obj).chain().extend<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5); + } +} + + +// _.extendWith +namespace TestExtendWith { + type Obj = { a: string }; + type S1 = { a: number }; + type S2 = { b: number }; + type S3 = { c: number }; + type S4 = { d: number }; + type S5 = { e: number }; + + let obj: Obj; + let s1: S1; + let s2: S2; + let s3: S3; + let s4: S4; + let s5: S5; + + let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; + + { + let result: Obj; + + result = _.extendWith(obj); + } + + { + let result: { a: number }; + + result = _.extendWith(obj, s1, customizer); + } + + { + let result: { a: number, b: number }; + + result = _.extendWith(obj, s1, s2, customizer); + } + + { + let result: { a: number, b: number, c: number }; + + result = _.extendWith(obj, s1, s2, s3, customizer); + } + + { + let result: { a: number, b: number, c: number, d: number }; + + result = _.extendWith(obj, s1, s2, s3, s4, customizer); + } + + { + let result: { a: number, b: number, c: number, d: number, e: number }; + + result = _.extendWith<{ a: number, b: number, c: number, d: number, e: number }>(obj, s1, s2, s3, s4, s5, customizer); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(obj).extendWith(); + } + + { + let result: _.LoDashImplicitObjectWrapper<{ a: number }>; + + result = _(obj).extendWith(s1, customizer); + } + + { + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number }>; + + result = _(obj).extendWith(s1, s2, customizer); + } + + { + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number }>; + + result = _(obj).extendWith(s1, s2, s3, customizer); + } + + { + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; + + result = _(obj).extendWith(s1, s2, s3, s4, customizer); + } + + { + let result: _.LoDashImplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; + + result = _(obj).extendWith<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5, customizer); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(obj).chain().extendWith(); + } + + { + let result: _.LoDashExplicitObjectWrapper<{ a: number }>; + + result = _(obj).chain().extendWith(s1, customizer); + } + + { + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number }>; + + result = _(obj).chain().extendWith(s1, s2, customizer); + } + + { + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number }>; + + result = _(obj).chain().extendWith(s1, s2, s3, customizer); + } + + { + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number }>; + + result = _(obj).chain().extendWith(s1, s2, s3, s4, customizer); + } + + { + let result: _.LoDashExplicitObjectWrapper<{ a: number, b: number, c: number, d: number, e: number }>; + + result = _(obj).chain().extendWith<{ a: number, b: number, c: number, d: number, e: number }>(s1, s2, s3, s4, s5, customizer); } } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 1e39d223f0..8407681ab2 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -13761,53 +13761,52 @@ declare module _ { * _.assign({ 'a': 1 }, new Foo, new Bar); * // => { 'a': 1, 'c': 3, 'e': 5 } */ - assign( + assign( object: TObject, source: TSource - ): TResult; + ): TObject & TSource; /** * @see assign */ - assign( + assign( object: TObject, source1: TSource1, source2: TSource2 - ): TResult; + ): TObject & TSource1 & TSource2; /** * @see assign */ - assign( + assign( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3 - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3; /** * @see assign */ - assign - ( + assign( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4 - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3 & TSource4; /** * @see _.assign */ - assign(object: TObject): TObject; + assign(object: TObject): TObject; /** * @see _.assign */ - assign( - object: TObject, ...otherArgs: any[] + assign( + object: any, + ...otherArgs: any[] ): TResult; } @@ -13815,36 +13814,36 @@ declare module _ { /** * @see _.assign */ - assign( + assign( source: TSource - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assign */ - assign( + assign( source1: TSource1, source2: TSource2 - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assign */ - assign( + assign( source1: TSource1, source2: TSource2, source3: TSource3 - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assign */ - assign( + assign( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4 - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see _.assign @@ -13854,43 +13853,43 @@ declare module _ { /** * @see _.assign */ - assign(...otherArgs: any[]): LoDashImplicitObjectWrapper; + assign(...otherArgs: any[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { /** * @see _.assign */ - assign( + assign( source: TSource - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assign */ - assign( + assign( source1: TSource1, source2: TSource2 - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assign */ - assign( + assign( source1: TSource1, source2: TSource2, source3: TSource3 - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assign */ - assign( + assign( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4 - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see _.assign @@ -13900,7 +13899,7 @@ declare module _ { /** * @see _.assign */ - assign(...otherArgs: any[]): LoDashExplicitObjectWrapper; + assign(...otherArgs: any[]): LoDashExplicitObjectWrapper; } //_.assignWith @@ -13935,57 +13934,56 @@ declare module _ { * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - assignWith( + assignWith( object: TObject, source: TSource, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource; /** * @see assignWith */ - assignWith( + assignWith( object: TObject, source1: TSource1, source2: TSource2, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource1 & TSource2; /** * @see assignWith */ - assignWith( + assignWith( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3; /** * @see assignWith */ - assignWith - ( + assignWith( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3 & TSource4; /** * @see _.assignWith */ - assignWith(object: TObject): TObject; + assignWith(object: TObject): TObject; /** * @see _.assignWith */ - assignWith( - object: TObject, ...otherArgs: any[] + assignWith( + object: any, + ...otherArgs: any[] ): TResult; } @@ -13993,40 +13991,40 @@ declare module _ { /** * @see _.assignWith */ - assignWith( + assignWith( source: TSource, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignWith */ - assignWith( + assignWith( source1: TSource1, source2: TSource2, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignWith */ - assignWith( + assignWith( source1: TSource1, source2: TSource2, source3: TSource3, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignWith */ - assignWith( + assignWith( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see _.assignWith @@ -14036,47 +14034,47 @@ declare module _ { /** * @see _.assignWith */ - assignWith(...otherArgs: any[]): LoDashImplicitObjectWrapper; + assignWith(...otherArgs: any[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { /** * @see _.assignWith */ - assignWith( + assignWith( source: TSource, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignWith */ - assignWith( + assignWith( source1: TSource1, source2: TSource2, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignWith */ - assignWith( + assignWith( source1: TSource1, source2: TSource2, source3: TSource3, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignWith */ - assignWith( + assignWith( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see _.assignWith @@ -14086,7 +14084,7 @@ declare module _ { /** * @see _.assignWith */ - assignWith(...otherArgs: any[]): LoDashExplicitObjectWrapper; + assignWith(...otherArgs: any[]): LoDashExplicitObjectWrapper; } //_.assignIn @@ -14120,53 +14118,52 @@ declare module _ { * _.assignIn({ 'a': 1 }, new Foo, new Bar); * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 } */ - assignIn( + assignIn( object: TObject, source: TSource - ): TResult; + ): TObject & TSource; /** * @see assignIn */ - assignIn( + assignIn( object: TObject, source1: TSource1, source2: TSource2 - ): TResult; + ): TObject & TSource1 & TSource2; /** * @see assignIn */ - assignIn( + assignIn( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3 - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3; /** * @see assignIn */ - assignIn - ( + assignIn( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4 - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3 & TSource4; /** * @see _.assignIn */ - assignIn(object: TObject): TObject; + assignIn(object: TObject): TObject; /** * @see _.assignIn */ - assignIn( - object: TObject, ...otherArgs: any[] + assignIn( + object: any, + ...otherArgs: any[] ): TResult; } @@ -14174,36 +14171,36 @@ declare module _ { /** * @see _.assignIn */ - assignIn( + assignIn( source: TSource - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignIn */ - assignIn( + assignIn( source1: TSource1, source2: TSource2 - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignIn */ - assignIn( + assignIn( source1: TSource1, source2: TSource2, source3: TSource3 - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignIn */ - assignIn( + assignIn( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4 - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see _.assignIn @@ -14213,43 +14210,43 @@ declare module _ { /** * @see _.assignIn */ - assignIn(...otherArgs: any[]): LoDashImplicitObjectWrapper; + assignIn(...otherArgs: any[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { /** * @see _.assignIn */ - assignIn( + assignIn( source: TSource - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignIn */ - assignIn( + assignIn( source1: TSource1, source2: TSource2 - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignIn */ - assignIn( + assignIn( source1: TSource1, source2: TSource2, source3: TSource3 - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignIn */ - assignIn( + assignIn( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4 - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see _.assignIn @@ -14259,7 +14256,7 @@ declare module _ { /** * @see _.assignIn */ - assignIn(...otherArgs: any[]): LoDashExplicitObjectWrapper; + assignIn(...otherArgs: any[]): LoDashExplicitObjectWrapper; } //_.assignInWith @@ -14295,57 +14292,56 @@ declare module _ { * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - assignInWith( + assignInWith( object: TObject, source: TSource, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource; /** * @see assignInWith */ - assignInWith( + assignInWith( object: TObject, source1: TSource1, source2: TSource2, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource1 & TSource2; /** * @see assignInWith */ - assignInWith( + assignInWith( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3; /** * @see assignInWith */ - assignInWith - ( + assignInWith( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: AssignCustomizer - ): TResult; + ): TObject & TSource1 & TSource2 & TSource3 & TSource4; /** * @see _.assignInWith */ - assignInWith(object: TObject): TObject; + assignInWith(object: TObject): TObject; /** * @see _.assignInWith */ - assignInWith( - object: TObject, ...otherArgs: any[] + assignInWith( + object: any, + ...otherArgs: any[] ): TResult; } @@ -14353,40 +14349,40 @@ declare module _ { /** * @see _.assignInWith */ - assignInWith( + assignInWith( source: TSource, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignInWith */ - assignInWith( + assignInWith( source1: TSource1, source2: TSource2, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignInWith */ - assignInWith( + assignInWith( source1: TSource1, source2: TSource2, source3: TSource3, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see assignInWith */ - assignInWith( + assignInWith( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; + ): LoDashImplicitObjectWrapper; /** * @see _.assignInWith @@ -14396,47 +14392,47 @@ declare module _ { /** * @see _.assignInWith */ - assignInWith(...otherArgs: any[]): LoDashImplicitObjectWrapper; + assignInWith(...otherArgs: any[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { /** * @see _.assignInWith */ - assignInWith( + assignInWith( source: TSource, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignInWith */ - assignInWith( + assignInWith( source1: TSource1, source2: TSource2, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignInWith */ - assignInWith( + assignInWith( source1: TSource1, source2: TSource2, source3: TSource3, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see assignInWith */ - assignInWith( + assignInWith( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; + ): LoDashExplicitObjectWrapper; /** * @see _.assignInWith @@ -14446,7 +14442,7 @@ declare module _ { /** * @see _.assignInWith */ - assignInWith(...otherArgs: any[]): LoDashExplicitObjectWrapper; + assignInWith(...otherArgs: any[]): LoDashExplicitObjectWrapper; } //_.create @@ -14479,6 +14475,7 @@ declare module _ { create(properties?: U): LoDashExplicitObjectWrapper; } + //_.defaults interface LoDashStatic { /** @@ -14492,59 +14489,52 @@ declare module _ { * @param sources The source objects. * @return The destination object. */ - defaults( - object: Obj, - ...sources: {}[] - ): TResult; + defaults( + object: TObject, + source: TSource + ): TSource & TObject; /** * @see _.defaults */ - defaults( - object: Obj, - source1: S1, - ...sources: {}[] - ): TResult; + defaults( + object: TObject, + source1: TSource1, + source2: TSource2 + ): TSource2 & TSource1 & TObject; /** * @see _.defaults */ - defaults( - object: Obj, - source1: S1, - source2: S2, - ...sources: {}[] - ): TResult; + defaults( + object: TObject, + source1: TSource1, + source2: TSource2, + source3: TSource3 + ): TSource3 & TSource2 & TSource1 & TObject; /** * @see _.defaults */ - defaults( - object: Obj, - source1: S1, - source2: S2, - source3: S3, - ...sources: {}[] - ): TResult; + defaults( + object: TObject, + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4 + ): TSource4 & TSource3 & TSource2 & TSource1 & TObject; /** * @see _.defaults */ - defaults( - object: Obj, - source1: S1, - source2: S2, - source3: S3, - source4: S4, - ...sources: {}[] - ): TResult; + defaults(object: TObject): TObject; /** * @see _.defaults */ - defaults( - object: {}, - ...sources: {}[] + defaults( + object: any, + ...sources: any[] ): TResult; } @@ -14552,40 +14542,36 @@ declare module _ { /** * @see _.defaults */ - defaults( - source1: S1, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; + defaults( + source: TSource + ): LoDashImplicitObjectWrapper; /** * @see _.defaults */ - defaults( - source1: S1, - source2: S2, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; + defaults( + source1: TSource1, + source2: TSource2 + ): LoDashImplicitObjectWrapper; /** * @see _.defaults */ - defaults( - source1: S1, - source2: S2, - source3: S3, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; + defaults( + source1: TSource1, + source2: TSource2, + source3: TSource3 + ): LoDashImplicitObjectWrapper; /** * @see _.defaults */ - defaults( - source1: S1, - source2: S2, - source3: S3, - source4: S4, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; + defaults( + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4 + ): LoDashImplicitObjectWrapper; /** * @see _.defaults @@ -14595,47 +14581,43 @@ declare module _ { /** * @see _.defaults */ - defaults(...sources: {}[]): LoDashImplicitObjectWrapper; + defaults(...sources: any[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { /** * @see _.defaults */ - defaults( - source1: S1, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; + defaults( + source: TSource + ): LoDashExplicitObjectWrapper; /** * @see _.defaults */ - defaults( - source1: S1, - source2: S2, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; + defaults( + source1: TSource1, + source2: TSource2 + ): LoDashExplicitObjectWrapper; /** * @see _.defaults */ - defaults( - source1: S1, - source2: S2, - source3: S3, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; + defaults( + source1: TSource1, + source2: TSource2, + source3: TSource3 + ): LoDashExplicitObjectWrapper; /** * @see _.defaults */ - defaults( - source1: S1, - source2: S2, - source3: S3, - source4: S4, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; + defaults( + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4 + ): LoDashExplicitObjectWrapper; /** * @see _.defaults @@ -14645,7 +14627,7 @@ declare module _ { /** * @see _.defaults */ - defaults(...sources: {}[]): LoDashExplicitObjectWrapper; + defaults(...sources: any[]): LoDashExplicitObjectWrapper; } //_.defaultsDeep @@ -14668,163 +14650,307 @@ declare module _ { defaultsDeep(...sources: any[]): LoDashImplicitObjectWrapper } - //_.extend + // _.extend interface LoDashStatic { /** - * @see assign + * @see _.assignIn */ - extend( + extend( object: TObject, - source: TSource, - customizer?: AssignCustomizer - ): TResult; + source: TSource + ): TObject & TSource; /** - * @see assign + * @see _.assignIn */ - extend( + extend( + object: TObject, + source1: TSource1, + source2: TSource2 + ): TObject & TSource1 & TSource2; + + /** + * @see _.assignIn + */ + extend( object: TObject, source1: TSource1, source2: TSource2, - customizer?: AssignCustomizer - ): TResult; + source3: TSource3 + ): TObject & TSource1 & TSource2 & TSource3; /** - * @see assign + * @see _.assignIn */ - extend( + extend( object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, - customizer?: AssignCustomizer - ): TResult; + source4: TSource4 + ): TObject & TSource1 & TSource2 & TSource3 & TSource4; /** - * @see assign + * @see _.assignIn */ - extend - ( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer?: AssignCustomizer - ): TResult; + extend(object: TObject): TObject; /** - * @see _.assign + * @see _.assignIn */ - extend(object: TObject): TObject; - - /** - * @see _.assign - */ - extend( - object: TObject, ...otherArgs: any[] + extend( + object: any, + ...otherArgs: any[] ): TResult; } interface LoDashImplicitObjectWrapper { /** - * @see _.assign + * @see _.assignIn */ - extend( - source: TSource, - customizer?: AssignCustomizer - ): LoDashImplicitObjectWrapper; + extend( + source: TSource + ): LoDashImplicitObjectWrapper; /** - * @see assign + * @see _.assignIn */ - extend( + extend( + source1: TSource1, + source2: TSource2 + ): LoDashImplicitObjectWrapper; + + /** + * @see _.assignIn + */ + extend( source1: TSource1, source2: TSource2, - customizer?: AssignCustomizer - ): LoDashImplicitObjectWrapper; + source3: TSource3 + ): LoDashImplicitObjectWrapper; /** - * @see assign + * @see _.assignIn */ - extend( + extend( source1: TSource1, source2: TSource2, source3: TSource3, - customizer?: AssignCustomizer - ): LoDashImplicitObjectWrapper; + source4: TSource4 + ): LoDashImplicitObjectWrapper; /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer?: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.assign + * @see _.assignIn */ extend(): LoDashImplicitObjectWrapper; /** - * @see _.assign + * @see _.assignIn */ - extend(...otherArgs: any[]): LoDashImplicitObjectWrapper; + extend(...otherArgs: any[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { /** - * @see _.assign + * @see _.assignIn */ - extend( - source: TSource, - customizer?: AssignCustomizer - ): LoDashExplicitObjectWrapper; + extend( + source: TSource + ): LoDashExplicitObjectWrapper; /** - * @see assign + * @see _.assignIn */ - extend( + extend( + source1: TSource1, + source2: TSource2 + ): LoDashExplicitObjectWrapper; + + /** + * @see _.assignIn + */ + extend( source1: TSource1, source2: TSource2, - customizer?: AssignCustomizer - ): LoDashExplicitObjectWrapper; + source3: TSource3 + ): LoDashExplicitObjectWrapper; /** - * @see assign + * @see _.assignIn */ - extend( + extend( source1: TSource1, source2: TSource2, source3: TSource3, - customizer?: AssignCustomizer - ): LoDashExplicitObjectWrapper; + source4: TSource4 + ): LoDashExplicitObjectWrapper; /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer?: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see _.assign + * @see _.assignIn */ extend(): LoDashExplicitObjectWrapper; /** - * @see _.assign + * @see _.assignIn */ - extend(...otherArgs: any[]): LoDashExplicitObjectWrapper; + extend(...otherArgs: any[]): LoDashExplicitObjectWrapper; + } + + interface LoDashStatic { + /** + * @see _.assignInWith + */ + extendWith( + object: TObject, + source: TSource, + customizer: AssignCustomizer + ): TObject & TSource; + + /** + * @see _.assignInWith + */ + extendWith( + object: TObject, + source1: TSource1, + source2: TSource2, + customizer: AssignCustomizer + ): TObject & TSource1 & TSource2; + + /** + * @see _.assignInWith + */ + extendWith( + object: TObject, + source1: TSource1, + source2: TSource2, + source3: TSource3, + customizer: AssignCustomizer + ): TObject & TSource1 & TSource2 & TSource3; + + /** + * @see _.assignInWith + */ + extendWith( + object: TObject, + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4, + customizer: AssignCustomizer + ): TObject & TSource1 & TSource2 & TSource3 & TSource4; + + /** + * @see _.assignInWith + */ + extendWith(object: TObject): TObject; + + /** + * @see _.assignInWith + */ + extendWith( + object: any, + ...otherArgs: any[] + ): TResult; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.assignInWith + */ + extendWith( + source: TSource, + customizer: AssignCustomizer + ): LoDashImplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith( + source1: TSource1, + source2: TSource2, + customizer: AssignCustomizer + ): LoDashImplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith( + source1: TSource1, + source2: TSource2, + source3: TSource3, + customizer: AssignCustomizer + ): LoDashImplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith( + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4, + customizer: AssignCustomizer + ): LoDashImplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith(): LoDashImplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith(...otherArgs: any[]): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.assignInWith + */ + extendWith( + source: TSource, + customizer: AssignCustomizer + ): LoDashExplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith( + source1: TSource1, + source2: TSource2, + customizer: AssignCustomizer + ): LoDashExplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith( + source1: TSource1, + source2: TSource2, + source3: TSource3, + customizer: AssignCustomizer + ): LoDashExplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith( + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4, + customizer: AssignCustomizer + ): LoDashExplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith(): LoDashExplicitObjectWrapper; + + /** + * @see _.assignInWith + */ + extendWith(...otherArgs: any[]): LoDashExplicitObjectWrapper; } //_.findKey @@ -19907,15 +20033,12 @@ declare module "lodash/extend" { export = extend; } -/** -* uncoment it if definition exists -*/ -/* + declare module "lodash/extendWith" { const extendWith: typeof _.extendWith; export = extendWith; } -*/ + declare module "lodash/add" { const add: typeof _.add; From b32c4f463dce4e9506d7aa9ab219e917b711499a Mon Sep 17 00:00:00 2001 From: Yonezawa-T2 Date: Tue, 24 May 2016 22:56:40 +0900 Subject: [PATCH 08/18] Updates kii-cloud-sdk v2.4.3 -> v2.4.4. (#9400) Adds `getPendingEmailAddress` and `getPendingPhoneNumber`. --- kii-cloud-sdk/kii-cloud-sdk.d.ts | 40 +++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/kii-cloud-sdk/kii-cloud-sdk.d.ts b/kii-cloud-sdk/kii-cloud-sdk.d.ts index 970061e8d1..550aa736fa 100644 --- a/kii-cloud-sdk/kii-cloud-sdk.d.ts +++ b/kii-cloud-sdk/kii-cloud-sdk.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Kii Cloud SDK v2.4.3 +// Type definitions for Kii Cloud SDK v2.4.4 // Project: http://en.kii.com/ // Definitions by: Kii Consortium // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6059,6 +6059,18 @@ declare namespace KiiCloud { */ getEmailAddress(): string; + /** + * Get the email of this user that has not been verified. + * When the user's email has been changed and email verification is required in you app configuration, + * New email is stored as pending email. + * After the new email has been verified, the address can be obtained by {@link KiiUser.getEmailAddress} + * + * @return User's new email address has not been verified. + * null if no pending email field is included in refresh + * response or undefined when no refresh operation has been done before. + */ + getPendingEmailAddress(): string; + /** * Get the phone number associated with this user * @@ -6066,6 +6078,18 @@ declare namespace KiiCloud { */ getPhoneNumber(): string; + /** + * Get the phone of this user that has not been verified. + * When the user's phone has been changed and phone verification is required in you app configuration, + * New phone is stored as pending phone. + * After the new phone has been verified, the address can be obtained by {@link KiiUser.getPhoneNumber} + * + * @return User's new phone number has not been verified. + * null if no pending phone field is included in refresh + * response or undefined when no refresh operation has been done before. + */ + getPendingPhoneNumber(): string; + /** * Get the country code associated with this user * @@ -7126,7 +7150,12 @@ declare namespace KiiCloud { ownerOfGroups(callbacks?: { success(theUser: KiiUser, groupList: KiiGroup[]): any; failure(theUser: KiiUser, anErrorString: string): any; }): Promise<[KiiUser, KiiGroup[]]>; /** - * Updates the user's phone number on the server + * Change phone number of logged in user. + * If the phone number verification is required by your app configuration, + * User's phone number would not changed to new one until the new phone number verification has been done. + * In this case, new phone can be obtained by {@link KiiUser#getPendingPhoneNumber()}. + * This API does not refresh the KiiUser automatically. + * Please execute {@link KiiUser#refresh()} before checking the value of {@link KiiUser#getPhoneNumber()} or {@link KiiUser#getPendingPhoneNumber()}. * * @param newPhoneNumber The new phone number to change to * @param callbacks An object with callback methods defined @@ -7169,7 +7198,12 @@ declare namespace KiiCloud { changePhone(newPhoneNumber: string, callbacks?: { success(theUser: KiiUser): any; failure(theUser: KiiUser, anErrorString: string): any; }): Promise; /** - * Updates the user's email address on the server + * Change email of logged in user. + * If the email address verification is required by your app configuration, + * User's email would not changed to new one until the new email verification has been done. + * In this case, new mail address can be obtained by {@link KiiUser#getPendingEmailAddress()}. + * This API does not refresh the KiiUser automatically. + * Please execute {@link KiiUser#refresh()} before checking the value of {@link KiiUser#getEmailAddress()} or {@link KiiUser#getPendingEmailAddress()} * * @param newEmail The new email address to change to * @param callbacks An object with callback methods defined From 10dc219acc06f971dd55530fc7b02969bd52a5a6 Mon Sep 17 00:00:00 2001 From: Dmitry Pesterev Date: Tue, 24 May 2016 19:00:13 +0500 Subject: [PATCH 09/18] Updated jquery.tooltipster to 3.3.0 (#9406) * Definitions for jquery.tooltipster 3.3.0 * Updated tests to test type union in content * Version --- .../jquery.tooltipster-tests.ts | 10 +++-- jquery.tooltipster/jquery.tooltipster.d.ts | 41 ++++++++++++++----- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/jquery.tooltipster/jquery.tooltipster-tests.ts b/jquery.tooltipster/jquery.tooltipster-tests.ts index 8a8f29acae..21a5446c12 100644 --- a/jquery.tooltipster/jquery.tooltipster-tests.ts +++ b/jquery.tooltipster/jquery.tooltipster-tests.ts @@ -1,8 +1,8 @@ /// -// Type definition tests for jQuery Tooltipster 3.0.5 +// Type definition tests for jQuery Tooltipster 3.3.0 // Project: https://github.com/iamceege/tooltipster -// Definitions by: Patrick Magee +// Definitions by: Patrick Magee , Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Tests taken from the getting started section of the Tooltipster website @@ -13,6 +13,10 @@ $(document).ready(function () { $('#my-tooltip').tooltipster({ content: $(' This text is in bold case !') }); + + $('#my-tooltip').tooltipster({ + content: 'string test' + }); }); @@ -191,4 +195,4 @@ $(document).ready(function () { }); }); -$('#my-special-tooltip').tooltipster('content', 'My new content'); \ No newline at end of file +$('#my-special-tooltip').tooltipster('content', 'My new content'); diff --git a/jquery.tooltipster/jquery.tooltipster.d.ts b/jquery.tooltipster/jquery.tooltipster.d.ts index a4df0a36e3..13260f15fe 100644 --- a/jquery.tooltipster/jquery.tooltipster.d.ts +++ b/jquery.tooltipster/jquery.tooltipster.d.ts @@ -1,6 +1,6 @@ -// Type definitions for jQuery Tooltipster 3.0.5 +// Type definitions for jQuery Tooltipster 3.3.0 // Project: https://github.com/iamceege/tooltipster -// Definitions by: Patrick Magee +// Definitions by: Patrick Magee , Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -21,14 +21,13 @@ interface JQueryTooltipsterOptions { */ arrowColor?: any; /** - * If autoClose is set to false, the tooltip will never close unless you call the 'close' method yourself. Default: true + * If autoClose is set to false, the tooltip will never close unless you call the 'hide' method yourself. Default: true */ autoClose?: boolean; /** * If set, this will override the content of the tooltip. Default: null - * @type string, jQuery object */ - content?: any; + content?: string | JQuery; /** * If the content of the tooltip is provided as a string, it is displayed as plain text by default. If this content should actually be interpreted as HTML, set this option to true. Default: false */ @@ -38,15 +37,19 @@ interface JQueryTooltipsterOptions { */ contentCloning?: boolean; /** + * Tooltipster logs notices into the console when you're doing something you ideally shouldn't be doing. Set to false to disable logging. Default: true + */ + debug?: boolean; + /** * Delay how long it takes (in milliseconds) for the tooltip to start animating in. Default: 200 */ delay?: number; /** - * Set a fixed width for the tooltip. The tooltip will always be a consistent width - no matter your content size. Default: 0 (auto width) + * Set a minimum width for the tooltip. Default: 0 (auto width) */ - fixedWidth?: number; + minWidth?: number; /** - * Set a max width for the tooltip. If the tooltip ends up being smaller than the set max width, the tooltip's width will be set automatically. Default: 0 (no max width) + * Set a maximum width for the tooltip. Default: null (no max width) */ maxWidth?: number; /** @@ -66,10 +69,13 @@ interface JQueryTooltipsterOptions { */ functionAfter?: (origin) => void; /** - * If using the iconDesktop or iconTouch options, this sets the content for your icon. Default: '(?)' - * @type string, jQuery object + * If true, the tooltip will close if its origin is clicked. This option only applies when 'trigger' is 'hover' and 'autoClose' is false. Default: false */ - icon?: any; + hideOnClick?: boolean; + /** + * If using the iconDesktop or iconTouch options, this sets the content for your icon. Default: '(?)' + */ + icon?: string | JQuery; /** * If you provide a jQuery object to the 'icon' option, this sets if it is a clone of this object that should actually be used. Default: true */ @@ -95,6 +101,10 @@ interface JQueryTooltipsterOptions { */ interactiveTolerance?: number; /** + * Allows you to put multiple tooltips on a single element. Read further instructions down this page. Default: false + */ + multiple?: boolean; + /** * Offsets the tooltip (in pixels) farther left/right from the origin. Default: 0 */ offsetX?: number; @@ -116,6 +126,15 @@ interface JQueryTooltipsterOptions { */ positionTracker?: boolean; /** + * Called after the tooltip has been repositioned by the position tracker (if enabled). Default: A function that will close the tooltip if the trigger is 'hover' and autoClose is false. + */ + positionTrackerCallback?: (origin) => void; + /** + * Specify if a TITLE attribute should be restored on the HTML element after a call to the 'destroy' method. This attribute may be omitted, or be restored with the value that existed before Tooltipster was initialized, or be restored with the stringified value of the current content. Note: in case of multiple tooltips on a single element, only the last destroyed tooltip may trigger a restoration. Default: 'current' + * 'none', 'previous' or 'current' + */ + restoration?: string; + /** * Set the speed of the animation. Default: 350 */ speed?: number; From dfa9185e5b2004b3a1fa7538a943df309ec115c8 Mon Sep 17 00:00:00 2001 From: Timofey Kachalov Date: Tue, 24 May 2016 17:00:38 +0300 Subject: [PATCH 10/18] Escodegen precedence (#9402) * Added Precedence enum * Added test for Precedence enum * Added Precedence enum * fixed test --- escodegen/escodegen-tests.ts | 2 ++ escodegen/escodegen.d.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/escodegen/escodegen-tests.ts b/escodegen/escodegen-tests.ts index 247ea2e02d..f6c18cf5cd 100644 --- a/escodegen/escodegen-tests.ts +++ b/escodegen/escodegen-tests.ts @@ -49,6 +49,8 @@ let generateOptions: escodegen.GenerateOptions = { verbatim: " " }; +let precedence: escodegen.Precedence = escodegen.Precedence.Primary; + let myCode: string = escodegen.generate({}, generateOptions); let ast: any = escodegen.attachComments({}, {}, {}); diff --git a/escodegen/escodegen.d.ts b/escodegen/escodegen.d.ts index dac9311c6b..b72cfdedc6 100644 --- a/escodegen/escodegen.d.ts +++ b/escodegen/escodegen.d.ts @@ -135,6 +135,35 @@ declare module 'escodegen' { */ verbatim?: string; } + + /** + * https://github.com/estools/escodegen/commit/adf113333cd4888cf59bfc4f957df98bf7db82b6 + */ + export enum Precedence { + Sequence, + Yield, + Await, + Assignment, + Conditional, + ArrowFunction, + LogicalOR, + LogicalAND, + BitwiseOR, + BitwiseXOR, + BitwiseAND, + Equality, + Relational, + BitwiseSHIFT, + Additive, + Multiplicative, + Unary, + Postfix, + Call, + New, + TaggedTemplate, + Member, + Primary + } /** * Produces given Abstract Syntax Tree as javascript code From ffe35810b4b38652bbb9f890f57555337e7da0c8 Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Tue, 24 May 2016 07:01:41 -0700 Subject: [PATCH 11/18] Maker.js 0.8.0 and Bezier-js (#9408) * Added definitions for Bezier.Js * updates for maker.js and bezier.js * removed copyright * deleted bezierjs * Added definitions for Bezier.Js * updates for maker.js and bezier.js * deleted bezierjs * changed name to DefinitelyTyped * update tests for 0.8.0 * rename to bezier-js * add pdfkit reference * public clockwise --- bezier-js/bezier-js-tests.ts | 95 +++++ bezier-js/bezier-js.d.ts | 197 +++++++++++ maker.js/makerjs-tests.ts | 11 +- maker.js/makerjs.d.ts | 661 +++++++++++++++++++++++++++++------ 4 files changed, 849 insertions(+), 115 deletions(-) create mode 100644 bezier-js/bezier-js-tests.ts create mode 100644 bezier-js/bezier-js.d.ts diff --git a/bezier-js/bezier-js-tests.ts b/bezier-js/bezier-js-tests.ts new file mode 100644 index 0000000000..1814d67dc0 --- /dev/null +++ b/bezier-js/bezier-js-tests.ts @@ -0,0 +1,95 @@ +/// + +function test() { + + var bezierjs: typeof BezierJs; + + var bezier = new bezierjs.Bezier([1,2,3,4]); + var cap = new bezierjs.BezierCap([]); + var point: BezierJs.Point = { x: 0, y: 0 }; + var utils = bezier.getUtils(); + var line: BezierJs.Line = { p1: { x:0, y: 0}, p2: {x:1, y: 1}}; + var abc: BezierJs.ABC = { A: null, B: null, C: null }; + var arc: BezierJs.Arc = { e: 0, s: 0, x: 0, y: 0, r: 1 }; + var bbox: BezierJs.BBox = bezier.bbox(); + var closest: BezierJs.Closest = { mdist: 1, mpos: 0 }; + var inflection: BezierJs.Inflection = { values: null, x: [0], y: [0], z:[0] }; + var minmax: BezierJs.MinMax = { min: 0, max: 0 }; + var offset: BezierJs.Offset = { x: 0, y: 0, c: point, n: point }; + var pair: BezierJs.Pair = { left: bezier, right: bezier }; + var poly: BezierJs.PolyBezier = bezier.outline(1); + var projection: BezierJs.Projection = { x: 0, y: 0, t: 9, d: 4 }; + var shape: BezierJs.Shape = { startcap: cap, endcap: cap, forward: bezier, back: bezier, bbox: bbox }; + var split: BezierJs.Split = { left: bezier, right: bezier, span: [point] }; + + bezier.arcs(); + bezier.clockwise; + bezier.compute(.5); + bezier.computedirection(); + bezier.curveintersects([bezier], [bezier]); + bezier.derivative(0); + bezier.get(1); + bezier.getLUT()[0].x; + bezier.hull(0); + bezier.inflections().values; + bezier.intersects(bezier); + bezier.length(); + bezier.lineIntersects(line); + bezier.normal(0); + bezier.offset(1,2); + bezier.on(point, 0); + bezier.order = 5; + bezier.outlineshapes(1,3); + bezier.overlaps(bezier); + bezier.point(9); + bezier.project(point); + bezier.raise(); + bezier.reduce(); + bezier.scale(4); + bezier.selfintersects(); + bezier.simple(); + bezier.split(0, 1); + bezier.toSVG(); + bezier.update(); + + cap.virtual = true; + + poly.addCurve(bezier); + poly.bbox(); + poly.curve(7); + poly.curves[0]._3d; + poly.length(); + poly.offset(9).points[0].y; + poly.points[0]; + + utils.abcratio(0, 1); + utils.align([point], line); + utils.angle(point, point, point); + utils.approximately(5, 7, .001); + utils.arcfn(1, function(){}); + utils.bboxoverlap(bbox, bbox); + utils.between(0, 0, 1); + utils.closest([point], point); + utils.copy({}); + utils.dist(point, point); + utils.droots([9]); + utils.expandbox(bbox, bbox); + utils.findbbox([bezier]); + utils.getccenter(point, point, point); + utils.getminmax(bezier, 'x', [0]); + utils.length(function(){}); + utils.lerp(1, point, point); + utils.lli(offset, offset); + utils.lli4(point, point, point, point); + utils.lli8(0, 0, 0, 0, 0, 0, 0, 0); + utils.makeline(point, point); + utils.makeshape(bezier, bezier); + utils.map(0, 0, 0, 0, 0); + utils.pairiteration(bezier, bezier); + utils.pointsToString([point]); + utils.projectionratio(0, 0); + utils.roots([point], line); + utils.round(.999, .001); + utils.shapeintersections(shape, bbox, shape, bbox); + +} \ No newline at end of file diff --git a/bezier-js/bezier-js.d.ts b/bezier-js/bezier-js.d.ts new file mode 100644 index 0000000000..7d54a19d95 --- /dev/null +++ b/bezier-js/bezier-js.d.ts @@ -0,0 +1,197 @@ +// Type definitions for Bezier.js +// Project: https://github.com/Pomax/bezierjs +// Definitions by: Dan Marshall +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare module BezierJs { + interface Point { + x: number; + y: number; + z?: number; + } + interface Projection extends Point { + t?: number; + d?: number; + } + interface Inflection { + x: number[]; + y: number[]; + z?: number[]; + values: number[]; + } + interface Offset extends Point { + c: Point; + n: Point; + } + interface Pair { + left: Bezier; + right: Bezier; + } + interface Split extends Pair { + span: Point[]; + _t1?: number; + _t2?: number; + } + interface MinMax { + min: number; + mid?: number; + max: number; + size?: number; + } + interface BBox { + x: MinMax; + y: MinMax; + z?: MinMax; + } + interface Line { + p1: Point; + p2: Point; + } + interface Arc extends Point { + e: number; + r: number; + s: number; + } + interface Shape { + startcap: BezierCap; + forward: Bezier; + back: Bezier; + endcap: BezierCap; + bbox: BBox; + } + interface ABC { + A: Point; + B: Point; + C: Point; + } + interface Closest { + mdist: number; + mpos: number; + } + /** + * Bezier curve constructor. The constructor argument can be one of three things: + * + * 1. array/4 of {x:..., y:..., z:...}, z optional + * 2. numerical array/8 ordered x1,y1,x2,y2,x3,y3,x4,y4 + * 3. numerical array/12 ordered x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4 + * + */ + class Bezier { + clockwise: boolean; + private _linear; + _3d: boolean; + _t1: number; + _t2: number; + _lut: Point[]; + dpoints: Point[][]; + order: number; + points: Point[]; + dims: string[]; + dimlen: number; + constructor(points: Point[]); + constructor(coords: number[]); + constructor(n1: number, n2: number, n3: number, n4: number, n5: number, n6: number, n7: number, n8: number); + constructor(p1: Point, p2: Point, p3: Point, p4?: Point); + static fromSVG(svgString: string): Bezier; + static getABC(n: number, S: Point, B: Point, E: Point, t: number): ABC; + static quadraticFromPoints(p1: Point, p2: Point, p3: Point, t: number): Bezier; + static cubicFromPoints(S: Point, B: Point, E: Point, t: number, d1: number): Bezier; + static getUtils(): typeof utils; + getUtils(): typeof utils; + valueOf(): string; + toString(): string; + toSVG(): string; + update(): void; + computedirection(): void; + length(): number; + getLUT(steps?: number): Point[]; + on(point: Point, error: number): number; + project(point: Point): Projection; + get(t: number): Point; + point(idx: number): Point; + compute(t: number): Point; + raise(): Bezier; + derivative(t: number): Point; + inflections(): number[]; + normal(t: number): Point; + private __normal2(t); + private __normal3(t); + private __normal(t); + hull(t: number): Point[]; + split(t1: number, t2?: number): Bezier | Split; + extrema(): Inflection; + bbox(): BBox; + overlaps(curve: Bezier): boolean; + offset(t: number, d?: number): Offset | Bezier[]; + simple(): boolean; + reduce(): any[]; + scale(d: Function): Bezier; + scale(d: number): Bezier; + outline(d1: number, d2?: number, d3?: number, d4?: number): PolyBezier; + outlineshapes(d1: number, d2: number): Shape[]; + intersects(curve: Bezier): string[] | number[]; + intersects(curve: Line): string[] | number[]; + lineIntersects(line: Line): number[]; + selfintersects(): string[]; + curveintersects(c1: Bezier[], c2: Bezier[]): string[]; + arcs(errorThreshold?: number): Arc[]; + private _error(pc, np1, s, e); + private _iterate(errorThreshold, circles); + } + class BezierCap extends Bezier { + virtual: boolean; + } +} +declare module BezierJs.utils { + var Tvalues: number[]; + var Cvalues: number[]; + function arcfn(t: number, derivativeFn: Function): number; + function between(v: number, m: number, M: number): boolean; + function approximately(a: number, b: number, precision?: number): boolean; + function length(derivativeFn: Function): number; + function map(v: number, ds: number, de: number, ts: number, te: number): number; + function lerp(r: number, v1: Point, v2: Point): Point; + function pointToString(p: Point): string; + function pointsToString(points: Point[]): string; + function copy(obj: Object): any; + function angle(o: Point, v1: Point, v2: Point): number; + function round(v: number, d: number): number; + function dist(p1: Point, p2: Point): number; + function closest(LUT: Point[], point: Point): Closest; + function abcratio(t: number, n: number): number; + function projectionratio(t: number, n: number): number; + function lli8(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): Point; + function lli4(p1: Point, p2: Point, p3: Point, p4: Point): Point; + function lli(v1: Offset, v2: Offset): Point; + function makeline(p1: Point, p2: Point): Bezier; + function findbbox(sections: Bezier[]): BBox; + function shapeintersections(s1: Shape, bbox1: BBox, s2: Shape, bbox2: BBox): string[][] | number[][]; + function makeshape(forward: Bezier, back: Bezier): Shape; + function getminmax(curve: Bezier, d: string, list: number[]): MinMax; + function align(points: Point[], line: Line): Point[]; + function roots(points: Point[], line: Line): number[]; + function droots(p: number[]): number[]; + function inflections(points: Point[]): number[]; + function bboxoverlap(b1: BBox, b2: BBox): boolean; + function expandbox(bbox: BBox, _bbox: BBox): void; + function pairiteration(c1: Bezier, c2: Bezier): string[]; + function getccenter(p1: Point, p2: Point, p3: Point): Arc; +} +declare module BezierJs { + /** + * Poly Bezier + * @param {[type]} curves [description] + */ + class PolyBezier { + curves: Bezier[]; + private _3d; + points: Point[]; + constructor(curves: Bezier[]); + valueOf(): string; + toString(): string; + addCurve(curve: Bezier): void; + length(): number; + curve(idx: number): Bezier; + bbox(): BBox; + offset(d: number): PolyBezier; + } +} diff --git a/maker.js/makerjs-tests.ts b/maker.js/makerjs-tests.ts index e314f09669..ef32f885ff 100644 --- a/maker.js/makerjs-tests.ts +++ b/maker.js/makerjs-tests.ts @@ -25,11 +25,11 @@ function test() { } function testAngle() { - makerjs.angle.areEqual(12, 13); makerjs.angle.mirror(45, true, false); makerjs.angle.noRevolutions(90); makerjs.angle.ofArcEnd(paths.arc); makerjs.angle.ofArcMiddle(paths.arc); + makerjs.angle.ofArcSpan(paths.arc); makerjs.angle.ofLineInDegrees(paths.line); makerjs.angle.ofPointInDegrees([0,0], [1,1]); makerjs.angle.ofPointInRadians([0,0], [1,1]); @@ -67,7 +67,9 @@ function test() { } function testMeasure() { - makerjs.measure.arcAngle(paths.arc); + makerjs.measure.isPointEqual(p1, p2); + makerjs.measure.isPathEqual(paths.line, paths.circle, 4); + makerjs.measure.isAngleEqual(12, 13); makerjs.measure.isArcConcaveTowardsPoint(paths.arc, [0,0]); makerjs.measure.isBetween(7, 8, 9, false); makerjs.measure.isBetweenArcAngles(7, paths.arc, false); @@ -119,7 +121,6 @@ function test() { } function testPath() { - makerjs.path.areEqual(paths.line, paths.circle, 4); makerjs.path.breakAtPoint(paths.arc, [0,0]).type; makerjs.path.dogbone(paths.line, paths.line, 7); makerjs.path.fillet(paths.arc, paths.line, 4); @@ -129,7 +130,6 @@ function test() { makerjs.path.moveRelative(paths.circle, [0,0]); makerjs.path.rotate(paths.line, 5, [0,0]); makerjs.path.scale(paths.arc, 8); - makerjs.path.slopeIntersectionPoint(paths.line, paths.line); } function testPaths() { @@ -156,8 +156,6 @@ function test() { function testPoint() { makerjs.point.add(p1, p2); - makerjs.point.areEqual(p1, p2); - makerjs.point.areEqualRounded(p1, p2); makerjs.point.average(p1, p2); makerjs.point.clone(p1); makerjs.point.closest([0,0], [p1, p2]); @@ -170,7 +168,6 @@ function test() { makerjs.point.rotate(p1, 5, p2); makerjs.point.rounded(p1); makerjs.point.scale(p2, 8); - makerjs.point.serialize(p1); makerjs.point.subtract(p2, p1); makerjs.point.zero(); } diff --git a/maker.js/makerjs.d.ts b/maker.js/makerjs.d.ts index fdfade36da..28db25f854 100644 --- a/maker.js/makerjs.d.ts +++ b/maker.js/makerjs.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Microsoft/maker.js // Definitions by: Dan Marshall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// /** * Root module for Maker.js. * @@ -37,6 +38,13 @@ declare namespace MakerJs { * @param accuracy Optional exemplar of number of decimal places. */ function round(n: number, accuracy?: number): number; + /** + * Create a string representation of a route array. + * + * @param route Array of strings which are segments of a route. + * @returns String of the flattened array. + */ + function createRouteKey(route: string[]): string; /** * Clone an object. * @@ -89,6 +97,12 @@ declare namespace MakerJs { */ high: IPoint; } + /** + * A map of measurements. + */ + interface IMeasureMap { + [key: string]: IMeasure; + } /** * A line, curved line or other simple two dimensional shape. */ @@ -181,7 +195,6 @@ declare namespace MakerJs { function isPathArc(item: any): boolean; /** * A map of functions which accept a path as a parameter. - * @private */ interface IPathFunctionMap { /** @@ -191,7 +204,6 @@ declare namespace MakerJs { } /** * A map of functions which accept a path and an origin point as parameters. - * @private */ interface IPathOriginFunctionMap { /** @@ -213,10 +225,31 @@ declare namespace MakerJs { Circle: string; Arc: string; }; + /** + * Slope and y-intercept of a line. + */ + interface ISlope { + /** + * Boolean to see if line has slope or is vertical. + */ + hasSlope: boolean; + /** + * Optional value of non-vertical slope. + */ + slope?: number; + /** + * Line used to calculate this slope. + */ + line: IPathLine; + /** + * Optional value of y when x = 0. + */ + yIntercept?: number; + } /** * Options to pass to path.intersection() */ - interface IPathIntersectionOptions { + interface IPathIntersectionBaseOptions { /** * Optional boolean to only return deep intersections, i.e. not on an end point or tangent. */ @@ -226,6 +259,19 @@ declare namespace MakerJs { */ out_AreOverlapped?: boolean; } + /** + * Options to pass to path.intersection() + */ + interface IPathIntersectionOptions extends IPathIntersectionBaseOptions { + /** + * Optional boolean to only return deep intersections, i.e. not on an end point or tangent. + */ + path1Offset?: IPoint; + /** + * Optional output variable which will be set to true if the paths are overlapped. + */ + path2Offset?: IPoint; + } /** * An intersection of two paths. */ @@ -268,6 +314,14 @@ declare namespace MakerJs { * Point which is known to be outside of the model. */ farPoint?: IPoint; + /** + * Cached measurements for model A. + */ + measureA?: measure.Atlas; + /** + * Cached measurements for model B. + */ + measureB?: measure.Atlas; } /** * Options to pass to model.findLoops. @@ -278,6 +332,19 @@ declare namespace MakerJs { */ removeFromOriginal?: boolean; } + /** + * Options to pass to model.simplify() + */ + interface ISimplifyOptions { + /** + * Optional + */ + pointMatchingDistance?: number; + /** + * Optional + */ + scalarMatchingDistance?: number; + } /** * A path that may be indicated to "flow" in either direction between its endpoints. */ @@ -370,11 +437,104 @@ declare namespace MakerJs { pathId: string; } /** - * Path and its reference id within a model + * A route to either a path or a model, and the absolute offset of it. */ - interface IRefPathInModel extends IRefPathIdInModel { + interface IRouteOffset { + layer: string; + offset: IPoint; + route: string[]; + routeKey: string; + } + /** + * A path reference in a walk. + */ + interface IWalkPath extends IRefPathIdInModel, IRouteOffset { pathContext: IPath; } + /** + * Callback signature for path in model.walk(). + */ + interface IWalkPathCallback { + (context: IWalkPath): void; + } + /** + * A link in a chain, with direction of flow. + */ + interface IChainLink { + /** + * Reference to the path. + */ + walkedPath: IWalkPath; + /** + * Path flows forwards or reverse. + */ + reversed: boolean; + /** + * The endpoints of the path, in absolute coords. + */ + endPoints: IPoint[]; + } + /** + * A chain of paths which connect end to end. + */ + interface IChain { + /** + * The links in this chain. + */ + links: IChainLink[]; + /** + * Flag if this chain forms a loop end to end. + */ + endless?: boolean; + } + /** + * Callback to model.findChains() with resulting array of chains and unchained paths. + */ + interface IChainCallback { + (chains: IChain[], loose: IWalkPath[], layer: string): void; + } + /** + * Options to pass to model.findLoops. + */ + interface IFindChainsOptions extends IPointMatchOptions { + /** + * Flag to separate chains by layers. + */ + byLayers?: boolean; + } + /** + * Reference to a model within a model. + */ + interface IRefModelInModel { + parentModel: IModel; + childId: string; + childModel: IModel; + } + /** + * A model reference in a walk. + */ + interface IWalkModel extends IRefModelInModel, IRouteOffset { + } + /** + * Callback signature for model.walk(). + */ + interface IWalkModelCallback { + (context: IWalkModel): void; + } + /** + * Callback signature for model.walk(), which may return false to halt any further walking. + */ + interface IWalkModelCancellableCallback { + (context: IWalkModel): boolean; + } + /** + * Options to pass to model.walk(). + */ + interface IWalkOptions { + onPath?: IWalkPathCallback; + beforeChildWalk?: IWalkModelCancellableCallback; + afterChildWalk?: IWalkModelCallback; + } /** * Describes a parameter and its limits. */ @@ -425,14 +585,6 @@ declare namespace MakerJs { } } declare namespace MakerJs.angle { - /** - * Find out if two angles are equal. - * - * @param a First angle. - * @param b Second angle. - * @returns true if angles are the same, false if they are not - */ - function areEqual(angle1: number, angle2: number, accuracy?: number): boolean; /** * Ensures an angle is not greater than 360 * @@ -469,6 +621,13 @@ declare namespace MakerJs.angle { * @returns Middle angle of arc. */ function ofArcMiddle(arc: IPathArc, ratio?: number): number; + /** + * Total angle of an arc between its start and end angles. + * + * @param arc The arc to measure. + * @returns Angle of arc. + */ + function ofArcSpan(arc: IPathArc): number; /** * Angle of a line path. * @@ -512,23 +671,6 @@ declare namespace MakerJs.point { * @returns A new point object. */ function add(a: IPoint, b: IPoint, subtract?: boolean): IPoint; - /** - * Find out if two points are equal. - * - * @param a First point. - * @param b Second point. - * @returns true if points are the same, false if they are not - */ - function areEqual(a: IPoint, b: IPoint, withinDistance?: number): boolean; - /** - * Find out if two points are equal after rounding. - * - * @param a First point. - * @param b Second point. - * @param accuracy Optional exemplar of number of decimal places. - * @returns true if points are the same, false if they are not - */ - function areEqualRounded(a: IPoint, b: IPoint, accuracy?: number): boolean; /** * Get the average of two points. * @@ -580,7 +722,16 @@ declare namespace MakerJs.point { * @param pathContext The path object. * @returns Array with 2 elements: [0] is the point object corresponding to the origin, [1] is the point object corresponding to the end. */ - function fromPathEnds(pathContext: IPath): IPoint[]; + function fromPathEnds(pathContext: IPath, pathOffset?: IPoint): IPoint[]; + /** + * Calculates the intersection of slopes of two lines. + * + * @param lineA First line to use for slope. + * @param lineB Second line to use for slope. + * @param options Optional IPathIntersectionOptions. + * @returns point of intersection of the two slopes, or null if the slopes did not intersect. + */ + function fromSlopeIntersection(lineA: IPathLine, lineB: IPathLine, options?: IPathIntersectionBaseOptions): IPoint; /** * Get the middle point of a path. * @@ -623,14 +774,6 @@ declare namespace MakerJs.point { * @returns A new point. */ function scale(pointToScale: IPoint, scaleValue: number): IPoint; - /** - * Get a string representation of a point. - * - * @param pointContext The point to serialize. - * @param accuracy Optional exemplar of number of decimal places. - * @returns String representing the point. - */ - function serialize(pointContext: IPoint, accuracy?: number): string; /** * Subtract a point from another point, and return the result as a new point. Shortcut to Add(a, b, subtract = true). * @@ -649,13 +792,12 @@ declare namespace MakerJs.point { } declare namespace MakerJs.path { /** - * Find out if two paths are equal. + * Create a clone of a path. This is faster than cloneObject. * - * @param a First path. - * @param b Second path. - * @returns true if paths are the same, false if they are not + * @param pathToClone The path to clone. + * @returns Cloned path. */ - function areEqual(path1: IPath, path2: IPath, withinPointDistance?: number): boolean; + function clone(pathToClone: IPath): IPath; /** * Create a clone of a path, mirrored on either or both x and y axes. * @@ -679,9 +821,18 @@ declare namespace MakerJs.path { * * @param pathToMove The path to move. * @param delta The x & y adjustments as a point object. + * @param subtract Optional boolean to subtract instead of add. * @returns The original path (for chaining). */ - function moveRelative(pathToMove: IPath, delta: IPoint): IPath; + function moveRelative(pathToMove: IPath, delta: IPoint, subtract?: boolean): IPath; + /** + * Move some paths relatively during a task execution, then unmove them. + * + * @param pathsToMove The paths to move. + * @param deltas The x & y adjustments as a point object array. + * @param task The function to call while the paths are temporarily moved. + */ + function moveTemporary(pathsToMove: IPath[], deltas: IPoint[], task: Function): void; /** * Rotate a path. * @@ -715,11 +866,6 @@ declare namespace MakerJs.path { declare namespace MakerJs.paths { /** * Class for arc path. - * - * @param origin The center point of the arc. - * @param radius The radius of the arc. - * @param startAngle The start angle of the arc. - * @param endAngle The end angle of the arc. */ class Arc implements IPathArc { origin: IPoint; @@ -727,19 +873,71 @@ declare namespace MakerJs.paths { startAngle: number; endAngle: number; type: string; + /** + * Class for arc path, created from origin point, radius, start angle, and end angle. + * + * @param origin The center point of the arc. + * @param radius The radius of the arc. + * @param startAngle The start angle of the arc. + * @param endAngle The end angle of the arc. + */ constructor(origin: IPoint, radius: number, startAngle: number, endAngle: number); + /** + * Class for arc path, created from 2 points, radius, large Arc flag, and clockwise flag. + * + * @param pointA First end point of the arc. + * @param pointB Second end point of the arc. + * @param radius The radius of the arc. + * @param largeArc Boolean flag to indicate clockwise direction. + * @param clockwise Boolean flag to indicate clockwise direction. + */ + constructor(pointA: IPoint, pointB: IPoint, radius: number, largeArc: boolean, clockwise: boolean); + /** + * Class for arc path, created from 2 points and optional boolean flag indicating clockwise. + * + * @param pointA First end point of the arc. + * @param pointB Second end point of the arc. + * @param clockwise Boolean flag to indicate clockwise direction. + */ + constructor(pointA: IPoint, pointB: IPoint, clockwise?: boolean); + /** + * Class for arc path, created from 3 points. + * + * @param pointA First end point of the arc. + * @param pointB Middle point on the arc. + * @param pointC Second end point of the arc. + */ + constructor(pointA: IPoint, pointB: IPoint, pointC: IPoint); } /** * Class for circle path. - * - * @param origin The center point of the circle. - * @param radius The radius of the circle. */ class Circle implements IPathCircle { + type: string; origin: IPoint; radius: number; - type: string; + /** + * Class for circle path, created from origin point and radius. + * + * @param origin The center point of the circle. + * @param radius The radius of the circle. + */ constructor(origin: IPoint, radius: number); + /** + * Class for circle path, created from 2 points. + * + * @param pointA First point on the circle. + * @param pointB Second point on the circle. + */ + constructor(pointA: IPoint, pointB: IPoint); + /** + * Class for circle path, created from 3 points. + * + * @param pointA First point on the circle. + * @param pointB Second point on the circle. + * @param pointC Third point on the circle. + */ + constructor(pointA: IPoint, pointB: IPoint, pointC: IPoint); } /** * Class for line path. @@ -832,6 +1030,14 @@ declare namespace MakerJs.model { * @returns The original model (for chaining). */ function moveRelative(modelToMove: IModel, delta: IPoint): IModel; + /** + * Prefix the ids of paths in a model. + * + * @param modelToPrefix The model to prefix. + * @param prefix The prefix to prepend on paths ids. + * @returns The original model (for chaining). + */ + function prefixPathIds(modelToPrefix: IModel, prefix: string): IModel; /** * Rotate a model. * @@ -865,6 +1071,15 @@ declare namespace MakerJs.model { * @param callback Callback for each path. */ function walkPaths(modelContext: IModel, callback: IModelPathCallback): void; + /** + * Recursively walk through all paths for a given model. + * + * @param modelContext The model to walk. + * @param pathCallback Callback for each path. + * @param modelCallbackBeforeWalk Callback for each model prior to recursion, which can cancel the recursion if it returns false. + * @param modelCallbackAfterWalk Callback for each model after recursion. + */ + function walk(modelContext: IModel, options: IWalkOptions): void; } declare namespace MakerJs.model { /** @@ -875,7 +1090,7 @@ declare namespace MakerJs.model { * @param farPoint Optional point of reference which is outside the bounds of the modelContext. * @returns Boolean true if the path is inside of the modelContext. */ - function isPathInsideModel(pathContext: IPath, modelContext: IModel, farPoint?: IPoint): boolean; + function isPathInsideModel(pathContext: IPath, modelContext: IModel, pathOffset?: IPoint, farPoint?: IPoint, measureAtlas?: measure.Atlas): boolean; /** * Break a model's paths everywhere they intersect with another path. * @@ -884,7 +1099,7 @@ declare namespace MakerJs.model { */ function breakPathsAtIntersections(modelToBreak: IModel, modelToIntersect?: IModel): void; /** - * Combine 2 models. The models should be originated, and every path within each model should be part of a loop. + * Combine 2 models. * * @param modelA First model to combine. * @param modelB Second model to combine. @@ -896,6 +1111,106 @@ declare namespace MakerJs.model { * @param farPoint Optional point of reference which is outside the bounds of both models. */ function combine(modelA: IModel, modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, options?: ICombineOptions): void; + /** + * Combine 2 models, resulting in a intersection. + * + * @param modelA First model to combine. + * @param modelB Second model to combine. + */ + function combineIntersection(modelA: IModel, modelB: IModel): void; + /** + * Combine 2 models, resulting in a subtraction of B from A. + * + * @param modelA First model to combine. + * @param modelB Second model to combine. + */ + function combineSubtraction(modelA: IModel, modelB: IModel): void; + /** + * Combine 2 models, resulting in a union. + * + * @param modelA First model to combine. + * @param modelB Second model to combine. + */ + function combineUnion(modelA: IModel, modelB: IModel): void; +} +declare namespace MakerJs { + /** + * Compare keys to see if they are equal. + */ + interface ICollectionKeyComparer { + (a: K, b: K): boolean; + } + /** + * A collection for items that share a common key. + */ + interface ICollection { + key: K; + items: T[]; + } + /** + * Collects items that share a common key. + */ + class Collector { + private comparer; + collections: ICollection[]; + constructor(comparer?: ICollectionKeyComparer); + addItemToCollection(key: K, item: T): void; + findCollection(key: K, action?: (index: number) => void): T[]; + removeCollection(key: K): boolean; + removeItemFromCollection(key: K, item: T): boolean; + getCollectionsOfMultiple(cb: (key: K, items: T[]) => void): void; + } +} +declare namespace MakerJs.model { + /** + * Simplify a model's paths by reducing redundancy: combine multiple overlapping paths into a single path. The model must be originated. + * + * @param modelContext The originated model to search for similar paths. + * @param options Optional options object. + * @returns The simplified model (for chaining). + */ + function simplify(modelToSimplify: IModel, options?: ISimplifyOptions): IModel; +} +declare namespace MakerJs.path { + /** + * Expand path by creating a model which surrounds it. + * + * @param pathToExpand Path to expand. + * @param expansion Distance to expand. + * @param isolateCaps Optional flag to put the end caps into a separate model named "caps". + * @returns Model which surrounds the path. + */ + function expand(pathToExpand: IPath, expansion: number, isolateCaps?: boolean): IModel; + /** + * Represent an arc using straight lines. + * + * @param arc Arc to straighten. + * @param bevel Optional flag to bevel the angle to prevent it from being too sharp. + * @param prefix Optional prefix to apply to path ids. + * @returns Model of straight lines with same endpoints as the arc. + */ + function straighten(arc: IPathArc, bevel?: boolean, prefix?: string): IModel; +} +declare namespace MakerJs.model { + /** + * Expand all paths in a model, then combine the resulting expansions. + * + * @param modelToExpand Model to expand. + * @param distance Distance to expand. + * @param joints Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints. + * @returns Model which surrounds the paths of the original model. + */ + function expandPaths(modelToExpand: IModel, distance: number, joints?: number, combineOptions?: ICombineOptions): IModel; + /** + * Outline a model by a specified distance. Useful for accommodating for kerf. + * + * @param modelToOutline Model to outline. + * @param distance Distance to outline. + * @param joints Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints. + * @param inside Optional boolean to draw lines inside the model instead of outside. + * @returns Model which surrounds the paths outside of the original model. + */ + function outline(modelToOutline: IModel, distance: number, joints?: number, inside?: boolean): IModel; } declare namespace MakerJs.units { /** @@ -909,12 +1224,48 @@ declare namespace MakerJs.units { } declare namespace MakerJs.measure { /** - * Total angle of an arc between its start and end angles. + * Find out if two angles are equal. * - * @param arc The arc to measure. - * @returns Angle of arc. + * @param angleA First angle. + * @param angleB Second angle. + * @returns true if angles are the same, false if they are not */ - function arcAngle(arc: IPathArc): number; + function isAngleEqual(angleA: number, angleB: number, accuracy?: number): boolean; + /** + * Find out if two paths are equal. + * + * @param pathA First path. + * @param pathB Second path. + * @returns true if paths are the same, false if they are not + */ + function isPathEqual(pathA: IPath, pathB: IPath, withinPointDistance?: number, pathAOffset?: IPoint, pathBOffset?: IPoint): boolean; + /** + * Find out if two points are equal. + * + * @param a First point. + * @param b Second point. + * @returns true if points are the same, false if they are not + */ + function isPointEqual(a: IPoint, b: IPoint, withinDistance?: number): boolean; + /** + * Check for slope equality. + * + * @param slopeA The ISlope to test. + * @param slopeB The ISlope to check for equality. + * @returns Boolean true if slopes are equal. + */ + function isSlopeEqual(slopeA: ISlope, slopeB: ISlope): boolean; +} +declare namespace MakerJs.measure { + /** + * Increase a measurement by an additional measurement. + * + * @param baseMeasure The measurement to increase. + * @param addMeasure The additional measurement. + * @param addOffset Optional offset point of the additional measurement. + * @returns The increased original measurement (for chaining). + */ + function increase(baseMeasure: IMeasure, addMeasure: IMeasure): IMeasure; /** * Check for arc being concave or convex towards a given point. * @@ -923,16 +1274,25 @@ declare namespace MakerJs.measure { * @returns Boolean true if arc is concave towards point. */ function isArcConcaveTowardsPoint(arc: IPathArc, towardsPoint: IPoint): boolean; + /** + * Check for arc overlapping another arc. + * + * @param arcA The arc to test. + * @param arcB The arc to check for overlap. + * @param excludeTangents Boolean to exclude exact endpoints and only look for deep overlaps. + * @returns Boolean true if arc1 is overlapped with arcB. + */ + function isArcOverlapping(arcA: IPathArc, arcB: IPathArc, excludeTangents: boolean): boolean; /** * Check if a given number is between two given limits. * * @param valueInQuestion The number to test. - * @param limit1 First limit. - * @param limit2 Second limit. + * @param limitA First limit. + * @param limitB Second limit. * @param exclusive Flag to exclude equaling the limits. * @returns Boolean true if value is between (or equal to) the limits. */ - function isBetween(valueInQuestion: number, limit1: number, limit2: number, exclusive: boolean): boolean; + function isBetween(valueInQuestion: number, limitA: number, limitB: number, exclusive: boolean): boolean; /** * Check if a given angle is between an arc's start and end angles. * @@ -951,6 +1311,27 @@ declare namespace MakerJs.measure { * @returns Boolean true if point is between (or equal to) the line's origin and end points. */ function isBetweenPoints(pointInQuestion: IPoint, line: IPathLine, exclusive: boolean): boolean; + /** + * Check for line overlapping another line. + * + * @param lineA The line to test. + * @param lineB The line to check for overlap. + * @param excludeTangents Boolean to exclude exact endpoints and only look for deep overlaps. + * @returns Boolean true if line1 is overlapped with lineB. + */ + function isLineOverlapping(lineA: IPathLine, lineB: IPathLine, excludeTangents: boolean): boolean; + /** + * Check for measurement overlapping another measurement. + * + * @param measureA The measurement to test. + * @param measureB The measurement to check for overlap. + * @returns Boolean true if measure1 is overlapped with measureB. + */ + function isMeasurementOverlapping(measureA: IMeasure, measureB: IMeasure): boolean; + /** + * Gets the slope of a line. + */ + function lineSlope(line: IPathLine): ISlope; /** * Calculates the distance between two points. * @@ -965,7 +1346,7 @@ declare namespace MakerJs.measure { * @param pathToMeasure The path to measure. * @returns object with low and high points. */ - function pathExtents(pathToMeasure: IPath): IMeasure; + function pathExtents(pathToMeasure: IPath, addOffset?: IPoint): IMeasure; /** * Measures the length of a path. * @@ -977,9 +1358,38 @@ declare namespace MakerJs.measure { * Measures the smallest rectangle which contains a model. * * @param modelToMeasure The model to measure. + * @param atlas Optional atlas to save measurements. * @returns object with low and high points. */ - function modelExtents(modelToMeasure: IModel): IMeasure; + function modelExtents(modelToMeasure: IModel, atlas?: measure.Atlas): IMeasure; + /** + * A list of maps of measurements. + * + * @param modelToMeasure The model to measure. + * @param atlas Optional atlas to save measurements. + * @returns object with low and high points. + */ + class Atlas { + modelContext: IModel; + /** + * Flag that models have been measured. + */ + modelsMeasured: boolean; + /** + * Map of model measurements, mapped by routeKey. + */ + modelMap: IMeasureMap; + /** + * Map of path measurements, mapped by routeKey. + */ + pathMap: IMeasureMap; + /** + * Constructor. + * @param modelContext The model to measure. + */ + constructor(modelContext: IModel); + measureModels(): void; + } } declare namespace MakerJs.exporter { /** @@ -1050,12 +1460,12 @@ declare namespace MakerJs.solvers { /** * Solves for the angle of a triangle when you know lengths of 3 sides. * - * @param length1 Length of side of triangle, opposite of the angle you are trying to find. - * @param length2 Length of any other side of the triangle. - * @param length3 Length of the remaining side of the triangle. + * @param lengthA Length of side of triangle, opposite of the angle you are trying to find. + * @param lengthB Length of any other side of the triangle. + * @param lengthC Length of the remaining side of the triangle. * @returns Angle opposite of the side represented by the first parameter. */ - function solveTriangleSSS(length1: number, length2: number, length3: number): number; + function solveTriangleSSS(lengthA: number, lengthB: number, lengthC: number): number; /** * Solves for the length of a side of a triangle when you know length of one side and 2 angles. * @@ -1076,33 +1486,24 @@ declare namespace MakerJs.path { * @returns IPathIntersection object, with points(s) of intersection (and angles, when a path is an arc or circle); or null if the paths did not intersect. */ function intersection(path1: IPath, path2: IPath, options?: IPathIntersectionOptions): IPathIntersection; - /** - * Calculates the intersection of slopes of two lines. - * - * @param line1 First line to use for slope. - * @param line2 Second line to use for slope. - * @param options Optional IPathIntersectionOptions. - * @returns point of intersection of the two slopes, or null if the slopes did not intersect. - */ - function slopeIntersectionPoint(line1: IPathLine, line2: IPathLine, options?: IPathIntersectionOptions): IPoint; } declare namespace MakerJs.path { /** * Adds a round corner to the outside angle between 2 lines. The lines must meet at one point. * - * @param line1 First line to fillet, which will be modified to fit the fillet. - * @param line2 Second line to fillet, which will be modified to fit the fillet. + * @param lineA First line to fillet, which will be modified to fit the fillet. + * @param lineB Second line to fillet, which will be modified to fit the fillet. * @returns Arc path object of the new fillet. */ - function dogbone(line1: IPathLine, line2: IPathLine, filletRadius: number, options?: IPointMatchOptions): IPathArc; + function dogbone(lineA: IPathLine, lineB: IPathLine, filletRadius: number, options?: IPointMatchOptions): IPathArc; /** * Adds a round corner to the inside angle between 2 paths. The paths must meet at one point. * - * @param path1 First path to fillet, which will be modified to fit the fillet. - * @param path2 Second path to fillet, which will be modified to fit the fillet. + * @param pathA First path to fillet, which will be modified to fit the fillet. + * @param pathB Second path to fillet, which will be modified to fit the fillet. * @returns Arc path object of the new fillet. */ - function fillet(path1: IPath, path2: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc; + function fillet(pathA: IPath, pathB: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc; } declare namespace MakerJs.kit { /** @@ -1123,22 +1524,15 @@ declare namespace MakerJs.kit { } declare namespace MakerJs.model { /** - * @private + * Find paths that have common endpoints and form chains. + * + * @param modelContext The model to search for chains. + * @param options Optional options object. + * @returns A list of chains. */ - interface IPointMappedItem { - averagePoint: IPoint; - item: T; - } - /** - * @private - */ - class PointMap { - matchingDistance: number; - list: IPointMappedItem[]; - constructor(matchingDistance?: number); - add(pointToAdd: IPoint, item: T): void; - find(pointToFind: IPoint, saveAverage: boolean): T; - } + function findChains(modelContext: IModel, callback: IChainCallback, options?: IFindChainsOptions): void; +} +declare namespace MakerJs.model { /** * Find paths that have common endpoints and form loops. * @@ -1153,7 +1547,14 @@ declare namespace MakerJs.model { * @param loopToDetach The model to search for loops. */ function detachLoop(loopToDetach: IModel): void; - function removeDeadEnds(modelContext: IModel, pointMatchingDistance?: number): void; + /** + * Remove paths from a model which have endpoints that do not connect to other paths. + * + * @param modelContext The model to search for dead ends. + * @param options Optional options object. + * @returns The input model (for chaining). + */ + function removeDeadEnds(modelContext: IModel, pointMatchingDistance?: number): IModel; } declare namespace MakerJs.exporter { /** @@ -1249,6 +1650,37 @@ declare namespace MakerJs.exporter { } } declare namespace MakerJs.exporter { + /** + * Injects drawing into a PDFKit document. + * + * @param modelToExport Model object to export. + * @param options Export options object. + * @returns String of PDF file contents. + */ + function toPDF(doc: PDFKit.PDFDocument, modelToExport: IModel, options?: IPDFRenderOptions): void; + /** + * PDF rendering options. + */ + interface IPDFRenderOptions extends IExportOptions { + /** + * Rendered reference origin. + */ + origin?: IPoint; + /** + * SVG color of the rendered paths. + */ + stroke?: string; + } +} +declare namespace MakerJs.exporter { + /** + * Convert a chain to SVG path data. + */ + function chainToSVGPathData(chain: IChain, offset: IPoint): string; + /** + * Convert a path to SVG path data. + */ + function pathToSVGPathData(pathToExport: IPath, offset: IPoint, offset2: IPoint): string; function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string; function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string; function toSVG(pathToExport: IPath, options?: ISVGRenderOptions): string; @@ -1273,6 +1705,10 @@ declare namespace MakerJs.exporter { * Optional attributes to add to the root svg tag. */ svgAttrs?: IXmlTagAttrs; + /** + * SVG fill color. + */ + fill?: string; /** * SVG font size and font size units. */ @@ -1314,9 +1750,11 @@ declare namespace MakerJs.models { } } declare namespace MakerJs.models { - class Polygon extends ConnectTheDots { - constructor(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number); - static getPoints(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number): IPoint[]; + class Polygon implements IModel { + paths: IPathMap; + constructor(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number, circumscribed?: boolean); + static circumscribedRadius(radius: number, angleInRadians: number): number; + static getPoints(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number, circumscribed?: boolean): IPoint[]; } } declare namespace MakerJs.models { @@ -1344,19 +1782,24 @@ declare namespace MakerJs.models { } } declare namespace MakerJs.models { - class Oval extends RoundRectangle { + class Oval implements IModel { + paths: IPathMap; constructor(width: number, height: number); } } declare namespace MakerJs.models { class OvalArc implements IModel { paths: IPathMap; - constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number, selfIntersect?: boolean); + models: IModelMap; + constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number, selfIntersect?: boolean, isolateCaps?: boolean); } } declare namespace MakerJs.models { - class Rectangle extends ConnectTheDots { + class Rectangle implements IModel { + paths: IPathMap; + origin: IPoint; constructor(width: number, height: number); + constructor(measurement: IMeasure); } } declare namespace MakerJs.models { @@ -1375,11 +1818,13 @@ declare namespace MakerJs.models { class Slot implements IModel { paths: IPathMap; origin: IPoint; - constructor(origin: IPoint, endPoint: IPoint, radius: number); + models: IModelMap; + constructor(origin: IPoint, endPoint: IPoint, radius: number, isolateCaps?: boolean); } } declare namespace MakerJs.models { - class Square extends Rectangle { + class Square implements IModel { + paths: IPathMap; constructor(side: number); } } From 4eb951c3079978734ce0b1055ee3f21026bf17dd Mon Sep 17 00:00:00 2001 From: William Comartin Date: Tue, 24 May 2016 10:10:12 -0400 Subject: [PATCH 12/18] Adding Definitions for js-quantities (#9411) * Add js-quantities library definitions * Change Module to Namespace * Remove intl-tel-input --- js-quantities/js-quantities-tests.ts | 9 ++++ js-quantities/js-quantities.d.ts | 79 ++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 js-quantities/js-quantities-tests.ts create mode 100644 js-quantities/js-quantities.d.ts diff --git a/js-quantities/js-quantities-tests.ts b/js-quantities/js-quantities-tests.ts new file mode 100644 index 0000000000..c8d00eef53 --- /dev/null +++ b/js-quantities/js-quantities-tests.ts @@ -0,0 +1,9 @@ +/// + +var Val1 = Qty('1 m') + +var Val2 = Qty(1); + +var Val3 = Qty(1, 'm'); + +var Val4 = Qty(Val1); \ No newline at end of file diff --git a/js-quantities/js-quantities.d.ts b/js-quantities/js-quantities.d.ts new file mode 100644 index 0000000000..a2e3c2d96c --- /dev/null +++ b/js-quantities/js-quantities.d.ts @@ -0,0 +1,79 @@ +// Type definitions for JS-quantities +// Project: http://gentooboontoo.github.io/js-quantities/ +// Definitions by: William Comartin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare var Qty: QtyModule.QtyStatic; + +declare namespace QtyModule { + interface QtyStatic { + (value: string): Qty; + (value: number): Qty; + (value: number, unit: string): Qty; + (value: Qty): Qty; + } + + interface Qty { + version: string; + + scalar: number; + baseScalar: number; + + parse(value: string): Qty; + + swiftConverter(srcUnits:string, dstUnits:string): (value:number) => number; + + getkinds(): string[]; + + getUnits(kind:string): string[]; + + getAliases(unitName:string): string[]; + + formatter(scalar:number, units:string):string; + + toFloat(): number; + + isUnitless(): boolean; + + isCompatible(other:string|Qty): boolean; + + isInverse(other:string|Qty): boolean + + kind(): string; + + isBase(): boolean; + + toBase(): Qty; + + units(): string; + + eq(other:Qty): boolean; + lt(other:Qty): boolean; + lte(other:Qty): boolean; + gt(other:Qty): boolean; + gte(other:Qty): boolean; + + toPrec(precQuantity: Qty|string|number): Qty; + + toString(targetUnitsOrMaxDecimalsOrPrec?:number|string|Qty, maxDecimals?: number): string; + + format(targetUnits?:string, formatter?:(scalar:number, units:string) => string): string; + + compareTo(other:Qty|string): number; + + same(other: Qty): boolean; + + inverse(): Qty; + + isDegrees(): boolean; + + isTemperature(): boolean; + + to(other:string|Qty): Qty; + + add(other:string|Qty): Qty; + sub(other:string|Qty): Qty; + mul(other:number|string|Qty): Qty; + div(other:number|string|Qty): Qty; + } +} \ No newline at end of file From 587f9d9cb018514c03434ccc0fc53ffcad32e8b7 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 24 May 2016 10:20:46 -0400 Subject: [PATCH 13/18] isomorphic-fetch,whatwg-fetch: Add ArrayBuffer to BodyInit (#9387) * isomorphic-fetch: whitespace * isomorphic-fetch: Add ArrayBuffer{,View} to BodyInit Relevant specs: BodyInit: https://fetch.spec.whatwg.org/#bodyinit BufferSource: https://heycam.github.io/webidl/#common-BufferSource * whatwg-fetch: Add ArrayBuffer{,View} to BodyInit Relevant specs: BodyInit: https://fetch.spec.whatwg.org/#bodyinit BufferSource: https://heycam.github.io/webidl/#common-BufferSource --- isomorphic-fetch/isomorphic-fetch.d.ts | 14 +++++++------- whatwg-fetch/whatwg-fetch.d.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/isomorphic-fetch/isomorphic-fetch.d.ts b/isomorphic-fetch/isomorphic-fetch.d.ts index 0edbe24afb..19754db0f1 100644 --- a/isomorphic-fetch/isomorphic-fetch.d.ts +++ b/isomorphic-fetch/isomorphic-fetch.d.ts @@ -4,23 +4,23 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare enum RequestContext { - "audio", "beacon", "cspreport", "download", "embed", "eventsource", - "favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe", - "image", "imageset", "import", "internal", "location", "manifest", - "object", "ping", "plugin", "prefetch", "script", "serviceworker", + "audio", "beacon", "cspreport", "download", "embed", "eventsource", + "favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe", + "image", "imageset", "import", "internal", "location", "manifest", + "object", "ping", "plugin", "prefetch", "script", "serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker", "xmlhttprequest", "xslt" } declare enum RequestMode { "same-origin", "no-cors", "cors" } declare enum RequestCredentials { "omit", "same-origin", "include" } -declare enum RequestCache { - "default", "no-store", "reload", "no-cache", "force-cache", +declare enum RequestCache { + "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" } declare enum ResponseType { "basic", "cors", "default", "error", "opaque" } declare type HeaderInit = Headers | Array; -declare type BodyInit = Blob | FormData | string; +declare type BodyInit = ArrayBuffer | ArrayBufferView | Blob | FormData | string; declare type RequestInfo = Request | string; interface RequestInit { diff --git a/whatwg-fetch/whatwg-fetch.d.ts b/whatwg-fetch/whatwg-fetch.d.ts index b1e667650f..8997ab6917 100644 --- a/whatwg-fetch/whatwg-fetch.d.ts +++ b/whatwg-fetch/whatwg-fetch.d.ts @@ -82,7 +82,7 @@ interface ResponseInit { } declare type HeaderInit = Headers|Array; -declare type BodyInit = Blob|FormData|string; +declare type BodyInit = ArrayBuffer|ArrayBufferView|Blob|FormData|string; declare type RequestInfo = Request|string; interface Window { From 9d184d8b22f961c127df21f4a338e9e9d641a615 Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Tue, 24 May 2016 07:21:30 -0700 Subject: [PATCH 14/18] backbone.radio: add module definition (#9413) --- backbone.radio/backbone.radio-tests.ts | 8 +++++++- backbone.radio/backbone.radio.d.ts | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backbone.radio/backbone.radio-tests.ts b/backbone.radio/backbone.radio-tests.ts index 295c552af2..764fb65943 100644 --- a/backbone.radio/backbone.radio-tests.ts +++ b/backbone.radio/backbone.radio-tests.ts @@ -101,4 +101,10 @@ function TestGlobalApiAndChannels() { Backbone.Radio.reply('auth', 'authenticate', onStart); Backbone.Radio.request('auth', 'authenticate', 'pelle', 42); -} \ No newline at end of file +} + +import Radio = require('backbone.radio'); +function TestImport() { + var channel: Backbone.Radio.Channel = Radio.channel('channel-name'); + channel.command('show:view'); +} diff --git a/backbone.radio/backbone.radio.d.ts b/backbone.radio/backbone.radio.d.ts index 50895b0275..dd049ec1fe 100644 --- a/backbone.radio/backbone.radio.d.ts +++ b/backbone.radio/backbone.radio.d.ts @@ -90,3 +90,9 @@ declare namespace Backbone { } } } + +declare module 'backbone.radio' { + import Backbone = require('backbone'); + + export = Backbone.Radio; +} From f2b2aeb303d2d8c9d0114ce754a6a8179c6e99ca Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Tue, 24 May 2016 10:23:55 -0400 Subject: [PATCH 15/18] Added missing exports for format and compile functions to support custom named formats (#9364) * Added exports for functions format(name: string, fmt: string | Function): Function and compile(format: string): Function to morgan namespace. These fnctions are exported in the morgan js module and can be used in conjunction with the token function to create named custom formats. Inncluded tests. * Added interface definitions to clarify the signatures of callback function used in defining custom tokens (TokenCallbackFn) with morgan.token(...). Added interface definitions to clarify signatures of custom format functions returned by morgan.compile(...) and used as arguments to morgan.format(...) and morgan(...). Added interface Morgan to clarify return type of morgan.token(...), morgan.compile(...) and morgan.format(...). For a detailed discussion of the rationale of there changes see comments in pull request #9364. Updated tests. Updated version reference to morgan 1.7.0. --- morgan/morgan-tests.ts | 57 ++++++++++++++++++- morgan/morgan.d.ts | 122 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 173 insertions(+), 6 deletions(-) diff --git a/morgan/morgan-tests.ts b/morgan/morgan-tests.ts index 4a0df99024..f26784c848 100644 --- a/morgan/morgan-tests.ts +++ b/morgan/morgan-tests.ts @@ -4,6 +4,7 @@ */ import morgan = require('morgan'); +import express = require('express'); // a pre-defined name morgan('combined') @@ -15,8 +16,8 @@ morgan('tiny') morgan(':remote-addr :method :url') // a custom function -morgan(function (req, res) { - return req.method + ' ' + req.url +morgan(function (tokens, req, res) { + return req.method + ' ' + req.url + ' ' + tokens['date'](req, res, 'iso'); // use predefined :date[iso] token with format argument }) morgan('combined', { @@ -29,3 +30,55 @@ morgan('combined', { } } }); + + +// test interface definition for morgan +var morgan2 : morgan.Morgan = morgan; + +// a named custom format defined as string (example: extend 'tiny' format with user-agent token) +morgan.format('tiny-extended', ':method :url :status :res[content-length] - :response-time ms :user-agent'); + + +// a named custom format defined using the Function signature (example: extend 'dev' format with user-agent token) + +// extend morgan.FormatFn interface with memoizer property to avoid unnecessary re-compiling +// of status-code range driven colorized format functions +interface IFormatFnIndexer { + [memoizerName: string]: morgan.FormatFn; +} + +interface IExtendedFormatFn extends morgan.FormatFn { + memoizer?: IFormatFnIndexer; +} + + +var developmentExtendedFormatLine : IExtendedFormatFn = function(tokens, req, res):string { + + // get the status code if response written + var status = res.statusCode + ? res.statusCode + : undefined; + + // get status color + var color = status >= 500 ? 31 // red + : status >= 400 ? 33 // yellow + : status >= 300 ? 36 // cyan + : status >= 200 ? 32 // green + : 0; // no color + + // get colored format function, if previously memoized, otherwise undefined + var fn: morgan.FormatFn = developmentExtendedFormatLine.memoizer[color]; + + if (!fn) { + // compile + fn = developmentExtendedFormatLine.memoizer[color] = morgan.compile('\x1b[0m:method :url \x1b[' + + color + 'm:status \x1b[0m:response-time ms - :res[content-length]\x1b[0m :user-agent'); + } + + return fn(tokens, req, res); +}; + +developmentExtendedFormatLine.memoizer = {}; + + +morgan.format('dev-extended', developmentExtendedFormatLine); diff --git a/morgan/morgan.d.ts b/morgan/morgan.d.ts index bf1e840956..8a985b5a1c 100644 --- a/morgan/morgan.d.ts +++ b/morgan/morgan.d.ts @@ -1,4 +1,4 @@ -// Type definitions for morgan 1.2.2 +// Type definitions for morgan 1.7.0 // Project: https://github.com/expressjs/morgan // Definitions by: James Roland Cabresos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,7 +10,114 @@ declare module "morgan" { namespace morgan { - export function token(name: string, callback: (req: express.Request, res: express.Response) => T): express.RequestHandler; + export interface FormatFn extends Function { + (tokens: TokenIndexer, req: express.Request, res: express.Response): string; + } + + export interface TokenCallbackFn extends Function { + (req: express.Request, res: express.Response, arg?: string | number | boolean): string; + } + + export interface TokenIndexer { + [tokenName: string]: TokenCallbackFn; + } + + /** + * Public interface of morgan logger + */ + export interface Morgan { + /*** + * Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names), + * or a string of a format string containing defined tokens. + * @param format + * @param options + */ + (format: string, options?: Options): express.RequestHandler; + /*** + * Standard Apache combined log output. + * :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" + * @param format + * @param options + */ + (format: 'combined', options?: Options): express.RequestHandler; + /*** + * Standard Apache common log output. + * :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] + * @param format + * @param options + */ + (format: 'common', options?: Options): express.RequestHandler; + /** + * Concise output colored by response status for development use. The :status token will be colored red for server error codes, yellow for client error codes, cyan for redirection codes, and uncolored for all other codes. + * :method :url :status :response-time ms - :res[content-length] + * @param format + * @param options + */ + (format: 'dev', options?: Options): express.RequestHandler; + + /*** + * Shorter than default, also including response time. + * :remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms + * @param format + * @param options + */ + (format: 'short', options?: Options): express.RequestHandler; + + /*** + * The minimal output. + * :method :url :status :res[content-length] - :response-time ms + * @param format + * @param options + */ + (format: 'tiny', options?: Options): express.RequestHandler; + + /*** + * Create a new morgan logger middleware function using the given format and options. The format argument may be a + * custom format function which adheres to the signature. + * @param format + * @param options + */ + (format: FormatFn, options?: Options): express.RequestHandler; + + /** + * Define a custom token which can be used in custom morgan logging formats. + */ + token(name: string, callback: TokenCallbackFn): Morgan; + /** + * Define a named custom format by specifying a format string in token notation + */ + format(name: string, fmt: string): Morgan; + + /** + * Define a named custom format by specifying a format function + */ + format(name: string, fmt: FormatFn): Morgan; + + /** + * Compile a format string in token notation into a format function + */ + compile(format: string): FormatFn; + } + + /** + * Define a custom token which can be used in custom morgan logging formats. + */ + export function token(name: string, callback: TokenCallbackFn): Morgan; + + /** + * Define a named custom format by specifying a format string in token notation + */ + export function format(name: string, fmt: string): Morgan; + + /** + * Define a named custom format by specifying a format function + */ + export function format(name: string, fmt: FormatFn): Morgan; + + /** + * Compile a format string in token notation into a format function + */ + export function compile(format: string): FormatFn; export interface StreamOptions { /** @@ -48,7 +155,8 @@ declare module "morgan" { } /*** - * Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names), a string of a format string, or a function that will produce a log entry. + * Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names), + * or a string of a format string containing defined tokens. * @param format * @param options */ @@ -94,7 +202,13 @@ declare module "morgan" { */ function morgan(format: 'tiny', options?: morgan.Options): express.RequestHandler; - function morgan(custom: (req: express.Request, res: express.Response) => string): express.RequestHandler + /*** + * Create a new morgan logger middleware function using the given format and options. The format argument may be a + * custom format function which adheres to the signature. + * @param format + * @param options + */ + function morgan(format: morgan.FormatFn, options?: morgan.Options): express.RequestHandler export = morgan; } From 4248c2618591b7e85a9bece7cff5bd6bd518af10 Mon Sep 17 00:00:00 2001 From: Chitoku Date: Tue, 24 May 2016 23:24:03 +0900 Subject: [PATCH 16/18] Add FileCallback and PerRouteMiddleware (#9374) * Add FileCallback and PerRouteMiddleware * Use import syntax in ECMAScript 6 --- browser-sync/browser-sync-tests.ts | 2 +- browser-sync/browser-sync.d.ts | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/browser-sync/browser-sync-tests.ts b/browser-sync/browser-sync-tests.ts index 822c941d9f..72bcb6465e 100644 --- a/browser-sync/browser-sync-tests.ts +++ b/browser-sync/browser-sync-tests.ts @@ -1,5 +1,5 @@ /// -import browserSync = require("browser-sync"); +import * as browserSync from "browser-sync"; (() => { //make sure that the interfaces are correctly exposed diff --git a/browser-sync/browser-sync.d.ts b/browser-sync/browser-sync.d.ts index 3bc083d1f1..00d234f958 100644 --- a/browser-sync/browser-sync.d.ts +++ b/browser-sync/browser-sync.d.ts @@ -8,10 +8,10 @@ /// declare module "browser-sync" { - import chokidar = require("chokidar"); - import fs = require("fs"); - import http = require("http"); - import mm = require("micromatch"); + import * as chokidar from "chokidar"; + import * as fs from "fs"; + import * as http from "http"; + import * as mm from "micromatch"; namespace browserSync { interface Options { @@ -23,14 +23,14 @@ declare module "browser-sync" { * weinre.port - Default: 8080 * Note: requires at least version 2.0.0 */ - ui?: UIOptions; + ui?: UIOptions | boolean; /** * Browsersync can watch your files as you work. Changes you make will either be injected into the page (CSS * & images) or will cause all browsers to do a full-page refresh. See anymatch for more information on glob * patterns. * Default: false */ - files?: string | string[]; + files?: string | (string | FileCallback)[]; /** * File watching options that get passed along to Chokidar. Check their docs for available options * Default: undefined @@ -245,7 +245,7 @@ declare module "browser-sync" { * Note: requires at least version 1.6.2 */ socket?: SocketOptions; - middleware?: MiddlewareHandler | MiddlewareHandler[]; + middleware?: MiddlewareHandler | PerRouteMiddleware | (MiddlewareHandler | PerRouteMiddleware)[]; } interface Hash { @@ -261,6 +261,12 @@ declare module "browser-sync" { }; } + interface FileCallback { + match?: string | string[]; + fn: (event: string, file: string) => any; + options?: chokidar.WatchOptions; + } + interface ServerOptions { /** set base directory */ baseDir?: string | string[]; @@ -274,7 +280,7 @@ declare module "browser-sync" { */ routes?: Hash; /** configure custom middleware */ - middleware?: MiddlewareHandler[]; + middleware?: (MiddlewareHandler | PerRouteMiddleware)[]; } interface ProxyOptions { @@ -289,6 +295,11 @@ declare module "browser-sync" { (req: http.ServerRequest, res: http.ServerResponse, next: Function): any; } + interface PerRouteMiddleware { + route: string; + handle: MiddlewareHandler; + } + interface GhostOptions { clicks?: boolean; scroll?: boolean; From 8d252184e421915fbc9f56a5debcb098e0d2d68d Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 24 May 2016 16:24:29 +0200 Subject: [PATCH 17/18] Allow ES6 import syntax for wolfy87-eventemitter.d.ts (#9415) * Boostrap -> Bootstrap * Allow ES6 import syntax for wolfy87-eventemitter.d.ts See https://github.com/Microsoft/TypeScript/issues/5073 --- redux-bootstrap/redux-bootstrap.d.ts | 4 ++-- wolfy87-eventemitter/wolfy87-eventemitter-tests.ts | 5 ++--- wolfy87-eventemitter/wolfy87-eventemitter.d.ts | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/redux-bootstrap/redux-bootstrap.d.ts b/redux-bootstrap/redux-bootstrap.d.ts index b7873b0793..933fa988a7 100644 --- a/redux-bootstrap/redux-bootstrap.d.ts +++ b/redux-bootstrap/redux-bootstrap.d.ts @@ -9,7 +9,7 @@ declare module "redux-bootstrap" { - interface BoostrapOptions { + interface BootstrapOptions { routes: JSX.Element; reducers: ReducersOption; middlewares?: Redux.Middleware[]; @@ -27,5 +27,5 @@ declare module "redux-bootstrap" { [index: string]: Redux.Reducer; } - export default function bootstrap(options: BoostrapOptions): BootstrapResult; + export default function bootstrap(options: BootstrapOptions): BootstrapResult; } diff --git a/wolfy87-eventemitter/wolfy87-eventemitter-tests.ts b/wolfy87-eventemitter/wolfy87-eventemitter-tests.ts index d2d4e6f0cf..ec26166dc8 100644 --- a/wolfy87-eventemitter/wolfy87-eventemitter-tests.ts +++ b/wolfy87-eventemitter/wolfy87-eventemitter-tests.ts @@ -1,6 +1,6 @@ -/// +/// -import EventEmitter = require("wolfy87-eventemitter"); +import * as EventEmitter from 'wolfy87-eventemitter'; var emitter = new EventEmitter(); @@ -108,4 +108,3 @@ function testNoConflict() { var NoConflictEventEmitter = EventEmitter.noConflict(); var e: Wolfy87EventEmitter.EventEmitter = new NoConflictEventEmitter(); } - diff --git a/wolfy87-eventemitter/wolfy87-eventemitter.d.ts b/wolfy87-eventemitter/wolfy87-eventemitter.d.ts index 45c4e54e5d..8291c50c11 100644 --- a/wolfy87-eventemitter/wolfy87-eventemitter.d.ts +++ b/wolfy87-eventemitter/wolfy87-eventemitter.d.ts @@ -9,7 +9,7 @@ declare namespace Wolfy87EventEmitter { * Hash Object for manipulating multiple events. */ interface MultipleEvents { - [event:string]: any //Function | Function[] + [event: string]: any //Function | Function[] } /** @@ -506,6 +506,7 @@ declare namespace Wolfy87EventEmitter { declare module "wolfy87-eventemitter" { class EventEmitter extends Wolfy87EventEmitter.EventEmitter {} + namespace EventEmitter {} export = EventEmitter; } From b9989e602b3225d48aa4a9dfa0631ae41fea100d Mon Sep 17 00:00:00 2001 From: Marian Palkus Date: Wed, 25 May 2016 10:39:55 +0200 Subject: [PATCH 18/18] Update definitions of enzyme to version 2.3.0. (#9361) * Update definitions of enzyme to version 2.3.0. * Fixed URL of enzyme repository. --- enzyme/enzyme-1.2.0-tests.tsx | 605 ++++++++++++++++++++++++++++++++++ enzyme/enzyme-1.2.0.d.ts | 473 ++++++++++++++++++++++++++ enzyme/enzyme-tests.tsx | 191 ++++++++++- enzyme/enzyme.d.ts | 89 ++++- 4 files changed, 1344 insertions(+), 14 deletions(-) create mode 100644 enzyme/enzyme-1.2.0-tests.tsx create mode 100644 enzyme/enzyme-1.2.0.d.ts diff --git a/enzyme/enzyme-1.2.0-tests.tsx b/enzyme/enzyme-1.2.0-tests.tsx new file mode 100644 index 0000000000..44db5705bc --- /dev/null +++ b/enzyme/enzyme-1.2.0-tests.tsx @@ -0,0 +1,605 @@ +/// +/// + +import { shallow, mount, render, describeWithDOM, spyLifecycle } from "enzyme"; +import * as React from "react"; +import {Component, ReactElement, HTMLAttributes} from "react"; +import {ShallowWrapper, ReactWrapper, CheerioWrapper} from "enzyme"; + + +// Help classes/interfaces +interface MyComponentProps { + propsProperty: any; + numberProp?: number; +} + +interface StatelessProps { + stateless: any; +} + +interface MyComponentState { + stateProperty: any; +} + +class MyComponent extends Component { + setState(...args: any[]) { + } +} + +const MyStatelessComponent = (props: StatelessProps) => ; + +// API +namespace SpyLifecycleTest { + spyLifecycle(MyComponent); +} + +// ShallowWrapper +namespace ShallowWrapperTest { + var shallowWrapper: ShallowWrapper = + shallow(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String, + elementWrapper: ShallowWrapper + + function test_find() { + elementWrapper = shallowWrapper.find('.selector'); + shallowWrapper = shallowWrapper.find(MyComponent); + shallowWrapper.find(MyStatelessComponent).props().stateless; + shallowWrapper.find(MyStatelessComponent).shallow(); + } + + function test_findWhere() { + shallowWrapper = + shallowWrapper.findWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_filter() { + elementWrapper = shallowWrapper.filter('.selector'); + shallowWrapper = shallowWrapper.filter(MyComponent).shallow(); + } + + function test_filterWhere() { + shallowWrapper = + shallowWrapper.filterWhere(wrapper => { + wrapper.props().propsProperty; + return true; + }); + } + + function test_contains() { + boolVal = shallowWrapper.contains(
); + } + + function test_hasClass() { + boolVal = shallowWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = shallowWrapper.is('.some-class'); + } + + function test_not() { + elementWrapper = shallowWrapper.find('.foo').not('.bar'); + } + + function test_children() { + shallowWrapper = shallowWrapper.children(); + shallowWrapper.children(MyStatelessComponent).props().stateless; + } + + function test_parents() { + shallowWrapper = shallowWrapper.parents(); + } + + function test_parent() { + shallowWrapper = shallowWrapper.parent(); + } + + function test_closest() { + elementWrapper = shallowWrapper.closest('.selector'); + shallowWrapper = shallowWrapper.closest(MyComponent); + } + + function test_shallow() { + shallowWrapper = shallowWrapper.shallow(); + } + + function test_unmount() { + shallowWrapper = shallowWrapper.unmount(); + } + + function test_render() { + var cheerioWrapper: CheerioWrapper = shallowWrapper.render(); + } + + function test_text() { + stringVal = shallowWrapper.text(); + } + + + function test_html() { + stringVal = shallowWrapper.html(); + } + + function test_get() { + reactElement = shallowWrapper.get(1); + } + + function test_at() { + shallowWrapper = shallowWrapper.at(1); + } + + function test_first() { + shallowWrapper = shallowWrapper.first(); + } + + function test_last() { + shallowWrapper = shallowWrapper.last(); + } + + function test_state() { + shallowWrapper.state(); + shallowWrapper.state('key'); + } + + function test_props() { + objectVal = shallowWrapper.props(); + } + + function test_prop() { + shallowWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + shallowWrapper.simulate('click'); + shallowWrapper.simulate('click', args); + } + + function test_setState() { + shallowWrapper = shallowWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + shallowWrapper = shallowWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + shallowWrapper = shallowWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = shallowWrapper.instance(); + } + + function test_update() { + shallowWrapper = shallowWrapper.update(); + } + + function test_debug() { + stringVal = shallowWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = shallowWrapper.type(); + } + + function test_forEach() { + shallowWrapper = + shallowWrapper.forEach(wrapper => wrapper.shallow().props().propsProperty); + } + + function test_map() { + var arrayNumbers: Array = + shallowWrapper.map(wrapper => wrapper.props().numberProp); + } + + function test_reduce() { + const total: number[] = + shallowWrapper.reduce( + (amount: number, n: ShallowWrapper) => amount + n.props().numberProp + ); + } + + function test_reduceRight() { + const total: number[] = + shallowWrapper.reduceRight( + (amount: number, n: ShallowWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = shallowWrapper.some('.selector'); + boolVal = shallowWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = shallowWrapper.someWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_every() { + boolVal = shallowWrapper.every('.selector'); + boolVal = shallowWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = shallowWrapper.everyWhere((aShallowWrapper: ShallowWrapper) => true); + } +} + + +// ReactWrapper +namespace ReactWrapperTest { + var reactWrapper: ReactWrapper = + mount(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String, + elementWrapper: ReactWrapper + + function test_unmount() { + reactWrapper = reactWrapper.unmount(); + } + + function test_mount() { + reactWrapper = reactWrapper.mount(); + } + + function test_find() { + elementWrapper = reactWrapper.find('.selector'); + reactWrapper = reactWrapper.find(MyComponent); + reactWrapper.find(MyStatelessComponent).props().stateless; + } + + function test_findWhere() { + reactWrapper = + reactWrapper.findWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_filter() { + elementWrapper = reactWrapper.filter('.selector'); + reactWrapper = reactWrapper.filter(MyComponent); + } + + function test_filterWhere() { + reactWrapper = + reactWrapper.filterWhere(wrapper => { + wrapper.props().propsProperty; + return true; + }); + } + + function test_contains() { + boolVal = reactWrapper.contains(
); + } + + function test_hasClass() { + boolVal = reactWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = reactWrapper.is('.some-class'); + } + + function test_not() { + elementWrapper = reactWrapper.find('.foo').not('.bar'); + } + + function test_children() { + reactWrapper = reactWrapper.children(); + } + + function test_parents() { + reactWrapper = reactWrapper.parents(); + } + + function test_parent() { + reactWrapper = reactWrapper.parent(); + } + + function test_closest() { + elementWrapper = reactWrapper.closest('.selector'); + reactWrapper = reactWrapper.closest(MyComponent); + } + + function test_text() { + stringVal = reactWrapper.text(); + } + + function test_html() { + stringVal = reactWrapper.html(); + } + + function test_get() { + reactElement = reactWrapper.get(1); + } + + function test_at() { + reactWrapper = reactWrapper.at(1); + } + + function test_first() { + reactWrapper = reactWrapper.first(); + } + + function test_last() { + reactWrapper = reactWrapper.last(); + } + + function test_state() { + reactWrapper.state(); + reactWrapper.state('key'); + } + + function test_props() { + objectVal = reactWrapper.props(); + } + + function test_prop() { + reactWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + reactWrapper.simulate('click'); + reactWrapper.simulate('click', args); + } + + function test_setState() { + reactWrapper = reactWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + reactWrapper = reactWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + reactWrapper = reactWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = reactWrapper.instance(); + } + + function test_update() { + reactWrapper = reactWrapper.update(); + } + + function test_debug() { + stringVal = reactWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = reactWrapper.type(); + } + + function test_forEach() { + reactWrapper = + reactWrapper.forEach(wrapper => wrapper.props().propsProperty); + } + + function test_map() { + var arrayNumbers: Array = + reactWrapper.map(wrapper => wrapper.props().numberProp); + } + + function test_reduce() { + const total: number[] = + reactWrapper.reduce( + (amount: number, n: ReactWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + reactWrapper.reduceRight( + (amount: number, n: ReactWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = reactWrapper.some('.selector'); + boolVal = reactWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = reactWrapper.someWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_every() { + boolVal = reactWrapper.every('.selector'); + boolVal = reactWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = reactWrapper.everyWhere((aReactWrapper: ReactWrapper) => true); + } +} + +// CheerioWrapper +namespace CheerioWrapperTest { + var cheerioWrapper: CheerioWrapper = + render(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String, + elementWrapper: CheerioWrapper + + function test_find() { + elementWrapper = cheerioWrapper.find('.selector'); + cheerioWrapper = cheerioWrapper.find(MyComponent); + cheerioWrapper.find(MyStatelessComponent).props().stateless; + } + + function test_findWhere() { + cheerioWrapper = + cheerioWrapper.findWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_filter() { + elementWrapper = cheerioWrapper.filter('.selector'); + cheerioWrapper = cheerioWrapper.filter(MyComponent); + } + + function test_filterWhere() { + cheerioWrapper = + cheerioWrapper.filterWhere(wrapper => { + wrapper.props().propsProperty; + return true; + }); + } + + function test_contains() { + boolVal = cheerioWrapper.contains(
); + } + + function test_hasClass() { + boolVal = cheerioWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = cheerioWrapper.is('.some-class'); + } + + function test_not() { + elementWrapper = cheerioWrapper.find('.foo').not('.bar'); + } + + function test_children() { + cheerioWrapper = cheerioWrapper.children(); + } + + function test_parents() { + cheerioWrapper = cheerioWrapper.parents(); + } + + function test_parent() { + cheerioWrapper = cheerioWrapper.parent(); + } + + function test_closest() { + elementWrapper = cheerioWrapper.closest('.selector'); + cheerioWrapper = cheerioWrapper.closest(MyComponent); + } + + function test_text() { + stringVal = cheerioWrapper.text(); + } + + function test_html() { + stringVal = cheerioWrapper.html(); + } + + function test_get() { + reactElement = cheerioWrapper.get(1); + } + + function test_at() { + cheerioWrapper = cheerioWrapper.at(1); + } + + function test_first() { + cheerioWrapper = cheerioWrapper.first(); + } + + function test_last() { + cheerioWrapper = cheerioWrapper.last(); + } + + function test_state() { + cheerioWrapper.state(); + cheerioWrapper.state('key'); + } + + function test_props() { + objectVal = cheerioWrapper.props(); + } + + function test_prop() { + cheerioWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + cheerioWrapper.simulate('click'); + cheerioWrapper.simulate('click', args); + } + + function test_setState() { + cheerioWrapper = cheerioWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + cheerioWrapper = cheerioWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + cheerioWrapper = cheerioWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = cheerioWrapper.instance(); + } + + function test_update() { + cheerioWrapper = cheerioWrapper.update(); + } + + function test_debug() { + stringVal = cheerioWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = cheerioWrapper.type(); + } + + function test_forEach() { + cheerioWrapper = + cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper)=> { + }); + } + + function test_map() { + var arrayNumbers: Array = + cheerioWrapper.map(wrapper => wrapper.props().numberProp); + } + + function test_reduce() { + const total: number[] = + cheerioWrapper.reduce( + (amount: number, n: CheerioWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + cheerioWrapper.reduceRight( + (amount: number, n: CheerioWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = cheerioWrapper.some('.selector'); + boolVal = cheerioWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = cheerioWrapper.someWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_every() { + boolVal = cheerioWrapper.every('.selector'); + boolVal = cheerioWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = cheerioWrapper.everyWhere((aCheerioWrapper: CheerioWrapper) => true); + } +} diff --git a/enzyme/enzyme-1.2.0.d.ts b/enzyme/enzyme-1.2.0.d.ts new file mode 100644 index 0000000000..13c00041a5 --- /dev/null +++ b/enzyme/enzyme-1.2.0.d.ts @@ -0,0 +1,473 @@ +// Type definitions for Enzyme v1.2.0 +// Project: https://github.com/airbnb/enzyme +// Definitions by: Marian Palkus , Cap3 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "enzyme" { + + import {ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes} from "react"; + + export class ElementClass extends Component { + } + + /** + * Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the + * following three categories: + * + * 1. A Valid CSS Selector + * 2. A React Component Constructor + * 3. A React Component's displayName + */ + export type EnzymeSelector = String | typeof ElementClass; + + interface CommonWrapper { + /** + * Find every node in the render tree that matches the provided selector. + * @param selector The selector to match. + */ + find(component: ComponentClass): CommonWrapper; + find(statelessComponent: StatelessComponent): CommonWrapper; + find(selector: string): CommonWrapper; + + /** + * Finds every node in the render tree that returns true for the provided predicate function. + * @param predicate + */ + findWhere(predicate: (wrapper: CommonWrapper) => Boolean): CommonWrapper; + + /** + * Removes nodes in the current wrapper that do not match the provided selector. + * @param selector The selector to match. + */ + filter(component: ComponentClass): CommonWrapper; + filter(statelessComponent: StatelessComponent): CommonWrapper; + filter(selector: string): CommonWrapper; + + /** + * Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true. + * @param predicate + */ + filterWhere(predicate: (wrapper: this) => Boolean): this; + + /** + * Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in. + * @param node + */ + contains(node: ReactElement): Boolean; + + /** + * Returns whether or not the current node has a className prop including the passed in class name. + * @param className + */ + hasClass(className: String): Boolean; + + /** + * Returns whether or not the current node matches a provided selector. + * @param selector + */ + is(selector: EnzymeSelector): Boolean; + + /** + * Returns a new wrapper with only the nodes of the current wrapper that don't match the provided selector. + * This method is effectively the negation or inverse of filter. + * @param selector + */ + not(selector: EnzymeSelector): this; + + /** + * Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector + * can be provided and it will filter the children by this selector. + * @param [selector] + */ + children(component: ComponentClass): CommonWrapper; + children(statelessComponent: StatelessComponent): CommonWrapper; + children(selector: string): CommonWrapper; + children(): CommonWrapper; + + /** + * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the + * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector. + * + * Note: can only be called on a wrapper of a single node. + * @param [selector] + */ + parents(component: ComponentClass): CommonWrapper; + parents(statelessComponent: StatelessComponent): CommonWrapper; + parents(selector: string): CommonWrapper; + parents(): CommonWrapper; + + /** + * Returns a wrapper with the direct parent of the node in the current wrapper. + */ + parent(): CommonWrapper; + + /** + * Returns a wrapper of the first element that matches the selector by traversing up through the current node's + * ancestors in the tree, starting with itself. + * + * Note: can only be called on a wrapper of a single node. + * @param selector + */ + closest(component: ComponentClass): CommonWrapper; + closest(statelessComponent: StatelessComponent): CommonWrapper; + closest(selector: string): CommonWrapper; + + /** + * Returns a string of the rendered text of the current render tree. This function should be looked at with + * skepticism if being used to test what the actual HTML output of the component will be. If that is what you + * would like to test, use enzyme's render function instead. + * + * Note: can only be called on a wrapper of a single node. + */ + text(): String; + + /** + * Returns a string of the rendered HTML markup of the current render tree. + * + * Note: can only be called on a wrapper of a single node. + */ + html(): String; + + /** + * Returns the node at a given index of the current wrapper. + * @param index + */ + get(index: number): ReactElement; + + /** + * Returns a wrapper around the node at a given index of the current wrapper. + * @param index + */ + at(index: number): this; + + /** + * Reduce the set of matched nodes to the first in the set. + */ + first(): this; + + /** + * Reduce the set of matched nodes to the last in the set. + */ + last(): this; + + /** + * Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value. + * @param [key] + */ + state(key?: String): any; + + /** + * Returns the props hash for the current node of the wrapper. + * + * NOTE: can only be called on a wrapper of a single node. + */ + props(): P; + + /** + * Returns the prop value for the node of the current wrapper with the provided key. + * + * NOTE: can only be called on a wrapper of a single node. + * @param key + */ + prop(key: String): any; + + /** + * Simulate events. + * Returns itself. + * @param event + * @param args? + */ + simulate(event: string, ...args: any[]): this; + + /** + * A method to invoke setState() on the root component instance similar to how you might in the definition of + * the component, and re-renders. This method is useful for testing your component in hard to achieve states, + * however should be used sparingly. If possible, you should utilize your component's external API in order to + * get it into whatever state you want to test, in order to be as accurate of a test as possible. This is not + * always practical, however. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setState(state: S): this; + + /** + * A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test + * how the component behaves over time with changing props. Calling this, for instance, will call the + * componentWillReceiveProps lifecycle method. + * + * Similar to setState, this method accepts a props object and will merge it in with the already existing props. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setProps(props: P): this; + + /** + * A method that sets the context of the root component, and re-renders. Useful for when you are wanting to + * test how the component behaves over time with changing contexts. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setContext(context: Object): this; + + /** + * Gets the instance of the component being rendered as the root node passed into shallow(). + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + */ + instance(): Component; + + /** + * Forces a re-render. Useful to run before checking the render output if something external may be updating + * the state of the component somewhere. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + */ + update(): this; + + /** + * Returns an html-like string of the wrapper for debugging purposes. Useful to print out to the console when + * tests are not passing when you expect them to. + */ + debug(): String; + + /** + * Returns the type of the current node of this wrapper. If it's a composite component, this will be the + * component constructor. If it's native DOM node, it will be a string of the tag name. + * + * Note: can only be called on a wrapper of a single node. + */ + type(): String | Function; + + /** + * Iterates through each node of the current wrapper and executes the provided function with a wrapper around + * the corresponding node passed in as the first argument. + * + * Returns itself. + * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first + * argument, and will be run with a context of the original instance. + */ + forEach(fn: (wrapper: this) => any): this; + + /** + * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map + * function. + * Returns an array of the returned values from the mapping function.. + * @param fn A mapping function to be run for every node in the collection, the results of which will be mapped + * to the returned array. Should expect a ShallowWrapper as the first argument, and will be run + * with a context of the original instance. + */ + map(fn: (wrapper: this) => V): V[]; + + /** + * Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node + * is passed in as a ShallowWrapper, and is processed from left to right. + * @param fn + * @param initialValue + */ + reduce(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[]; + + /** + * Applies the provided reducing function to every node in the wrapper to reduce to a single value. + * Each node is passed in as a ShallowWrapper, and is processed from right to left. + * @param fn + * @param initialValue + */ + reduceRight(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[]; + + /** + * Returns whether or not any of the nodes in the wrapper match the provided selector. + * @param selector + */ + some(selector: EnzymeSelector): Boolean; + + /** + * Returns whether or not any of the nodes in the wrapper pass the provided predicate function. + * @param fn + */ + someWhere(fn: (wrapper: this) => Boolean): Boolean; + + /** + * Returns whether or not all of the nodes in the wrapper match the provided selector. + * @param selector + */ + every(selector: EnzymeSelector): Boolean; + + /** + * Returns whether or not any of the nodes in the wrapper pass the provided predicate function. + * @param fn + */ + everyWhere(fn: (wrapper: this) => Boolean): Boolean; + + length: number; + } + + export interface ShallowWrapper extends CommonWrapper { + shallow(): ShallowWrapper; + render(): CheerioWrapper; + unmount(): ShallowWrapper; + + /** + * Find every node in the render tree that matches the provided selector. + * @param selector The selector to match. + */ + find(component: ComponentClass): ShallowWrapper; + find(statelessComponent: (props: P2) => JSX.Element): ShallowWrapper; + find(selector: string): ShallowWrapper; + + /** + * Removes nodes in the current wrapper that do not match the provided selector. + * @param selector The selector to match. + */ + filter(component: ComponentClass): ShallowWrapper; + filter(statelessComponent: StatelessComponent): ShallowWrapper; + filter(selector: string): ShallowWrapper; + + /** + * Finds every node in the render tree that returns true for the provided predicate function. + * @param predicate + */ + findWhere(predicate: (wrapper: CommonWrapper) => Boolean): ShallowWrapper; + + /** + * Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector + * can be provided and it will filter the children by this selector. + * @param [selector] + */ + children(component: ComponentClass): ShallowWrapper; + children(statelessComponent: StatelessComponent): ShallowWrapper; + children(selector: string): ShallowWrapper; + children(): ShallowWrapper; + + /** + * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the + * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector. + * + * Note: can only be called on a wrapper of a single node. + * @param [selector] + */ + parents(component: ComponentClass): ShallowWrapper; + parents(statelessComponent: StatelessComponent): ShallowWrapper; + parents(selector: string): ShallowWrapper; + parents(): ShallowWrapper; + + /** + * Returns a wrapper of the first element that matches the selector by traversing up through the current node's + * ancestors in the tree, starting with itself. + * + * Note: can only be called on a wrapper of a single node. + * @param selector + */ + closest(component: ComponentClass): ShallowWrapper; + closest(statelessComponent: StatelessComponent): ShallowWrapper; + closest(selector: string): ShallowWrapper; + + /** + * Returns a wrapper with the direct parent of the node in the current wrapper. + */ + parent(): ShallowWrapper; + } + + export interface ReactWrapper extends CommonWrapper { + unmount(): ReactWrapper; + mount(): ReactWrapper; + + /** + * Find every node in the render tree that matches the provided selector. + * @param selector The selector to match. + */ + find(component: ComponentClass): ReactWrapper; + find(statelessComponent: (props: P2) => JSX.Element): ReactWrapper; + find(selector: string): ReactWrapper; + + /** + * Finds every node in the render tree that returns true for the provided predicate function. + * @param predicate + */ + findWhere(predicate: (wrapper: CommonWrapper) => Boolean): ReactWrapper; + + /** + * Removes nodes in the current wrapper that do not match the provided selector. + * @param selector The selector to match. + */ + filter(component: ComponentClass): ReactWrapper; + filter(statelessComponent: StatelessComponent): ReactWrapper; + filter(selector: string): ReactWrapper; + + /** + * Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector + * can be provided and it will filter the children by this selector. + * @param [selector] + */ + children(component: ComponentClass): ReactWrapper; + children(statelessComponent: StatelessComponent): ReactWrapper; + children(selector: string): ReactWrapper; + children(): ReactWrapper; + + /** + * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the + * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector. + * + * Note: can only be called on a wrapper of a single node. + * @param [selector] + */ + parents(component: ComponentClass): ReactWrapper; + parents(statelessComponent: StatelessComponent): ReactWrapper; + parents(selector: string): ReactWrapper; + parents(): ReactWrapper; + + /** + * Returns a wrapper of the first element that matches the selector by traversing up through the current node's + * ancestors in the tree, starting with itself. + * + * Note: can only be called on a wrapper of a single node. + * @param selector + */ + closest(component: ComponentClass): ReactWrapper; + closest(statelessComponent: StatelessComponent): ReactWrapper; + closest(selector: string): ReactWrapper; + + /** + * Returns a wrapper with the direct parent of the node in the current wrapper. + */ + parent(): ReactWrapper; + } + + export interface CheerioWrapper extends CommonWrapper { + + } + + /** + * Shallow rendering is useful to constrain yourself to testing a component as a unit, and to ensure that + * your tests aren't indirectly asserting on behavior of child components. + * @param node + * @param [options] + */ + export function shallow(node: ReactElement

, options?: any): ShallowWrapper; + + /** + * Mounts and renders a react component into the document and provides a testing wrapper around it. + * @param node + * @param [options] + */ + export function mount(node: ReactElement

, options?: any): ReactWrapper; + + /** + * Render react components to static HTML and analyze the resulting HTML structure. + * @param node + * @param [options] + */ + export function render(node: ReactElement

, options?: any): CheerioWrapper; + + export function describeWithDOM(description: String, fn: Function): void; + + export function spyLifecycle(component: typeof Component): void; +} \ No newline at end of file diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx index 4cc45e9fd4..805201e53a 100644 --- a/enzyme/enzyme-tests.tsx +++ b/enzyme/enzyme-tests.tsx @@ -73,6 +73,26 @@ namespace ShallowWrapperTest { boolVal = shallowWrapper.contains(

); } + function test_containsMatchingElement() { + boolVal = shallowWrapper.contains(
); + } + + function test_containsAllMatchingElements() { + boolVal = shallowWrapper.containsAllMatchingElements([
]); + } + + function test_containsAnyMatchingElement() { + boolVal = shallowWrapper.containsAnyMatchingElements([
]); + } + + function test_equals() { + boolVal = shallowWrapper.equals(
); + } + + function test_matchesElement() { + boolVal = shallowWrapper.matchesElement(
); + } + function test_hasClass() { boolVal = shallowWrapper.find('.my-button').hasClass('disabled'); } @@ -90,6 +110,20 @@ namespace ShallowWrapperTest { shallowWrapper.children(MyStatelessComponent).props().stateless; } + function test_childAt() { + const childWrapper: ShallowWrapper = shallowWrapper.childAt(0); + + interface TmpType1 { + foo: any + } + + interface TmpType2 { + bar: any + } + + const childWrapper2: ShallowWrapper = shallowWrapper.childAt(0); + } + function test_parents() { shallowWrapper = shallowWrapper.parents(); } @@ -143,6 +177,13 @@ namespace ShallowWrapperTest { function test_state() { shallowWrapper.state(); shallowWrapper.state('key'); + const tmp: String = shallowWrapper.state('key'); + } + + function test_context() { + shallowWrapper.context(); + shallowWrapper.context('key'); + const tmp: String = shallowWrapper.context('key'); } function test_props() { @@ -151,8 +192,12 @@ namespace ShallowWrapperTest { function test_prop() { shallowWrapper.prop('key'); + const tmp: String = shallowWrapper.prop('key'); } + function test_key() { + stringVal = shallowWrapper.key(); + } function test_simulate(...args: any[]) { shallowWrapper.simulate('click'); @@ -160,15 +205,15 @@ namespace ShallowWrapperTest { } function test_setState() { - shallowWrapper = shallowWrapper.setState({stateProperty: 'state'}); + shallowWrapper = shallowWrapper.setState({ stateProperty: 'state' }); } function test_setProps() { - shallowWrapper = shallowWrapper.setProps({propsProperty: 'foo'}); + shallowWrapper = shallowWrapper.setProps({ propsProperty: 'foo' }); } function test_setContext() { - shallowWrapper = shallowWrapper.setContext({name: 'baz'}); + shallowWrapper = shallowWrapper.setContext({ name: 'baz' }); } function test_instance() { @@ -184,7 +229,11 @@ namespace ShallowWrapperTest { } function test_type() { - var stringOrFunction: String|Function = shallowWrapper.type(); + var stringOrFunction: String | Function = shallowWrapper.type(); + } + + function test_name() { + var str: String = shallowWrapper.name(); } function test_forEach() { @@ -250,6 +299,24 @@ namespace ReactWrapperTest { reactWrapper = reactWrapper.mount(); } + function test_ref() { + reactWrapper = reactWrapper.ref('refName'); + + interface TmpType1 { + foo: string + } + + interface TmpType2 { + bar: string + } + + const tmp: ReactWrapper = reactWrapper.ref('refName'); + } + + function test_detach() { + reactWrapper.detach(); + } + function test_find() { elementWrapper = reactWrapper.find('.selector'); reactWrapper = reactWrapper.find(MyComponent); @@ -278,6 +345,26 @@ namespace ReactWrapperTest { boolVal = reactWrapper.contains(
); } + function test_containsMatchingElement() { + boolVal = reactWrapper.contains(
); + } + + function test_containsAllMatchingElements() { + boolVal = reactWrapper.containsAllMatchingElements([
]); + } + + function test_containsAnyMatchingElement() { + boolVal = reactWrapper.containsAnyMatchingElements([
]); + } + + function test_equals() { + boolVal = reactWrapper.equals(
); + } + + function test_matchesElement() { + boolVal = reactWrapper.matchesElement(
); + } + function test_hasClass() { boolVal = reactWrapper.find('.my-button').hasClass('disabled'); } @@ -294,6 +381,20 @@ namespace ReactWrapperTest { reactWrapper = reactWrapper.children(); } + function test_childAt() { + const childWrapper: ReactWrapper = reactWrapper.childAt(0); + + interface TmpType1 { + foo: any + } + + interface TmpType2 { + bar: any + } + + const childWrapper2: ReactWrapper = reactWrapper.childAt(0); + } + function test_parents() { reactWrapper = reactWrapper.parents(); } @@ -334,6 +435,13 @@ namespace ReactWrapperTest { function test_state() { reactWrapper.state(); reactWrapper.state('key'); + const tmp: String = reactWrapper.state('key'); + } + + function test_context() { + reactWrapper.context(); + reactWrapper.context('key'); + const tmp: String = reactWrapper.context('key'); } function test_props() { @@ -342,8 +450,12 @@ namespace ReactWrapperTest { function test_prop() { reactWrapper.prop('key'); + const tmp: String = reactWrapper.prop('key'); } + function test_key() { + stringVal = reactWrapper.key(); + } function test_simulate(...args: any[]) { reactWrapper.simulate('click'); @@ -351,15 +463,15 @@ namespace ReactWrapperTest { } function test_setState() { - reactWrapper = reactWrapper.setState({stateProperty: 'state'}); + reactWrapper = reactWrapper.setState({ stateProperty: 'state' }); } function test_setProps() { - reactWrapper = reactWrapper.setProps({propsProperty: 'foo'}); + reactWrapper = reactWrapper.setProps({ propsProperty: 'foo' }); } function test_setContext() { - reactWrapper = reactWrapper.setContext({name: 'baz'}); + reactWrapper = reactWrapper.setContext({ name: 'baz' }); } function test_instance() { @@ -375,7 +487,11 @@ namespace ReactWrapperTest { } function test_type() { - var stringOrFunction: String|Function = reactWrapper.type(); + var stringOrFunction: String | Function = reactWrapper.type(); + } + + function test_name() { + var str: String = reactWrapper.name(); } function test_forEach() { @@ -460,6 +576,26 @@ namespace CheerioWrapperTest { boolVal = cheerioWrapper.contains(
); } + function test_containsMatchingElement() { + boolVal = cheerioWrapper.contains(
); + } + + function test_containsAllMatchingElements() { + boolVal = cheerioWrapper.containsAllMatchingElements([
]); + } + + function test_containsAnyMatchingElement() { + boolVal = cheerioWrapper.containsAnyMatchingElements([
]); + } + + function test_equals() { + boolVal = cheerioWrapper.equals(
); + } + + function test_matchesElement() { + boolVal = cheerioWrapper.matchesElement(
); + } + function test_hasClass() { boolVal = cheerioWrapper.find('.my-button').hasClass('disabled'); } @@ -476,6 +612,20 @@ namespace CheerioWrapperTest { cheerioWrapper = cheerioWrapper.children(); } + function test_childAt() { + const childWrapper: CheerioWrapper = cheerioWrapper.childAt(0); + + interface TmpType1 { + foo: any + } + + interface TmpType2 { + bar: any + } + + const childWrapper2: CheerioWrapper = cheerioWrapper.childAt(0); + } + function test_parents() { cheerioWrapper = cheerioWrapper.parents(); } @@ -516,6 +666,13 @@ namespace CheerioWrapperTest { function test_state() { cheerioWrapper.state(); cheerioWrapper.state('key'); + const tmp: String = cheerioWrapper.state('key'); + } + + function test_context() { + cheerioWrapper.context(); + cheerioWrapper.context('key'); + const tmp: String = cheerioWrapper.context('key'); } function test_props() { @@ -524,8 +681,12 @@ namespace CheerioWrapperTest { function test_prop() { cheerioWrapper.prop('key'); + const tmp: String = cheerioWrapper.prop('key'); } + function test_key() { + stringVal = cheerioWrapper.key(); + } function test_simulate(...args: any[]) { cheerioWrapper.simulate('click'); @@ -533,15 +694,15 @@ namespace CheerioWrapperTest { } function test_setState() { - cheerioWrapper = cheerioWrapper.setState({stateProperty: 'state'}); + cheerioWrapper = cheerioWrapper.setState({ stateProperty: 'state' }); } function test_setProps() { - cheerioWrapper = cheerioWrapper.setProps({propsProperty: 'foo'}); + cheerioWrapper = cheerioWrapper.setProps({ propsProperty: 'foo' }); } function test_setContext() { - cheerioWrapper = cheerioWrapper.setContext({name: 'baz'}); + cheerioWrapper = cheerioWrapper.setContext({ name: 'baz' }); } function test_instance() { @@ -557,12 +718,16 @@ namespace CheerioWrapperTest { } function test_type() { - var stringOrFunction: String|Function = cheerioWrapper.type(); + var stringOrFunction: String | Function = cheerioWrapper.type(); + } + + function test_name() { + var str: String = cheerioWrapper.name(); } function test_forEach() { cheerioWrapper = - cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper)=> { + cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper) => { }); } diff --git a/enzyme/enzyme.d.ts b/enzyme/enzyme.d.ts index 13c00041a5..2698fd366b 100644 --- a/enzyme/enzyme.d.ts +++ b/enzyme/enzyme.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Enzyme v1.2.0 +// Type definitions for Enzyme v2.3.0 // Project: https://github.com/airbnb/enzyme // Definitions by: Marian Palkus , Cap3 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -57,6 +57,34 @@ declare module "enzyme" { */ contains(node: ReactElement): Boolean; + /** + * Returns whether or not a given react element exists in the shallow render tree. + * @param node + */ + containsMatchingElement(node: ReactElement): Boolean; + + /** + * Returns whether or not all the given react elements exists in the shallow render tree + * @param nodes + */ + containsAllMatchingElements(nodes: ReactElement[]): Boolean; + + /** + * Returns whether or not one of the given react elements exists in the shallow render tree. + * @param nodes + */ + containsAnyMatchingElements(nodes: ReactElement[]): Boolean; + + /** + * Returns whether or not the current render tree is equal to the given node, based on the expected value. + */ + equals(node: ReactElement): Boolean; + + /** + * Returns whether or not a given react element matches the shallow render tree. + */ + matchesElement(node: ReactElement): Boolean; + /** * Returns whether or not the current node has a className prop including the passed in class name. * @param className @@ -86,6 +114,13 @@ declare module "enzyme" { children(selector: string): CommonWrapper; children(): CommonWrapper; + /** + * Returns a new wrapper with child at the specified index. + * @param index + */ + childAt(index: Number): CommonWrapper; + childAt(index: Number): CommonWrapper; + /** * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector. @@ -157,6 +192,13 @@ declare module "enzyme" { * @param [key] */ state(key?: String): any; + state(key?: String): T; + + /** + * Returns the context hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value. + */ + context(key?: String): any; + context(key?: String): T; /** * Returns the props hash for the current node of the wrapper. @@ -172,6 +214,13 @@ declare module "enzyme" { * @param key */ prop(key: String): any; + prop(key: String): T; + + /** + * Returns the key value for the node of the current wrapper. + * NOTE: can only be called on a wrapper of a single node. + */ + key(): String; /** * Simulate events. @@ -247,6 +296,11 @@ declare module "enzyme" { */ type(): String | Function; + /** + * Returns the name of the current node of the wrapper. + */ + name(): String; + /** * Iterates through each node of the current wrapper and executes the provided function with a wrapper around * the corresponding node passed in as the first argument. @@ -347,6 +401,13 @@ declare module "enzyme" { children(selector: string): ShallowWrapper; children(): ShallowWrapper; + /** + * Returns a new wrapper with child at the specified index. + * @param index + */ + childAt(index: Number): ShallowWrapper; + childAt(index: Number): ShallowWrapper; + /** * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector. @@ -380,6 +441,25 @@ declare module "enzyme" { unmount(): ReactWrapper; mount(): ReactWrapper; + /** + * Returns a wrapper of the node that matches the provided reference name. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + */ + ref(refName: String): ReactWrapper; + ref(refName: String): ReactWrapper; + + /** + * Detaches the react tree from the DOM. Runs ReactDOM.unmountComponentAtNode() under the hood. + * + * This method will most commonly be used as a "cleanup" method if you decide to use the attachTo option in mount(node, options). + * + * The method is intentionally not "fluent" (in that it doesn't return this) because you should not be doing anything with this wrapper after this method is called. + * + * Using the attachTo is not generally recommended unless it is absolutely necessary to test something. It is your responsibility to clean up after yourself at the end of the test if you do decide to use it, though. + */ + detach() : void; + /** * Find every node in the render tree that matches the provided selector. * @param selector The selector to match. @@ -412,6 +492,13 @@ declare module "enzyme" { children(selector: string): ReactWrapper; children(): ReactWrapper; + /** + * Returns a new wrapper with child at the specified index. + * @param index + */ + childAt(index: Number): ReactWrapper; + childAt(index: Number): ReactWrapper; + /** * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.