From 1e7989f8ced1eb4f3f37b19ec1286178e5ccb3c5 Mon Sep 17 00:00:00 2001 From: icnocop Date: Wed, 29 Nov 2017 17:55:13 -0800 Subject: [PATCH] [jquery] Overriding the beforeSend function for AjaxSettings and UrlAjaxSettings to indicate a more appropriate settings parameter type Fixed errors when running lint --- types/jquery/index.d.ts | 16 ++++++++++++++++ types/jquery/jquery-tests.ts | 6 ++---- types/jquery/test/example-tests.ts | 2 -- types/jquery/test/longdesc-tests.ts | 2 -- types/jquery/tslint.json | 10 ++++++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index ef3d33a09e..9c635a747b 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -5405,6 +5405,14 @@ declare namespace JQuery { * A string containing the URL to which the request is sent. */ url?: string; + /** + * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, + * XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and + * settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend + * function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless + * of the type of request. + */ + beforeSend?(this: TContext, jqXHR: jqXHR, settings: AjaxSettings): false | void; } interface UrlAjaxSettings extends Ajax.AjaxSettingsBase { @@ -5412,6 +5420,14 @@ declare namespace JQuery { * A string containing the URL to which the request is sent. */ url: string; + /** + * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, + * XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and + * settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend + * function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless + * of the type of request. + */ + beforeSend?(this: TContext, jqXHR: jqXHR, settings: UrlAjaxSettings): false | void; } namespace Ajax { diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 6cb790f408..338509a37a 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -1,5 +1,3 @@ -// tslint:disable:interface-name - function JQueryStatic() { function type_assertion() { const $Canvas = $ as JQueryStatic; @@ -6195,7 +6193,7 @@ function JQuery_AjaxSettings() { this; // $ExpectType jqXHR jqXHR; - // $ExpectType AjaxSettingsBase + // $ExpectType AjaxSettings settings; }, cache: false, @@ -6305,7 +6303,7 @@ function JQuery_AjaxSettings() { this; // $ExpectType jqXHR jqXHR; - // $ExpectType AjaxSettingsBase + // $ExpectType AjaxSettings settings; return false; diff --git a/types/jquery/test/example-tests.ts b/types/jquery/test/example-tests.ts index f32a2c3723..728a42b3d6 100644 --- a/types/jquery/test/example-tests.ts +++ b/types/jquery/test/example-tests.ts @@ -1,5 +1,3 @@ -/* tslint:disable:no-arg object-literal-shorthand one-variable-per-declaration only-arrow-functions prefer-const prefer-for-of triple-equals no-var */ - function examples() { function add_0() { $('div').css('border', '2px solid red') diff --git a/types/jquery/test/longdesc-tests.ts b/types/jquery/test/longdesc-tests.ts index bf63445c16..23ff500d24 100644 --- a/types/jquery/test/longdesc-tests.ts +++ b/types/jquery/test/longdesc-tests.ts @@ -1,5 +1,3 @@ -/* tslint:disable:object-literal-key-quotes object-literal-shorthand one-variable-per-declaration only-arrow-functions prefer-const prefer-for-of triple-equals no-var */ - function longdesc() { function add_0() { $('p').add('div').addClass('widget'); diff --git a/types/jquery/tslint.json b/types/jquery/tslint.json index 24680d3efb..dea67c016f 100644 --- a/types/jquery/tslint.json +++ b/types/jquery/tslint.json @@ -5,7 +5,9 @@ "await-promise": false, "ban-types": false, "callable-types": false, + "interface-name": false, "no-any-union": false, + "no-arg": false, "no-boolean-literal-compare": false, "no-declare-current-package": false, "no-empty-interface": false, @@ -14,12 +16,20 @@ "no-unnecessary-generics": false, "no-unnecessary-qualifier": false, "no-unnecessary-type-assertion": false, + "no-var": false, "no-var-keyword": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-for-of": false, "prefer-switch": false, "prefer-template": false, "space-before-function-paren": false, "space-within-parens": false, + "triple-equals": false, "use-default-type-parameter": false } }