From 42fdf759bb330dc982230d8b6aa5cfafaed821b7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 19 Dec 2018 14:09:24 -0800 Subject: [PATCH 1/4] Round 1 of fixes --- types/blissfuljs/index.d.ts | 5 +--- types/debounce-promise/index.d.ts | 4 ++- types/debounce-promise/package.json | 7 ++++++ .../ts3.1/debounce-promise-tests.ts | 25 +++++++++++++++++++ types/debounce-promise/ts3.1/index.d.ts | 18 +++++++++++++ types/debounce-promise/ts3.1/package.json | 7 ++++++ types/debounce-promise/ts3.1/tsconfig.json | 16 ++++++++++++ types/debounce-promise/ts3.1/tslint.json | 1 + types/pixi.js/index.d.ts | 2 +- types/quill/tsconfig.json | 3 ++- 10 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 types/debounce-promise/package.json create mode 100644 types/debounce-promise/ts3.1/debounce-promise-tests.ts create mode 100644 types/debounce-promise/ts3.1/index.d.ts create mode 100644 types/debounce-promise/ts3.1/package.json create mode 100644 types/debounce-promise/ts3.1/tsconfig.json create mode 100644 types/debounce-promise/ts3.1/tslint.json diff --git a/types/blissfuljs/index.d.ts b/types/blissfuljs/index.d.ts index 9174ee4e944d00..5ea06224f12b27 100644 --- a/types/blissfuljs/index.d.ts +++ b/types/blissfuljs/index.d.ts @@ -2,6 +2,7 @@ // Project: http://blissfuljs.com/ // Definitions by: François Skorzec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 interface Element { _: BlissNS.BlissBindedElement; @@ -285,7 +286,6 @@ declare namespace BlissNS { addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): T; addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): T; addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): T; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): T; addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): T; addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): T; addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): T; @@ -555,18 +555,15 @@ declare namespace BlissNS { getElementsByTagName(name: "video"): NodeListOf; getElementsByTagName(name: "view"): NodeListOf; getElementsByTagName(name: "wbr"): NodeListOf; - getElementsByTagName(name: "x-ms-webview"): NodeListOf; getElementsByTagName(name: "xmp"): NodeListOf; getElementsByTagName(name: string): NodeListOf; getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; hasAttribute(name: string): boolean; hasAttributeNS(namespaceURI: string, localName: string): boolean; - msGetRegionContent(): MSRangeCollection; msGetUntransformedBounds(): ClientRect; msMatchesSelector(selectors: string): boolean; msReleasePointerCapture(pointerId: number): T; msSetPointerCapture(pointerId: number): T; - msZoomTo(args: MsZoomToOptions): T; releasePointerCapture(pointerId: number): T; removeAttribute(name?: string): T; removeAttributeNS(namespaceURI: string, localName: string): T; diff --git a/types/debounce-promise/index.d.ts b/types/debounce-promise/index.d.ts index 905ca7fc509e59..2356d300607fbd 100644 --- a/types/debounce-promise/index.d.ts +++ b/types/debounce-promise/index.d.ts @@ -11,12 +11,14 @@ declare namespace debounce { } } +type ArgumentsType = T extends (...args: infer A) => any ? A : never; + declare function debounce any>( func: T, wait?: number, options?: debounce.DebounceOptions ): ( - ...args: Parameters + ...args: ArgumentsType ) => ReturnType extends Promise ? ReturnType : Promise>; diff --git a/types/debounce-promise/package.json b/types/debounce-promise/package.json new file mode 100644 index 00000000000000..bb80441dc0c06c --- /dev/null +++ b/types/debounce-promise/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "types": "index", + "typesVersions": { + ">=3.1.0-0": { "*": ["ts3.1/*"] } + } +} diff --git a/types/debounce-promise/ts3.1/debounce-promise-tests.ts b/types/debounce-promise/ts3.1/debounce-promise-tests.ts new file mode 100644 index 00000000000000..75b53dc76473b3 --- /dev/null +++ b/types/debounce-promise/ts3.1/debounce-promise-tests.ts @@ -0,0 +1,25 @@ +import debounce = require("debounce-promise"); +import { DebounceOptions } from "debounce-promise"; + +const options: DebounceOptions = {}; +const optionsA: DebounceOptions = { leading: true }; +const f = async () => 2; +const f2 = (a: string) => 2; +debounce(f, 100); +debounce(f, 0, options); +debounce(f, 100, optionsA); +debounce(f, 10, { accumulate: true }); +const foo = debounce(async () => f2, 10, { + leading: true, + accumulate: true +}); +foo().then(f => f("2")); +const bar = debounce(async () => [1, 2, 3], 100); +bar().then(ar => ar.concat()); + +// Converts the return value from the producer function to a promise +const two = debounce((a: string, b: number, c: { d: boolean }) => [4], 10, { + leading: true, + accumulate: true +}); +two("1", 2, { d: false }).then(ar => ar.pop(), () => 2); diff --git a/types/debounce-promise/ts3.1/index.d.ts b/types/debounce-promise/ts3.1/index.d.ts new file mode 100644 index 00000000000000..29aa7356a1518e --- /dev/null +++ b/types/debounce-promise/ts3.1/index.d.ts @@ -0,0 +1,18 @@ +declare namespace debounce { + interface DebounceOptions { + leading?: boolean; + accumulate?: boolean; + } +} + +declare function debounce any>( + func: T, + wait?: number, + options?: debounce.DebounceOptions +): ( + ...args: Parameters +) => ReturnType extends Promise + ? ReturnType + : Promise>; + +export = debounce; diff --git a/types/debounce-promise/ts3.1/package.json b/types/debounce-promise/ts3.1/package.json new file mode 100644 index 00000000000000..d27d838dc68a3e --- /dev/null +++ b/types/debounce-promise/ts3.1/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "types": "index", + "typesVersions": { + ">=3.2.0-0": { "*": ["ts3.2/*"] } + } +} diff --git a/types/debounce-promise/ts3.1/tsconfig.json b/types/debounce-promise/ts3.1/tsconfig.json new file mode 100644 index 00000000000000..cfd321d0148e94 --- /dev/null +++ b/types/debounce-promise/ts3.1/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": ["../../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "debounce-promise-tests.ts"] +} diff --git a/types/debounce-promise/ts3.1/tslint.json b/types/debounce-promise/ts3.1/tslint.json new file mode 100644 index 00000000000000..3db14f85eaf7b9 --- /dev/null +++ b/types/debounce-promise/ts3.1/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pixi.js/index.d.ts b/types/pixi.js/index.d.ts index eeb86830fe464d..b0b6b64452fefb 100644 --- a/types/pixi.js/index.d.ts +++ b/types/pixi.js/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/pixijs/pixi.js/tree/dev // Definitions by: clark-stevenson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.3 declare namespace PIXI { // from CONST diff --git a/types/quill/tsconfig.json b/types/quill/tsconfig.json index a5297158c9f2d2..3d488f0e4d4e3a 100644 --- a/types/quill/tsconfig.json +++ b/types/quill/tsconfig.json @@ -15,10 +15,11 @@ ], "types": [], "noEmit": true, + "esModuleInterop": true, "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", "quill-tests.ts" ] -} \ No newline at end of file +} From 5b119f476719d20cea7ee29311db14fd2b67a3cd Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 20 Dec 2018 15:23:06 -0800 Subject: [PATCH 2/4] Round 2 of fixes --- types/styled-components/test/index.tsx | 8 ++++---- types/tingle.js/tingle.js-tests.ts | 5 +---- types/workbox-sw/tsconfig.json | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/types/styled-components/test/index.tsx b/types/styled-components/test/index.tsx index d382b42628ef84..0c175d8ce99985 100644 --- a/types/styled-components/test/index.tsx +++ b/types/styled-components/test/index.tsx @@ -655,8 +655,8 @@ async function typedThemes() { createGlobalStyle, ThemeProvider, ThemeConsumer - } = (await import("styled-components")) as ThemedStyledComponentsModule< - typeof theme + } = (await import("styled-components")) as any as ThemedStyledComponentsModule< + typeof theme >; const ThemedDiv = styled.div` @@ -753,10 +753,10 @@ async function themeAugmentation() { accent: string; } - const base = (await import("styled-components")) as ThemedStyledComponentsModule< + const base = (await import("styled-components")) as any as ThemedStyledComponentsModule< BaseTheme >; - const extra = (await import("styled-components")) as ThemedStyledComponentsModule< + const extra = (await import("styled-components")) as any as ThemedStyledComponentsModule< ExtraTheme, BaseTheme >; diff --git a/types/tingle.js/tingle.js-tests.ts b/types/tingle.js/tingle.js-tests.ts index 28c7a08c7e0224..9734178a008736 100644 --- a/types/tingle.js/tingle.js-tests.ts +++ b/types/tingle.js/tingle.js-tests.ts @@ -15,9 +15,6 @@ instance = new modal({ }, }); -instance.addFooterBtn('text', undefined, function(e) { - e.x; - this.innerText; -}); +instance.addFooterBtn('text', undefined, e => e.x); instance.setStickyFooter(false); diff --git a/types/workbox-sw/tsconfig.json b/types/workbox-sw/tsconfig.json index d6c28215257151..28446158f9f934 100644 --- a/types/workbox-sw/tsconfig.json +++ b/types/workbox-sw/tsconfig.json @@ -8,7 +8,6 @@ "target": "es2017", "lib": [ "es2015", - "dom", "webworker" ], "noImplicitAny": true, From 68237acb4cd0561b0e65baf437748bf53ea8ac56 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 20 Dec 2018 15:29:36 -0800 Subject: [PATCH 3/4] blissfuljs doesn't actually require TS 3.0 --- types/blissfuljs/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/blissfuljs/index.d.ts b/types/blissfuljs/index.d.ts index 5ea06224f12b27..4712e91badddb6 100644 --- a/types/blissfuljs/index.d.ts +++ b/types/blissfuljs/index.d.ts @@ -2,7 +2,6 @@ // Project: http://blissfuljs.com/ // Definitions by: François Skorzec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0 interface Element { _: BlissNS.BlissBindedElement; From b8157ded63101ba5f1986b93287377d17ca49b3a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 20 Dec 2018 15:41:09 -0800 Subject: [PATCH 4/4] Remove unused file inside typesVersion --- types/debounce-promise/ts3.1/package.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 types/debounce-promise/ts3.1/package.json diff --git a/types/debounce-promise/ts3.1/package.json b/types/debounce-promise/ts3.1/package.json deleted file mode 100644 index d27d838dc68a3e..00000000000000 --- a/types/debounce-promise/ts3.1/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "private": true, - "types": "index", - "typesVersions": { - ">=3.2.0-0": { "*": ["ts3.2/*"] } - } -}