From c3cbb348e26415a8b7362d2105b6495cb9642ea2 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Tue, 16 Oct 2018 13:15:06 -0400 Subject: [PATCH] [jquery] Add `includeMargin` parameter to `.outerHeight()` and `.outerWidth()` setters. (#29756) * [jquery] Add `includeMargin` parameter to `.outerHeight()` and `.outerWidth()` setters. See https://github.com/jquery/jquery/blob/354f6036f251a3ce9b24cd7b228b4c7a79001520/test/unit/dimensions.js#L477-L484. * [jquery-awesome-cursor] Add missing `dom` lib target. * [jquery-toast-plugin] Add missing `dom` lib target. * [jquery.growl] Add missing `dom` lib target. * [materialize-css] Disable `unified-signatures` rule for plugin overloads. These overloads follow the jQuery plugin pattern and are effectively separate methods. * [ng-cordova] Update promise types to be compatible with changes from `ng.IPromise`. Ref: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/23115 * [ng-tags-input] Add missing `dom` lib target. * [p-loading] Add missing `dom` lib target. * [summernote] Add missing `dom` lib target. * [swig-email-templates] Add missing `dom` lib target. * [materialize-css] Unify signatures according to feedback. See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29756#pullrequestreview-165249412. --- types/jquery-awesome-cursor/tsconfig.json | 3 +- types/jquery-toast-plugin/tsconfig.json | 3 +- types/jquery.growl/tsconfig.json | 3 +- types/jquery/index.d.ts | 6 ++-- types/jquery/jquery-tests.ts | 30 ++++++++++++++++++++ types/materialize-css/carousel.d.ts | 4 +-- types/materialize-css/character-counter.d.ts | 3 +- types/materialize-css/collapsible.d.ts | 3 +- types/materialize-css/range.d.ts | 3 +- types/ng-cordova/file.d.ts | 5 +++- types/ng-cordova/fileTransfer.d.ts | 6 +++- types/ng-tags-input/tsconfig.json | 3 +- types/p-loading/tsconfig.json | 3 +- types/summernote/tsconfig.json | 3 +- types/swig-email-templates/tsconfig.json | 3 +- 15 files changed, 61 insertions(+), 20 deletions(-) diff --git a/types/jquery-awesome-cursor/tsconfig.json b/types/jquery-awesome-cursor/tsconfig.json index cb81088d83..7fb68010e3 100644 --- a/types/jquery-awesome-cursor/tsconfig.json +++ b/types/jquery-awesome-cursor/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/jquery-toast-plugin/tsconfig.json b/types/jquery-toast-plugin/tsconfig.json index 95759d345b..81dae6d531 100644 --- a/types/jquery-toast-plugin/tsconfig.json +++ b/types/jquery-toast-plugin/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/jquery.growl/tsconfig.json b/types/jquery.growl/tsconfig.json index 8416f143a7..7b2e28e9d9 100644 --- a/types/jquery.growl/tsconfig.json +++ b/types/jquery.growl/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 3b06f50ceb..344194e5af 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -21610,7 +21610,8 @@ $( "div" ).one( "click", function() { ``` */ - outerHeight(value: string | number | ((this: TElement, index: number, height: number) => string | number)): this; + outerHeight(value: string | number | ((this: TElement, index: number, height: number) => string | number), + includeMargin?: boolean): this; /** * Get the current computed outer height (including padding, border, and optionally margin) for the * first element in the set of matched elements. @@ -21703,7 +21704,8 @@ $( "div" ).one( "click", function() { ``` */ - outerWidth(value: string | number | ((this: TElement, index: number, width: number) => string | number)): this; + outerWidth(value: string | number | ((this: TElement, index: number, width: number) => string | number), + includeMargin?: boolean): this; /** * Get the current computed outer width (including padding, border, and optionally margin) for the * first element in the set of matched elements. diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 37ddc27c56..31518d8d84 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -2616,12 +2616,27 @@ function JQuery() { } function outerHeight() { + // $ExpectType JQuery + $('p').outerHeight({} as string | number, true); + // $ExpectType JQuery $('p').outerHeight('200px'); // $ExpectType JQuery $('p').outerHeight(400); + // $ExpectType JQuery + $('p').outerHeight(function(index, height) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + height; + + return '200px'; + }, false); + // $ExpectType JQuery $('p').outerHeight(function(index, height) { // $ExpectType HTMLElement @@ -2724,12 +2739,27 @@ function JQuery() { } function outerWidth() { + // $ExpectType JQuery + $('p').outerWidth({} as string | number, true); + // $ExpectType JQuery $('p').outerWidth('200px'); // $ExpectType JQuery $('p').outerWidth(400); + // $ExpectType JQuery + $('p').outerWidth(function(index, width) { + // $ExpectType HTMLElement + this; + // $ExpectType number + index; + // $ExpectType number + width; + + return '200px'; + }, false); + // $ExpectType JQuery $('p').outerWidth(function(index, width) { // $ExpectType HTMLElement diff --git a/types/materialize-css/carousel.d.ts b/types/materialize-css/carousel.d.ts index fd660694d1..6c762ec830 100644 --- a/types/materialize-css/carousel.d.ts +++ b/types/materialize-css/carousel.d.ts @@ -110,8 +110,6 @@ declare namespace M { interface JQuery { carousel(method: keyof Pick): JQuery; - carousel(method: keyof Pick, n?: number): JQuery; - carousel(method: keyof Pick, n?: number): JQuery; - carousel(method: keyof Pick, n?: number): JQuery; + carousel(method: keyof Pick | keyof Pick | keyof Pick, n?: number): JQuery; carousel(options?: Partial): JQuery; } diff --git a/types/materialize-css/character-counter.d.ts b/types/materialize-css/character-counter.d.ts index 4d34ac170e..7634075a9b 100644 --- a/types/materialize-css/character-counter.d.ts +++ b/types/materialize-css/character-counter.d.ts @@ -20,6 +20,5 @@ declare namespace M { } interface JQuery { - characterCounter(method: keyof Pick): JQuery; - characterCounter(): JQuery; + characterCounter(method?: keyof Pick): JQuery; } diff --git a/types/materialize-css/collapsible.d.ts b/types/materialize-css/collapsible.d.ts index 649a59e9bb..d69e958730 100644 --- a/types/materialize-css/collapsible.d.ts +++ b/types/materialize-css/collapsible.d.ts @@ -77,7 +77,6 @@ declare namespace M { interface JQuery { collapsible(method: keyof Pick): JQuery; - collapsible(method: keyof Pick, n: number): JQuery; - collapsible(method: keyof Pick, n: number): JQuery; + collapsible(method: keyof Pick | keyof Pick, n: number): JQuery; collapsible(options?: Partial): JQuery; } diff --git a/types/materialize-css/range.d.ts b/types/materialize-css/range.d.ts index dac7a7edf2..a1de53baa9 100644 --- a/types/materialize-css/range.d.ts +++ b/types/materialize-css/range.d.ts @@ -20,6 +20,5 @@ declare namespace M { } interface JQuery { - range(): JQuery; - range(method: keyof Pick): JQuery; + range(method?: keyof Pick): JQuery; } diff --git a/types/ng-cordova/file.d.ts b/types/ng-cordova/file.d.ts index 8ebe777c14..c6c71972b4 100644 --- a/types/ng-cordova/file.d.ts +++ b/types/ng-cordova/file.d.ts @@ -36,7 +36,10 @@ declare namespace ngCordova { } export interface IFilePromise extends ng.IPromise { - then(successCallback: (promiseValue: T) => ng.IPromise | TResult, errorCallback?: (error: IFileError) => ng.IPromise | TResult): ng.IPromise; + then( + successCallback: (promiseValue: T) => ng.IPromise | TResult, + errorCallback?: (error: IFileError) => ng.IPromise | TResult2 + ): ng.IPromise; catch(onRejected: (error: IFileError) => ng.IPromise | TResult): ng.IPromise; } diff --git a/types/ng-cordova/fileTransfer.d.ts b/types/ng-cordova/fileTransfer.d.ts index e4ef359c14..9c1d8bf3c2 100644 --- a/types/ng-cordova/fileTransfer.d.ts +++ b/types/ng-cordova/fileTransfer.d.ts @@ -14,7 +14,11 @@ declare namespace ngCordova { } export interface IFileTransferPromise extends ng.IPromise { - then(successCallback: (promiseValue: T) => ng.IPromise | TResult, errorCallback?: (error: FileTransferError) => ng.IPromise | TResult, notifyCallback?: (state: any) => any): ng.IPromise; + then( + successCallback: (promiseValue: T) => ng.IPromise | TResult, + errorCallback?: (error: FileTransferError) => ng.IPromise | TResult2, + notifyCallback?: (state: any) => any + ): ng.IPromise; catch(onRejected: (error: FileTransferError) => ng.IPromise | TResult): ng.IPromise; } diff --git a/types/ng-tags-input/tsconfig.json b/types/ng-tags-input/tsconfig.json index 42a59350cb..09cfc54e25 100644 --- a/types/ng-tags-input/tsconfig.json +++ b/types/ng-tags-input/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/p-loading/tsconfig.json b/types/p-loading/tsconfig.json index 09fd52fdda..6f45b638aa 100644 --- a/types/p-loading/tsconfig.json +++ b/types/p-loading/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/summernote/tsconfig.json b/types/summernote/tsconfig.json index 127f97e02f..cfa86cb32d 100644 --- a/types/summernote/tsconfig.json +++ b/types/summernote/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/swig-email-templates/tsconfig.json b/types/swig-email-templates/tsconfig.json index b25f125136..67d0c3ccdf 100644 --- a/types/swig-email-templates/tsconfig.json +++ b/types/swig-email-templates/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true,