From 34f2dd7506ae13bab704c28a06abd8468e3d45c6 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 3 Dec 2013 14:11:46 +0000 Subject: [PATCH 1/4] jQuery: Added AJAX JSDoc + tightened up overloads --- jquery/jquery.d.ts | 90 +++++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index c741d2ee2..d6a7c6309 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -348,36 +348,78 @@ interface JQueryStatic { * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). */ ajax(settings: JQueryAjaxSettings): JQueryXHR; - /** - * Perform an asynchronous HTTP (Ajax) request. - * - * @param url A string containing the URL to which the request is sent. - * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). - */ + /** + * Perform an asynchronous HTTP (Ajax) request. + * + * @param url A string containing the URL to which the request is sent. + * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + */ ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR; - /** - * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). - * - * @param dataTypes An optional string containing one or more space-separated dataTypes - * @param handler A handler to set default values for future Ajax requests. - */ + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param dataTypes An optional string containing one or more space-separated dataTypes + * @param handler A handler to set default values for future Ajax requests. + */ ajaxPrefilter(dataTypes: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; - /** - * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). - * - * @param handler A handler to set default values for future Ajax requests. - */ + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param handler A handler to set default values for future Ajax requests. + */ ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; ajaxSettings: JQueryAjaxSettings; - ajaxSetup(): void; + /** + * Set default values for future Ajax requests. Its use is not recommended. + * + * @param options A set of key/value pairs that configure the default Ajax request. All options are optional. + */ ajaxSetup(options: JQueryAjaxSettings): void; - get(url: string, data?: any, success?: any, dataType?: any): JQueryXHR; - getJSON(url: string, data?: any, success?: any): JQueryXHR; - getScript(url: string, success?: any): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: Object, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: string, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, data?: Object, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, data?: string, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load a JavaScript file from the server using a GET HTTP request, then execute it. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; param: JQueryParam; @@ -400,9 +442,9 @@ interface JQueryStatic { noConflict(removeAll?: boolean): Object; - when(...deferreds: JQueryGenericPromise[]): JQueryPromise; - when(...deferreds: T[]): JQueryPromise; - when(...deferreds: any[]): JQueryPromise; + when(...deferreds: JQueryGenericPromise[]): JQueryPromise; + when(...deferreds: T[]): JQueryPromise; + when(...deferreds: any[]): JQueryPromise; // CSS css(e: any, propertyName: string, value?: any): any; From a1e6cb6236006c0161bc6a07771a69fe07f855ba Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 3 Dec 2013 14:20:55 +0000 Subject: [PATCH 2/4] jQuery: Added data-less get / getJSON overloads data on success => any --- jquery/jquery.d.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index d6a7c6309..c627ea088 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -383,11 +383,10 @@ interface JQueryStatic { * Load data from the server using a HTTP GET request. * * @param url A string containing the URL to which the request is sent. - * @param data A plain object or string that is sent to the server with the request. * @param success A callback function that is executed if the request succeeds. * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). */ - get(url: string, data?: Object, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; /** * Load data from the server using a HTTP GET request. * @@ -396,7 +395,23 @@ interface JQueryStatic { * @param success A callback function that is executed if the request succeeds. * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). */ - get(url: string, data?: string, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + get(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; /** * Load JSON-encoded data from the server using a GET HTTP request. * @@ -404,7 +419,7 @@ interface JQueryStatic { * @param data A plain object or string that is sent to the server with the request. * @param success A callback function that is executed if the request succeeds. */ - getJSON(url: string, data?: Object, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + getJSON(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; /** * Load JSON-encoded data from the server using a GET HTTP request. * @@ -412,7 +427,7 @@ interface JQueryStatic { * @param data A plain object or string that is sent to the server with the request. * @param success A callback function that is executed if the request succeeds. */ - getJSON(url: string, data?: string, success?: (data: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + getJSON(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; /** * Load a JavaScript file from the server using a GET HTTP request, then execute it. * From 0727cb849eaaa74b2918f5a7277e544746969ac2 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 3 Dec 2013 14:23:09 +0000 Subject: [PATCH 3/4] jQuery: tabs to spaces --- jquery/jquery.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index c627ea088..d0095b126 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -457,9 +457,9 @@ interface JQueryStatic { noConflict(removeAll?: boolean): Object; - when(...deferreds: JQueryGenericPromise[]): JQueryPromise; - when(...deferreds: T[]): JQueryPromise; - when(...deferreds: any[]): JQueryPromise; + when(...deferreds: JQueryGenericPromise[]): JQueryPromise; + when(...deferreds: T[]): JQueryPromise; + when(...deferreds: any[]): JQueryPromise; // CSS css(e: any, propertyName: string, value?: any): any; From 0283025a75b3adb734db4f13ba16ed80a829e434 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 3 Dec 2013 14:35:04 +0000 Subject: [PATCH 4/4] jQuery: a few more while I'm at it --- jquery/jquery.d.ts | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index d0095b126..18f8ee5f3 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -438,13 +438,46 @@ interface JQueryStatic { param: JQueryParam; - post(url: string, data?: any, success?: any, dataType?: any): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; - // Callbacks + /** + * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. + * + * @param flags An optional list of space-separated flags that change how the callback list behaves. + */ Callbacks(flags?: string): JQueryCallback; - // Core - holdReady(hold: boolean): any; + /** + * Holds or releases the execution of jQuery's ready event. + * + * @param hold Indicates whether the ready hold is being requested or released + */ + holdReady(hold: boolean): void; (selector: string, context?: any): JQuery; (element: Element): JQuery; @@ -455,6 +488,11 @@ interface JQueryStatic { (array: any[]): JQuery; (): JQuery; + /** + * Relinquish jQuery's control of the $ variable. + * + * @param removeAll A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself). + */ noConflict(removeAll?: boolean): Object; when(...deferreds: JQueryGenericPromise[]): JQueryPromise;