From e0a3b954e72083430ba2c0b5728d0df249198b1c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 30 Dec 2016 15:12:18 -0800 Subject: [PATCH 01/45] jquery: allow null argument to `attr` --- jquery/index.d.ts | 318 ++++++++++++++++++++--------------------- jquery/jquery-tests.ts | 1 + 2 files changed, 160 insertions(+), 159 deletions(-) diff --git a/jquery/index.d.ts b/jquery/index.d.ts index fa22a1599b..91e579e6a2 100644 --- a/jquery/index.d.ts +++ b/jquery/index.d.ts @@ -74,7 +74,7 @@ interface JQueryAjaxSettings { */ dataFilter? (data: any, ty: any): any; /** - * The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). + * The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). */ dataType?: string; /** @@ -168,11 +168,11 @@ interface JQueryAjaxSettings { */ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { /** - * The .overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header. As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5). + * The .overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header. As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5). */ overrideMimeType(mimeType: string): any; /** - * Cancel the request. + * Cancel the request. * * @param statusText A string passed as the textStatus parameter for the done callback. Default value: "canceled" */ @@ -197,13 +197,13 @@ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { interface JQueryCallback { /** * Add a callback or a collection of callbacks to a callback list. - * + * * @param callbacks A function, or array of functions, that are to be added to the callback list. */ add(callbacks: Function): JQueryCallback; /** * Add a callback or a collection of callbacks to a callback list. - * + * * @param callbacks A function, or array of functions, that are to be added to the callback list. */ add(callbacks: Function[]): JQueryCallback; @@ -225,7 +225,7 @@ interface JQueryCallback { /** * Call all of the callbacks with the given arguments - * + * * @param arguments The argument or list of arguments to pass back to the callback list. */ fire(...arguments: any[]): JQueryCallback; @@ -237,7 +237,7 @@ interface JQueryCallback { /** * Call all callbacks in a list with the given context and arguments. - * + * * @param context A reference to the context in which the callbacks in the list should be fired. * @param arguments An argument, or array of arguments, to pass to the callbacks in the list. */ @@ -245,7 +245,7 @@ interface JQueryCallback { /** * Determine whether a supplied callback is in a list - * + * * @param callback The callback to search for. */ has(callback: Function): boolean; @@ -262,13 +262,13 @@ interface JQueryCallback { /** * Remove a callback or a collection of callbacks from a callback list. - * + * * @param callbacks A function, or array of functions, that are to be removed from the callback list. */ remove(callbacks: Function): JQueryCallback; /** * Remove a callback or a collection of callbacks from a callback list. - * + * * @param callbacks A function, or array of functions, that are to be removed from the callback list. */ remove(callbacks: Function[]): JQueryCallback; @@ -280,7 +280,7 @@ interface JQueryCallback { interface JQueryGenericPromise { /** * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. - * + * * @param doneFilter A function that is called when the Deferred is resolved. * @param failFilter An optional function that is called when the Deferred is rejected. */ @@ -288,7 +288,7 @@ interface JQueryGenericPromise { /** * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. - * + * * @param doneFilter A function that is called when the Deferred is resolved. * @param failFilter An optional function that is called when the Deferred is rejected. */ @@ -316,38 +316,38 @@ interface JQueryPromise extends JQueryGenericPromise { state(): string; /** * Add handlers to be called when the Deferred object is either resolved or rejected. - * + * * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is resolved. - * + * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is rejected. - * + * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object generates progress notifications. - * + * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; // Deprecated - given no typings pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; - + /** * Return a Deferred's Promise object. - * + * * @param target Object onto which the promise methods have to be attached */ promise(target?: any): JQueryPromise; @@ -363,42 +363,42 @@ interface JQueryDeferred extends JQueryGenericPromise { state(): string; /** * Add handlers to be called when the Deferred object is either resolved or rejected. - * + * * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is resolved. - * + * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is rejected. - * + * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object generates progress notifications. - * + * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Call the progressCallbacks on a Deferred object with the given args. - * + * * @param args Optional arguments that are passed to the progressCallbacks. */ notify(value?: any, ...args: any[]): JQueryDeferred; /** * Call the progressCallbacks on a Deferred object with the given context and args. - * + * * @param context Context passed to the progressCallbacks as the this object. * @param args Optional arguments that are passed to the progressCallbacks. */ @@ -406,13 +406,13 @@ interface JQueryDeferred extends JQueryGenericPromise { /** * Reject a Deferred object and call any failCallbacks with the given args. - * + * * @param args Optional arguments that are passed to the failCallbacks. */ reject(value?: any, ...args: any[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given context and args. - * + * * @param context Context passed to the failCallbacks as the this object. * @param args An optional array of arguments that are passed to the failCallbacks. */ @@ -420,7 +420,7 @@ interface JQueryDeferred extends JQueryGenericPromise { /** * Resolve a Deferred object and call any doneCallbacks with the given args. - * + * * @param value First argument passed to doneCallbacks. * @param args Optional subsequent arguments that are passed to the doneCallbacks. */ @@ -428,7 +428,7 @@ interface JQueryDeferred extends JQueryGenericPromise { /** * Resolve a Deferred object and call any doneCallbacks with the given context and args. - * + * * @param context Context passed to the doneCallbacks as the this object. * @param args An optional array of arguments that are passed to the doneCallbacks. */ @@ -436,7 +436,7 @@ interface JQueryDeferred extends JQueryGenericPromise { /** * Return a Deferred's Promise object. - * + * * @param target Object onto which the promise methods have to be attached */ promise(target?: any): JQueryPromise; @@ -527,14 +527,14 @@ interface JQuerySupport { interface JQueryParam { /** * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. - * + * * @param obj An array or object to serialize. */ (obj: any): string; /** * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. - * + * * @param obj An array or object to serialize. * @param traditional A Boolean indicating whether to perform a traditional "shallow" serialization. */ @@ -568,47 +568,47 @@ interface JQuerySerializeArrayElement { value: string; } -interface JQueryAnimationOptions { +interface JQueryAnimationOptions { /** * A string or number determining how long the animation will run. */ - duration?: any; + duration?: any; /** * A string indicating which easing function to use for the transition. */ - easing?: string; + easing?: string; /** * A function to call once the animation is complete. */ - complete?: Function; + complete?: Function; /** * A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set. */ - step?: (now: number, tween: any) => any; + step?: (now: number, tween: any) => any; /** * A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties. (version added: 1.8) */ - progress?: (animation: JQueryPromise, progress: number, remainingMs: number) => any; + progress?: (animation: JQueryPromise, progress: number, remainingMs: number) => any; /** * A function to call when the animation begins. (version added: 1.8) */ - start?: (animation: JQueryPromise) => any; + start?: (animation: JQueryPromise) => any; /** * A function to be called when the animation completes (its Promise object is resolved). (version added: 1.8) */ - done?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + done?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; /** * A function to be called when the animation fails to complete (its Promise object is rejected). (version added: 1.8) */ - fail?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + fail?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; /** * A function to be called when the animation completes or stops without completing (its Promise object is either resolved or rejected). (version added: 1.8) */ - always?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + always?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; /** * A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call .dequeue("queuename") to start it. */ - queue?: any; + queue?: any; /** * A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions. (version added: 1.4) */ @@ -972,7 +972,7 @@ interface JQueryStatic { /** * Check to see if a DOM element is a descendant of another DOM element. - * + * * @param container The DOM element that may contain the other element. * @param contained The DOM element that may be contained by (a descendant of) the other element. */ @@ -980,7 +980,7 @@ interface JQueryStatic { /** * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. - * + * * @param collection The object or array to iterate over. * @param callback The function that will be executed on every object. */ @@ -991,7 +991,7 @@ interface JQueryStatic { /** * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. - * + * * @param collection The object or array to iterate over. * @param callback The function that will be executed on every object. */ @@ -1088,21 +1088,21 @@ interface JQueryStatic { /** * Convert an array-like object into a true JavaScript array. - * + * * @param obj Any object to turn into a native Array. */ makeArray(obj: any): any[]; /** * Translate all items in an array or object to new array of items. - * + * * @param array The Array to translate. * @param callback The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object. */ map(array: T[], callback: (elementOfArray?: T, indexInArray?: number) => U): U[]; /** * Translate all items in an array or object to new array of items. - * + * * @param arrayOrObject The Array or Object to translate. * @param callback The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object. */ @@ -1110,7 +1110,7 @@ interface JQueryStatic { /** * Merge the contents of two arrays together into the first array. - * + * * @param first The first array to merge, the elements of second added. * @param second The second array to merge into the first, unaltered. */ @@ -1128,7 +1128,7 @@ interface JQueryStatic { /** * Takes a well-formed JSON string and returns the resulting JavaScript object. - * + * * @param json The JSON string to parse. */ parseJSON(json: string): any; @@ -1142,21 +1142,21 @@ interface JQueryStatic { /** * Remove the whitespace from the beginning and end of a string. - * + * * @param str Remove the whitespace from the beginning and end of a string. */ trim(str: string): string; /** * Determine the internal JavaScript [[Class]] of an object. - * + * * @param obj Object to get the internal JavaScript [[Class]] of. */ type(obj: any): string; /** * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers. - * + * * @param array The Array of DOM elements. */ unique(array: Element[]): Element[]; @@ -1267,9 +1267,9 @@ interface JQuery { * Set one or more attributes for the set of matched elements. * * @param attributeName The name of the attribute to set. - * @param value A value to set for the attribute. + * @param value A value to set for the attribute. If this is `null`, the attribute will be deleted. */ - attr(attributeName: string, value: string|number): JQuery; + attr(attributeName: string, value: string|number|null): JQuery; /** * Set one or more attributes for the set of matched elements. * @@ -1283,7 +1283,7 @@ interface JQuery { * @param attributes An object of attribute-value pairs to set. */ attr(attributes: Object): JQuery; - + /** * Determine whether any of the matched elements are assigned the given class. * @@ -1461,7 +1461,7 @@ interface JQuery { * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). */ innerHeight(height: number|string): JQuery; - + /** * Get the current computed width for the first element in the set of matched elements, including padding but not border. */ @@ -1473,7 +1473,7 @@ interface JQuery { * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). */ innerWidth(width: number|string): JQuery; - + /** * Get the current coordinates of the first element in the set of matched elements, relative to the document. */ @@ -1906,7 +1906,7 @@ interface JQuery { /** * Attach a handler to an event for the elements. - * + * * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. @@ -1914,14 +1914,14 @@ interface JQuery { bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Attach a handler to an event for the elements. - * + * * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param handler A function to execute each time the event is triggered. */ bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Attach a handler to an event for the elements. - * + * * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param eventData An object containing data that will be passed to the event handler. * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. @@ -1929,14 +1929,14 @@ interface JQuery { bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; /** * Attach a handler to an event for the elements. - * + * * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. */ bind(eventType: string, preventBubble: boolean): JQuery; /** * Attach a handler to an event for the elements. - * + * * @param events An object containing one or more DOM event types and functions to execute for them. */ bind(events: any): JQuery; @@ -2511,14 +2511,14 @@ interface JQuery { /** * Execute all handlers and behaviors attached to the matched elements for the given event type. - * + * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param extraParameters Additional parameters to pass along to the event handler. */ trigger(eventType: string, extraParameters?: any[]|Object): JQuery; /** * Execute all handlers and behaviors attached to the matched elements for the given event type. - * + * * @param event A jQuery.Event object. * @param extraParameters Additional parameters to pass along to the event handler. */ @@ -2526,7 +2526,7 @@ interface JQuery { /** * Execute all handlers attached to an element for an event. - * + * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param extraParameters An array of additional parameters to pass along to the event handler. */ @@ -2534,7 +2534,7 @@ interface JQuery { /** * Execute all handlers attached to an element for an event. - * + * * @param event A jQuery.Event object. * @param extraParameters An array of additional parameters to pass along to the event handler. */ @@ -2542,21 +2542,21 @@ interface JQuery { /** * Remove a previously-attached event handler from the elements. - * + * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param handler The function that is to be no longer executed. */ unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * Remove a previously-attached event handler from the elements. - * + * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). */ unbind(eventType: string, fls: boolean): JQuery; /** * Remove a previously-attached event handler from the elements. - * + * * @param evt A JavaScript event object as passed to an event handler. */ unbind(evt: any): JQuery; @@ -2567,7 +2567,7 @@ interface JQuery { undelegate(): JQuery; /** * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. - * + * * @param selector A selector which will be used to filter the event results. * @param eventType A string containing a JavaScript event type, such as "click" or "keydown" * @param handler A function to execute at the time the event is triggered. @@ -2575,27 +2575,27 @@ interface JQuery { undelegate(selector: string, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. - * + * * @param selector A selector which will be used to filter the event results. * @param events An object of one or more event types and previously bound functions to unbind from them. */ undelegate(selector: string, events: Object): JQuery; /** * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. - * + * * @param namespace A string containing a namespace to unbind all events from. */ undelegate(namespace: string): JQuery; /** * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) - * + * * @param handler A function to execute when the event is triggered. */ unload(handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) - * + * * @param eventData A plain object of data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. */ @@ -2610,13 +2610,13 @@ interface JQuery { /** * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) - * + * * @param handler A function to execute when the event is triggered. */ error(handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) - * + * * @param eventData A plain object of data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. */ @@ -2624,13 +2624,13 @@ interface JQuery { /** * Add a collection of DOM elements onto the jQuery stack. - * + * * @param elements An array of elements to push onto the stack and make into a new jQuery object. */ pushStack(elements: any[]): JQuery; /** * Add a collection of DOM elements onto the jQuery stack. - * + * * @param elements An array of elements to push onto the stack and make into a new jQuery object. * @param name The name of a jQuery method that generated the array of elements. * @param arguments The arguments that were passed in to the jQuery method (for serialization). @@ -2639,56 +2639,56 @@ interface JQuery { /** * Insert content, specified by the parameter, after each element in the set of matched elements. - * + * * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert after each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. */ after(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, after each element in the set of matched elements. - * + * * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. */ after(func: (index: number, html: string) => string|Element|JQuery): JQuery; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. - * + * * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. */ append(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. - * + * * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. */ append(func: (index: number, html: string) => string|Element|JQuery): JQuery; /** * Insert every element in the set of matched elements to the end of the target. - * + * * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. */ appendTo(target: JQuery|any[]|Element|string): JQuery; /** * Insert content, specified by the parameter, before each element in the set of matched elements. - * + * * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert before each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. */ before(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, before each element in the set of matched elements. - * + * * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. */ before(func: (index: number, html: string) => string|Element|JQuery): JQuery; /** * Create a deep copy of the set of matched elements. - * + * * param withDataAndEvents A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false. * param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). */ @@ -2696,7 +2696,7 @@ interface JQuery { /** * Remove the set of matched elements from the DOM. - * + * * param selector A selector expression that filters the set of matched elements to be removed. */ detach(selector?: string): JQuery; @@ -2708,62 +2708,62 @@ interface JQuery { /** * Insert every element in the set of matched elements after the target. - * + * * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. */ insertAfter(target: JQuery|any[]|Element|Text|string): JQuery; /** * Insert every element in the set of matched elements before the target. - * + * * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. */ insertBefore(target: JQuery|any[]|Element|Text|string): JQuery; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. - * + * * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. */ prepend(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. - * + * * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. */ prepend(func: (index: number, html: string) => string|Element|JQuery): JQuery; /** * Insert every element in the set of matched elements to the beginning of the target. - * + * * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. */ prependTo(target: JQuery|any[]|Element|string): JQuery; /** * Remove the set of matched elements from the DOM. - * + * * @param selector A selector expression that filters the set of matched elements to be removed. */ remove(selector?: string): JQuery; /** * Replace each target element with the set of matched elements. - * + * * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace. */ replaceAll(target: JQuery|any[]|Element|string): JQuery; /** * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. - * + * * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. */ replaceWith(newContent: JQuery|any[]|Element|Text|string): JQuery; /** * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. - * + * * param func A function that returns content with which to replace the set of matched elements. */ replaceWith(func: () => Element|JQuery): JQuery; @@ -2774,13 +2774,13 @@ interface JQuery { text(): string; /** * Set the content of each element in the set of matched elements to the specified text. - * + * * @param text The text to set as the content of each matched element. When Number or Boolean is supplied, it will be converted to a String representation. */ text(text: string|number|boolean): JQuery; /** * Set the content of each element in the set of matched elements to the specified text. - * + * * @param func A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments. */ text(func: (index: number, text: string) => string): JQuery; @@ -2798,20 +2798,20 @@ interface JQuery { /** * Wrap an HTML structure around each element in the set of matched elements. - * + * * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. */ wrap(wrappingElement: JQuery|Element|string): JQuery; /** * Wrap an HTML structure around each element in the set of matched elements. - * + * * @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. */ wrap(func: (index: number) => string|JQuery): JQuery; /** * Wrap an HTML structure around all elements in the set of matched elements. - * + * * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. */ wrapAll(wrappingElement: JQuery|Element|string): JQuery; @@ -2819,27 +2819,27 @@ interface JQuery { /** * Wrap an HTML structure around the content of each element in the set of matched elements. - * + * * @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. */ wrapInner(wrappingElement: JQuery|Element|string): JQuery; /** * Wrap an HTML structure around the content of each element in the set of matched elements. - * + * * @param func A callback function which generates a structure to wrap around the content of the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. */ wrapInner(func: (index: number) => string): JQuery; /** * Iterate over a jQuery object, executing a function for each matched element. - * + * * @param func A function to execute for each matched element. */ each(func: (index: number, elem: Element) => any): JQuery; /** * Retrieve one of the elements matched by the jQuery object. - * + * * @param index A zero-based integer indicating which element to retrieve. */ get(index: number): HTMLElement; @@ -2855,7 +2855,7 @@ interface JQuery { index(): number; /** * Search for a given element from among the matched elements. - * + * * @param selector A selector representing a jQuery collection in which to look for an element. */ index(selector: string|JQuery|Element): number; @@ -2874,66 +2874,66 @@ interface JQuery { /** * Add elements to the set of matched elements. - * + * * @param selector A string representing a selector expression to find additional elements to add to the set of matched elements. * @param context The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method. */ add(selector: string, context?: Element): JQuery; /** * Add elements to the set of matched elements. - * + * * @param elements One or more elements to add to the set of matched elements. */ add(...elements: Element[]): JQuery; /** * Add elements to the set of matched elements. - * + * * @param html An HTML fragment to add to the set of matched elements. */ add(html: string): JQuery; /** * Add elements to the set of matched elements. - * + * * @param obj An existing jQuery object to add to the set of matched elements. */ add(obj: JQuery): JQuery; /** * Get the children of each element in the set of matched elements, optionally filtered by a selector. - * + * * @param selector A string containing a selector expression to match elements against. */ children(selector?: string): JQuery; /** * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. - * + * * @param selector A string containing a selector expression to match elements against. */ closest(selector: string): JQuery; /** * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. - * + * * @param selector A string containing a selector expression to match elements against. * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. */ closest(selector: string, context?: Element): JQuery; /** * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. - * + * * @param obj A jQuery object to match elements against. */ closest(obj: JQuery): JQuery; /** * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. - * + * * @param element An element to match elements against. */ closest(element: Element): JQuery; /** * Get an array of all the elements and selectors matched against the current element up through the DOM tree. - * + * * @param selectors An array or string containing a selector expression to match elements against (can also be a jQuery object). * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. */ @@ -2951,52 +2951,52 @@ interface JQuery { /** * Reduce the set of matched elements to the one at the specified index. - * + * * @param index An integer indicating the 0-based position of the element. OR An integer indicating the position of the element, counting backwards from the last element in the set. - * + * */ eq(index: number): JQuery; /** * Reduce the set of matched elements to those that match the selector or pass the function's test. - * + * * @param selector A string containing a selector expression to match the current set of elements against. */ filter(selector: string): JQuery; /** * Reduce the set of matched elements to those that match the selector or pass the function's test. - * + * * @param func A function used as a test for each element in the set. this is the current DOM element. */ filter(func: (index: number, element: Element) => any): JQuery; /** * Reduce the set of matched elements to those that match the selector or pass the function's test. - * + * * @param element An element to match the current set of elements against. */ filter(element: Element): JQuery; /** * Reduce the set of matched elements to those that match the selector or pass the function's test. - * + * * @param obj An existing jQuery object to match the current set of elements against. */ filter(obj: JQuery): JQuery; /** * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. - * + * * @param selector A string containing a selector expression to match elements against. */ find(selector: string): JQuery; /** * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. - * + * * @param element An element to match elements against. */ find(element: Element): JQuery; /** * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. - * + * * @param obj A jQuery object to match elements against. */ find(obj: JQuery): JQuery; @@ -3008,38 +3008,38 @@ interface JQuery { /** * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. - * + * * @param selector A string containing a selector expression to match elements against. */ has(selector: string): JQuery; /** * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. - * + * * @param contained A DOM element to match elements against. */ has(contained: Element): JQuery; /** * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. - * + * * @param selector A string containing a selector expression to match elements against. */ is(selector: string): boolean; /** * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. - * + * * @param func A function used as a test for the set of elements. It accepts one argument, index, which is the element's index in the jQuery collection.Within the function, this refers to the current DOM element. */ is(func: (index: number, element: Element) => boolean): boolean; /** * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. - * + * * @param obj An existing jQuery object to match the current set of elements against. */ is(obj: JQuery): boolean; /** * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. - * + * * @param elements One or more elements to match the current set of elements against. */ is(elements: any): boolean; @@ -3051,42 +3051,42 @@ interface JQuery { /** * Pass each element in the current matched set through a function, producing a new jQuery object containing the return values. - * + * * @param callback A function object that will be invoked for each element in the current set. */ map(callback: (index: number, domElement: Element) => any): JQuery; /** * Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. - * + * * @param selector A string containing a selector expression to match elements against. */ next(selector?: string): JQuery; /** * Get all following siblings of each element in the set of matched elements, optionally filtered by a selector. - * + * * @param selector A string containing a selector expression to match elements against. */ nextAll(selector?: string): JQuery; /** * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. - * + * * @param selector A string containing a selector expression to indicate where to stop matching following sibling elements. * @param filter A string containing a selector expression to match elements against. */ nextUntil(selector?: string, filter?: string): JQuery; /** * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. - * + * * @param element A DOM node or jQuery object indicating where to stop matching following sibling elements. * @param filter A string containing a selector expression to match elements against. */ nextUntil(element?: Element, filter?: string): JQuery; /** * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. - * + * * @param obj A DOM node or jQuery object indicating where to stop matching following sibling elements. * @param filter A string containing a selector expression to match elements against. */ @@ -3094,25 +3094,25 @@ interface JQuery { /** * Remove elements from the set of matched elements. - * + * * @param selector A string containing a selector expression to match elements against. */ not(selector: string): JQuery; /** * Remove elements from the set of matched elements. - * + * * @param func A function used as a test for each element in the set. this is the current DOM element. */ not(func: (index: number, element: Element) => boolean): JQuery; /** * Remove elements from the set of matched elements. - * + * * @param elements One or more DOM elements to remove from the matched set. */ not(elements: Element|Element[]): JQuery; /** * Remove elements from the set of matched elements. - * + * * @param obj An existing jQuery object to match the current set of elements against. */ not(obj: JQuery): JQuery; @@ -3124,35 +3124,35 @@ interface JQuery { /** * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. - * + * * @param selector A string containing a selector expression to match elements against. */ parent(selector?: string): JQuery; /** * Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector. - * + * * @param selector A string containing a selector expression to match elements against. */ parents(selector?: string): JQuery; /** * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. - * + * * @param selector A string containing a selector expression to indicate where to stop matching ancestor elements. * @param filter A string containing a selector expression to match elements against. */ parentsUntil(selector?: string, filter?: string): JQuery; /** * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. - * + * * @param element A DOM node or jQuery object indicating where to stop matching ancestor elements. * @param filter A string containing a selector expression to match elements against. */ parentsUntil(element?: Element, filter?: string): JQuery; /** * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. - * + * * @param obj A DOM node or jQuery object indicating where to stop matching ancestor elements. * @param filter A string containing a selector expression to match elements against. */ @@ -3160,35 +3160,35 @@ interface JQuery { /** * Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. - * + * * @param selector A string containing a selector expression to match elements against. */ prev(selector?: string): JQuery; /** * Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector. - * + * * @param selector A string containing a selector expression to match elements against. */ prevAll(selector?: string): JQuery; /** * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. - * + * * @param selector A string containing a selector expression to indicate where to stop matching preceding sibling elements. * @param filter A string containing a selector expression to match elements against. */ prevUntil(selector?: string, filter?: string): JQuery; /** * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. - * + * * @param element A DOM node or jQuery object indicating where to stop matching preceding sibling elements. * @param filter A string containing a selector expression to match elements against. */ prevUntil(element?: Element, filter?: string): JQuery; /** * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. - * + * * @param obj A DOM node or jQuery object indicating where to stop matching preceding sibling elements. * @param filter A string containing a selector expression to match elements against. */ @@ -3196,14 +3196,14 @@ interface JQuery { /** * Get the siblings of each element in the set of matched elements, optionally filtered by a selector. - * + * * @param selector A string containing a selector expression to match elements against. */ siblings(selector?: string): JQuery; /** * Reduce the set of matched elements to a subset specified by a range of indices. - * + * * @param start An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set. * @param end An integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set. */ @@ -3211,32 +3211,32 @@ interface JQuery { /** * Show the queue of functions to be executed on the matched elements. - * + * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. */ queue(queueName?: string): any[]; /** * Manipulate the queue of functions to be executed, once for each matched element. - * + * * @param newQueue An array of functions to replace the current queue contents. */ queue(newQueue: Function[]): JQuery; /** * Manipulate the queue of functions to be executed, once for each matched element. - * + * * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. */ queue(callback: Function): JQuery; /** * Manipulate the queue of functions to be executed, once for each matched element. - * + * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. * @param newQueue An array of functions to replace the current queue contents. */ queue(queueName: string, newQueue: Function[]): JQuery; /** * Manipulate the queue of functions to be executed, once for each matched element. - * + * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. */ diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index b64fdc43cf..e11a8b806f 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -575,6 +575,7 @@ function test_appendTo() { function test_attr() { var title = $("em").attr("title"); + $("em").attr("title", null); // Delete an attribute. $("div").text(title); $('#greatphoto').attr('alt', 'Beijing Brush Seller'); $('#greatphoto') From 166c9eed52ea27dabc8004111646febf77031988 Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Sat, 31 Dec 2016 19:37:16 +0700 Subject: [PATCH 02/45] [react-intl] Update React namespaces (#13592) * Update React namespaces * import redux and react types * update to latest version * Update index.d.ts * Update index.d.ts --- react-intl/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-intl/index.d.ts b/react-intl/index.d.ts index 9cc491499a..80a2372e12 100644 --- a/react-intl/index.d.ts +++ b/react-intl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-intl 2.1.5 +// Type definitions for react-intl 2.2.0 // Project: http://formatjs.io/react/ // Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From c2a28d182e47d352ca82e0ea6073728b75e69652 Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Sat, 31 Dec 2016 15:57:32 +0100 Subject: [PATCH 03/45] add AsyncCreatable to supported components (#13492) --- react-select/index.d.ts | 1 + react-select/react-select-tests.tsx | 46 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/react-select/index.d.ts b/react-select/index.d.ts index 102eaa4741..336eb5460b 100644 --- a/react-select/index.d.ts +++ b/react-select/index.d.ts @@ -444,4 +444,5 @@ declare class ReactSelectClass extends React.Component { } class Async extends React.Component { } + class AsyncCreatable extends React.Component { } } diff --git a/react-select/react-select-tests.tsx b/react-select/react-select-tests.tsx index eb0dde3061..d2704878d9 100644 --- a/react-select/react-select-tests.tsx +++ b/react-select/react-select-tests.tsx @@ -223,3 +223,49 @@ class SelectCreatableTest extends React.Component, {}> { } } + +class SelectAsyncCreatableTest extends React.Component, {}> { + + render() { + const getOptions = (input: string, callback: Function) => { + setTimeout(function() { + callback(null, options); + }, 500); + }; + const options: Option[] = [{ label: "Foo", value: "bar" }]; + const onChange = (value: any) => console.log(value); + + const asyncCreatableSelectProps: ReactCreatableSelectProps & ReactAsyncSelectProps = { + name: "test-select-async-creatable", + className: "test-select-async-creatable", + key: "1", + matchPos: "any", + matchProp: "any", + multi: true, + onValueClick: onChange, + valueKey: "github", + labelKey: "name", + onChange: onChange, + simpleValue: undefined, + value: options, + loadOptions: getOptions, + cache: {}, + ignoreAccents: false, + ignoreCase: true, + isLoading: false, + minimumInput: 5, + searchPromptText: "search...", + searchingText: "searching...", + isOptionUnique: () => { return true; }, + isValidNewOption: () => { return true; }, + newOptionCreator: () => { return { label: "NewFoo", value: "newBar" }; }, + promptTextCreator: () => { return ""; }, + shouldKeyDownEventCreateNewOption: () => { return true; } + }; + + return
+ +
+ } + +} From e98fbaf304490c1cd8d4d4fcd5f6e016d71975d9 Mon Sep 17 00:00:00 2001 From: Thomas Schulz Date: Sat, 31 Dec 2016 17:11:24 +0100 Subject: [PATCH 04/45] [jQuery] More consistent JSDocs and parameters --- jquery/index.d.ts | 60 ++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/jquery/index.d.ts b/jquery/index.d.ts index 91e579e6a2..cf180b3733 100644 --- a/jquery/index.d.ts +++ b/jquery/index.d.ts @@ -317,28 +317,29 @@ interface JQueryPromise extends JQueryGenericPromise { /** * Add handlers to be called when the Deferred object is either resolved or rejected. * - * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. - * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + * @param alwaysCallback1 A function, or array of functions, that is called when the Deferred is resolved or rejected. + * @param alwaysCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is resolved. * - * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. - * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + * @param doneCallback1 A function, or array of functions, that are called when the Deferred is resolved. + * @param doneCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is rejected. * - * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. - * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + * @param failCallback1 A function, or array of functions, that are called when the Deferred is rejected. + * @param failCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object generates progress notifications. * - * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. + * @param progressCallback1 A function, or array of functions, to be called when the Deferred generates progress notifications. + * @param progressCallbackN Optional additional functions, or arrays of functions, to be called when the Deferred generates progress notifications. */ progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; @@ -364,28 +365,29 @@ interface JQueryDeferred extends JQueryGenericPromise { /** * Add handlers to be called when the Deferred object is either resolved or rejected. * - * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. - * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + * @param alwaysCallback1 A function, or array of functions, that is called when the Deferred is resolved or rejected. + * @param alwaysCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is resolved. * - * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. - * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + * @param doneCallback1 A function, or array of functions, that are called when the Deferred is resolved. + * @param doneCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is rejected. * - * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. - * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + * @param failCallback1 A function, or array of functions, that are called when the Deferred is rejected. + * @param failCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object generates progress notifications. * - * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. + * @param progressCallback1 A function, or array of functions, to be called when the Deferred generates progress notifications. + * @param progressCallbackN Optional additional functions, or arrays of functions, to be called when the Deferred generates progress notifications. */ progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; @@ -402,7 +404,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * @param context Context passed to the progressCallbacks as the this object. * @param args Optional arguments that are passed to the progressCallbacks. */ - notifyWith(context: any, value?: any[]): JQueryDeferred; + notifyWith(context: any, args?: any[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given args. @@ -416,7 +418,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * @param context Context passed to the failCallbacks as the this object. * @param args An optional array of arguments that are passed to the failCallbacks. */ - rejectWith(context: any, value?: any[]): JQueryDeferred; + rejectWith(context: any, args?: any[]): JQueryDeferred; /** * Resolve a Deferred object and call any doneCallbacks with the given args. @@ -432,7 +434,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * @param context Context passed to the doneCallbacks as the this object. * @param args An optional array of arguments that are passed to the doneCallbacks. */ - resolveWith(context: any, value?: T[]): JQueryDeferred; + resolveWith(context: any, args?: T[]): JQueryDeferred; /** * Return a Deferred's Promise object. @@ -1064,7 +1066,7 @@ interface JQueryStatic { /** * Determines whether its argument is a number. * - * @param obj The value to be tested. + * @param value The value to be tested. */ isNumeric(value: any): boolean; /** @@ -1248,7 +1250,7 @@ interface JQuery { /** * Adds the specified class(es) to each of the set of matched elements. * - * @param function A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. + * @param func A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. */ addClass(func: (index: number, className: string) => string): JQuery; @@ -1356,7 +1358,7 @@ interface JQuery { /** * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. * - * @param function A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + * @param func A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. */ removeClass(func: (index: number, className: string) => string): JQuery; @@ -1460,7 +1462,7 @@ interface JQuery { * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). */ - innerHeight(height: number|string): JQuery; + innerHeight(value: number|string): JQuery; /** * Get the current computed width for the first element in the set of matched elements, including padding but not border. @@ -1472,7 +1474,7 @@ interface JQuery { * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). */ - innerWidth(width: number|string): JQuery; + innerWidth(value: number|string): JQuery; /** * Get the current coordinates of the first element in the set of matched elements, relative to the document. @@ -1503,7 +1505,7 @@ interface JQuery { * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). */ - outerHeight(height: number|string): JQuery; + outerHeight(value: number|string): JQuery; /** * Get the current computed width for the first element in the set of matched elements, including padding and border. @@ -1517,7 +1519,7 @@ interface JQuery { * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). */ - outerWidth(width: number|string): JQuery; + outerWidth(value: number|string): JQuery; /** * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. @@ -1984,7 +1986,7 @@ interface JQuery { /** * Bind an event handler to the "click" JavaScript event * - * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. */ click(handler: (eventObject: JQueryEventObject) => any): JQuery; /** From 5fc4439b7b9b78f134856d51e948e8e27759f359 Mon Sep 17 00:00:00 2001 From: d-ph Date: Sat, 31 Dec 2016 16:21:50 +0000 Subject: [PATCH 05/45] Fix `bluebird-global` typings being incompatible with es2015 libs. (#13653) * #13643 Bluebird-global typings incompatible with es2015 libs. Make `bluebird-global` work nicely with es20xx ts stdlibs. Make unit tests for `bluebird-global` run with es2017 ts stdlib. This is not ideal, because I'd like the tests to run also against vanilla es5, but that's the lesser of two evils. * #13643 Bluebird-global typings incompatible with es2015 libs. Disable some tslint rules, which flag errors in the code taken from the standard ts lib. * #13643 Bluebird-global typings incompatible with es2015 libs. Move comments from tsconfig.json to index.d.ts. --- bluebird-global/bluebird-global-tests.ts | 13 +++ bluebird-global/index.d.ts | 118 ++++++++++++++++++++++- bluebird-global/tsconfig.json | 4 + bluebird-global/tslint.json | 5 +- 4 files changed, 134 insertions(+), 6 deletions(-) diff --git a/bluebird-global/bluebird-global-tests.ts b/bluebird-global/bluebird-global-tests.ts index 9087e57d08..43d5fee050 100644 --- a/bluebird-global/bluebird-global-tests.ts +++ b/bluebird-global/bluebird-global-tests.ts @@ -29,3 +29,16 @@ function testFunctionReturningPromise() { console.log("finally callback"); }); } + +function testPromiseRejection() { + new Promise((resolve, reject) => { + reject(new Error("problem occurred")); + }) + .catch((error) => { + return "recovered from error"; + }) + .then((value) => { + return value.toUpperCase(); + }); + +} diff --git a/bluebird-global/index.d.ts b/bluebird-global/index.d.ts index 81a352ce5a..caf873510d 100644 --- a/bluebird-global/index.d.ts +++ b/bluebird-global/index.d.ts @@ -27,6 +27,11 @@ * the Promise and PromiseConstructor interfaces defined in the standard ts library. * For various reasons this couldn't be done in The `bluebird` typings. * + * 4. Contributors: After changing this file please manually test these cases (via altering ./tsconfig.json ): + * a. target es5, no `lib` key + * b. target es6, no `lib` key + * c. target es5, latest "es20xx", e.g. "es2017" + * d. target es6, latest "es20xx", e.g. "es2017" */ import * as Bluebird from "bluebird"; @@ -35,7 +40,78 @@ declare global { /* * Patch all instance method */ - interface Promise extends Bluebird {} + interface Promise { + all: typeof Bluebird.prototype.all; + any: typeof Bluebird.prototype.any; + asCallback: typeof Bluebird.prototype.asCallback; + bind: typeof Bluebird.prototype.bind; + call: typeof Bluebird.prototype.call; + cancel: typeof Bluebird.prototype.cancel; + // catch: typeof Bluebird.prototype.catch; + caught: typeof Bluebird.prototype.caught; + delay: typeof Bluebird.prototype.delay; + disposer: typeof Bluebird.prototype.disposer; + done: typeof Bluebird.prototype.done; + each: typeof Bluebird.prototype.each; + error: typeof Bluebird.prototype.error; + filter: typeof Bluebird.prototype.filter; + finally: typeof Bluebird.prototype.finally; + get: typeof Bluebird.prototype.get; + isCancelled: typeof Bluebird.prototype.isCancelled; + isFulfilled: typeof Bluebird.prototype.isFulfilled; + isPending: typeof Bluebird.prototype.isPending; + isRejected: typeof Bluebird.prototype.isRejected; + isResolved: typeof Bluebird.prototype.isResolved; + lastly: typeof Bluebird.prototype.lastly; + map: typeof Bluebird.prototype.map; + mapSeries: typeof Bluebird.prototype.mapSeries; + nodeify: typeof Bluebird.prototype.nodeify; + props: typeof Bluebird.prototype.props; + race: typeof Bluebird.prototype.race; + reason: typeof Bluebird.prototype.reason; + reduce: typeof Bluebird.prototype.reduce; + reflect: typeof Bluebird.prototype.reflect; + return: typeof Bluebird.prototype.return; + some: typeof Bluebird.prototype.some; + spread: typeof Bluebird.prototype.spread; + suppressUnhandledRejections: typeof Bluebird.prototype.suppressUnhandledRejections; + tap: typeof Bluebird.prototype.tap; + // then: typeof Bluebird.prototype.then; + thenReturn: typeof Bluebird.prototype.thenReturn; + thenThrow: typeof Bluebird.prototype.thenThrow; + throw: typeof Bluebird.prototype.throw; + timeout: typeof Bluebird.prototype.timeout; + toJSON: typeof Bluebird.prototype.toJSON; + toString: typeof Bluebird.prototype.toString; + value: typeof Bluebird.prototype.value; + + /* + * Copy&paste ::then and ::catch from lib.es2015.promise.d.ts, because Bluebird's typings are not + * in line with the standard lib. + * + * This is only needed for es5 target, which doesn't include the lib.es2015.promise.d.ts typings. + * + * @todo Make Bluebird's typings be in line with the standard lib. + */ + then(onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; + then(onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled: (value: T) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; + then(onfulfilled: (value: T) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; + catch(onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; + catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; + + /* + * TypeScript disallows adding overrides via `catch: typeof Bluebird.prototype.catch`. Copy&paste them then. + * + * @todo Duplication of code is never ideal. See whether there's a better way of achieving this. + */ + catch(predicate: (error: any) => boolean, onReject: (error: any) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; + catch(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable): Bluebird; + catch(predicate: Object, onReject: (error: any) => T | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; + catch(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; + } /* * Patch all static methods and the constructor @@ -43,7 +119,7 @@ declare global { interface PromiseConstructor { new (callback: (resolve: (thenableOrResult?: T | Bluebird.Thenable) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Promise; - all: typeof Bluebird.all; + // all: typeof Bluebird.all; any: typeof Bluebird.any; attempt: typeof Bluebird.attempt; bind: typeof Bluebird.bind; @@ -66,13 +142,45 @@ declare global { promisify: typeof Bluebird.promisify; promisifyAll: typeof Bluebird.promisifyAll; props: typeof Bluebird.props; - race: typeof Bluebird.race; + // race: typeof Bluebird.race; reduce: typeof Bluebird.reduce; - reject: typeof Bluebird.reject; - resolve: typeof Bluebird.resolve; + // reject: typeof Bluebird.reject; + // resolve: typeof Bluebird.resolve; some: typeof Bluebird.some; try: typeof Bluebird.try; using: typeof Bluebird.using; + + /* + * Copy&paste from lib.es2015.promise.d.ts, because Bluebird's typings are not in line with the standard lib. + * + * This is only needed for es5 target, which doesn't include the lib.es2015.promise.d.ts typings. + * + * @todo Make Bluebird's typings be in line with the standard lib. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + all(values: (T | PromiseLike)[]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; + race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; + race(values: (T | PromiseLike)[]): Promise; + reject(reason: any): Promise; + reject(reason: any): Promise; + resolve(value: T | PromiseLike): Promise; + resolve(): Promise; } /* diff --git a/bluebird-global/tsconfig.json b/bluebird-global/tsconfig.json index 078363a850..12ed67cdc4 100644 --- a/bluebird-global/tsconfig.json +++ b/bluebird-global/tsconfig.json @@ -9,6 +9,10 @@ "typeRoots": [ "../" ], + "lib": [ + "es2017", + "dom" + ], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/bluebird-global/tslint.json b/bluebird-global/tslint.json index 9b7feabed9..eaffa3152c 100644 --- a/bluebird-global/tslint.json +++ b/bluebird-global/tslint.json @@ -1,6 +1,9 @@ { "extends": "../tslint.json", "rules": { - "no-empty-interface": false + "no-empty-interface": false, + "array-type": false, + "unified-signatures": false, + "forbidden-types": false } } From fe65c087d5ac1f882d37c76c782939ddc5c297f6 Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Sat, 31 Dec 2016 11:43:12 -0800 Subject: [PATCH 06/45] Mathjs add matrix properties (#13435) * add missing matrix properties * force 'sparse' or 'dense' for matrix format * add options to matrix without data * fix toJson return type * fix return type of forEach and its callback * remove duplicate declaration * remove default functions --- mathjs/index.d.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mathjs/index.d.ts b/mathjs/index.d.ts index 9671dd8005..d11a72d97b 100644 --- a/mathjs/index.d.ts +++ b/mathjs/index.d.ts @@ -526,8 +526,8 @@ declare namespace mathjs { * to manipulate the data in the matrix, like getting the size and getting or setting values in the matrix. Supported * storage formats are 'dense' and 'sparse'. */ - matrix(format?: string): Matrix; - matrix(data: MathArray|Matrix, format?: string, dataType?:string): Matrix; + matrix(format?: 'sparse'|'dense'): Matrix; + matrix(data: MathArray|Matrix, format?: 'sparse'|'dense', dataType?: string): Matrix; /** * Create a number or convert a string, boolean, or unit to a number. When value is a matrix, all elements will be converted to number. @@ -1292,10 +1292,21 @@ declare namespace mathjs { } export interface Matrix { - size(): number[]; + type: string; + storage(): string; + datatype(): string; + density(): number; subset(index: Index, replacement?: any, defaultValue?: any): Matrix; + get(index: number[]): any; + set(index: number[], value: any, defaultValue?: number|string): Matrix; resize(size: MathArray|Matrix, defaultValue?: number|string): Matrix; clone(): Matrix; + size(): number[]; + map(callback: (a: any, b: number, c: Matrix) => any, skipZeros?: boolean): Matrix; + forEach(callback: (a: any, b: number, c: Matrix) => void, skipZeros?: boolean): void; + toJSON(): any; + diagonal(k?: number|BigNumber): any[]; + swapRows(i: number, j: number): Matrix; } export interface BigNumber { From f31f6630d738212abaf3658a79923deda119305c Mon Sep 17 00:00:00 2001 From: mad-mike Date: Sat, 31 Dec 2016 23:34:32 +0100 Subject: [PATCH 07/45] Add types for simple-oauth2 library (#13655) * Add types for simple-oauth2 library * Update config files for simple-oauth2 * apply tslint feedback * Use branding for nominal types * Remove nominal types for Tokens --- simple-oauth2/index.d.ts | 113 +++++++++++++++++++ simple-oauth2/simple-oauth2-tests.ts | 162 +++++++++++++++++++++++++++ simple-oauth2/tsconfig.json | 20 ++++ simple-oauth2/tslint.json | 1 + 4 files changed, 296 insertions(+) create mode 100644 simple-oauth2/index.d.ts create mode 100644 simple-oauth2/simple-oauth2-tests.ts create mode 100644 simple-oauth2/tsconfig.json create mode 100644 simple-oauth2/tslint.json diff --git a/simple-oauth2/index.d.ts b/simple-oauth2/index.d.ts new file mode 100644 index 0000000000..72d960f946 --- /dev/null +++ b/simple-oauth2/index.d.ts @@ -0,0 +1,113 @@ +// Type definitions for simple-oauth2 1.0 +// Project: https://github.com/lelylan/simple-oauth2 +// Definitions by: [Michael Müller] +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import Bluebird = require("bluebird"); + +/** Creates a new simple-oauth2 client with the passed configuration */ +export function create(options: ModuleOptions): OAuthClient; + +interface ModuleOptions { + client: { + /** Service registered client id. Required. */ + id: string, + /** Service registered client secret. Required. */ + secret: string, + /** Parameter name used to send the client secret. Default to client_secret. */ + secretParamName?: string, + /** Parameter name used to send the client id. Default to client_id. */ + idParamName?: string + }; + auth: { + /** String used to set the host to request the tokens to. Required. */ + tokenHost: string, + /** String path to request an access token. Default to /oauth/token. */ + tokenPath?: string, + /** String path to revoken an access token. Default to /oauth/revoke. */ + revokePath?: string, + /** String used to set the host to request an "authorization code". Default to the value set on auth.tokenHost. */ + authorizeHost?: string, + /** String path to request an authorization code. Default to /oauth/authorize. */ + authorizePath?: string + }; + /** optional object used to set global options to the internal http library (request-js). */ + http?: {}; + options?: { + /** Wheather or not the client.id/client.secret params are sent in the request body. Defaults to true. */ + useBodyAuth?: boolean, + useBasicAuthorizationHeader?: boolean + }; +} + +type TokenType = "access_token" | "refresh_token"; + +interface AccessToken { + token: {}; + + /** Check if the access token is expired or not */ + expired(): boolean; + /** Refresh the access token */ + refresh(params: {}, callback: (error: any, result: AccessToken) => void): Bluebird; + refresh(callback?: (error: any, result: AccessToken) => void): Bluebird; + /** Revoke access or refresh token */ + revoke(tokenType: TokenType, callback?: (error: any) => void): Bluebird; +} + +interface Token { + [x: string]: any; +} +type AuthorizationCode = string; +interface AuthorizationTokenConfig { + code: AuthorizationCode; + redirect_uri: string; +} + +interface PasswordTokenConfig { + /** A string that represents the registered username */ + username: string; + /** A string that represents the registered password. */ + password: string; + /** A string that represents the application privileges */ + scope: string; +} + +interface ClientCredentialTokenConfig { + /** A string that represents the application privileges */ + scope?: string; +} + +export interface OAuthClient { + authorizationCode: { + /** + * Redirect the user to the autorization page + * @return {string} the absolute authorization url + */ + authorizeURL(params?: { + /** A string that represents the registered application URI where the user is redirected after authentication */ + redirect_uri?: string, + /** A String that represents the application privileges */ + scope?: string, + /** A String that represents an option opaque value used by the client to main the state between the request and the callback */ + state?: string + }): string, + + /** Returns the Access Token object */ + getToken(params: AuthorizationTokenConfig, callback?: (error: any, result: Token) => void): Bluebird; + }; + + ownerPassword: { + /** Returns the Access Token Object */ + getToken(params: PasswordTokenConfig, callback?: (error: any, result: Token) => void): Bluebird; + }; + + clientCredentials: { + /** Returns the Access Token Object */ + getToken(params: ClientCredentialTokenConfig, callback?: (error: any, result: Token) => void): Bluebird; + }; + + accessToken: { + /** Creates an OAuth2.AccessToken instance */ + create(tokenToUse: Token): AccessToken; + }; +} diff --git a/simple-oauth2/simple-oauth2-tests.ts b/simple-oauth2/simple-oauth2-tests.ts new file mode 100644 index 0000000000..290ac6fc31 --- /dev/null +++ b/simple-oauth2/simple-oauth2-tests.ts @@ -0,0 +1,162 @@ +// off https://github.com/lelylan/simple-oauth2/blob/master/README.md +// slightly changed to remove external dependencies + +// Set the configuration settings +const credentials = { + client: { + id: '', + secret: '' + }, + auth: { + tokenHost: 'https://api.oauth.com' + } +}; + +// Initialize the OAuth2 Library +//const oauth2 = require('simple-oauth2').create(credentials); +import oauth2lib = require("simple-oauth2"); +const oauth2 = oauth2lib.create(credentials); + + +// #Authorization Code flow +(function () { + + // Authorization oauth2 URI + const authorizationUri = oauth2.authorizationCode.authorizeURL({ + redirect_uri: 'http://localhost:3000/callback', + scope: '', + state: '' + }); + + // Redirect example using Express (see http://expressjs.com/api.html#res.redirect) + //res.redirect(authorizationUri); + + // Get the access token object (the authorization code is given from the previous step). + const tokenConfig = { + code: '', + redirect_uri: 'http://localhost:3000/callback' + }; + + // Callbacks + // Save the access token + oauth2.authorizationCode.getToken(tokenConfig, (error, result) => { + if (error) { + return console.log('Access Token Error', error.message); + } + + const token = oauth2.accessToken.create(result); + }); + + // Promises + // Save the access token + oauth2.authorizationCode.getToken(tokenConfig) + .then((result) => { + const token = oauth2.accessToken.create(result); + }) + .catch((error) => { + console.log('Access Token Error', error.message); + }); +})(); + + +// #Client Credentials Flow +(function () { + const tokenConfig = {}; + + // Callbacks + // Get the access token object for the client + oauth2.clientCredentials.getToken(tokenConfig, (error, result) => { + if (error) { + return console.log('Access Token Error', error.message); + } + + const token = oauth2.accessToken.create(result); + }); + + + // Promises + // Get the access token object for the client + oauth2.clientCredentials + .getToken(tokenConfig) + .then((result) => { + const token = oauth2.accessToken.create(result); + }) + .catch((error) => { + console.log('Access Token error', error.message); + }); +})(); + + +// #Access Token object +(function () { + // Sample of a JSON access token (you got it through previous steps) + const tokenObject = { + 'access_token': '', + 'refresh_token': '', + 'expires_in': '7200' + }; + + // Create the access token wrapper + var token = oauth2.accessToken.create(tokenObject); + + // Check if the token is expired. If expired it is refreshed. + if (token.expired()) { + // Callbacks + token.refresh((error, result) => { + token = result; + }) + + // Promises + token.refresh() + .then((result) => { + token = result; + }); + } + + // Callbacks + // Revoke only the access token + token.revoke('access_token', (error) => { + // Session ended. But the refresh_token is still valid. + + // Revoke the refresh_token + token.revoke('refresh_token', (error) => { + console.log('token revoked.'); + }); + }); + + // Promises + // Revoke only the access token + token.revoke('access_token') + .then(() => { + // Revoke the refresh token + return token.revoke('refresh_token'); + }) + .then(() => { + console.log('Token revoked'); + }) + .catch((error) => { + console.log('Error revoking token.', error.message); + }); +})(); + + +// #Errors +// not applicable, as those errors about missing authentication codes are already found by the typescript compiler + +// (function () { +// // Callbacks +// oauth2.authorizationCode.getToken({}, (error, token) => { +// if (error) { +// return console.log(error.message); +// } +// }); + +// // Promises +// oauth2.authorizationCode +// .getToken({}) +// .catch((error) => { +// console.log(error.message); +// }); + +// // => { "status": "401", "message": "Unauthorized" } +// })(); diff --git a/simple-oauth2/tsconfig.json b/simple-oauth2/tsconfig.json new file mode 100644 index 0000000000..3d28a8b9a5 --- /dev/null +++ b/simple-oauth2/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "simple-oauth2-tests.ts" + ] +} diff --git a/simple-oauth2/tslint.json b/simple-oauth2/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/simple-oauth2/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 2b9e12cc1c5478b19208acd855e8155c9542c03b Mon Sep 17 00:00:00 2001 From: Thomas Schulz Date: Sun, 1 Jan 2017 00:01:26 +0100 Subject: [PATCH 08/45] [jQuery] Added documentation URLs to JSDoc --- jquery/index.d.ts | 585 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 552 insertions(+), 33 deletions(-) diff --git a/jquery/index.d.ts b/jquery/index.d.ts index cf180b3733..b7cbefa019 100644 --- a/jquery/index.d.ts +++ b/jquery/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for jQuery 1.10.x / 2.0.x // Project: http://jquery.com/ -// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton , Diullei Gomes , Tass Iliopoulos , Jason Swearingen , Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly , Dick van den Brink +// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton , Diullei Gomes , Tass Iliopoulos , Jason Swearingen , Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly , Dick van den Brink , Thomas Schulz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* ***************************************************************************** @@ -21,6 +21,7 @@ and limitations under the License. /** * Interface for the AJAX setting that will configure the AJAX request + * @see {@link https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings} */ interface JQueryAjaxSettings { /** @@ -165,6 +166,7 @@ interface JQueryAjaxSettings { /** * Interface for the jqXHR object + * @see {@link https://api.jquery.com/jQuery.ajax/#jqXHR} */ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { /** @@ -193,33 +195,39 @@ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { /** * Interface for the JQuery callback + * @see {@link https://api.jquery.com/category/callbacks-object/} */ interface JQueryCallback { /** * Add a callback or a collection of callbacks to a callback list. * * @param callbacks A function, or array of functions, that are to be added to the callback list. + * @see {@link https://api.jquery.com/callbacks.add/} */ add(callbacks: Function): JQueryCallback; /** * Add a callback or a collection of callbacks to a callback list. * * @param callbacks A function, or array of functions, that are to be added to the callback list. + * @see {@link https://api.jquery.com/callbacks.add/} */ add(callbacks: Function[]): JQueryCallback; /** * Disable a callback list from doing anything more. + * @see {@link https://api.jquery.com/callbacks.disable/} */ disable(): JQueryCallback; /** * Determine if the callbacks list has been disabled. + * @see {@link https://api.jquery.com/callbacks.disabled/} */ disabled(): boolean; /** * Remove all of the callbacks from a list. + * @see {@link https://api.jquery.com/callbacks.empty/} */ empty(): JQueryCallback; @@ -227,11 +235,13 @@ interface JQueryCallback { * Call all of the callbacks with the given arguments * * @param arguments The argument or list of arguments to pass back to the callback list. + * @see {@link https://api.jquery.com/callbacks.fire/} */ fire(...arguments: any[]): JQueryCallback; /** * Determine if the callbacks have already been called at least once. + * @see {@link https://api.jquery.com/callbacks.fired/} */ fired(): boolean; @@ -240,6 +250,7 @@ interface JQueryCallback { * * @param context A reference to the context in which the callbacks in the list should be fired. * @param arguments An argument, or array of arguments, to pass to the callbacks in the list. + * @see {@link https://api.jquery.com/callbacks.fireWith/} */ fireWith(context?: any, args?: any[]): JQueryCallback; @@ -247,16 +258,19 @@ interface JQueryCallback { * Determine whether a supplied callback is in a list * * @param callback The callback to search for. + * @see {@link https://api.jquery.com/callbacks.has/} */ has(callback: Function): boolean; /** * Lock a callback list in its current state. + * @see {@link https://api.jquery.com/callbacks.lock/} */ lock(): JQueryCallback; /** * Determine if the callbacks list has been locked. + * @see {@link https://api.jquery.com/callbacks.locked/} */ locked(): boolean; @@ -264,12 +278,14 @@ interface JQueryCallback { * Remove a callback or a collection of callbacks from a callback list. * * @param callbacks A function, or array of functions, that are to be removed from the callback list. + * @see {@link https://api.jquery.com/callbacks.remove/} */ remove(callbacks: Function): JQueryCallback; /** * Remove a callback or a collection of callbacks from a callback list. * * @param callbacks A function, or array of functions, that are to be removed from the callback list. + * @see {@link https://api.jquery.com/callbacks.remove/} */ remove(callbacks: Function[]): JQueryCallback; } @@ -283,6 +299,7 @@ interface JQueryGenericPromise { * * @param doneFilter A function that is called when the Deferred is resolved. * @param failFilter An optional function that is called when the Deferred is rejected. + * @see {@link https://api.jquery.com/deferred.then/#deferred-then-doneFilter-failFilter-progressFilter} */ then(doneFilter: (value?: T, ...values: any[]) => U|JQueryPromise, failFilter?: (...reasons: any[]) => any, progressFilter?: (...progression: any[]) => any): JQueryPromise; @@ -291,6 +308,7 @@ interface JQueryGenericPromise { * * @param doneFilter A function that is called when the Deferred is resolved. * @param failFilter An optional function that is called when the Deferred is rejected. + * @see {@link https://api.jquery.com/deferred.then/#deferred-then-doneFilter-failFilter-progressFilter} */ then(doneFilter: (value?: T, ...values: any[]) => void, failFilter?: (...reasons: any[]) => any, progressFilter?: (...progression: any[]) => any): JQueryPromise; } @@ -308,10 +326,12 @@ interface JQueryPromiseOperator { /** * Interface for the JQuery promise, part of callbacks + * @see {@link https://api.jquery.com/category/deferred-object/} */ interface JQueryPromise extends JQueryGenericPromise { /** * Determine the current state of a Deferred object. + * @see {@link https://api.jquery.com/deferred.state/} */ state(): string; /** @@ -319,6 +339,7 @@ interface JQueryPromise extends JQueryGenericPromise { * * @param alwaysCallback1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + * @see {@link https://api.jquery.com/deferred.always/} */ always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** @@ -326,6 +347,7 @@ interface JQueryPromise extends JQueryGenericPromise { * * @param doneCallback1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + * @see {@link https://api.jquery.com/deferred.done/} */ done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** @@ -333,6 +355,7 @@ interface JQueryPromise extends JQueryGenericPromise { * * @param failCallback1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + * @see {@link https://api.jquery.com/deferred.fail/} */ fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** @@ -340,6 +363,7 @@ interface JQueryPromise extends JQueryGenericPromise { * * @param progressCallback1 A function, or array of functions, to be called when the Deferred generates progress notifications. * @param progressCallbackN Optional additional functions, or arrays of functions, to be called when the Deferred generates progress notifications. + * @see {@link https://api.jquery.com/deferred.progress/} */ progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; @@ -350,16 +374,19 @@ interface JQueryPromise extends JQueryGenericPromise { * Return a Deferred's Promise object. * * @param target Object onto which the promise methods have to be attached + * @see {@link https://api.jquery.com/deferred.promise/} */ promise(target?: any): JQueryPromise; } /** * Interface for the JQuery deferred, part of callbacks + * @see {@link https://api.jquery.com/category/deferred-object/} */ interface JQueryDeferred extends JQueryGenericPromise { /** * Determine the current state of a Deferred object. + * @see {@link https://api.jquery.com/deferred.state/} */ state(): string; /** @@ -367,6 +394,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param alwaysCallback1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + * @see {@link https://api.jquery.com/deferred.always/} */ always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** @@ -374,6 +402,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param doneCallback1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + * @see {@link https://api.jquery.com/deferred.done/} */ done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** @@ -381,6 +410,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param failCallback1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbackN Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + * @see {@link https://api.jquery.com/deferred.fail/} */ fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** @@ -388,6 +418,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param progressCallback1 A function, or array of functions, to be called when the Deferred generates progress notifications. * @param progressCallbackN Optional additional functions, or arrays of functions, to be called when the Deferred generates progress notifications. + * @see {@link https://api.jquery.com/deferred.progress/} */ progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; @@ -395,6 +426,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * Call the progressCallbacks on a Deferred object with the given args. * * @param args Optional arguments that are passed to the progressCallbacks. + * @see {@link https://api.jquery.com/deferred.notify/} */ notify(value?: any, ...args: any[]): JQueryDeferred; @@ -403,6 +435,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param context Context passed to the progressCallbacks as the this object. * @param args Optional arguments that are passed to the progressCallbacks. + * @see {@link https://api.jquery.com/deferred.notifyWith/} */ notifyWith(context: any, args?: any[]): JQueryDeferred; @@ -410,6 +443,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * Reject a Deferred object and call any failCallbacks with the given args. * * @param args Optional arguments that are passed to the failCallbacks. + * @see {@link https://api.jquery.com/deferred.reject/} */ reject(value?: any, ...args: any[]): JQueryDeferred; /** @@ -417,6 +451,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param context Context passed to the failCallbacks as the this object. * @param args An optional array of arguments that are passed to the failCallbacks. + * @see {@link https://api.jquery.com/deferred.rejectWith/} */ rejectWith(context: any, args?: any[]): JQueryDeferred; @@ -425,6 +460,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param value First argument passed to doneCallbacks. * @param args Optional subsequent arguments that are passed to the doneCallbacks. + * @see {@link https://api.jquery.com/deferred.resolve/} */ resolve(value?: T, ...args: any[]): JQueryDeferred; @@ -433,6 +469,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * * @param context Context passed to the doneCallbacks as the this object. * @param args An optional array of arguments that are passed to the doneCallbacks. + * @see {@link https://api.jquery.com/deferred.resolveWith/} */ resolveWith(context: any, args?: T[]): JQueryDeferred; @@ -440,6 +477,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * Return a Deferred's Promise object. * * @param target Object onto which the promise methods have to be attached + * @see {@link https://api.jquery.com/deferred.promise/} */ promise(target?: any): JQueryPromise; @@ -449,25 +487,98 @@ interface JQueryDeferred extends JQueryGenericPromise { /** * Interface of the JQuery extension of the W3C event object + * @see {@link https://api.jquery.com/category/events/event-object/} */ interface BaseJQueryEventObject extends Event { + /** + * The current DOM element within the event bubbling phase. + * @see {@link https://api.jquery.com/event.currentTarget/} + */ currentTarget: Element; + /** + * An optional object of data passed to an event method when the current executing handler is bound. + * @see {@link https://api.jquery.com/event.data/} + */ data: any; + /** + * The element where the currently-called jQuery event handler was attached. + * @see {@link https://api.jquery.com/event.delegateTarget/} + */ delegateTarget: Element; + /** + * Returns whether event.preventDefault() was ever called on this event object. + * @see {@link https://api.jquery.com/event.isDefaultPrevented/} + */ isDefaultPrevented(): boolean; + /** + * Returns whether event.stopImmediatePropagation() was ever called on this event object. + * @see {@link https://api.jquery.com/event.isImmediatePropagationStopped/} + */ isImmediatePropagationStopped(): boolean; + /** + * Returns whether event.stopPropagation() was ever called on this event object. + * @see {@link https://api.jquery.com/event.isPropagationStopped/} + */ isPropagationStopped(): boolean; + /** + * The namespace specified when the event was triggered. + * @see {@link https://api.jquery.com/event.namespace/} + */ namespace: string; + /** + * The browser's original Event object. + * @see {@link https://api.jquery.com/category/events/event-object/} + */ originalEvent: Event; + /** + * If this method is called, the default action of the event will not be triggered. + * @see {@link https://api.jquery.com/event.preventDefault/} + */ preventDefault(): any; + /** + * The other DOM element involved in the event, if any. + * @see {@link https://api.jquery.com/event.relatedTarget/} + */ relatedTarget: Element; + /** + * The last value returned by an event handler that was triggered by this event, unless the value was undefined. + * @see {@link https://api.jquery.com/event.result/} + */ result: any; + /** + * Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree. + * @see {@link https://api.jquery.com/event.stopImmediatePropagation/} + */ stopImmediatePropagation(): void; + /** + * Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. + * @see {@link https://api.jquery.com/event.stopPropagation/} + */ stopPropagation(): void; + /** + * The DOM element that initiated the event. + * @see {@link https://api.jquery.com/event.target/} + */ target: Element; + /** + * The mouse position relative to the left edge of the document. + * @see {@link https://api.jquery.com/event.pageX/} + */ pageX: number; + /** + * The mouse position relative to the top edge of the document. + * @see {@link https://api.jquery.com/event.pageY/} + */ pageY: number; + /** + * For key or mouse events, this property indicates the specific key or button that was pressed. + * @see {@link https://api.jquery.com/event.which/} + */ which: number; + /** + * Indicates whether the META key was pressed when the event fired. + * @see {@link https://api.jquery.com/event.metaKey/} + */ metaKey: boolean; } @@ -500,10 +611,16 @@ interface JQueryKeyEventObject extends JQueryInputEventObject { interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject{ } -/* - Collection of properties of the current browser -*/ - +/** + * A collection of properties that represent the presence of different browser features or bugs. + * + * Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally + * to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the + * use of an external library such as {@link http://modernizr.com/|Modernizr} instead of dependency on properties + * in jQuery.support. + * + * @deprecated since version 1.9 + */ interface JQuerySupport { ajax?: boolean; boxModel?: boolean; @@ -570,6 +687,9 @@ interface JQuerySerializeArrayElement { value: string; } +/** + * @see {@link https://api.jquery.com/animate/} + */ interface JQueryAnimationOptions { /** * A string or number determining how long the animation will run. @@ -629,6 +749,8 @@ interface JQueryEasingFunctions { /** * Static members of jQuery (those on $ and jQuery themselves) + * + * @see {@link https://api.jquery.com/Types/#jQuery} */ interface JQueryStatic { @@ -636,6 +758,7 @@ interface JQueryStatic { * Perform an asynchronous HTTP (Ajax) request. * * @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(). + * @see {@link https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings} */ ajax(settings: JQueryAjaxSettings): JQueryXHR; /** @@ -643,6 +766,7 @@ interface JQueryStatic { * * @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(). + * @see {@link https://api.jquery.com/jQuery.ajax/#jQuery-ajax-url-settings} */ ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR; @@ -651,12 +775,14 @@ interface JQueryStatic { * * @param dataTypes An optional string containing one or more space-separated dataTypes * @param handler A handler to set default values for future Ajax requests. + * @see {@link https://api.jquery.com/jQuery.ajaxPrefilter/} */ 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. + * @see {@link https://api.jquery.com/jQuery.ajaxPrefilter/} */ ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; @@ -666,6 +792,7 @@ interface JQueryStatic { * 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. + * @see {@link https://api.jquery.com/jQuery.ajaxSetup/} */ ajaxSetup(options: JQueryAjaxSettings): void; @@ -675,6 +802,7 @@ interface JQueryStatic { * @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. * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + * @see {@link https://api.jquery.com/jQuery.get/#jQuery-get-url-data-success-dataType} */ get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; /** @@ -684,12 +812,14 @@ 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. * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + * @see {@link https://api.jquery.com/jQuery.get/#jQuery-get-url-data-success-dataType} */ get(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; /** * Load data from the server using a HTTP GET request. * * @param settings The JQueryAjaxSettings to be used for the request + * @see {@link https://api.jquery.com/jQuery.get/#jQuery-get-settings} */ get(settings : JQueryAjaxSettings): JQueryXHR; /** @@ -697,6 +827,7 @@ interface JQueryStatic { * * @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. + * @see {@link https://api.jquery.com/jQuery.getJSON/} */ getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; /** @@ -705,6 +836,7 @@ interface JQueryStatic { * @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. + * @see {@link https://api.jquery.com/jQuery.getJSON/} */ getJSON(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; /** @@ -712,11 +844,14 @@ interface JQueryStatic { * * @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. + * @see {@link https://api.jquery.com/jQuery.getScript/} */ getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; /** * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + * + * @see {@link https://api.jquery.com/jQuery.param/} */ param: JQueryParam; @@ -726,6 +861,7 @@ interface JQueryStatic { * @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). + * @see {@link https://api.jquery.com/jQuery.post/#jQuery-post-url-data-success-dataType} */ post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; /** @@ -735,18 +871,21 @@ 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. 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). + * @see {@link https://api.jquery.com/jQuery.post/#jQuery-post-url-data-success-dataType} */ post(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; /** * Load data from the server using a HTTP POST request. * * @param settings The JQueryAjaxSettings to be used for the request + * @see {@link https://api.jquery.com/jQuery.post/#jQuery-post-settings} */ post(settings : JQueryAjaxSettings): JQueryXHR; /** * 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. + * @see {@link https://api.jquery.com/jQuery.Callbacks/} */ Callbacks(flags?: string): JQueryCallback; @@ -754,6 +893,7 @@ interface JQueryStatic { * Holds or releases the execution of jQuery's ready event. * * @param hold Indicates whether the ready hold is being requested or released + * @see {@link https://api.jquery.com/jQuery.holdReady/} */ holdReady(hold: boolean): void; @@ -762,6 +902,7 @@ interface JQueryStatic { * * @param selector A string containing a selector expression * @param context A DOM Element, Document, or jQuery to use as context + * @see {@link https://api.jquery.com/jQuery/#jQuery-selector-context} */ (selector: string, context?: Element|JQuery): JQuery; @@ -769,6 +910,7 @@ interface JQueryStatic { * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param element A DOM element to wrap in a jQuery object. + * @see {@link https://api.jquery.com/jQuery/#jQuery-element} */ (element: Element): JQuery; @@ -776,6 +918,7 @@ interface JQueryStatic { * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. + * @see {@link https://api.jquery.com/jQuery/#jQuery-elementArray} */ (elementArray: Element[]): JQuery; @@ -783,6 +926,7 @@ interface JQueryStatic { * Binds a function to be executed when the DOM has finished loading. * * @param callback A function to execute after the DOM is ready. + * @see {@link https://api.jquery.com/jQuery/#jQuery-callback} */ (callback: (jQueryAlias?: JQueryStatic) => any): JQuery; @@ -790,6 +934,7 @@ interface JQueryStatic { * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param object A plain object to wrap in a jQuery object. + * @see {@link https://api.jquery.com/jQuery/#jQuery-object} */ (object: {}): JQuery; @@ -797,11 +942,13 @@ interface JQueryStatic { * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param object An existing jQuery object to clone. + * @see {@link https://api.jquery.com/jQuery/#jQuery-object} */ (object: JQuery): JQuery; /** * Specify a function to execute when the DOM is fully loaded. + * @see {@link https://api.jquery.com/jQuery/#jQuery} */ (): JQuery; @@ -810,6 +957,7 @@ interface JQueryStatic { * * @param html A string of HTML to create on the fly. Note that this parses HTML, not XML. * @param ownerDocument A document in which the new elements will be created. + * @see {@link https://api.jquery.com/jQuery/#jQuery-html-ownerDocument} */ (html: string, ownerDocument?: Document): JQuery; @@ -818,6 +966,7 @@ interface JQueryStatic { * * @param html A string defining a single, standalone, HTML element (e.g.
or
). * @param attributes An object of attributes, events, and methods to call on the newly-created element. + * @see {@link https://api.jquery.com/jQuery/#jQuery-html-attributes} */ (html: string, attributes: Object): JQuery; @@ -825,6 +974,7 @@ interface JQueryStatic { * 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). + * @see {@link https://api.jquery.com/jQuery.noConflict/} */ noConflict(removeAll?: boolean): JQueryStatic; @@ -832,13 +982,20 @@ interface JQueryStatic { * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. * * @param deferreds One or more Deferred objects, or plain JavaScript objects. + * @see {@link https://api.jquery.com/jQuery.when/} */ when(...deferreds: Array/* as JQueryDeferred */>): JQueryPromise; /** * Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties. + * @see {@link https://api.jquery.com/jQuery.cssHooks/} */ cssHooks: { [key: string]: any; }; + + /** + * An object containing all CSS properties that may be used without a unit. The .css() method uses this object to see if it may append px to unitless values. + * @see {@link https://api.jquery.com/jQuery.cssNumber/} + */ cssNumber: any; /** @@ -847,6 +1004,7 @@ interface JQueryStatic { * @param element The DOM element to associate with the data. * @param key A string naming the piece of data to set. * @param value The new data value. + * @see {@link https://api.jquery.com/jQuery.data/#jQuery-data-element-key-value} */ data(element: Element, key: string, value: T): T; /** @@ -854,12 +1012,14 @@ interface JQueryStatic { * * @param element The DOM element to associate with the data. * @param key A string naming the piece of data to set. + * @see {@link https://api.jquery.com/jQuery.data/#jQuery-data-element-key} */ data(element: Element, key: string): any; /** * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. * * @param element The DOM element to associate with the data. + * @see {@link https://api.jquery.com/jQuery.data/#jQuery-data-element} */ data(element: Element): any; @@ -868,6 +1028,7 @@ interface JQueryStatic { * * @param element A DOM element from which to remove and execute a queued function. * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @see {@link https://api.jquery.com/jQuery.dequeue/} */ dequeue(element: Element, queueName?: string): void; @@ -875,6 +1036,7 @@ interface JQueryStatic { * Determine whether an element has any jQuery data associated with it. * * @param element A DOM element to be checked for data. + * @see {@link https://api.jquery.com/jQuery.hasData/} */ hasData(element: Element): boolean; @@ -883,6 +1045,7 @@ interface JQueryStatic { * * @param element A DOM element to inspect for an attached queue. * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @see {@link https://api.jquery.com/jQuery.queue/#jQuery-queue-element-queueName} */ queue(element: Element, queueName?: string): any[]; /** @@ -891,6 +1054,7 @@ interface JQueryStatic { * @param element A DOM element where the array of queued functions is attached. * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. * @param newQueue An array of functions to replace the current queue contents. + * @see {@link https://api.jquery.com/jQuery.queue/#jQuery-queue-element-queueName-newQueue} */ queue(element: Element, queueName: string, newQueue: Function[]): JQuery; /** @@ -899,6 +1063,7 @@ interface JQueryStatic { * @param element A DOM element on which to add a queued function. * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. * @param callback The new function to add to the queue. + * @see {@link https://api.jquery.com/jQuery.queue/#jQuery-queue-element-queueName-callback} */ queue(element: Element, queueName: string, callback: Function): JQuery; @@ -907,6 +1072,7 @@ interface JQueryStatic { * * @param element A DOM element from which to remove data. * @param name A string naming the piece of data to remove. + * @see {@link https://api.jquery.com/jQuery.removeData/} */ removeData(element: Element, name?: string): JQuery; @@ -914,6 +1080,7 @@ interface JQueryStatic { * A constructor function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function. * * @param beforeStart A function that is called just before the constructor returns. + * @see {@link https://api.jquery.com/jQuery.Deferred/} */ Deferred(beforeStart?: (deferred: JQueryDeferred) => any): JQueryDeferred; @@ -927,12 +1094,14 @@ interface JQueryStatic { tick: () => void; /** * The rate (in milliseconds) at which animations fire. + * @see {@link https://api.jquery.com/jQuery.fx.interval/} */ interval: number; stop: () => void; speeds: { slow: number; fast: number; }; /** * Globally disable all animations. + * @see {@link https://api.jquery.com/jQuery.fx.off/} */ off: boolean; step: any; @@ -941,17 +1110,19 @@ interface JQueryStatic { /** * Takes a function and returns a new one that will always have a particular context. * - * @param fnction The function whose context will be changed. + * @param func The function whose context will be changed. * @param context The object to which the context (this) of the function should be set. * @param additionalArguments Any number of arguments to be passed to the function referenced in the function argument. + * @see {@link https://api.jquery.com/jQuery.proxy/#jQuery-proxy-function-context-additionalArguments} */ - proxy(fnction: (...args: any[]) => any, context: Object, ...additionalArguments: any[]): any; + proxy(func: (...args: any[]) => any, context: Object, ...additionalArguments: any[]): any; /** * Takes a function and returns a new one that will always have a particular context. * * @param context The object to which the context (this) of the function should be set. * @param name The name of the function whose context will be changed (should be a property of the context object). * @param additionalArguments Any number of arguments to be passed to the function named in the name argument. + * @see {@link https://api.jquery.com/jQuery.proxy/#jQuery-proxy-context-name-additionalArguments} */ proxy(context: Object, name: string, ...additionalArguments: any[]): any; @@ -961,6 +1132,7 @@ interface JQueryStatic { * Takes a string and throws an exception containing it. * * @param message The message to send out. + * @see {@link https://api.jquery.com/jQuery.error/} */ error(message: any): JQuery; @@ -977,6 +1149,7 @@ interface JQueryStatic { * * @param container The DOM element that may contain the other element. * @param contained The DOM element that may be contained by (a descendant of) the other element. + * @see {@link https://api.jquery.com/jQuery.contains/} */ contains(container: Element, contained: Element): boolean; @@ -985,6 +1158,7 @@ interface JQueryStatic { * * @param collection The object or array to iterate over. * @param callback The function that will be executed on every object. + * @see {@link https://api.jquery.com/jQuery.each/#jQuery-each-array-callback} */ each( collection: T[], @@ -996,6 +1170,7 @@ interface JQueryStatic { * * @param collection The object or array to iterate over. * @param callback The function that will be executed on every object. + * @see {@link https://api.jquery.com/jQuery.each/#jQuery-each-object-callback} */ each( collection: any, @@ -1008,6 +1183,7 @@ interface JQueryStatic { * @param target An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument. * @param object1 An object containing additional properties to merge in. * @param objectN Additional objects containing properties to merge in. + * @see {@link https://api.jquery.com/jQuery.extend/#jQuery-extend-target-object1-objectN} */ extend(target: any, object1?: any, ...objectN: any[]): any; /** @@ -1017,6 +1193,7 @@ interface JQueryStatic { * @param target The object to extend. It will receive the new properties. * @param object1 An object containing additional properties to merge in. * @param objectN Additional objects containing properties to merge in. + * @see {@link https://api.jquery.com/jQuery.extend/#jQuery-extend-deep-target-object1-objectN} */ extend(deep: boolean, target: any, object1?: any, ...objectN: any[]): any; @@ -1024,6 +1201,7 @@ interface JQueryStatic { * Execute some JavaScript code globally. * * @param code The JavaScript code to execute. + * @see {@link https://api.jquery.com/jQuery.globalEval/} */ globalEval(code: string): any; @@ -1033,6 +1211,7 @@ interface JQueryStatic { * @param array The array to search through. * @param func The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value. this will be the global window object. * @param invert If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false. + * @see {@link https://api.jquery.com/jQuery.grep/} */ grep(array: T[], func: (elementOfArray?: T, indexInArray?: number) => boolean, invert?: boolean): T[]; @@ -1042,6 +1221,7 @@ interface JQueryStatic { * @param value The value to search for. * @param array An array through which to search. * @param fromIndex he index of the array at which to begin the search. The default is 0, which will search the whole array. + * @see {@link https://api.jquery.com/jQuery.inArray/} */ inArray(value: T, array: T[], fromIndex?: number): number; @@ -1049,42 +1229,49 @@ interface JQueryStatic { * Determine whether the argument is an array. * * @param obj Object to test whether or not it is an array. + * @see {@link https://api.jquery.com/jQuery.isArray/} */ isArray(obj: any): boolean; /** * Check to see if an object is empty (contains no enumerable properties). * * @param obj The object that will be checked to see if it's empty. + * @see {@link https://api.jquery.com/jQuery.isEmptyObject/} */ isEmptyObject(obj: any): boolean; /** * Determine if the argument passed is a Javascript function object. * * @param obj Object to test whether or not it is a function. + * @see {@link https://api.jquery.com/jQuery.isFunction/} */ isFunction(obj: any): boolean; /** * Determines whether its argument is a number. * * @param value The value to be tested. + * @see {@link https://api.jquery.com/jQuery.isNumeric/} */ isNumeric(value: any): boolean; /** * Check to see if an object is a plain object (created using "{}" or "new Object"). * * @param obj The object that will be checked to see if it's a plain object. + * @see {@link https://api.jquery.com/jQuery.isPlainObject/} */ isPlainObject(obj: any): boolean; /** * Determine whether the argument is a window. * * @param obj Object to test whether or not it is a window. + * @see {@link https://api.jquery.com/jQuery.isWindow/} */ isWindow(obj: any): boolean; /** * Check to see if a DOM node is within an XML document (or is an XML document). * * @param node he DOM node that will be checked to see if it's in an XML document. + * @see {@link https://api.jquery.com/jQuery.isXMLDoc/} */ isXMLDoc(node: Node): boolean; @@ -1092,6 +1279,7 @@ interface JQueryStatic { * Convert an array-like object into a true JavaScript array. * * @param obj Any object to turn into a native Array. + * @see {@link https://api.jquery.com/jQuery.makeArray/} */ makeArray(obj: any): any[]; @@ -1100,6 +1288,7 @@ interface JQueryStatic { * * @param array The Array to translate. * @param callback The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object. + * @see {@link https://api.jquery.com/jQuery.map/#jQuery-map-array-callback} */ map(array: T[], callback: (elementOfArray?: T, indexInArray?: number) => U): U[]; /** @@ -1107,6 +1296,7 @@ interface JQueryStatic { * * @param arrayOrObject The Array or Object to translate. * @param callback The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object. + * @see {@link https://api.jquery.com/jQuery.map/#jQuery-map-object-callback} */ map(arrayOrObject: any, callback: (value?: any, indexOrKey?: any) => any): any; @@ -1115,16 +1305,19 @@ interface JQueryStatic { * * @param first The first array to merge, the elements of second added. * @param second The second array to merge into the first, unaltered. + * @see {@link https://api.jquery.com/jQuery.merge/} */ merge(first: T[], second: T[]): T[]; /** * An empty function. + * @see {@link https://api.jquery.com/jQuery.noop/} */ noop(): any; /** * Return a number representing the current time. + * @see {@link https://api.jquery.com/jQuery.now/} */ now(): number; @@ -1132,6 +1325,7 @@ interface JQueryStatic { * Takes a well-formed JSON string and returns the resulting JavaScript object. * * @param json The JSON string to parse. + * @see {@link https://api.jquery.com/jQuery.parseJSON/} */ parseJSON(json: string): any; @@ -1139,6 +1333,7 @@ interface JQueryStatic { * Parses a string into an XML document. * * @param data a well-formed XML string to be parsed + * @see {@link https://api.jquery.com/jQuery.parseXML/} */ parseXML(data: string): XMLDocument; @@ -1146,6 +1341,7 @@ interface JQueryStatic { * Remove the whitespace from the beginning and end of a string. * * @param str Remove the whitespace from the beginning and end of a string. + * @see {@link https://api.jquery.com/jQuery.trim/} */ trim(str: string): string; @@ -1153,6 +1349,7 @@ interface JQueryStatic { * Determine the internal JavaScript [[Class]] of an object. * * @param obj Object to get the internal JavaScript [[Class]] of. + * @see {@link https://api.jquery.com/jQuery.type/} */ type(obj: any): string; @@ -1160,6 +1357,7 @@ interface JQueryStatic { * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers. * * @param array The Array of DOM elements. + * @see {@link https://api.jquery.com/jQuery.unique/} */ unique(array: Element[]): Element[]; @@ -1169,6 +1367,7 @@ interface JQueryStatic { * @param data HTML string to be parsed * @param context DOM element to serve as the context in which the HTML fragment will be created * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string + * @see {@link https://api.jquery.com/jQuery.parseHTML/} */ parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[]; @@ -1178,48 +1377,57 @@ interface JQueryStatic { * @param data HTML string to be parsed * @param context DOM element to serve as the context in which the HTML fragment will be created * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string + * @see {@link https://api.jquery.com/jQuery.parseHTML/} */ parseHTML(data: string, context?: Document, keepScripts?: boolean): any[]; } /** * The jQuery instance members + * + * @see {@link https://api.jquery.com/Types/#jQuery} */ interface JQuery { /** * Register a handler to be called when Ajax requests complete. This is an AjaxEvent. * * @param handler The function to be invoked. + * @see {@link https://api.jquery.com/ajaxComplete/} */ ajaxComplete(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery; /** * Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. * * @param handler The function to be invoked. + * @see {@link https://api.jquery.com/ajaxError/} */ ajaxError(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxSettings: JQueryAjaxSettings, thrownError: any) => any): JQuery; /** * Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. * * @param handler The function to be invoked. + * @see {@link https://api.jquery.com/ajaxSend/} */ ajaxSend(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxOptions: JQueryAjaxSettings) => any): JQuery; /** * Register a handler to be called when the first Ajax request begins. This is an Ajax Event. * * @param handler The function to be invoked. + * @see {@link https://api.jquery.com/ajaxStart/} */ ajaxStart(handler: () => any): JQuery; /** * Register a handler to be called when all Ajax requests have completed. This is an Ajax Event. * * @param handler The function to be invoked. + * @see {@link https://api.jquery.com/ajaxStop/} */ ajaxStop(handler: () => any): JQuery; /** * Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event. * * @param handler The function to be invoked. + * @see {@link https://api.jquery.com/ajaxSuccess/} */ ajaxSuccess(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: JQueryAjaxSettings) => any): JQuery; @@ -1229,15 +1437,18 @@ interface JQuery { * @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 complete A callback function that is executed when the request completes. + * @see {@link https://api.jquery.com/load/} */ load(url: string, data?: string|Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery; /** * Encode a set of form elements as a string for submission. + * @see {@link https://api.jquery.com/serialize/} */ serialize(): string; /** * Encode a set of form elements as an array of names and values. + * @see {@link https://api.jquery.com/serializeArray/} */ serializeArray(): JQuerySerializeArrayElement[]; @@ -1245,17 +1456,20 @@ interface JQuery { * Adds the specified class(es) to each of the set of matched elements. * * @param className One or more space-separated classes to be added to the class attribute of each matched element. + * @see {@link https://api.jquery.com/addClass/#addClass-className} */ addClass(className: string): JQuery; /** * Adds the specified class(es) to each of the set of matched elements. * * @param func A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/addClass/#addClass-function} */ addClass(func: (index: number, className: string) => string): JQuery; /** * Add the previous set of elements on the stack to the current set, optionally filtered by a selector. + * @see {@link https://api.jquery.com/addBack/} */ addBack(selector?: string): JQuery; @@ -1263,6 +1477,7 @@ interface JQuery { * Get the value of an attribute for the first element in the set of matched elements. * * @param attributeName The name of the attribute to get. + * @see {@link https://api.jquery.com/attr/#attr-attributeName} */ attr(attributeName: string): string; /** @@ -1270,6 +1485,7 @@ interface JQuery { * * @param attributeName The name of the attribute to set. * @param value A value to set for the attribute. If this is `null`, the attribute will be deleted. + * @see {@link https://api.jquery.com/attr/#attr-attributeName-value} */ attr(attributeName: string, value: string|number|null): JQuery; /** @@ -1277,12 +1493,14 @@ interface JQuery { * * @param attributeName The name of the attribute to set. * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments. + * @see {@link https://api.jquery.com/attr/#attr-attributeName-function} */ attr(attributeName: string, func: (index: number, attr: string) => string|number): JQuery; /** * Set one or more attributes for the set of matched elements. * * @param attributes An object of attribute-value pairs to set. + * @see {@link https://api.jquery.com/attr/#attr-attributes} */ attr(attributes: Object): JQuery; @@ -1290,35 +1508,35 @@ interface JQuery { * Determine whether any of the matched elements are assigned the given class. * * @param className The class name to search for. + * @see {@link https://api.jquery.com/hasClass/} */ hasClass(className: string): boolean; /** * Get the HTML contents of the first element in the set of matched elements. + * @see {@link https://api.jquery.com/html/#html} */ html(): string; /** * Set the HTML contents of each element in the set of matched elements. * * @param htmlString A string of HTML to set as the content of each matched element. + * @see {@link https://api.jquery.com/html/#html-htmlString} */ html(htmlString: string): JQuery; /** * Set the HTML contents of each element in the set of matched elements. * * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/html/#html-function} */ html(func: (index: number, oldhtml: string) => string): JQuery; - /** - * Set the HTML contents of each element in the set of matched elements. - * - * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. - */ /** * Get the value of a property for the first element in the set of matched elements. * * @param propertyName The name of the property to get. + * @see {@link https://api.jquery.com/prop/#prop-propertyName} */ prop(propertyName: string): any; /** @@ -1326,12 +1544,14 @@ interface JQuery { * * @param propertyName The name of the property to set. * @param value A value to set for the property. + * @see {@link https://api.jquery.com/prop/#prop-propertyName-value} */ prop(propertyName: string, value: string|number|boolean): JQuery; /** * Set one or more properties for the set of matched elements. * * @param properties An object of property-value pairs to set. + * @see {@link https://api.jquery.com/prop/#prop-properties} */ prop(properties: Object): JQuery; /** @@ -1339,6 +1559,7 @@ interface JQuery { * * @param propertyName The name of the property to set. * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element. + * @see {@link https://api.jquery.com/prop/#prop-propertyName-function} */ prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): JQuery; @@ -1346,6 +1567,7 @@ interface JQuery { * Remove an attribute from each element in the set of matched elements. * * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes. + * @see {@link https://api.jquery.com/removeAttr/} */ removeAttr(attributeName: string): JQuery; @@ -1353,12 +1575,14 @@ interface JQuery { * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. * * @param className One or more space-separated classes to be removed from the class attribute of each matched element. + * @see {@link https://api.jquery.com/removeClass/#removeClass-className} */ removeClass(className?: string): JQuery; /** * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. * * @param func A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + * @see {@link https://api.jquery.com/removeClass/#removeClass-function} */ removeClass(func: (index: number, className: string) => string): JQuery; @@ -1366,6 +1590,7 @@ interface JQuery { * Remove a property for the set of matched elements. * * @param propertyName The name of the property to remove. + * @see {@link https://api.jquery.com/removeProp/} */ removeProp(propertyName: string): JQuery; @@ -1374,12 +1599,14 @@ interface JQuery { * * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set. * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. + * @see {@link https://api.jquery.com/toggleClass/#toggleClass-className} */ toggleClass(className: string, swtch?: boolean): JQuery; /** * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. * * @param swtch A boolean value to determine whether the class should be added or removed. + * @see {@link https://api.jquery.com/toggleClass/#toggleClass-state} */ toggleClass(swtch?: boolean): JQuery; /** @@ -1387,31 +1614,35 @@ interface JQuery { * * @param func A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments. * @param swtch A boolean value to determine whether the class should be added or removed. + * @see {@link https://api.jquery.com/toggleClass/#toggleClass-function-state} */ toggleClass(func: (index: number, className: string, swtch: boolean) => string, swtch?: boolean): JQuery; /** * Get the current value of the first element in the set of matched elements. + * @see {@link https://api.jquery.com/val/#val} */ val(): any; /** * Set the value of each element in the set of matched elements. * * @param value A string of text, an array of strings or number corresponding to the value of each matched element to set as selected/checked. + * @see {@link https://api.jquery.com/val/#val-value} */ val(value: string|string[]|number): JQuery; /** * Set the value of each element in the set of matched elements. * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + * @see {@link https://api.jquery.com/val/#val-function} */ val(func: (index: number, value: string) => string): JQuery; - /** * Get the value of style properties for the first element in the set of matched elements. * * @param propertyName A CSS property. + * @see {@link https://api.jquery.com/css/#css-propertyName} */ css(propertyName: string): string; /** @@ -1419,6 +1650,7 @@ interface JQuery { * * @param propertyName A CSS property name. * @param value A value to set for the property. + * @see {@link https://api.jquery.com/css/#css-propertyName-value} */ css(propertyName: string, value: string|number): JQuery; /** @@ -1426,34 +1658,40 @@ interface JQuery { * * @param propertyName A CSS property name. * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + * @see {@link https://api.jquery.com/css/#css-propertyName-function} */ css(propertyName: string, value: (index: number, value: string) => string|number): JQuery; /** * Set one or more CSS properties for the set of matched elements. * * @param properties An object of property-value pairs to set. + * @see {@link https://api.jquery.com/css/#css-properties} */ css(properties: Object): JQuery; /** * Get the current computed height for the first element in the set of matched elements. + * @see {@link https://api.jquery.com/height/#height} */ height(): number; /** * Set the CSS height of every matched element. * * @param value An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string). + * @see {@link https://api.jquery.com/height/#height-value} */ height(value: number|string): JQuery; /** * Set the CSS height of every matched element. * * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/height/#height-function} */ height(func: (index: number, height: number) => number|string): JQuery; /** * Get the current computed height for the first element in the set of matched elements, including padding but not border. + * @see {@link https://api.jquery.com/innerHeight/#innerHeight} */ innerHeight(): number; @@ -1461,11 +1699,13 @@ interface JQuery { * Sets the inner height on elements in the set of matched elements, including padding but not border. * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + * @see {@link https://api.jquery.com/innerHeight/#innerHeight-value} */ innerHeight(value: number|string): JQuery; /** * Get the current computed width for the first element in the set of matched elements, including padding but not border. + * @see {@link https://api.jquery.com/innerWidth/#innerWidth} */ innerWidth(): number; @@ -1473,23 +1713,27 @@ interface JQuery { * Sets the inner width on elements in the set of matched elements, including padding but not border. * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + * @see {@link https://api.jquery.com/innerWidth/#innerWidth-value} */ innerWidth(value: number|string): JQuery; /** * Get the current coordinates of the first element in the set of matched elements, relative to the document. + * @see {@link https://api.jquery.com/offset/#offset} */ offset(): JQueryCoordinates; /** * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. * * @param coordinates An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + * @see {@link https://api.jquery.com/offset/#offset-coordinates} */ offset(coordinates: JQueryCoordinates): JQuery; /** * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. * * @param func A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties. + * @see {@link https://api.jquery.com/offset/#offset-function} */ offset(func: (index: number, coords: JQueryCoordinates) => JQueryCoordinates): JQuery; @@ -1497,6 +1741,7 @@ interface JQuery { * Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements. * * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + * @see {@link https://api.jquery.com/outerHeight/#outerHeight-includeMargin} */ outerHeight(includeMargin?: boolean): number; @@ -1504,6 +1749,7 @@ interface JQuery { * Sets the outer height on elements in the set of matched elements, including padding and border. * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + * @see {@link https://api.jquery.com/outerHeight/#outerHeight-value} */ outerHeight(value: number|string): JQuery; @@ -1511,6 +1757,7 @@ interface JQuery { * Get the current computed width for the first element in the set of matched elements, including padding and border. * * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + * @see {@link https://api.jquery.com/outerWidth/#outerWidth-includeMargin} */ outerWidth(includeMargin?: boolean): number; @@ -1518,50 +1765,59 @@ interface JQuery { * Sets the outer width on elements in the set of matched elements, including padding and border. * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + * @see {@link https://api.jquery.com/outerWidth/#outerWidth-value} */ outerWidth(value: number|string): JQuery; /** * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. + * @see {@link https://api.jquery.com/position/} */ position(): JQueryCoordinates; /** * Get the current horizontal position of the scroll bar for the first element in the set of matched elements or set the horizontal position of the scroll bar for every matched element. + * @see {@link https://api.jquery.com/scrollLeft/#scrollLeft} */ scrollLeft(): number; /** * Set the current horizontal position of the scroll bar for each of the set of matched elements. * * @param value An integer indicating the new position to set the scroll bar to. + * @see {@link https://api.jquery.com/scrollLeft/#scrollLeft-value} */ scrollLeft(value: number): JQuery; /** * Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element. + * @see {@link https://api.jquery.com/scrollTop/#scrollTop} */ scrollTop(): number; /** * Set the current vertical position of the scroll bar for each of the set of matched elements. * * @param value An integer indicating the new position to set the scroll bar to. + * @see {@link https://api.jquery.com/scrollTop/#scrollTop-value} */ scrollTop(value: number): JQuery; /** * Get the current computed width for the first element in the set of matched elements. + * @see {@link https://api.jquery.com/width/#width} */ width(): number; /** * Set the CSS width of each element in the set of matched elements. * * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + * @see {@link https://api.jquery.com/width/#width-value} */ width(value: number|string): JQuery; /** * Set the CSS width of each element in the set of matched elements. * * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/width/#width-function} */ width(func: (index: number, width: number) => number|string): JQuery; @@ -1569,6 +1825,7 @@ interface JQuery { * Remove from the queue all items that have not yet been run. * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @see {@link https://api.jquery.com/clearQueue/} */ clearQueue(queueName?: string): JQuery; @@ -1577,22 +1834,26 @@ interface JQuery { * * @param key A string naming the piece of data to set. * @param value The new data value; it can be any Javascript type including Array or Object. + * @see {@link https://api.jquery.com/data/#data-key-value} */ data(key: string, value: any): JQuery; /** * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. * * @param key Name of the data stored. + * @see {@link https://api.jquery.com/data/#data-key} */ data(key: string): any; /** * Store arbitrary data associated with the matched elements. * * @param obj An object of key-value pairs of data to update. + * @see {@link https://api.jquery.com/data/#data-obj} */ data(obj: { [key: string]: any; }): JQuery; /** * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + * @see {@link https://api.jquery.com/data/#data} */ data(): any; @@ -1600,6 +1861,7 @@ interface JQuery { * Execute the next function on the queue for the matched elements. * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @see {@link https://api.jquery.com/dequeue/} */ dequeue(queueName?: string): JQuery; @@ -1607,16 +1869,19 @@ interface JQuery { * Remove a previously-stored piece of data. * * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete. + * @see {@link https://api.jquery.com/removeData/#removeData-name} */ removeData(name: string): JQuery; /** * Remove a previously-stored piece of data. * * @param list An array of strings naming the pieces of data to delete. + * @see {@link https://api.jquery.com/removeData/#removeData-list} */ removeData(list: string[]): JQuery; /** * Remove all previously-stored piece of data. + * @see {@link https://api.jquery.com/removeData/} */ removeData(): JQuery; @@ -1625,6 +1890,7 @@ interface JQuery { * * @param type The type of queue that needs to be observed. (default: fx) * @param target Object onto which the promise methods have to be attached + * @see {@link https://api.jquery.com/promise/} */ promise(type?: string, target?: Object): JQueryPromise; @@ -1634,6 +1900,7 @@ interface JQuery { * @param properties An object of CSS properties and values that the animation will move toward. * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/animate/#animate-properties-duration-easing-complete} */ animate(properties: Object, duration?: string|number, complete?: Function): JQuery; /** @@ -1643,6 +1910,7 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. (default: swing) * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/animate/#animate-properties-duration-easing-complete} */ animate(properties: Object, duration?: string|number, easing?: string, complete?: Function): JQuery; /** @@ -1650,6 +1918,7 @@ interface JQuery { * * @param properties An object of CSS properties and values that the animation will move toward. * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/animate/#animate-properties-options} */ animate(properties: Object, options: JQueryAnimationOptions): JQuery; @@ -1658,6 +1927,7 @@ interface JQuery { * * @param duration An integer indicating the number of milliseconds to delay execution of the next item in the queue. * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @see {@link https://api.jquery.com/delay/} */ delay(duration: number, queueName?: string): JQuery; @@ -1666,6 +1936,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeIn/#fadeIn-duration-complete} */ fadeIn(duration?: number|string, complete?: Function): JQuery; /** @@ -1674,12 +1945,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeIn/#fadeIn-duration-easing-complete} */ fadeIn(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Display the matched elements by fading them to opaque. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/fadeIn/#fadeIn-options} */ fadeIn(options: JQueryAnimationOptions): JQuery; @@ -1688,6 +1961,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeOut/#fadeOut-duration-complete} */ fadeOut(duration?: number|string, complete?: Function): JQuery; /** @@ -1696,12 +1970,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeOut/#fadeOut-duration-easing-complete} */ fadeOut(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Hide the matched elements by fading them to transparent. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/fadeOut/#fadeOut-options} */ fadeOut(options: JQueryAnimationOptions): JQuery; @@ -1711,6 +1987,7 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param opacity A number between 0 and 1 denoting the target opacity. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeTo/#fadeTo-duration-opacity-complete} */ fadeTo(duration: string|number, opacity: number, complete?: Function): JQuery; /** @@ -1720,6 +1997,7 @@ interface JQuery { * @param opacity A number between 0 and 1 denoting the target opacity. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeTo/#fadeTo-duration-opacity-easing-complete} */ fadeTo(duration: string|number, opacity: number, easing?: string, complete?: Function): JQuery; @@ -1728,6 +2006,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeToggle/#fadeToggle-duration-easing-complete} */ fadeToggle(duration?: number|string, complete?: Function): JQuery; /** @@ -1736,12 +2015,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/fadeToggle/#fadeToggle-duration-easing-complete} */ fadeToggle(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Display or hide the matched elements by animating their opacity. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/fadeToggle/#fadeToggle-options} */ fadeToggle(options: JQueryAnimationOptions): JQuery; @@ -1749,6 +2030,7 @@ interface JQuery { * Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements. * * @param queue The name of the queue in which to stop animations. + * @see {@link https://api.jquery.com/finish/} */ finish(queue?: string): JQuery; @@ -1757,6 +2039,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/hide/#hide} */ hide(duration?: number|string, complete?: Function): JQuery; /** @@ -1765,12 +2048,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/hide/#hide-duration-easing-complete} */ hide(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Hide the matched elements. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/hide/#hide-options} */ hide(options: JQueryAnimationOptions): JQuery; @@ -1779,6 +2064,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/show/#show} */ show(duration?: number|string, complete?: Function): JQuery; /** @@ -1787,12 +2073,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/show/#show-duration-easing-complete} */ show(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Display the matched elements. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/show/#show-options} */ show(options: JQueryAnimationOptions): JQuery; @@ -1801,6 +2089,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/slideDown/#slideDown-duration-complete} */ slideDown(duration?: number|string, complete?: Function): JQuery; /** @@ -1809,12 +2098,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/slideDown/#slideDown-duration-easing-complete} */ slideDown(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Display the matched elements with a sliding motion. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/slideDown/#slideDown-options} */ slideDown(options: JQueryAnimationOptions): JQuery; @@ -1823,6 +2114,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/slideToggle/#slideToggle-duration-complete} */ slideToggle(duration?: number|string, complete?: Function): JQuery; /** @@ -1831,12 +2123,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/slideToggle/#slideToggle-duration-easing-complete} */ slideToggle(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Display or hide the matched elements with a sliding motion. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/slideToggle/#slideToggle-options} */ slideToggle(options: JQueryAnimationOptions): JQuery; @@ -1845,6 +2139,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/slideUp/#slideUp-duration-complete} */ slideUp(duration?: number|string, complete?: Function): JQuery; /** @@ -1853,12 +2148,14 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/slideUp/#slideUp-duration-easing-complete} */ slideUp(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Hide the matched elements with a sliding motion. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/slideUp/#slideUp-options} */ slideUp(options: JQueryAnimationOptions): JQuery; @@ -1867,6 +2164,7 @@ interface JQuery { * * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false. * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false. + * @see {@link https://api.jquery.com/stop/#stop-clearQueue-jumpToEnd} */ stop(clearQueue?: boolean, jumpToEnd?: boolean): JQuery; /** @@ -1875,6 +2173,7 @@ interface JQuery { * @param queue The name of the queue in which to stop animations. * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false. * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false. + * @see {@link https://api.jquery.com/stop/#stop-queue-clearQueue-jumpToEnd} */ stop(queue?: string, clearQueue?: boolean, jumpToEnd?: boolean): JQuery; @@ -1883,6 +2182,7 @@ interface JQuery { * * @param duration A string or number determining how long the animation will run. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/toggle/#toggle-duration-complete} */ toggle(duration?: number|string, complete?: Function): JQuery; /** @@ -1891,18 +2191,21 @@ interface JQuery { * @param duration A string or number determining how long the animation will run. * @param easing A string indicating which easing function to use for the transition. * @param complete A function to call once the animation is complete. + * @see {@link https://api.jquery.com/toggle/#toggle-duration-easing-complete} */ toggle(duration?: number|string, easing?: string, complete?: Function): JQuery; /** * Display or hide the matched elements. * * @param options A map of additional options to pass to the method. + * @see {@link https://api.jquery.com/toggle/#toggle-options} */ toggle(options: JQueryAnimationOptions): JQuery; /** * Display or hide the matched elements. * * @param showOrHide A Boolean indicating whether to show or hide the elements. + * @see {@link https://api.jquery.com/toggle/#toggle-display} */ toggle(showOrHide: boolean): JQuery; @@ -1912,6 +2215,7 @@ interface JQuery { * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-handler} */ bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -1919,6 +2223,7 @@ interface JQuery { * * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-handler} */ bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -1927,6 +2232,7 @@ interface JQuery { * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param eventData An object containing data that will be passed to the event handler. * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-preventBubble} */ bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; /** @@ -1934,23 +2240,27 @@ interface JQuery { * * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-preventBubble} */ bind(eventType: string, preventBubble: boolean): JQuery; /** * Attach a handler to an event for the elements. * * @param events An object containing one or more DOM event types and functions to execute for them. + * @see {@link https://api.jquery.com/bind/#bind-events} */ bind(events: any): JQuery; /** * Trigger the "blur" event on an element + * @see {@link https://api.jquery.com/blur/#blur} */ blur(): JQuery; /** * Bind an event handler to the "blur" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/blur/#blur-handler} */ blur(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -1958,17 +2268,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/blur/#blur-eventData-handler} */ blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "change" event on an element. + * @see {@link https://api.jquery.com/change/#change} */ change(): JQuery; /** * Bind an event handler to the "change" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/change/#change-handler} */ change(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -1976,17 +2289,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/change/#change-eventData-handler} */ change(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "click" event on an element. + * @see {@link https://api.jquery.com/click/#click} */ click(): JQuery; /** * Bind an event handler to the "click" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/click/#click-handler} */ click(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -1994,17 +2310,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/click/#click-eventData-handler} */ click(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "contextmenu" event on an element. + * @see {@link https://api.jquery.com/contextmenu/#contextmenu} */ contextmenu(): JQuery; /** * Bind an event handler to the "contextmenu" JavaScript event. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/contextmenu/#contextmenu-handler} */ contextmenu(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2012,17 +2331,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/contextmenu/#contextmenu-eventData-handler} */ contextmenu(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Trigger the "dblclick" event on an element. + * @see {@link https://api.jquery.com/dblclick/#dblclick} */ dblclick(): JQuery; /** * Bind an event handler to the "dblclick" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/dblclick/#dblclick-handler} */ dblclick(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2030,20 +2352,31 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/dblclick/#dblclick-eventData-handler} */ dblclick(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. + * @see {@link https://api.jquery.com/delegate/#delegate-selector-eventType-handler} + */ delegate(selector: any, eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. + * @see {@link https://api.jquery.com/delegate/#delegate-selector-eventType-eventData-handler} + */ delegate(selector: any, eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "focus" event on an element. + * @see {@link https://api.jquery.com/focus/#focus} */ focus(): JQuery; /** * Bind an event handler to the "focus" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/focus/#focus-handler} */ focus(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2051,17 +2384,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/focus/#focus-eventData-handler} */ focus(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "focusin" event on an element. + * @see {@link https://api.jquery.com/focusin/#focusin} */ focusin(): JQuery; /** * Bind an event handler to the "focusin" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/focusin/#focusin-handler} */ focusin(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2069,17 +2405,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/focusin/#focusin-eventData-handler} */ focusin(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "focusout" event on an element. + * @see {@link https://api.jquery.com/focusout/#focusout} */ focusout(): JQuery; /** * Bind an event handler to the "focusout" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/focusout/#focusout-handler} */ focusout(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2087,6 +2426,7 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/focusout/#focusout-eventData-handler} */ focusout(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; @@ -2095,23 +2435,27 @@ interface JQuery { * * @param handlerIn A function to execute when the mouse pointer enters the element. * @param handlerOut A function to execute when the mouse pointer leaves the element. + * @see {@link https://api.jquery.com/hover/#hover-handlerIn-handlerOut} */ hover(handlerIn: (eventObject: JQueryEventObject) => any, handlerOut: (eventObject: JQueryEventObject) => any): JQuery; /** * Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements. * * @param handlerInOut A function to execute when the mouse pointer enters or leaves the element. + * @see {@link https://api.jquery.com/hover/#hover-handlerInOut} */ hover(handlerInOut: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "keydown" event on an element. + * @see {@link https://api.jquery.com/keydown/#keydown} */ keydown(): JQuery; /** * Bind an event handler to the "keydown" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/keydown/#keydown-handler} */ keydown(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; /** @@ -2119,17 +2463,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/keydown/#keydown-eventData-handler} */ keydown(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; /** * Trigger the "keypress" event on an element. + * @see {@link https://api.jquery.com/keypress/#keypress} */ keypress(): JQuery; /** * Bind an event handler to the "keypress" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/keypress/#keypress-handler} */ keypress(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; /** @@ -2137,17 +2484,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/keypress/#keypress-eventData-handler} */ keypress(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; /** * Trigger the "keyup" event on an element. + * @see {@link https://api.jquery.com/keyup/#keyup} */ keyup(): JQuery; /** * Bind an event handler to the "keyup" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/keyup/#keyup-handler} */ keyup(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; /** @@ -2155,6 +2505,7 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/keyup/#keyup-eventData-handler} */ keyup(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; @@ -2162,6 +2513,7 @@ interface JQuery { * Bind an event handler to the "load" JavaScript event. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/load/} */ load(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2169,17 +2521,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/load/} */ load(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "mousedown" event on an element. + * @see {@link https://api.jquery.com/mousedown/#mousedown} */ mousedown(): JQuery; /** * Bind an event handler to the "mousedown" JavaScript event. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mousedown/#mousedown-handler} */ mousedown(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2187,17 +2542,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mousedown/#mousedown-eventData-handler} */ mousedown(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Trigger the "mouseenter" event on an element. + * @see {@link https://api.jquery.com/mouseenter/#mouseenter} */ mouseenter(): JQuery; /** * Bind an event handler to be fired when the mouse enters an element. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseenter/#mouseenter-handler} */ mouseenter(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2205,17 +2563,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseenter/#mouseenter-eventData-handler} */ mouseenter(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Trigger the "mouseleave" event on an element. + * @see {@link https://api.jquery.com/mouseleave/#mouseleave} */ mouseleave(): JQuery; /** * Bind an event handler to be fired when the mouse leaves an element. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseleave/#mouseleave-handler} */ mouseleave(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2223,17 +2584,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseleave/#mouseleave-eventData-handler} */ mouseleave(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Trigger the "mousemove" event on an element. + * @see {@link https://api.jquery.com/mousemove/#mousemove} */ mousemove(): JQuery; /** * Bind an event handler to the "mousemove" JavaScript event. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mousemove/#mousemove-handler} */ mousemove(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2241,17 +2605,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mousemove/#mousemove-eventData-handler} */ mousemove(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Trigger the "mouseout" event on an element. + * @see {@link https://api.jquery.com/mouseout/#mouseout} */ mouseout(): JQuery; /** * Bind an event handler to the "mouseout" JavaScript event. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseout/#mouseout-handler} */ mouseout(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2259,17 +2626,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseout/#mouseout-eventData-handler} */ mouseout(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Trigger the "mouseover" event on an element. + * @see {@link https://api.jquery.com/mouseover/#mouseover} */ mouseover(): JQuery; /** * Bind an event handler to the "mouseover" JavaScript event. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseover/#mouseover-handler} */ mouseover(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2277,17 +2647,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseover/#mouseover-eventData-handler} */ mouseover(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Trigger the "mouseup" event on an element. + * @see {@link https://api.jquery.com/mouseup/#mouseup} */ mouseup(): JQuery; /** * Bind an event handler to the "mouseup" JavaScript event. * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseup/#mouseup-handler} */ mouseup(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** @@ -2295,11 +2668,13 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/mouseup/#mouseup-eventData-handler} */ mouseup(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; /** * Remove an event handler. + * @see {@link https://api.jquery.com/off/#off} */ off(): JQuery; /** @@ -2308,6 +2683,7 @@ interface JQuery { * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. * @param handler A handler function previously attached for the event(s), or the special value false. + * @see {@link https://api.jquery.com/off/#off-events-selector-handler} */ off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2315,6 +2691,7 @@ interface JQuery { * * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". * @param handler A handler function previously attached for the event(s), or the special value false. Takes handler with extra args that can be attached with on(). + * @see {@link https://api.jquery.com/off/#off-events-selector-handler} */ off(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; /** @@ -2322,6 +2699,7 @@ interface JQuery { * * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". * @param handler A handler function previously attached for the event(s), or the special value false. + * @see {@link https://api.jquery.com/off/#off-events-selector-handler} */ off(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2329,6 +2707,7 @@ interface JQuery { * * @param events An object where the string keys represent one or more space-separated event types and optional namespaces, and the values represent handler functions previously attached for the event(s). * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + * @see {@link https://api.jquery.com/off/#off-events-selector} */ off(events: { [key: string]: any; }, selector?: string): JQuery; @@ -2337,6 +2716,7 @@ interface JQuery { * * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; /** @@ -2345,6 +2725,7 @@ interface JQuery { * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". * @param data Data to be passed to the handler in event.data when an event is triggered. * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ on(events: string, data : any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; /** @@ -2353,6 +2734,7 @@ interface JQuery { * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ on(events: string, selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; /** @@ -2362,6 +2744,7 @@ interface JQuery { * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. * @param data Data to be passed to the handler in event.data when an event is triggered. * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; /** @@ -2370,6 +2753,7 @@ interface JQuery { * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/on/#on-events-selector-data} */ on(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; /** @@ -2377,6 +2761,7 @@ interface JQuery { * * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/on/#on-events-selector-data} */ on(events: { [key: string]: any; }, data?: any): JQuery; @@ -2385,6 +2770,7 @@ interface JQuery { * * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. * @param handler A function to execute at the time the event is triggered. + * @see {@link https://api.jquery.com/one/#one-events-data-handler} */ one(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2393,6 +2779,7 @@ interface JQuery { * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. * @param data An object containing data that will be passed to the event handler. * @param handler A function to execute at the time the event is triggered. + * @see {@link https://api.jquery.com/one/#one-events-data-handler} */ one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; @@ -2402,6 +2789,7 @@ interface JQuery { * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler} */ one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2411,6 +2799,7 @@ interface JQuery { * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. * @param data Data to be passed to the handler in event.data when an event is triggered. * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler} */ one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; @@ -2420,6 +2809,7 @@ interface JQuery { * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/one/#one-events-selector-data} */ one(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; @@ -2428,6 +2818,7 @@ interface JQuery { * * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). * @param data Data to be passed to the handler in event.data when an event occurs. + * @see {@link https://api.jquery.com/one/#one-events-selector-data} */ one(events: { [key: string]: any; }, data?: any): JQuery; @@ -2436,17 +2827,20 @@ interface JQuery { * Specify a function to execute when the DOM is fully loaded. * * @param handler A function to execute after the DOM is ready. + * @see {@link https://api.jquery.com/ready/} */ ready(handler: (jQueryAlias?: JQueryStatic) => any): JQuery; /** * Trigger the "resize" event on an element. + * @see {@link https://api.jquery.com/resize/#resize} */ resize(): JQuery; /** * Bind an event handler to the "resize" JavaScript event. * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/resize/#resize-handler} */ resize(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2454,17 +2848,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/resize/#resize-eventData-handler} */ resize(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "scroll" event on an element. + * @see {@link https://api.jquery.com/scroll/#scroll} */ scroll(): JQuery; /** * Bind an event handler to the "scroll" JavaScript event. * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/scroll/#scroll-handler} */ scroll(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2472,17 +2869,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/scroll/#scroll-eventData-handler} */ scroll(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "select" event on an element. + * @see {@link https://api.jquery.com/select/#select} */ select(): JQuery; /** * Bind an event handler to the "select" JavaScript event. * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/select/#select-handler} */ select(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2490,17 +2890,20 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/select/#select-eventData-handler} */ select(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; /** * Trigger the "submit" event on an element. + * @see {@link https://api.jquery.com/submit/#submit} */ submit(): JQuery; /** * Bind an event handler to the "submit" JavaScript event * * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/submit/#submit-handler} */ submit(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2508,6 +2911,7 @@ interface JQuery { * * @param eventData An object containing data that will be passed to the event handler. * @param handler A function to execute each time the event is triggered. + * @see {@link https://api.jquery.com/submit/#submit-eventData-handler} */ submit(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; @@ -2516,6 +2920,7 @@ interface JQuery { * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param extraParameters Additional parameters to pass along to the event handler. + * @see {@link https://api.jquery.com/trigger/#trigger-eventType-extraParameters} */ trigger(eventType: string, extraParameters?: any[]|Object): JQuery; /** @@ -2523,6 +2928,7 @@ interface JQuery { * * @param event A jQuery.Event object. * @param extraParameters Additional parameters to pass along to the event handler. + * @see {@link https://api.jquery.com/trigger/#trigger-event-extraParameters} */ trigger(event: JQueryEventObject, extraParameters?: any[]|Object): JQuery; @@ -2531,6 +2937,7 @@ interface JQuery { * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param extraParameters An array of additional parameters to pass along to the event handler. + * @see {@link https://api.jquery.com/triggerHandler/#triggerHandler-eventType-extraParameters} */ triggerHandler(eventType: string, ...extraParameters: any[]): Object; @@ -2539,6 +2946,7 @@ interface JQuery { * * @param event A jQuery.Event object. * @param extraParameters An array of additional parameters to pass along to the event handler. + * @see {@link https://api.jquery.com/triggerHandler/#triggerHandler-event-extraParameters} */ triggerHandler(event: JQueryEventObject, ...extraParameters: any[]): Object; @@ -2547,6 +2955,7 @@ interface JQuery { * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param handler The function that is to be no longer executed. + * @see {@link https://api.jquery.com/unbind/#unbind-eventType-handler} */ unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2554,17 +2963,20 @@ interface JQuery { * * @param eventType A string containing a JavaScript event type, such as click or submit. * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). + * @see {@link https://api.jquery.com/unbind/#unbind-eventType-false} */ unbind(eventType: string, fls: boolean): JQuery; /** * Remove a previously-attached event handler from the elements. * * @param evt A JavaScript event object as passed to an event handler. + * @see {@link https://api.jquery.com/unbind/#unbind-event} */ unbind(evt: any): JQuery; /** * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * @see {@link https://api.jquery.com/undelegate/#undelegate} */ undelegate(): JQuery; /** @@ -2573,6 +2985,7 @@ interface JQuery { * @param selector A selector which will be used to filter the event results. * @param eventType A string containing a JavaScript event type, such as "click" or "keydown" * @param handler A function to execute at the time the event is triggered. + * @see {@link https://api.jquery.com/undelegate/#undelegate-selector-eventType} */ undelegate(selector: string, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2580,12 +2993,14 @@ interface JQuery { * * @param selector A selector which will be used to filter the event results. * @param events An object of one or more event types and previously bound functions to unbind from them. + * @see {@link https://api.jquery.com/undelegate/#undelegate-selector-events} */ undelegate(selector: string, events: Object): JQuery; /** * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. * * @param namespace A string containing a namespace to unbind all events from. + * @see {@link https://api.jquery.com/undelegate/#undelegate-namespace} */ undelegate(namespace: string): JQuery; @@ -2593,6 +3008,7 @@ interface JQuery { * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/unload/#unload-handler} */ unload(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2600,11 +3016,13 @@ interface JQuery { * * @param eventData A plain object of data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/unload/#unload-eventData-handler} */ unload(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** * The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. (DEPRECATED from v1.10) + * @see {@link https://api.jquery.com/context/} */ context: Element; @@ -2614,6 +3032,7 @@ interface JQuery { * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) * * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/error/#error-handler} */ error(handler: (eventObject: JQueryEventObject) => any): JQuery; /** @@ -2621,6 +3040,7 @@ interface JQuery { * * @param eventData A plain object of data that will be passed to the event handler. * @param handler A function to execute when the event is triggered. + * @see {@link https://api.jquery.com/error/#error-eventData-handler} */ error(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; @@ -2628,6 +3048,7 @@ interface JQuery { * Add a collection of DOM elements onto the jQuery stack. * * @param elements An array of elements to push onto the stack and make into a new jQuery object. + * @see {@link https://api.jquery.com/pushStack/#pushStack-elements} */ pushStack(elements: any[]): JQuery; /** @@ -2636,34 +3057,39 @@ interface JQuery { * @param elements An array of elements to push onto the stack and make into a new jQuery object. * @param name The name of a jQuery method that generated the array of elements. * @param arguments The arguments that were passed in to the jQuery method (for serialization). + * @see {@link https://api.jquery.com/pushStack/#pushStack-elements-name-arguments} */ pushStack(elements: any[], name: string, arguments: any[]): JQuery; /** * Insert content, specified by the parameter, after each element in the set of matched elements. * - * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert after each element in the set of matched elements. - * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + * @param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert after each element in the set of matched elements. + * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + * @see {@link https://api.jquery.com/after/#after-content-content} */ after(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, after each element in the set of matched elements. * - * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/after/#after-function} */ after(func: (index: number, html: string) => string|Element|JQuery): JQuery; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * - * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. - * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + * @param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + * @see {@link https://api.jquery.com/append/#append-content-content} */ append(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * - * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/append/#append-function} */ append(func: (index: number, html: string) => string|Element|JQuery): JQuery; @@ -2671,68 +3097,78 @@ interface JQuery { * Insert every element in the set of matched elements to the end of the target. * * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + * @see {@link https://api.jquery.com/appendTo/} */ appendTo(target: JQuery|any[]|Element|string): JQuery; /** * Insert content, specified by the parameter, before each element in the set of matched elements. * - * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert before each element in the set of matched elements. - * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + * @param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert before each element in the set of matched elements. + * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + * @see {@link https://api.jquery.com/before/#before-content-content} */ before(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, before each element in the set of matched elements. * - * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/before/#before-function} */ before(func: (index: number, html: string) => string|Element|JQuery): JQuery; /** * Create a deep copy of the set of matched elements. * - * param withDataAndEvents A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false. - * param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). + * @param withDataAndEvents A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false. + * @param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). + * @see {@link https://api.jquery.com/clone/} */ clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery; /** * Remove the set of matched elements from the DOM. * - * param selector A selector expression that filters the set of matched elements to be removed. + * @param selector A selector expression that filters the set of matched elements to be removed. + * @see {@link https://api.jquery.com/detach/} */ detach(selector?: string): JQuery; /** * Remove all child nodes of the set of matched elements from the DOM. + * @see {@link https://api.jquery.com/empty/} */ empty(): JQuery; /** * Insert every element in the set of matched elements after the target. * - * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + * @param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + * @see {@link https://api.jquery.com/insertAfter/} */ insertAfter(target: JQuery|any[]|Element|Text|string): JQuery; /** * Insert every element in the set of matched elements before the target. * - * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + * @param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + * @see {@link https://api.jquery.com/insertBefore/} */ insertBefore(target: JQuery|any[]|Element|Text|string): JQuery; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. * - * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. - * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + * @param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + * @see {@link https://api.jquery.com/prepend/#prepend-content-content} */ prepend(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. * - * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/prepend/#prepend-function} */ prepend(func: (index: number, html: string) => string|Element|JQuery): JQuery; @@ -2740,6 +3176,7 @@ interface JQuery { * Insert every element in the set of matched elements to the beginning of the target. * * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. + * @see {@link https://api.jquery.com/prependTo/} */ prependTo(target: JQuery|any[]|Element|string): JQuery; @@ -2747,6 +3184,7 @@ interface JQuery { * Remove the set of matched elements from the DOM. * * @param selector A selector expression that filters the set of matched elements to be removed. + * @see {@link https://api.jquery.com/remove/} */ remove(selector?: string): JQuery; @@ -2754,47 +3192,55 @@ interface JQuery { * Replace each target element with the set of matched elements. * * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace. + * @see {@link https://api.jquery.com/replaceAll/} */ replaceAll(target: JQuery|any[]|Element|string): JQuery; /** * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. * - * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + * @param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + * @see {@link https://api.jquery.com/replaceWith/#replaceWith-newContent} */ replaceWith(newContent: JQuery|any[]|Element|Text|string): JQuery; /** * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. * - * param func A function that returns content with which to replace the set of matched elements. + * @param func A function that returns content with which to replace the set of matched elements. + * @see {@link https://api.jquery.com/replaceWith/#replaceWith-function} */ replaceWith(func: () => Element|JQuery): JQuery; /** * Get the combined text contents of each element in the set of matched elements, including their descendants. + * @see {@link https://api.jquery.com/text/#text} */ text(): string; /** * Set the content of each element in the set of matched elements to the specified text. * * @param text The text to set as the content of each matched element. When Number or Boolean is supplied, it will be converted to a String representation. + * @see {@link https://api.jquery.com/text/#text-text} */ text(text: string|number|boolean): JQuery; /** * Set the content of each element in the set of matched elements to the specified text. * * @param func A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments. + * @see {@link https://api.jquery.com/text/#text-function} */ text(func: (index: number, text: string) => string): JQuery; /** * Retrieve all the elements contained in the jQuery set, as an array. * @name toArray + * @see {@link https://api.jquery.com/toArray/} */ toArray(): HTMLElement[]; /** * Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place. + * @see {@link https://api.jquery.com/unwrap/} */ unwrap(): JQuery; @@ -2802,12 +3248,14 @@ interface JQuery { * Wrap an HTML structure around each element in the set of matched elements. * * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + * @see {@link https://api.jquery.com/wrap/#wrap-wrappingElement} */ wrap(wrappingElement: JQuery|Element|string): JQuery; /** * Wrap an HTML structure around each element in the set of matched elements. * * @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/wrap/#wrap-function} */ wrap(func: (index: number) => string|JQuery): JQuery; @@ -2815,20 +3263,29 @@ interface JQuery { * Wrap an HTML structure around all elements in the set of matched elements. * * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + * @see {@link https://api.jquery.com/wrapAll/#wrapAll-wrappingElement} */ wrapAll(wrappingElement: JQuery|Element|string): JQuery; + /** + * Wrap an HTML structure around all elements in the set of matched elements. + * + * @param func A callback function returning the HTML content or jQuery object to wrap around all the matched elements. Within the function, this refers to the first element in the set. + * @see {@link https://api.jquery.com/wrapAll/#wrapAll-function} + */ wrapAll(func: (index: number) => string): JQuery; /** * Wrap an HTML structure around the content of each element in the set of matched elements. * * @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. + * @see {@link https://api.jquery.com/wrapInner/#wrapInner-wrappingElement} */ wrapInner(wrappingElement: JQuery|Element|string): JQuery; /** * Wrap an HTML structure around the content of each element in the set of matched elements. * * @param func A callback function which generates a structure to wrap around the content of the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + * @see {@link https://api.jquery.com/wrapInner/#wrapInner-function} */ wrapInner(func: (index: number) => string): JQuery; @@ -2836,6 +3293,7 @@ interface JQuery { * Iterate over a jQuery object, executing a function for each matched element. * * @param func A function to execute for each matched element. + * @see {@link https://api.jquery.com/each/} */ each(func: (index: number, elem: Element) => any): JQuery; @@ -2843,32 +3301,38 @@ interface JQuery { * Retrieve one of the elements matched by the jQuery object. * * @param index A zero-based integer indicating which element to retrieve. + * @see {@link https://api.jquery.com/get/#get-index} */ get(index: number): HTMLElement; /** * Retrieve the elements matched by the jQuery object. * @alias toArray + * @see {@link https://api.jquery.com/get/#get} */ get(): HTMLElement[]; /** * Search for a given element from among the matched elements. + * @see {@link https://api.jquery.com/index/#index} */ index(): number; /** * Search for a given element from among the matched elements. * * @param selector A selector representing a jQuery collection in which to look for an element. + * @see {@link https://api.jquery.com/index/#index-selector} */ index(selector: string|JQuery|Element): number; /** * The number of elements in the jQuery object. + * @see {@link https://api.jquery.com/length/} */ length: number; /** * A selector representing selector passed to jQuery(), if any, when creating the original set. * version deprecated: 1.7, removed: 1.9 + * @see {@link https://api.jquery.com/selector/} */ selector: string; [index: string]: any; @@ -2879,24 +3343,28 @@ interface JQuery { * * @param selector A string representing a selector expression to find additional elements to add to the set of matched elements. * @param context The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method. + * @see {@link https://api.jquery.com/add/#add-selector} */ add(selector: string, context?: Element): JQuery; /** * Add elements to the set of matched elements. * * @param elements One or more elements to add to the set of matched elements. + * @see {@link https://api.jquery.com/add/#add-elements} */ add(...elements: Element[]): JQuery; /** * Add elements to the set of matched elements. * * @param html An HTML fragment to add to the set of matched elements. + * @see {@link https://api.jquery.com/add/#add-html} */ add(html: string): JQuery; /** * Add elements to the set of matched elements. * * @param obj An existing jQuery object to add to the set of matched elements. + * @see {@link https://api.jquery.com/add/#add-selection} */ add(obj: JQuery): JQuery; @@ -2904,6 +3372,7 @@ interface JQuery { * Get the children of each element in the set of matched elements, optionally filtered by a selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/children/} */ children(selector?: string): JQuery; @@ -2911,6 +3380,7 @@ interface JQuery { * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/closest/#closest-selector} */ closest(selector: string): JQuery; /** @@ -2918,18 +3388,21 @@ interface JQuery { * * @param selector A string containing a selector expression to match elements against. * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. + * @see {@link https://api.jquery.com/closest/#closest-selector-context} */ closest(selector: string, context?: Element): JQuery; /** * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. * * @param obj A jQuery object to match elements against. + * @see {@link https://api.jquery.com/closest/#closest-selection} */ closest(obj: JQuery): JQuery; /** * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. * * @param element An element to match elements against. + * @see {@link https://api.jquery.com/closest/#closest-element} */ closest(element: Element): JQuery; @@ -2938,16 +3411,19 @@ interface JQuery { * * @param selectors An array or string containing a selector expression to match elements against (can also be a jQuery object). * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. + * @see {@link https://api.jquery.com/closest/#closest-selectors-context} */ closest(selectors: any, context?: Element): any[]; /** * Get the children of each element in the set of matched elements, including text and comment nodes. + * @see {@link https://api.jquery.com/contents/} */ contents(): JQuery; /** * End the most recent filtering operation in the current chain and return the set of matched elements to its previous state. + * @see {@link https://api.jquery.com/end/} */ end(): JQuery; @@ -2955,7 +3431,7 @@ interface JQuery { * Reduce the set of matched elements to the one at the specified index. * * @param index An integer indicating the 0-based position of the element. OR An integer indicating the position of the element, counting backwards from the last element in the set. - * + * @see {@link https://api.jquery.com/eq/} */ eq(index: number): JQuery; @@ -2963,24 +3439,28 @@ interface JQuery { * Reduce the set of matched elements to those that match the selector or pass the function's test. * * @param selector A string containing a selector expression to match the current set of elements against. + * @see {@link https://api.jquery.com/filter/#filter-selector} */ filter(selector: string): JQuery; /** * Reduce the set of matched elements to those that match the selector or pass the function's test. * * @param func A function used as a test for each element in the set. this is the current DOM element. + * @see {@link https://api.jquery.com/filter/#filter-function} */ filter(func: (index: number, element: Element) => any): JQuery; /** * Reduce the set of matched elements to those that match the selector or pass the function's test. * * @param element An element to match the current set of elements against. + * @see {@link https://api.jquery.com/filter/#filter-elements} */ filter(element: Element): JQuery; /** * Reduce the set of matched elements to those that match the selector or pass the function's test. * * @param obj An existing jQuery object to match the current set of elements against. + * @see {@link https://api.jquery.com/filter/#filter-selection} */ filter(obj: JQuery): JQuery; @@ -2988,23 +3468,27 @@ interface JQuery { * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/find/#find-selector} */ find(selector: string): JQuery; /** * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. * * @param element An element to match elements against. + * @see {@link https://api.jquery.com/find/#find-element} */ find(element: Element): JQuery; /** * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. * * @param obj A jQuery object to match elements against. + * @see {@link https://api.jquery.com/find/#find-element} */ find(obj: JQuery): JQuery; /** * Reduce the set of matched elements to the first in the set. + * @see {@link https://api.jquery.com/first/} */ first(): JQuery; @@ -3012,12 +3496,14 @@ interface JQuery { * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/has/#has-selector} */ has(selector: string): JQuery; /** * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. * * @param contained A DOM element to match elements against. + * @see {@link https://api.jquery.com/has/#has-contained} */ has(contained: Element): JQuery; @@ -3025,29 +3511,34 @@ interface JQuery { * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/is/#is-selector} */ is(selector: string): boolean; /** * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. * * @param func A function used as a test for the set of elements. It accepts one argument, index, which is the element's index in the jQuery collection.Within the function, this refers to the current DOM element. + * @see {@link https://api.jquery.com/is/#is-function} */ is(func: (index: number, element: Element) => boolean): boolean; /** * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. * * @param obj An existing jQuery object to match the current set of elements against. + * @see {@link https://api.jquery.com/is/#is-selection} */ is(obj: JQuery): boolean; /** * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. * * @param elements One or more elements to match the current set of elements against. + * @see {@link https://api.jquery.com/is/#is-elements} */ is(elements: any): boolean; /** * Reduce the set of matched elements to the final one in the set. + * @see {@link https://api.jquery.com/last/} */ last(): JQuery; @@ -3055,6 +3546,7 @@ interface JQuery { * Pass each element in the current matched set through a function, producing a new jQuery object containing the return values. * * @param callback A function object that will be invoked for each element in the current set. + * @see {@link https://api.jquery.com/map/} */ map(callback: (index: number, domElement: Element) => any): JQuery; @@ -3062,6 +3554,7 @@ interface JQuery { * Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/next/} */ next(selector?: string): JQuery; @@ -3069,6 +3562,7 @@ interface JQuery { * Get all following siblings of each element in the set of matched elements, optionally filtered by a selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/nextAll/} */ nextAll(selector?: string): JQuery; @@ -3077,6 +3571,7 @@ interface JQuery { * * @param selector A string containing a selector expression to indicate where to stop matching following sibling elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/nextUntil/#nextUntil-selector-filter} */ nextUntil(selector?: string, filter?: string): JQuery; /** @@ -3084,6 +3579,7 @@ interface JQuery { * * @param element A DOM node or jQuery object indicating where to stop matching following sibling elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/nextUntil/#nextUntil-element-filter} */ nextUntil(element?: Element, filter?: string): JQuery; /** @@ -3091,6 +3587,7 @@ interface JQuery { * * @param obj A DOM node or jQuery object indicating where to stop matching following sibling elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/nextUntil/#nextUntil-element-filter} */ nextUntil(obj?: JQuery, filter?: string): JQuery; @@ -3098,29 +3595,34 @@ interface JQuery { * Remove elements from the set of matched elements. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/not/#not-selector} */ not(selector: string): JQuery; /** * Remove elements from the set of matched elements. * * @param func A function used as a test for each element in the set. this is the current DOM element. + * @see {@link https://api.jquery.com/not/#not-function} */ not(func: (index: number, element: Element) => boolean): JQuery; /** * Remove elements from the set of matched elements. * * @param elements One or more DOM elements to remove from the matched set. + * @see {@link https://api.jquery.com/not/#not-selection} */ not(elements: Element|Element[]): JQuery; /** * Remove elements from the set of matched elements. * * @param obj An existing jQuery object to match the current set of elements against. + * @see {@link https://api.jquery.com/not/#not-selection} */ not(obj: JQuery): JQuery; /** * Get the closest ancestor element that is positioned. + * @see {@link https://api.jquery.com/offsetParent/} */ offsetParent(): JQuery; @@ -3128,6 +3630,7 @@ interface JQuery { * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/parent/} */ parent(selector?: string): JQuery; @@ -3135,6 +3638,7 @@ interface JQuery { * Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/parents/} */ parents(selector?: string): JQuery; @@ -3143,6 +3647,7 @@ interface JQuery { * * @param selector A string containing a selector expression to indicate where to stop matching ancestor elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/parentsUntil/#parentsUntil-selector-filter} */ parentsUntil(selector?: string, filter?: string): JQuery; /** @@ -3150,6 +3655,7 @@ interface JQuery { * * @param element A DOM node or jQuery object indicating where to stop matching ancestor elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/parentsUntil/#parentsUntil-element-filter} */ parentsUntil(element?: Element, filter?: string): JQuery; /** @@ -3157,6 +3663,7 @@ interface JQuery { * * @param obj A DOM node or jQuery object indicating where to stop matching ancestor elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/parentsUntil/#parentsUntil-element-filter} */ parentsUntil(obj?: JQuery, filter?: string): JQuery; @@ -3164,6 +3671,7 @@ interface JQuery { * Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/prev/} */ prev(selector?: string): JQuery; @@ -3171,6 +3679,7 @@ interface JQuery { * Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/prevAll/} */ prevAll(selector?: string): JQuery; @@ -3179,6 +3688,7 @@ interface JQuery { * * @param selector A string containing a selector expression to indicate where to stop matching preceding sibling elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/prevUntil/#prevUntil-selector-filter} */ prevUntil(selector?: string, filter?: string): JQuery; /** @@ -3186,6 +3696,7 @@ interface JQuery { * * @param element A DOM node or jQuery object indicating where to stop matching preceding sibling elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/prevUntil/#prevUntil-element-filter} */ prevUntil(element?: Element, filter?: string): JQuery; /** @@ -3193,6 +3704,7 @@ interface JQuery { * * @param obj A DOM node or jQuery object indicating where to stop matching preceding sibling elements. * @param filter A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/prevUntil/#prevUntil-element-filter} */ prevUntil(obj?: JQuery, filter?: string): JQuery; @@ -3200,6 +3712,7 @@ interface JQuery { * Get the siblings of each element in the set of matched elements, optionally filtered by a selector. * * @param selector A string containing a selector expression to match elements against. + * @see {@link https://api.jquery.com/siblings/} */ siblings(selector?: string): JQuery; @@ -3208,6 +3721,7 @@ interface JQuery { * * @param start An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set. * @param end An integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set. + * @see {@link https://api.jquery.com/slice/} */ slice(start: number, end?: number): JQuery; @@ -3215,18 +3729,21 @@ interface JQuery { * Show the queue of functions to be executed on the matched elements. * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @see {@link https://api.jquery.com/queue/#queue-queueName} */ queue(queueName?: string): any[]; /** * Manipulate the queue of functions to be executed, once for each matched element. * * @param newQueue An array of functions to replace the current queue contents. + * @see {@link https://api.jquery.com/queue/#queue-queueName-newQueue} */ queue(newQueue: Function[]): JQuery; /** * Manipulate the queue of functions to be executed, once for each matched element. * * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. + * @see {@link https://api.jquery.com/queue/#queue-queueName-callback} */ queue(callback: Function): JQuery; /** @@ -3234,6 +3751,7 @@ interface JQuery { * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. * @param newQueue An array of functions to replace the current queue contents. + * @see {@link https://api.jquery.com/queue/#queue-queueName-newQueue} */ queue(queueName: string, newQueue: Function[]): JQuery; /** @@ -3241,6 +3759,7 @@ interface JQuery { * * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. + * @see {@link https://api.jquery.com/queue/#queue-queueName-callback} */ queue(queueName: string, callback: Function): JQuery; } From a9bf9cf390b07c5b280855692871bce7cb77d79b Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Sat, 31 Dec 2016 18:42:09 -0800 Subject: [PATCH 09/45] Add typings for Facebook's ui method (#13611) --- facebook-js-sdk/facebook-js-sdk-tests.ts | 69 +++++++++++++ facebook-js-sdk/index.d.ts | 124 ++++++++++++++++++++++- 2 files changed, 188 insertions(+), 5 deletions(-) diff --git a/facebook-js-sdk/facebook-js-sdk-tests.ts b/facebook-js-sdk/facebook-js-sdk-tests.ts index 61721a4f71..56fc91cd02 100644 --- a/facebook-js-sdk/facebook-js-sdk-tests.ts +++ b/facebook-js-sdk/facebook-js-sdk-tests.ts @@ -39,3 +39,72 @@ FB.logout(function(response: fb.AuthResponse) { console.log(response.status); console.log(response.authResponse.accessToken); }); + +/** + * Dialog samples from Facebook documentation: + */ +FB.ui({ + display: 'popup', + method: 'live_broadcast', + phase: 'create', +}, response => { + if (!response.id) { + alert('dialog canceled'); + return; + } + alert('stream url:' + response.secure_stream_url); + + FB.ui({ + display: 'popup', + method: 'live_broadcast', + phase: 'publish', + broadcast_data: response, + }, response => { + alert("video status: \n" + response.status); + }); +}); + +FB.ui({ + method: 'pay', + action: 'purchaseitem', + product: 'YOUR_PRODUCT_URL' +}, data => { + console.log(data.payment_id); +}); + +FB.ui({ + method: 'pagetab', + redirect_uri: 'YOUR_URL' +}, response => {}); + +FB.ui({ + method: 'send', + link: 'http://www.nytimes.com/interactive/2015/04/15/travel/europe-favorite-streets.html', +}, response => {}); + +FB.ui({ + method: 'apprequests', + message: 'Take this bomb to blast your way to victory!', + to: 'USER_ID, USER_ID, INVITE_TOKEN', + action_type:'send', + object_id: 'YOUR_OBJECT_ID', // e.g. '191181717736427' +}, response => { + console.log(response); +}); + +FB.ui({ + method: 'apprequests', + message: 'Friend Smash Request!', + filters: [ + { name:'GROUP_1_NAME', user_ids:['USER_ID','USER_ID','USER_ID'] }, + { name:'GROUP_2_NAME', user_ids: ['USER_ID','USER_ID','USER_ID'] }, + ] +}, response => { + console.log(response); +}); + +FB.ui({ + method: 'share', + mobile_iframe: true, + href: 'https://developers.facebook.com/docs/', +}, response => {}); diff --git a/facebook-js-sdk/index.d.ts b/facebook-js-sdk/index.d.ts index bee34f0a2c..a7b78e73b0 100644 --- a/facebook-js-sdk/index.d.ts +++ b/facebook-js-sdk/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for the Facebook Javascript SDK +// Type definitions for the Facebook Javascript SDK 2.8 // Project: https://developers.facebook.com/docs/javascript // Definitions by: Amrit Kahlon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -12,7 +12,7 @@ declare namespace facebook { AppEvents: any; Canvas: any; Event: any; - + /** * The method FB.getAuthResponse() is a synchronous accessor for the current authResponse. * The synchronous nature of this method is what sets it apart from the other login methods. @@ -50,8 +50,33 @@ declare namespace facebook { * @param callback function to handle the response */ logout(callback: (response: AuthResponse) => void): void; - - ui: any; + + /** + * @see https://developers.facebook.com/docs/sharing/reference/share-dialog + */ + ui(params: ShareDialogParams, callback: (response: ShareDialogResponse) => void): void; + + /** + * @see https://developers.facebook.com/docs/games/services/gamerequests + */ + ui(params: GameRequestDialogParams, callback: (response: GameRequestDialogResponse) => void): void; + + /** + * @see https://developers.facebook.com/docs/payments/reference/paydialog + */ + ui(params: PayDialogParams, callback: (response: PayDialogResponse) => void): void; + + /** + * @see https://developers.facebook.com/docs/videos/live-video/exploring-live + */ + ui(params: LiveDialogParams, callback: (response: LiveDialogResponse) => void): void; + + /** + * @see https://developers.facebook.com/docs/sharing/reference/send-dialog + * @see https://developers.facebook.com/docs/pages/page-tab-dialog + */ + ui(params: SendDialogParams | AddPageTabDialogParams, callback: (response: null) => void): void; + XFBML: any; } @@ -73,6 +98,68 @@ declare namespace facebook { profile_selector_ids?: string; } + //////////////////////// + // + // DIALOGS + // + //////////////////////// + + interface DialogParams { + app_id?: string; + redirect_uri?: string; + display?: 'page' | 'iframe' | 'async' | 'popup'; + } + + interface ShareDialogParams extends DialogParams { + method: 'share'; + href: string; + hashtag?: string; + quote?: string; + mobile_iframe?: boolean; + } + + interface AddPageTabDialogParams extends DialogParams { + method: 'pagetab'; + redirect_uri: string; + } + + interface GameRequestDialogParams extends DialogParams { + method: 'apprequests'; + message: string; + action_type?: 'send' | 'askfor' | 'turn'; + data?: number; + exclude_ids?: string[]; + filters?: 'app_users' | 'app_non_users' | Array<{ name: string, user_ids: string[] }>; + max_recipients?: number; + object_id?: string; + suggestions?: string[]; + title?: number; + to?: string | number; + } + + interface SendDialogParams extends DialogParams { + method: 'send'; + to?: string; + link: string; + } + + interface PayDialogParams extends DialogParams { + method: 'pay'; + action: 'purchaseitem'; + product: string; + quantity?: number; + quantity_min?: number; + quantity_max?: number; + request_id?: string; + test_currency?: string; + } + + interface LiveDialogParams extends DialogParams { + method: 'live_broadcast'; + display: 'popup' | 'iframe'; + phase: 'create' | 'publish'; + broadcast_data?: LiveDialogResponse; + } //////////////////////// // @@ -87,6 +174,33 @@ declare namespace facebook { expiresIn: number; signedRequest: string; userID: string; - } + }; + } + + interface ShareDialogResponse { + post_id?: string; + error_message?: string; + } + + interface GameRequestDialogResponse { + request: string; + to: string[]; + } + + interface PayDialogResponse { + payment_id: string; + amount: string; + currency: string; + quantity: string; + request_id: string; + status: string; + signed_request: string; + } + + interface LiveDialogResponse { + id: string; + stream_url: string; + secure_stream_url: string; + status: string; } } From 2b2bff7d4f535c2742979dbf99b93e67d3daa139 Mon Sep 17 00:00:00 2001 From: Der-Alex Date: Sun, 1 Jan 2017 03:46:25 +0100 Subject: [PATCH 10/45] Added pug (former jade) template engine to consolidate typings (#13594) * added pug (former jade) to template engine list * added test for pug * Fixed typo RenderInterface to RendererInterface --- consolidate/consolidate-tests.ts | 4 ++++ consolidate/index.d.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/consolidate/consolidate-tests.ts b/consolidate/consolidate-tests.ts index 4145fd1e6c..06239710c0 100644 --- a/consolidate/consolidate-tests.ts +++ b/consolidate/consolidate-tests.ts @@ -92,6 +92,10 @@ cons.nunjucks(path); cons.nunjucks(path, options); cons.nunjucks(path, options, fn); +cons.pug(path); +cons.pug(path, options); +cons.pug(path, options, fn); + cons.qejs(path); cons.qejs(path, options); cons.qejs(path, options, fn); diff --git a/consolidate/index.d.ts b/consolidate/index.d.ts index 9f59a0ba13..454d13263f 100644 --- a/consolidate/index.d.ts +++ b/consolidate/index.d.ts @@ -48,6 +48,7 @@ interface Consolidate { mote: RendererInterface; mustache: RendererInterface; nunjucks: RendererInterface; + pug: RendererInterface; qejs: RendererInterface; ractive: RendererInterface; react: RendererInterface; From 7f09dc728ad5ba14ec5682b3ccee1224ea202a03 Mon Sep 17 00:00:00 2001 From: daspr2 Date: Sat, 31 Dec 2016 20:49:29 -0600 Subject: [PATCH 11/45] Updated Cucumber type definition (#13637) to use the new Cucumber Support Code Interface. --- cucumber/cucumber-tests.ts | 28 +++++++++++++++++++++++----- cucumber/index.d.ts | 8 ++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cucumber/cucumber-tests.ts b/cucumber/cucumber-tests.ts index 1b25f9b3bf..515322078d 100644 --- a/cucumber/cucumber-tests.ts +++ b/cucumber/cucumber-tests.ts @@ -1,23 +1,25 @@ -import cucumber = require("cucumber"); +import * as cucumber from "cucumber"; import * as assert from "power-assert"; function StepSample() { type Callback = cucumber.CallbackStepDefinition; type Table = cucumber.TableDefinition; + type HookScenario = cucumber.HookScenario; + type Hooks = cucumber.Hooks; var step = this; var hook = this; - hook.Before(function(scenario, callback){ + hook.Before(function(scenario: HookScenario, callback: Callback){ scenario.isFailed() && callback.pending(); - }) + }); - hook.Around(function(scenario, runScenario) { + hook.Around(function(scenario: HookScenario, runScenario: (error:string, callback?:Function)=>void) { scenario.isFailed() && runScenario(null, function(){ console.log('finish tasks'); }); }); - hook.registerHandler('AfterFeatures', function (event, callback) { + hook.registerHandler('AfterFeatures', function (event:any, callback:Function) { callback(); }); @@ -76,5 +78,21 @@ function StepSample() { ]; assert.deepEqual(table.hashes(), expected) }); + + cucumber.defineSupportCode(function(step: cucumber.StepDefinitions){ + step.Given( /^a variable set to (\d+)$/, (x:string) => { + console.log("the number is: " + x); + } ); + }); + cucumber.defineSupportCode(function(step: Hooks){ + step.After((scenario: HookScenario, callback?: Callback) => { + console.log("After"); + callback(); + } ) + }); + + let fns : cucumber.SupportCodeConsumer[] = cucumber.getSupportCodeFns() + + cucumber.clearSupportCodeFns(); } diff --git a/cucumber/index.d.ts b/cucumber/index.d.ts index de0a8d07d3..8756b77ea6 100644 --- a/cucumber/index.d.ts +++ b/cucumber/index.d.ts @@ -71,4 +71,12 @@ declare namespace cucumber { setDefaultTimeout(time:number): void; registerHandler(handlerOption:string, code:(event:any, callback:CallbackStepDefinition) =>void): void; } + + export interface SupportCodeConsumer { + (stepDefinitions:StepDefinitions | Hooks):void; + } + + export function defineSupportCode(consumer:SupportCodeConsumer): void; + export function getSupportCodeFns(): SupportCodeConsumer[]; + export function clearSupportCodeFns(): void; } From 643d0b8fa3808d7f6006ae23e8ba794ae8db1e4b Mon Sep 17 00:00:00 2001 From: stonio Date: Sun, 1 Jan 2017 03:53:04 +0100 Subject: [PATCH 12/45] [openlayers] Update method forEachFeatureAtPixel (#13640) * Update method forEachFeatureAtPixel * Move definition of interface AtPixelOptions --- openlayers/index.d.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/openlayers/index.d.ts b/openlayers/index.d.ts index 551f8fa2eb..5f30540d5a 100644 --- a/openlayers/index.d.ts +++ b/openlayers/index.d.ts @@ -6669,20 +6669,13 @@ declare module ol { * the {@link ol.layer.Layer layer} of the feature and will be null for * unmanaged layers. To stop detection, callback functions can return a * truthy value. - * @param {S=} opt_this Value to use as `this` when executing `callback`. - * @param {(function(this: U, ol.layer.Layer): boolean)=} opt_layerFilter Layer - * filter function. The filter function will receive one argument, the - * {@link ol.layer.Layer layer-candidate} and it should return a boolean - * value. Only layers which are visible and for which this function returns - * `true` will be tested for features. By default, all visible layers will - * be tested. - * @param {U=} opt_this2 Value to use as `this` when executing `layerFilter`. + * @param {olx.AtPixelOptions=} opt_options Optional options. * @return {T|undefined} Callback result, i.e. the return value of last * callback execution, or the first truthy callback return value. - * @template S,T,U + * @template S,T * @api stable */ - forEachFeatureAtPixel(pixel: ol.Pixel, callback: ((feature: (ol.Feature | ol.render.Feature), layer: ol.layer.Layer) => T), opt_this?: S, opt_layerFilter?: ((layer: ol.layer.Layer) => boolean), opt_this2?: U): (T); + forEachFeatureAtPixel(pixel: ol.Pixel, callback: ((feature: (ol.Feature | ol.render.Feature), layer: ol.layer.Layer) => T), opt_options?: olx.AtPixelOptions): (T); /** * Detect layers that have a color value at a pixel on the viewport, and @@ -11778,7 +11771,6 @@ declare module olx { easing?: ((t: number) => number); } - } /** @@ -13779,7 +13771,17 @@ declare module olx { zoom?: number; zoomFactor?: number; } - + + /** + * Object literal with options for the {@link ol.Map#forEachFeatureAtPixel} and + * {@link ol.Map#hasFeatureAtPixel} methods. + * @typedef {{layerFilter: ((function(ol.layer.Layer): boolean)|undefined), + * hitTolerance: (number|undefined)}} + */ + interface AtPixelOptions { + layerFilter?: ((layer: ol.layer.Layer) => boolean) + hitTolerance?: number + } /** * @typedef {{animate: boolean, From d389dfdb8335e079f543efef4433921434f7528c Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 1 Jan 2017 15:33:54 -0800 Subject: [PATCH 13/45] draft-js: Add package.json to reference `immutable` (#13667) --- draft-js/package.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 draft-js/package.json diff --git a/draft-js/package.json b/draft-js/package.json new file mode 100644 index 0000000000..84d23a146b --- /dev/null +++ b/draft-js/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "immutable": "^3.8.1" + } +} \ No newline at end of file From 3633866ea5079a65a958d49b97ac5c8e3dfd532d Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 1 Jan 2017 15:36:12 -0800 Subject: [PATCH 14/45] Prefer to directly export values instead of `export =` of a namespace (#13645) --- argon2/index.d.ts | 57 ++--- halogen/index.d.ts | 152 ++++++------ navigation-react/index.d.ts | 150 ++++++----- react-native-fs/index.d.ts | 358 +++++++++++++-------------- react-test-renderer/index.d.ts | 31 ++- redux-actions/index.d.ts | 215 ++++++++-------- redux-actions/redux-actions-tests.ts | 2 +- redux-batched-actions/index.d.ts | 27 +- xsd-schema-validator/index.d.ts | 14 +- 9 files changed, 487 insertions(+), 519 deletions(-) diff --git a/argon2/index.d.ts b/argon2/index.d.ts index f4e4c41d1f..1cbf1a5156 100644 --- a/argon2/index.d.ts +++ b/argon2/index.d.ts @@ -5,40 +5,35 @@ /// -declare namespace argon2 { +export var defaults: { + timeCost: number; + memoryCost: number; + parallelism: number; + argon2d: boolean; +}; - export var defaults: { - timeCost: number; - memoryCost: number; - parallelism: number; - argon2d: boolean; +export var limits: { + memoryCost: { + min: number; + max: number; }; - - export var limits: { - memoryCost: { - min: number; - max: number; - }; - timeCost: { - min: number; - max: number; - }; - parallelism: { - min: number; - max: number; - }; + timeCost: { + min: number; + max: number; }; + parallelism: { + min: number; + max: number; + }; +}; - export function hash(plain: string, salt: Buffer, options?: { - timeCost?: number; - memoryCost?: number; - parallelism?: number; - argon2d?: boolean; - }): Promise; +export function hash(plain: string, salt: Buffer, options?: { + timeCost?: number; + memoryCost?: number; + parallelism?: number; + argon2d?: boolean; +}): Promise; - export function verify(hash: string, plain: string): Promise; +export function verify(hash: string, plain: string): Promise; - export function generateSalt(length?: number): Promise; -} - -export = argon2; +export function generateSalt(length?: number): Promise; diff --git a/halogen/index.d.ts b/halogen/index.d.ts index 5a6448899c..72d57ace51 100644 --- a/halogen/index.d.ts +++ b/halogen/index.d.ts @@ -5,84 +5,78 @@ import * as react from "react"; -export = Halogen; - -declare namespace Halogen { - - type VerticalAlign = "baseline" | "length" | "sub" | "super" | "top" | "text-top" | "middle" | "bottom" | "text-bottom" | "initial" | "inherit"; - - interface HalogenCommonProps { - loading?: boolean; - color?: string; - id?: string; - className?: string; - verticalAlign?: VerticalAlign; - } - - interface SizeLoaderProps extends HalogenCommonProps { - size?: string; - } - - interface MarginLoaderProps extends HalogenCommonProps { - margin?: T; - size?: T; - } - - interface RadiusLoaderProps extends MarginLoaderProps { - height?: string; - width?: string; - radius?: string; - } - - /** - * React components - */ - type PulseLoader = react.Component, {}>; - export const PulseLoader: react.ComponentClass>; - - type RotateLoader = react.Component, {}>; - export const RotateLoader: react.ComponentClass>; - - type BeatLoader = react.Component, {}>; - export const BeatLoader: react.ComponentClass>; - - type RiseLoader = react.Component, {}>; - export const RiseLoader: react.ComponentClass>; - - type SyncLoader = react.Component, {}>; - export const SyncLoader: react.ComponentClass>; - - type GridLoader = react.Component, {}>; - export const GridLoader: react.ComponentClass>; - - type ClipLoader = react.Component; - export const ClipLoader: react.ComponentClass; - - type SquareLoader = react.Component; - export const SquareLoader: react.ComponentClass; - - type DotLoader = react.Component; - export const DotLoader: react.ComponentClass; - - type PacmanLoader = react.Component, {}>; - export const PacmanLoader: react.ComponentClass>; - - type MoonLoader = react.Component; - export const MoonLoader: react.ComponentClass; - - type RingLoader = react.Component; - export const RingLoader: react.ComponentClass; - - type BounceLoader = react.Component; - export const BounceLoader: react.ComponentClass; - - type SkewLoader = react.Component; - export const SkewLoader: react.ComponentClass; - - type FadeLoader = react.Component; - export const FadeLoader: react.ComponentClass; - - type ScaleLoader = react.Component; - export const ScaleLoader: react.ComponentClass; +type VerticalAlign = "baseline" | "length" | "sub" | "super" | "top" | "text-top" | "middle" | "bottom" | "text-bottom" | "initial" | "inherit"; +interface HalogenCommonProps { + loading?: boolean; + color?: string; + id?: string; + className?: string; + verticalAlign?: VerticalAlign; } + +interface SizeLoaderProps extends HalogenCommonProps { + size?: string; +} + +interface MarginLoaderProps extends HalogenCommonProps { + margin?: T; + size?: T; +} + +interface RadiusLoaderProps extends MarginLoaderProps { + height?: string; + width?: string; + radius?: string; +} + +/** + * React components + */ +type PulseLoader = react.Component, {}>; +export const PulseLoader: react.ComponentClass>; + +type RotateLoader = react.Component, {}>; +export const RotateLoader: react.ComponentClass>; + +type BeatLoader = react.Component, {}>; +export const BeatLoader: react.ComponentClass>; + +type RiseLoader = react.Component, {}>; +export const RiseLoader: react.ComponentClass>; + +type SyncLoader = react.Component, {}>; +export const SyncLoader: react.ComponentClass>; + +type GridLoader = react.Component, {}>; +export const GridLoader: react.ComponentClass>; + +type ClipLoader = react.Component; +export const ClipLoader: react.ComponentClass; + +type SquareLoader = react.Component; +export const SquareLoader: react.ComponentClass; + +type DotLoader = react.Component; +export const DotLoader: react.ComponentClass; + +type PacmanLoader = react.Component, {}>; +export const PacmanLoader: react.ComponentClass>; + +type MoonLoader = react.Component; +export const MoonLoader: react.ComponentClass; + +type RingLoader = react.Component; +export const RingLoader: react.ComponentClass; + +type BounceLoader = react.Component; +export const BounceLoader: react.ComponentClass; + +type SkewLoader = react.Component; +export const SkewLoader: react.ComponentClass; + +type FadeLoader = react.Component; +export const FadeLoader: react.ComponentClass; + +type ScaleLoader = react.Component; +export const ScaleLoader: react.ComponentClass; diff --git a/navigation-react/index.d.ts b/navigation-react/index.d.ts index edd9e746f2..131ce29735 100644 --- a/navigation-react/index.d.ts +++ b/navigation-react/index.d.ts @@ -5,89 +5,85 @@ import { StateNavigator } from 'navigation'; import { Component, HTMLProps } from 'react'; -export = NavigationReact; - -declare namespace NavigationReact { +/** + * Defines the Link Props contract + */ +interface LinkProps extends HTMLProps { /** - * Defines the Link Props contract + * Indicates whether Links listen for navigate events */ - interface LinkProps extends HTMLProps { - /** - * Indicates whether Links listen for navigate events - */ - lazy?: boolean; - /** - * Determines the effect on browser history - */ - historyAction?: 'add' | 'replace' | 'none'; - /** - * Handles Link click events - */ - navigating?: (e: MouseEvent, domId: string, link: string) => boolean; - /** - * The State Navigator - */ - stateNavigator?: StateNavigator; - } - + lazy?: boolean; /** - * Defines the Refresh Link Props contract + * Determines the effect on browser history */ - interface RefreshLinkProps extends LinkProps { - /** - * The NavigationData to pass - */ - navigationData?: any; - /** - * Indicates whether to include all the current NavigationData - */ - includeCurrentData?: boolean; - /** - * The data to add from the current NavigationData - */ - currentDataKeys?: string; - /** - * The Css Class to display when the Link is active - */ - activeCssClass?: string; - /** - * Indicates whether the Link is disabled when active - */ - disableActive?: boolean; - } - + historyAction?: 'add' | 'replace' | 'none'; /** - * Hyperlink Component the navigates to the current State + * Handles Link click events */ - class RefreshLink extends Component { } - + navigating?: (e: MouseEvent, domId: string, link: string) => boolean; /** - * Defines the Navigation Link Props contract + * The State Navigator */ - interface NavigationLinkProps extends RefreshLinkProps { - /** - * The key of the State to navigate to - */ - stateKey: string; - } - - /** - * Hyperlink Component the navigates to a State - */ - class NavigationLink extends Component { } - - /** - * Defines the Navigation Back Link Props contract - */ - interface NavigationBackLinkProps extends RefreshLinkProps { - /** - * Starting at 1, The number of Crumb steps to go back - */ - distance: number; - } - - /** - * Hyperlink Component the navigates back along the crumb trail - */ - class NavigationBackLink extends Component { } + stateNavigator?: StateNavigator; } + +/** + * Defines the Refresh Link Props contract + */ +interface RefreshLinkProps extends LinkProps { + /** + * The NavigationData to pass + */ + navigationData?: any; + /** + * Indicates whether to include all the current NavigationData + */ + includeCurrentData?: boolean; + /** + * The data to add from the current NavigationData + */ + currentDataKeys?: string; + /** + * The Css Class to display when the Link is active + */ + activeCssClass?: string; + /** + * Indicates whether the Link is disabled when active + */ + disableActive?: boolean; +} + +/** + * Hyperlink Component the navigates to the current State + */ +export class RefreshLink extends Component { } + +/** + * Defines the Navigation Link Props contract + */ +interface NavigationLinkProps extends RefreshLinkProps { + /** + * The key of the State to navigate to + */ + stateKey: string; +} + +/** + * Hyperlink Component the navigates to a State + */ +export class NavigationLink extends Component { } + +/** + * Defines the Navigation Back Link Props contract + */ +interface NavigationBackLinkProps extends RefreshLinkProps { + /** + * Starting at 1, The number of Crumb steps to go back + */ + distance: number; +} + +/** + * Hyperlink Component the navigates back along the crumb trail + */ +export class NavigationBackLink extends Component { } diff --git a/react-native-fs/index.d.ts b/react-native-fs/index.d.ts index a700005032..934d684a74 100644 --- a/react-native-fs/index.d.ts +++ b/react-native-fs/index.d.ts @@ -5,186 +5,182 @@ /// -declare namespace RNFS { - interface ReadDirItem { - // The name of the item - name: string; - // The absolute path to the item - path: string; - // Size in bytes - size: string; - // Is the file just a file? - isFile(): boolean; - // Is the file a directory? - isDirectory(): boolean; - } - - interface StatResult { - // The name of the item - name: string; - // The absolute path to the item - path: string; - // Size in bytes - size: string; - // UNIX file mode - mode: number; - // Is the file just a file? - isFile(): boolean; - // Is the file a directory? - isDirectory(): boolean; - } - - interface Headers { - [index: string]: string; - } - type Fields = Headers; - - interface MkdirOptions { - // iOS only - NSURLIsExcludedFromBackupKey?: boolean; - } - - interface DownloadResult { - // The download job ID, required if one wishes to cancel the download. See `stopDownload`. - jobId: number; - // The HTTP status code - statusCode: number; - // The number of bytes written to the file - bytesWritten: number; - } - - type DownloadCallbackBegin = (res: DownloadBeginCallbackResult) => void; - type DownloadCallbackProgress = (res: DownloadProgressCallbackResult) => void; - - interface DownloadFileOptions { - // URL to download file from - fromUrl: string; - // Local filesystem path to save the file to - toFile: string; - // An object of headers to be passed to the server - headers?: Headers; - background?: boolean; - progressDivider?: number; - begin?: DownloadCallbackBegin; - progress?: DownloadCallbackProgress; - } - - interface DownloadProgressCallbackResult { - // The download job ID, required if one wishes to cancel the download. See `stopDownload`. - jobId: number; - // The total size in bytes of the download resource - contentLength: number; - // The number of bytes written to the file so far - bytesWritten: number; - } - - interface DownloadBeginCallbackResult { - // The download job ID, required if one wishes to cancel the download. See `stopDownload`. - jobId: number; - // The HTTP status code - statusCode: number; - // The total size in bytes of the download resource - contentLength: number; - // The HTTP response headers from the server - headers: Headers; - } - - type UploadCallbackBegin = (res: UploadBeginCallbackResult) => void; - type UploadCallbackProgress = (res: UploadProgressCallbackResult) => void; - - interface UploadFileOptions { - // URL to upload file to - toUrl: string; - // An array of objects with the file information to be uploaded. - files: UploadFileItem[]; - // An object of headers to be passed to the server - headers?: Headers; - // An object of fields to be passed to the server - fields?: Fields; - // Default is 'POST', supports 'POST' and 'PUT' - method?: string; - begin?: UploadCallbackBegin; - progress?: UploadCallbackProgress; - } - - interface UploadResult { - // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. - jobId: number; - // The HTTP status code - statusCode: number; - // The HTTP response headers from the server - headers: Headers; - // The HTTP response body - body: string; - } - - interface UploadFileItem { - // Name of the file, if not defined then filename is used - name: string; - // Name of file - filename: string; - // Path to file - filepath: string; - // The mimetype of the file to be uploaded, if not defined it will get mimetype from `filepath` extension - filetype: string; - } - - interface UploadBeginCallbackResult { - // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. - jobId: number; - } - - interface UploadProgressCallbackResult { - // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. - jobId: number; - // The total number of bytes that will be sent to the server - totalBytesExpectedToSend: number; - // The number of bytes sent to the server - totalBytesSent: number; - } - - interface FSInfoResult { - // The total amount of storage space on the device (in bytes). - totalSpace: number; - // The amount of available storage space on the device (in bytes). - freeSpace: number; - } - - interface JobReturnValue { - jobId: number; - promise: Promise; - } - - // The absolute path to the main bundle directory - export const MainBundlePath: string; - // The absolute path to the caches directory - export const CachesDirectoryPath: string; - // The absolute path to the document directory - export const DocumentDirectoryPath: string; - // The absolute path to the temporary directory (iOS only) - export const TemporaryDirectoryPath: string; - // The absolute path to the external files, shared directory (android only) - export const ExternalDirectoryPath: string; - // The absolute path to the external storage, shared directory (android only) - export const ExternalStorageDirectoryPath: string; - - export function readDir(path: string): Promise; - export function readdir(path: string): Promise; - export function stat(filepath: string): Promise; - export function readFile(filepath: string, encoding?: string): Promise; - export function unlink(filepath: string): Promise; - export function writeFile(filepath: string, contents: string, encoding?: string): Promise; - export function appendFile(filepath: string, contents: string, encoding?: string): Promise; - export function moveFile(filepath: string, destPath: string): Promise; - export function copyFile(filepath: string, destPath: string): Promise; - export function exists(filepath: string): Promise; - export function hash(filepath: string, algorithm: string): Promise; - export function mkdir(filepath: string, options?: MkdirOptions): Promise; - export function downloadFile(options: DownloadFileOptions): JobReturnValue; - export function stopDownload(jobId: number): Promise; - export function uploadFiles(options: UploadFileOptions): JobReturnValue; - export function stopUpload(jobId: number): Promise; - export function getFSInfo(): Promise; +interface ReadDirItem { + // The name of the item + name: string; + // The absolute path to the item + path: string; + // Size in bytes + size: string; + // Is the file just a file? + isFile(): boolean; + // Is the file a directory? + isDirectory(): boolean; } -export = RNFS; \ No newline at end of file +interface StatResult { + // The name of the item + name: string; + // The absolute path to the item + path: string; + // Size in bytes + size: string; + // UNIX file mode + mode: number; + // Is the file just a file? + isFile(): boolean; + // Is the file a directory? + isDirectory(): boolean; +} + +interface Headers { + [index: string]: string; +} +type Fields = Headers; + +interface MkdirOptions { + // iOS only + NSURLIsExcludedFromBackupKey?: boolean; +} + +interface DownloadResult { + // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; + // The HTTP status code + statusCode: number; + // The number of bytes written to the file + bytesWritten: number; +} + +type DownloadCallbackBegin = (res: DownloadBeginCallbackResult) => void; +type DownloadCallbackProgress = (res: DownloadProgressCallbackResult) => void; + +interface DownloadFileOptions { + // URL to download file from + fromUrl: string; + // Local filesystem path to save the file to + toFile: string; + // An object of headers to be passed to the server + headers?: Headers; + background?: boolean; + progressDivider?: number; + begin?: DownloadCallbackBegin; + progress?: DownloadCallbackProgress; +} + +interface DownloadProgressCallbackResult { + // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; + // The total size in bytes of the download resource + contentLength: number; + // The number of bytes written to the file so far + bytesWritten: number; +} + +interface DownloadBeginCallbackResult { + // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; + // The HTTP status code + statusCode: number; + // The total size in bytes of the download resource + contentLength: number; + // The HTTP response headers from the server + headers: Headers; +} + +type UploadCallbackBegin = (res: UploadBeginCallbackResult) => void; +type UploadCallbackProgress = (res: UploadProgressCallbackResult) => void; + +interface UploadFileOptions { + // URL to upload file to + toUrl: string; + // An array of objects with the file information to be uploaded. + files: UploadFileItem[]; + // An object of headers to be passed to the server + headers?: Headers; + // An object of fields to be passed to the server + fields?: Fields; + // Default is 'POST', supports 'POST' and 'PUT' + method?: string; + begin?: UploadCallbackBegin; + progress?: UploadCallbackProgress; +} + +interface UploadResult { + // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. + jobId: number; + // The HTTP status code + statusCode: number; + // The HTTP response headers from the server + headers: Headers; + // The HTTP response body + body: string; +} + +interface UploadFileItem { + // Name of the file, if not defined then filename is used + name: string; + // Name of file + filename: string; + // Path to file + filepath: string; + // The mimetype of the file to be uploaded, if not defined it will get mimetype from `filepath` extension + filetype: string; +} + +interface UploadBeginCallbackResult { + // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. + jobId: number; +} + +interface UploadProgressCallbackResult { + // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. + jobId: number; + // The total number of bytes that will be sent to the server + totalBytesExpectedToSend: number; + // The number of bytes sent to the server + totalBytesSent: number; +} + +interface FSInfoResult { + // The total amount of storage space on the device (in bytes). + totalSpace: number; + // The amount of available storage space on the device (in bytes). + freeSpace: number; +} + +interface JobReturnValue { + jobId: number; + promise: Promise; +} + +// The absolute path to the main bundle directory +export const MainBundlePath: string; +// The absolute path to the caches directory +export const CachesDirectoryPath: string; +// The absolute path to the document directory +export const DocumentDirectoryPath: string; +// The absolute path to the temporary directory (iOS only) +export const TemporaryDirectoryPath: string; +// The absolute path to the external files, shared directory (android only) +export const ExternalDirectoryPath: string; +// The absolute path to the external storage, shared directory (android only) +export const ExternalStorageDirectoryPath: string; + +export function readDir(path: string): Promise; +export function readdir(path: string): Promise; +export function stat(filepath: string): Promise; +export function readFile(filepath: string, encoding?: string): Promise; +export function unlink(filepath: string): Promise; +export function writeFile(filepath: string, contents: string, encoding?: string): Promise; +export function appendFile(filepath: string, contents: string, encoding?: string): Promise; +export function moveFile(filepath: string, destPath: string): Promise; +export function copyFile(filepath: string, destPath: string): Promise; +export function exists(filepath: string): Promise; +export function hash(filepath: string, algorithm: string): Promise; +export function mkdir(filepath: string, options?: MkdirOptions): Promise; +export function downloadFile(options: DownloadFileOptions): JobReturnValue; +export function stopDownload(jobId: number): Promise; +export function uploadFiles(options: UploadFileOptions): JobReturnValue; +export function stopUpload(jobId: number): Promise; +export function getFSInfo(): Promise; diff --git a/react-test-renderer/index.d.ts b/react-test-renderer/index.d.ts index 59b48f99da..e3c27a057a 100644 --- a/react-test-renderer/index.d.ts +++ b/react-test-renderer/index.d.ts @@ -4,21 +4,18 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ReactElement } from "react"; -declare namespace ReactTestRenderer { - export interface Renderer { - toJSON(): ReactTestRendererJSON; - } - export interface ReactTestRendererJSON { - type: string; - props: { [propName: string]: string }; - children: null | Array; - $$typeof?: any; - } - export interface TestRendererOptions { - createNodeMock: (element: ReactElement) => any; - } - // https://github.com/facebook/react/blob/master/src/renderers/testing/ReactTestMount.js#L155 - export function create(nextElement: ReactElement, options?: TestRendererOptions): Renderer; -} -export = ReactTestRenderer; +interface Renderer { + toJSON(): ReactTestRendererJSON; +} +interface ReactTestRendererJSON { + type: string; + props: { [propName: string]: string }; + children: null | Array; + $$typeof?: any; +} +interface TestRendererOptions { + createNodeMock: (element: ReactElement) => any; +} +// https://github.com/facebook/react/blob/master/src/renderers/testing/ReactTestMount.js#L155 +export function create(nextElement: ReactElement, options?: TestRendererOptions): Renderer; diff --git a/redux-actions/index.d.ts b/redux-actions/index.d.ts index e174683b88..a22a0b41cc 100644 --- a/redux-actions/index.d.ts +++ b/redux-actions/index.d.ts @@ -3,115 +3,112 @@ // Definitions by: Jack Hsu , Alex Gorbatchev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = ReduxActions; export as namespace ReduxActions; -declare namespace ReduxActions { - // FSA-compliant action. - // See: https://github.com/acdlite/flux-standard-action - interface BaseAction { - type: string; - } - - export interface Action extends BaseAction { - payload?: Payload; - error?: boolean; - } - - export interface ActionMeta extends Action { - meta: Meta; - } - - interface ReducerMap { - [actionType: string]: Reducer | ReducerNextThrow; - } - - interface ReducerMapMeta { - [actionType: string]: Reducer | ReducerNextThrow; - } - - interface ReducerNextThrow { - next?(state: State, action: Action): State; - throw?(state: State, action: Action): State; - } - - interface ReducerNextThrowMeta { - next?(state: State, action: ActionMeta): State; - throw?(state: State, action: ActionMeta): State; - } - - type ActionFunctions = ActionFunction0> | ActionFunction1> | ActionFunction2> | ActionFunction3> | ActionFunction4> | ActionFunctionAny>; - - type Reducer = (state: State, action: Action) => State; - - type ReducerMeta = (state: State, action: ActionMeta) => State; - - /** argument inferring borrowed from lodash definitions */ - type ActionFunction0 = () => R; - type ActionFunction1 = (t1: T1) => R; - type ActionFunction2 = (t1: T1, t2: T2) => R; - type ActionFunction3 = (t1: T1, t2: T2, t3: T3) => R; - type ActionFunction4 = (t1: T1, t2: T2, t3: T3, t4: T4) => R; - type ActionFunctionAny = (...args: any[]) => R; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction0 - ): ActionFunction0>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction1 - ): ActionFunction1>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction2 - ): ActionFunction2>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction3 - ): ActionFunction3>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction4 - ): ActionFunction4>; - - export function createAction( - actionType: string - ): ActionFunctionAny>; - - export function createAction( - actionType: string, - payloadCreator: (...args: any[]) => Payload, - metaCreator: (...args: any[]) => Meta - ): (...args: any[]) => ActionMeta; - - export function handleAction( - actionType: string | ActionFunctions, - reducer: Reducer | ReducerNextThrow, - initialState: State - ): Reducer; - - export function handleAction( - actionType: { toString(): string }, - reducer: ReducerMeta | ReducerNextThrowMeta, - initialState: State - ): Reducer; - - export function handleActions( - reducerMap: ReducerMap, - initialState: StateAndPayload - ): Reducer; - - export function handleActions( - reducerMap: ReducerMap, - initialState: State - ): Reducer; - - export function combineActions( - ...actionTypes: Array> - ): Array>; +// FSA-compliant action. +// See: https://github.com/acdlite/flux-standard-action +interface BaseAction { + type: string; } + +interface Action extends BaseAction { + payload?: Payload; + error?: boolean; +} + +interface ActionMeta extends Action { + meta: Meta; +} + +interface ReducerMap { + [actionType: string]: Reducer | ReducerNextThrow; +} + +interface ReducerMapMeta { + [actionType: string]: Reducer | ReducerNextThrow; +} + +interface ReducerNextThrow { + next?(state: State, action: Action): State; + throw?(state: State, action: Action): State; +} + +interface ReducerNextThrowMeta { + next?(state: State, action: ActionMeta): State; + throw?(state: State, action: ActionMeta): State; +} + +type ActionFunctions = ActionFunction0> | ActionFunction1> | ActionFunction2> | ActionFunction3> | ActionFunction4> | ActionFunctionAny>; + +type Reducer = (state: State, action: Action) => State; + +type ReducerMeta = (state: State, action: ActionMeta) => State; + +/** argument inferring borrowed from lodash definitions */ +type ActionFunction0 = () => R; +type ActionFunction1 = (t1: T1) => R; +type ActionFunction2 = (t1: T1, t2: T2) => R; +type ActionFunction3 = (t1: T1, t2: T2, t3: T3) => R; +type ActionFunction4 = (t1: T1, t2: T2, t3: T3, t4: T4) => R; +type ActionFunctionAny = (...args: any[]) => R; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction0 +): ActionFunction0>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction1 +): ActionFunction1>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction2 +): ActionFunction2>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction3 +): ActionFunction3>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction4 +): ActionFunction4>; + +export function createAction( + actionType: string +): ActionFunctionAny>; + +export function createAction( + actionType: string, + payloadCreator: (...args: any[]) => Payload, + metaCreator: (...args: any[]) => Meta +): (...args: any[]) => ActionMeta; + +export function handleAction( + actionType: string | ActionFunctions, + reducer: Reducer | ReducerNextThrow, + initialState: State +): Reducer; + +export function handleAction( + actionType: { toString(): string }, + reducer: ReducerMeta | ReducerNextThrowMeta, + initialState: State +): Reducer; + +export function handleActions( + reducerMap: ReducerMap, + initialState: StateAndPayload +): Reducer; + +export function handleActions( + reducerMap: ReducerMap, + initialState: State +): Reducer; + +export function combineActions( + ...actionTypes: Array> +): Array>; diff --git a/redux-actions/redux-actions-tests.ts b/redux-actions/redux-actions-tests.ts index 237d7fa04f..60923b9f10 100644 --- a/redux-actions/redux-actions-tests.ts +++ b/redux-actions/redux-actions-tests.ts @@ -1,4 +1,4 @@ -import ReduxActions = require("redux-actions"); +import * as ReduxActions from "redux-actions"; let state: number; const minimalAction: ReduxActions.BaseAction = { type: 'INCREMENT' }; diff --git a/redux-batched-actions/index.d.ts b/redux-batched-actions/index.d.ts index 3d3970a0f5..ad90e7d9fd 100644 --- a/redux-batched-actions/index.d.ts +++ b/redux-batched-actions/index.d.ts @@ -3,21 +3,18 @@ // Definitions by: Chad Burggraf // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = ReduxBatchedActions; -export as namespace ReduxBatchedActions; - import { Action, Reducer } from 'redux'; -declare namespace ReduxBatchedActions { - /** - * Batching action creator that creates a higher-order - * action from an array of actions. - */ - export function batchActions(actions: A[]): Action; +export as namespace ReduxBatchedActions; - /** - * Creates a higher-order reducer that enables batching - * actions for the given reducer. - */ - export function enableBatching(reducer: Reducer): Reducer; -} +/** + * Batching action creator that creates a higher-order + * action from an array of actions. + */ +export function batchActions(actions: A[]): Action; + +/** + * Creates a higher-order reducer that enables batching + * actions for the given reducer. + */ +export function enableBatching(reducer: Reducer): Reducer; diff --git a/xsd-schema-validator/index.d.ts b/xsd-schema-validator/index.d.ts index ae321e563b..c4fd02e8f5 100644 --- a/xsd-schema-validator/index.d.ts +++ b/xsd-schema-validator/index.d.ts @@ -5,12 +5,8 @@ /// -declare namespace XsdSchemaValidator { - export function validateXML(xml: string|NodeJS.ReadableStream|{file: string}, pathToXsd: string, callback: (err: Error, result: { - valid: boolean; - messages: string[]; - result: string; - }) => void): void; -} - -export = XsdSchemaValidator; \ No newline at end of file +export function validateXML(xml: string|NodeJS.ReadableStream|{file: string}, pathToXsd: string, callback: (err: Error, result: { + valid: boolean; + messages: string[]; + result: string; +}) => void): void; From a15229fb73d770a3b47c4df693950c935d68476c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Sun, 1 Jan 2017 16:45:22 -0800 Subject: [PATCH 15/45] fs-promise: JSON replacer should be a string --- fs-promise/fs-promise-tests.ts | 8 +++++++- fs-promise/index.d.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs-promise/fs-promise-tests.ts b/fs-promise/fs-promise-tests.ts index 4469ea5c22..a90ae03804 100644 --- a/fs-promise/fs-promise-tests.ts +++ b/fs-promise/fs-promise-tests.ts @@ -6,7 +6,13 @@ var dir: string; var path: string; var data: any; var writeOptions: fs.WriteOptions; -var writeJsonOptions: fs.WriteJsonOptions; +var writeJsonOptions: fs.WriteJsonOptions = { + spaces: 2, + replacer(key, value) { + src = key; + return value; + } +}; var readJsonOptions: fs.ReadJsonOptions; async function test() { diff --git a/fs-promise/index.d.ts b/fs-promise/index.d.ts index 09b6ec4b9c..2038190ca1 100644 --- a/fs-promise/index.d.ts +++ b/fs-promise/index.d.ts @@ -15,7 +15,7 @@ export interface WriteOptions { type JsonReplacerArray = Array; -type JsonReplacerFunction = (key: any, value: any) => any; +type JsonReplacerFunction = (key: string, value: any) => any; type JsonReplacer = JsonReplacerArray | JsonReplacerFunction; From ecf131b26d0a1ed0d1bc4bccc77484c3a6805463 Mon Sep 17 00:00:00 2001 From: Michael Mrowetz Date: Thu, 29 Dec 2016 15:48:49 +0900 Subject: [PATCH 16/45] Add swagger-restify-mw --- swagger-node-runner/index.d.ts | 3 +- .../swagger-node-runner-tests.ts | 17 +++++++ swagger-restify-mw/index.d.ts | 47 +++++++++++++++++++ .../swagger-restify-mw-tests.ts | 43 +++++++++++++++++ swagger-restify-mw/tsconfig.json | 20 ++++++++ swagger-restify-mw/tslint.json | 1 + 6 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 swagger-restify-mw/index.d.ts create mode 100644 swagger-restify-mw/swagger-restify-mw-tests.ts create mode 100644 swagger-restify-mw/tsconfig.json create mode 100644 swagger-restify-mw/tslint.json diff --git a/swagger-node-runner/index.d.ts b/swagger-node-runner/index.d.ts index 13962ccfb8..61880b3f8d 100644 --- a/swagger-node-runner/index.d.ts +++ b/swagger-node-runner/index.d.ts @@ -34,6 +34,7 @@ import { Express, NextFunction } from "express"; import { Spec } from "swagger-schema-official"; import { EventEmitter } from "events"; import * as Hapi from "hapi"; +import * as Restify from "restify"; /** * Config object for SwaggerNodeRunner @@ -258,7 +259,7 @@ export interface HapiMiddleware extends Middleware { /** Restify specific Middleware */ export interface RestifyMiddleware extends Middleware { /** Register this Middleware with `app` */ - register: (app: any) => void; + register: (app: Restify.Server) => void; } diff --git a/swagger-node-runner/swagger-node-runner-tests.ts b/swagger-node-runner/swagger-node-runner-tests.ts index 73306f2f72..04b0f56bb8 100644 --- a/swagger-node-runner/swagger-node-runner-tests.ts +++ b/swagger-node-runner/swagger-node-runner-tests.ts @@ -1,6 +1,7 @@ import * as SwaggerNodeRunner from "swagger-node-runner"; import * as express from "express"; import * as Hapi from "hapi"; +import * as restify from "restify"; let config: SwaggerNodeRunner.Config = { appRoot: __dirname @@ -45,6 +46,22 @@ SwaggerNodeRunner.create(config, function(err, runner) { }); +// Restify Middelware + +let app = restify.createServer(); +SwaggerNodeRunner.create(config, function(err, runner) { +// SwaggerRestify.create(config, function(err, swaggerRestify) { + if (err) { throw err; } + + let restifyMiddelware = runner.restifyMiddleware() + + restifyMiddelware.register(app); + + let port = process.env.PORT || 10010; + app.listen(port); +}); + + let swaggerSecurityHandlerCb = (err: Error) => { //do nothing }; diff --git a/swagger-restify-mw/index.d.ts b/swagger-restify-mw/index.d.ts new file mode 100644 index 0000000000..c9518b2ecb --- /dev/null +++ b/swagger-restify-mw/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for swagger-restify-mw 0.7 +// Project: https://github.com/apigee-127/swagger-restify#readme +// Definitions by: Michael Mrowetz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* =================== USAGE =================== +import * as SwaggerRestify from "swagger-restify-mw"; +import * as restify from "restify"; + +let app = restify.createServer(); + +let config = { + appRoot: __dirname // required config +} as SwaggerRestify.Config; + +SwaggerRestify.create(config, function(err, swaggerRestify) { + if (err) { throw err; } + + swaggerRestify.register(app); + + let port = process.env.PORT || 10010; + app.listen(port); + + if (swaggerRestify.runner.swagger.paths['/hello']) { + console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott'); + } +}); + + =============================================== */ + +import { Config, RestifyMiddleware } from "swagger-node-runner"; + +/** export interfaces */ +export { Config, RestifyMiddleware } from "swagger-node-runner"; + +/** + * Create a new instance of a Restify specific `SwaggerNodeRunner` middleware + * + * The `swagger-node-runner` module has the following config priority: + * 1. `swagger_*` environment vars + * 2. `config` passed to `create()` + * 3. read from swagger node in `default.yaml` in config directory + * 4. module defaults + * + * @see @link{https://github.com/apigee-127/swagger-express|Github} + */ +export function create(config: Config, cb: (err: Error | undefined, middleware: RestifyMiddleware) => void): void; diff --git a/swagger-restify-mw/swagger-restify-mw-tests.ts b/swagger-restify-mw/swagger-restify-mw-tests.ts new file mode 100644 index 0000000000..02053c12ea --- /dev/null +++ b/swagger-restify-mw/swagger-restify-mw-tests.ts @@ -0,0 +1,43 @@ +import * as SwaggerRestify from "swagger-restify-mw"; +import * as restify from "restify"; + +let app = restify.createServer(); + +let config = { + appRoot: __dirname // required config +} as SwaggerRestify.Config; + +SwaggerRestify.create(config, function(err, swaggerRestify) { + if (err) { throw err; } + + swaggerRestify.register(app); + + let port = process.env.PORT || 10010; + app.listen(port); + + // if (swaggerRestify.runner.swagger.paths['/hello']) { + // console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott'); + // } +}); + + +let swaggerSecurityHandlerCb = (err: Error) => { + //do nothing +}; + + +let configComplex: SwaggerRestify.Config = { + appRoot: __dirname, + configDir: "some/directory", + controllersDirs: ["some/directory"], + fittingsDirs: ["some/directory"], + mockMode: true, + swaggerControllerPipe: 'swagger_controllers', + swaggerSecurityHandlers: { + // did not manage to research the typings of first 3 arguments + someHandlerName: ({}, {}, {}, swaggerSecurityHandlerCb) => { + //do nothing + } + }, + validateResponse: true +}; diff --git a/swagger-restify-mw/tsconfig.json b/swagger-restify-mw/tsconfig.json new file mode 100644 index 0000000000..373744af7c --- /dev/null +++ b/swagger-restify-mw/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "swagger-restify-mw-tests.ts" + ] +} diff --git a/swagger-restify-mw/tslint.json b/swagger-restify-mw/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/swagger-restify-mw/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3a5dcccaab6bfc5bd2b8a1eac0af84f62fac0082 Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Sun, 1 Jan 2017 17:34:25 -0800 Subject: [PATCH 17/45] add npm gaussian --- gaussian/gaussian-tests.ts | 14 ++++++++ gaussian/index.d.ts | 65 ++++++++++++++++++++++++++++++++++++++ gaussian/tsconfig.json | 19 +++++++++++ gaussian/tslint.json | 1 + 4 files changed, 99 insertions(+) create mode 100644 gaussian/gaussian-tests.ts create mode 100644 gaussian/index.d.ts create mode 100644 gaussian/tsconfig.json create mode 100644 gaussian/tslint.json diff --git a/gaussian/gaussian-tests.ts b/gaussian/gaussian-tests.ts new file mode 100644 index 0000000000..ecb733eab1 --- /dev/null +++ b/gaussian/gaussian-tests.ts @@ -0,0 +1,14 @@ +const d = gaussian(0, 1); +const _ = d.mean !== d.variance; +const __ = d.mean * d.standardDeviation; +d.pdf(-2); +d.cdf(-1.28155); +d.ppf(0.1); + +gaussian(0, 1).mul(gaussian(0, 1)); +gaussian(1, 1).mul(2); +gaussian(1, 1).add(gaussian(1, 2)); +gaussian(1, 1).sub(gaussian(1, 2)); +gaussian(1, 1).div(gaussian(1, 2)); +gaussian(1, 1).div(2); +gaussian(1, 1).scale(2); diff --git a/gaussian/index.d.ts b/gaussian/index.d.ts new file mode 100644 index 0000000000..1da491c0ed --- /dev/null +++ b/gaussian/index.d.ts @@ -0,0 +1,65 @@ +// Type definitions for gaussian 1.1.0 +// Project: https://github.com/errcw/gaussian +// Definitions by: Scott Cooper +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function gaussian(mean: number, variance: number): gaussian.Gaussian; + +export = gaussian; +export as namespace gaussian; + +declare namespace gaussian { + export interface Gaussian { + /** + * the mean (μ) of the distribution + */ + mean: number; + /** + * the variance (σ^2) of the distribution + */ + variance: number; + /** + * the standard deviation (σ) of the distribution + */ + standardDeviation: number; + /** + * the probability density function, which describes the + * probability of a random variable taking on the value x + */ + pdf(x: number): number; + /** + * the cumulative distribution function, which describes the + * probability of a random variable falling in the interval (−∞, x] + */ + cdf(x: number): number; + /** + * the percent point function, the inverse of cdf + */ + ppf(x: number): number; + /** + * returns the product distribution of this and the given + * distribution; equivalent to scale(d) when d is a constant + */ + mul(x: number | Gaussian): number; + /** + * returns the quotient distribution of this and the given + * distribution; equivalent to scale(1/d) when d is a constant + */ + div(x: number | Gaussian): number; + /** + * returns the result of adding this and the given + * distribution's means and variances + */ + add(x: Gaussian): number; + /** + * returns the result of subtracting this and the given + * distribution's means and variances + */ + sub(x: Gaussian): number; + /** + * returns the result of scaling this distribution by the + * given constant + */ + scale(x: number): number; + } +} diff --git a/gaussian/tsconfig.json b/gaussian/tsconfig.json new file mode 100644 index 0000000000..e09dded027 --- /dev/null +++ b/gaussian/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gaussian-tests.ts" + ] +} diff --git a/gaussian/tslint.json b/gaussian/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/gaussian/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 5ab553291508b349723e733f83c63dd2c9119cec Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Sun, 1 Jan 2017 17:39:29 -0800 Subject: [PATCH 18/45] use MAJOR.MINOR --- gaussian/gaussian-tests.ts | 4 ++-- gaussian/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gaussian/gaussian-tests.ts b/gaussian/gaussian-tests.ts index ecb733eab1..74c6cc714b 100644 --- a/gaussian/gaussian-tests.ts +++ b/gaussian/gaussian-tests.ts @@ -1,6 +1,6 @@ const d = gaussian(0, 1); -const _ = d.mean !== d.variance; -const __ = d.mean * d.standardDeviation; +const a = d.mean !== d.variance; +const b = d.mean * d.standardDeviation; d.pdf(-2); d.cdf(-1.28155); d.ppf(0.1); diff --git a/gaussian/index.d.ts b/gaussian/index.d.ts index 1da491c0ed..f0012597cb 100644 --- a/gaussian/index.d.ts +++ b/gaussian/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for gaussian 1.1.0 +// Type definitions for gaussian 1.1 // Project: https://github.com/errcw/gaussian // Definitions by: Scott Cooper // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From a785cc706516e662c43ce71ed0307ee7451ed078 Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Sun, 1 Jan 2017 17:52:12 -0800 Subject: [PATCH 19/45] add no implicit this and import statement to tests --- gaussian/gaussian-tests.ts | 2 ++ gaussian/tsconfig.json | 1 + 2 files changed, 3 insertions(+) diff --git a/gaussian/gaussian-tests.ts b/gaussian/gaussian-tests.ts index 74c6cc714b..bd2a226e88 100644 --- a/gaussian/gaussian-tests.ts +++ b/gaussian/gaussian-tests.ts @@ -1,3 +1,5 @@ +import * as gaussian from "."; + const d = gaussian(0, 1); const a = d.mean !== d.variance; const b = d.mean * d.standardDeviation; diff --git a/gaussian/tsconfig.json b/gaussian/tsconfig.json index e09dded027..f76c6bacc2 100644 --- a/gaussian/tsconfig.json +++ b/gaussian/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, + "noImplicitThis": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ From 9e55cea805dc39b73f9ac8e701a30b910feea294 Mon Sep 17 00:00:00 2001 From: Michael Mrowetz Date: Mon, 2 Jan 2017 15:02:16 +0900 Subject: [PATCH 20/45] remove commented line --- swagger-node-runner/swagger-node-runner-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/swagger-node-runner/swagger-node-runner-tests.ts b/swagger-node-runner/swagger-node-runner-tests.ts index 04b0f56bb8..2d20ad21c8 100644 --- a/swagger-node-runner/swagger-node-runner-tests.ts +++ b/swagger-node-runner/swagger-node-runner-tests.ts @@ -50,7 +50,6 @@ SwaggerNodeRunner.create(config, function(err, runner) { let app = restify.createServer(); SwaggerNodeRunner.create(config, function(err, runner) { -// SwaggerRestify.create(config, function(err, swaggerRestify) { if (err) { throw err; } let restifyMiddelware = runner.restifyMiddleware() From cb285bff597f667ea973d9a78f42a70feb89fc31 Mon Sep 17 00:00:00 2001 From: Michael Mrowetz Date: Mon, 2 Jan 2017 15:23:51 +0900 Subject: [PATCH 21/45] remove commented out code --- swagger-restify-mw/swagger-restify-mw-tests.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/swagger-restify-mw/swagger-restify-mw-tests.ts b/swagger-restify-mw/swagger-restify-mw-tests.ts index 02053c12ea..c8bd436c7c 100644 --- a/swagger-restify-mw/swagger-restify-mw-tests.ts +++ b/swagger-restify-mw/swagger-restify-mw-tests.ts @@ -14,10 +14,6 @@ SwaggerRestify.create(config, function(err, swaggerRestify) { let port = process.env.PORT || 10010; app.listen(port); - - // if (swaggerRestify.runner.swagger.paths['/hello']) { - // console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott'); - // } }); From bdc896651ebd8a0397f05f82769e92e272069e93 Mon Sep 17 00:00:00 2001 From: stonio Date: Mon, 2 Jan 2017 17:28:44 +0100 Subject: [PATCH 22/45] add maxFileSize --- jquery.fileupload/index.d.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jquery.fileupload/index.d.ts b/jquery.fileupload/index.d.ts index f34325ad8b..8eba9853b2 100644 --- a/jquery.fileupload/index.d.ts +++ b/jquery.fileupload/index.d.ts @@ -213,6 +213,18 @@ interface JQueryFileInputOptions { progress?: (e: JQueryEventObject, data: JQueryFileUploadProgressObject) => void; send?: (e: JQueryEventObject, data: JQueryFileUploadProgressObject) => void; + // Validation + + /** + * The maximum allowed file size in bytes. + * Type: integer + * Default: undefined + * Example: 10000000 // 10 MB + * Note: This option has only an effect for browsers supporting the File API. + * @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options#maxfilesize + */ + maxFileSize?: number; + // Other callbacks: submit?: Function; done?: (e: JQueryEventObject, data: JQueryFileUploadDone) => void; @@ -289,4 +301,4 @@ interface JQueryFileUploadProgressObject extends JQueryFileInputOptions, JQueryF } interface JQueryFileUploadDone extends JQueryFileInputOptions, JQueryFileUploadXhr { -} \ No newline at end of file +} From d6aea41f4dc72845ae966bdca05871520195c473 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Jan 2017 12:22:10 -0500 Subject: [PATCH 23/45] Added declarations for 'react-joyride'. (#13675) --- react-joyride/index.d.ts | 173 ++++++++++++++++++++++++++ react-joyride/react-joyride-tests.tsx | 55 ++++++++ react-joyride/tsconfig.json | 21 ++++ react-joyride/tslint.json | 1 + 4 files changed, 250 insertions(+) create mode 100644 react-joyride/index.d.ts create mode 100644 react-joyride/react-joyride-tests.tsx create mode 100644 react-joyride/tsconfig.json create mode 100644 react-joyride/tslint.json diff --git a/react-joyride/index.d.ts b/react-joyride/index.d.ts new file mode 100644 index 0000000000..3e8e1e58ed --- /dev/null +++ b/react-joyride/index.d.ts @@ -0,0 +1,173 @@ +// Type definitions for react-joyride 1.6 +// Project: https://github.com/gilbarbara/react-joyride +// Definitions by: Daniel Rosenwasser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import React = require("react"); + +export default class Joyride extends React.Component { + constructor(props: Props); + + addTooltip(data: Step): void; + start(autorun?: boolean): void; + next(): void; + back(): void; + stop(): void; + reset(restart: boolean): void; + + getProgress(): Progress; + parseSteps(steps: Step | Step[]): Step[]; + + static defaultProps: Props; +} + +export interface Progress { + index: number; + percentageComplete: number; + step: Step; +} + +interface Locale { + back?: string; + close?: string; + last?: string; + next?: string; + skip?: string; +} + +interface Props { + /** + * The tour's steps. Defaults to [] + */ + steps?: any[]; + + /** + * Run/stop the tour. + */ + run?: boolean; + + /** + * Toggle keyboard navigation (esc, space bar, return). Defaults to true + */ + keyboardNavigation?: boolean; + + /** + * The strings used in the tooltip. Defaults to `{ back: 'Back', close: 'Close', last: 'Last', next: 'Next', skip: 'Skip' }` + */ + locale?: Locale; + + /** + * Delay the reposition of the current step while the window is being resized. Defaults to false + */ + resizeDebounce?: boolean; + + /** + * The amount of delay for the resizeDebounce callback. Defaults to 200 + */ + resizeDebounceDelay?: number; + + /** + * The gap around the target inside the hole. Defaults to 5 + */ + holePadding?: number; + + /** + * The scrollTop offset used in scrollToSteps. Defaults to 20 + */ + scrollOffset?: number; + + /** + * Scroll the page to the next step if needed. Defaults to true + */ + scrollToSteps?: boolean; + + /** + * Scroll the page for the first step. Defaults to false + */ + scrollToFirstStep?: boolean; + + /** + * Display a back button. Defaults to true + */ + showBackButton?: boolean; + + /** + * Display an overlay with holes above your steps (for tours only). Defaults to true + */ + showOverlay?: boolean; + + /** + * Display a link to skip the tour. Defaults to false + */ + showSkipButton?: boolean; + + /** + * Display the tour progress in the next button e.g. 2/5 in continuous tours. Defaults to false + */ + showStepsProgress?: boolean; + + /** + * The tooltip offset from the target. Defaults to 30 + */ + tooltipOffset?: number; + + /** + * The type of your presentation. It can be continuous (played sequencially with the Next button) or single. Defaults to single + */ + type?: "continuous" | "single"; + + /** + * Don't close the tooltip on clicking the overlay. Defaults to false + */ + disableOverlay?: boolean; + + /** + * Console.log Joyride's inner actions. Defaults to false + */ + debug?: boolean; + + /** + * It will be called when the tour's state changes. + */ + callback?: (options: any) => void; +} + +export interface Step { + title?: string; + text: string; + selector: string; + position?: "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "right" | "left"; + type?: "click" | "hover"; + style?: StepStyles; + [prop: string]: any; +} + +export interface StepStyles { + backgroundColor?: string; + borderRadius?: string; + color?: string; + mainColor?: string; + textAlign?: string; + width?: string; + beacon?: BeaconStyles; + [style: string]: any; +} + +export interface BeaconStyles { + offsetX?: number; + offsetY?: number; + inner?: string; + outer?: string; +} + +export interface State { + action: string; + index: number; + play: boolean; + redraw: boolean; + shouldPlay: boolean; + showTooltip: boolean; + xPos: number; + yPos: number; + skipped: boolean; +} diff --git a/react-joyride/react-joyride-tests.tsx b/react-joyride/react-joyride-tests.tsx new file mode 100644 index 0000000000..8ff818637d --- /dev/null +++ b/react-joyride/react-joyride-tests.tsx @@ -0,0 +1,55 @@ +import React = require("react"); +import Joyride from "react-joyride"; + +class NewComponent extends React.Component { + j: Joyride; + + render() { + return ; + } + + doStuff() { + this.j.start(/*autorun*/ true); + + this.j.next(); + + this.j.reset(true); + this.j.reset(false); + + const { title, position } = this.j.getProgress().step; + + this.j.parseSteps({ + title: "Title", + text: "Hurray", + selector: ".selectable", + position: "top-right", + type: "click", + style: { + backgroundColor: "#000", + borderRadius: "0", + color: "#000", + mainColor: "#fff", + textAlign: "left", + width: "2px", + beacon: { + offsetX: 10, + offsetY: 10, + inner: "#000", + outer: "#000" + }, + button: { + display: "block" + }, + skip: { + color: "#000" + }, + hole: { + backgroundColor: "#000", + } + }, + name: "my-name", + parent: "MyParent" + }) + } +} + diff --git a/react-joyride/tsconfig.json b/react-joyride/tsconfig.json new file mode 100644 index 0000000000..d6f9b9ea2e --- /dev/null +++ b/react-joyride/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "jsx": "preserve", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-joyride-tests.tsx" + ] +} diff --git a/react-joyride/tslint.json b/react-joyride/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-joyride/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From e91fc673f7eea32476fdf0d5661ea003678c7deb Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 2 Jan 2017 10:00:13 -0800 Subject: [PATCH 24/45] d3-selection: Combine "insert" signatures (#13666) --- d3-selection/index.d.ts | 73 ++++++++++------------------------------- 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/d3-selection/index.d.ts b/d3-selection/index.d.ts index 44bf64c0e0..65703f66ff 100644 --- a/d3-selection/index.d.ts +++ b/d3-selection/index.d.ts @@ -503,63 +503,24 @@ interface Selection(type: string, before: string): Selection; - /** - * Inserts a new element of the type provided by the element creator function before the element matching the specified "before" - * selector string for each selected element. - * - * This method returns a new selection containing the appended elements. - * Each new element inherits the data of the current elements, if any. - * - * The generic refers to the type of the child element to be appended. - * - * @param type A creator function which is evaluated for each selected element, in order, being passed the current datum (d), - * the current index (i), and the current group (nodes), with this as the current DOM element. This function should return - * an element to be inserted. (The function typically creates a new element, but it may instead return an existing element.) - * @param before A CSS selector string for the element before which the insertion should occur. - */ - insert(type: ValueFn, before: string): Selection; - /** - * Inserts a new element of the specified type (tag name) before the element returned by the "before" child selector function - * for each selected element. - * - * This method returns a new selection containing the appended elements. - * Each new element inherits the data of the current elements, if any. - * - * The generic refers to the type of the child element to be appended. - * - * @param type A string representing the tag name for the element type to be inserted. The specified name may have a namespace prefix, - * such as svg:text to specify a text attribute in the SVG namespace. If no namespace is specified, the namespace will be inherited - * from the parent element; or, if the name is one of the known prefixes, the corresponding namespace will be used - * (for example, svg implies svg:svg) - * @param before A child selector function which is evaluated for each selected element, in order, being passed the current datum (d), - * the current index (i), and the current group (nodes), with this as the current DOM element. This function should return the child element - * before which the element should be inserted. - */ - insert(type: string, before: ValueFn): Selection; - /** - * Inserts a new element of the type provided by the element creator function before the element returned by the "before" child selector function - * for each selected element. - * - * This method returns a new selection containing the appended elements. - * Each new element inherits the data of the current elements, if any. - * - * The generic refers to the type of the child element to be appended. - * - * @param type A creator function which is evaluated for each selected element, in order, being passed the current datum (d), - * the current index (i), and the current group (nodes), with this as the current DOM element. This function should return - * an element to be inserted. (The function typically creates a new element, but it may instead return an existing element.) - * @param before A child selector function which is evaluated for each selected element, in order, being passed the current datum (d), - * the current index (i), and the current group (nodes), with this as the current DOM element. This function should return the child element - * before which the element should be inserted. - */ - insert(type: ValueFn, before: ValueFn): Selection; + insert( + type: string | ValueFn, + before: string | ValueFn + ): Selection; /** * Removes the selected elements from the document. From 1ca23b1980fd458b681e169d36fb56dbbdd7ea40 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 2 Jan 2017 14:05:54 -0800 Subject: [PATCH 25/45] chokidar: Change event type to `string` (#13572) --- chokidar/chokidar-tests.ts | 30 ++++++++++++++++++------------ chokidar/index.d.ts | 3 ++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/chokidar/chokidar-tests.ts b/chokidar/chokidar-tests.ts index 9ff862789d..a67638e927 100644 --- a/chokidar/chokidar-tests.ts +++ b/chokidar/chokidar-tests.ts @@ -9,20 +9,25 @@ var watcher = chokidar.watch('file, dir, or glob', { var log = console.log.bind(console); +let str: string; +let any: any; +let stats: fs.Stats; + watcher - .on('add', function(path:string) { log('File', path, 'has been added'); }) - .on('addDir', function(path:string) { log('Directory', path, 'has been added'); }) - .on('change', function(path:string) { log('File', path, 'has been changed'); }) - .on('unlink', function(path:string) { log('File', path, 'has been removed'); }) - .on('unlinkDir', function(path:string) { log('Directory', path, 'has been removed'); }) - .on('error', function(error:any) { log('Error happened', error); }) - .on('ready', function() { log('Initial scan complete. Ready for changes.'); }) - .on('raw', function(event:Event, path:string, details:any) { log('Raw event info:', event, path, details); }) + .on('add', path => { str = path; }) + .on('addDir', path => { str = path; }) + .on('change', path => { str = path; }) + .on('unlink', path => { str = path; }) + .on('unlinkDir', path => { str = path; }) + .on('error', (error) => { any = error; }) + .on('ready', () => { }) + .on('raw', (event, path, details) => { str = event; str = path; any = details; }) // 'add', 'addDir' and 'change' events also receive stat() results as second // argument when available: http://nodejs.org/api/fs.html#fs_class_fs_stats -watcher.on('change', function(path:string, stats:fs.Stats) { - if (stats) console.log('File', path, 'changed size to', stats.size); +watcher.on('change', (path, _stats) => { + str = path; + stats = _stats; }); // Watch new files. @@ -36,6 +41,7 @@ watcher.unwatch('new-file*'); watcher.close(); // One-liner -require('chokidar').watch('.', {ignored: /[\/\\]\./}).on('all', function(event:string, path:string) { - console.log(event, path); +chokidar.watch('.', {ignored: /[\/\\]\./}).on('all', (event, path) => { + str = event; + str = path; }); \ No newline at end of file diff --git a/chokidar/index.d.ts b/chokidar/index.d.ts index 2fcfb22eaa..ab37a73948 100644 --- a/chokidar/index.d.ts +++ b/chokidar/index.d.ts @@ -18,7 +18,8 @@ declare module "chokidar" on(event: 'add', fn: (path: string, stats?: fs.Stats) => void): this; on(event: 'change', fn: (path: string, stats?: fs.Stats) => void): this; on(event: 'unlink', fn: (path: string) => void): this; - on(event: 'raw', fn: (event: Event, path:string, details:any) => void): this; + on(event: 'raw', fn: (event: string, path:string, details:any) => void): this; + on(event: 'all', fn: (event: string, path: string) => void): this; on(event: string, fn: (path: string) => void): this; close(): this; } From 011656404fade24f845bea4d9e9257415ed306f4 Mon Sep 17 00:00:00 2001 From: Dolphin Wood Date: Tue, 3 Jan 2017 07:18:07 +0900 Subject: [PATCH 26/45] [service_worker_api] remove fetch API interfaces and add new APIs (#13664) * [service_worker_api] remove interfaces of fetch api resolve #12476, #12582 * [service_worker_api]: add missing api * [service_worker_api]: add event interfaces * [service_worker_api]: add `readonly` modifier * [sercive_worker_api]: update `onmessage` interface make `ServiceWorkerGlobalScope` interface compatible with `Window` * [service_worker_api]: update tests * [service_worker_api]: fix compilation * [service_worker_api]: use ts2.1 * [service_worker_api]: fix header comments * [service_worker_api]: fix reference with `types=...` * [service_worker_api]: add lints * [service_worker_api]: fix lint issues * [service_worker_api]: add reference to `whatwg-fetch` * [service_worker_api]: fix jsdoc annotations * [service_worker_api]: remove unnecessay comment * [service_worker_api]: add version 0.0 --- service_worker_api/index.d.ts | 688 +++++++----------- service_worker_api/service_worker_api-test.ts | 35 +- service_worker_api/tslint.json | 3 + 3 files changed, 287 insertions(+), 439 deletions(-) create mode 100644 service_worker_api/tslint.json diff --git a/service_worker_api/index.d.ts b/service_worker_api/index.d.ts index b688719d34..715fc4efbe 100644 --- a/service_worker_api/index.d.ts +++ b/service_worker_api/index.d.ts @@ -1,244 +1,10 @@ -// Type definitions for service_worker_api +// Type definitions for service_worker_api 0.0 // Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API // Definitions by: Tristan Caron // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.1 -// // REMOVED third "/" so this doesn't fire. Problem with duplicate Promises -// between es6 and typescript - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/5015 - -/** - * Provides methods relating to the body of the response/request, allowing you - * to declare what its content type is and how it should be handled. - */ -interface Body { - /** - * Contains a Boolean that indicates whether the body has been read. - * @readonly - */ - bodyUsed: boolean; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with an ArrayBuffer. - */ - arrayBuffer(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a Blob. - */ - blob(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a FormData object. - */ - formData(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a JSON object. - */ - json(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a USVString (text). - */ - text(): Promise; - -} - -/** - * Represents response/request headers, allowing you to query them and take - * different actions depending on the results. - */ -interface Header { - new(): Header; - - /** - * Appends a new value onto an existing header inside a Headers object, or - * adds the header if it does not already exist. - * - * @param name The name of the HTTP header you want to add to the Headers - * object. - * @param value The value of the HTTP header you want to add. - */ - append(name: string, value: string): void; - - /** - * Deletes a header from a Headers object. - * - * @param name The name of the HTTP header you want to delete from the - * Headers object. - */ - delete(name: string): void; - - /** - * Returns the first value of a given header from within a Headers object. - * - * @param name The name of the HTTP header whose value you want to retrieve - * from the Headers object. If the given name is not the name of an - * HTTP header, this method throws a TypeError. - */ - get(name: string): string; - - /** - * Returns an array of all the values of a header within a Headers object - * with a given name. - * - * @param name The name of the HTTP header whose values you want to retrieve - * from the Headers object. If the given name is not the name of an - * HTTP header, this method throws a TypeError. - */ - getAll(name:string): Array; - - /** - * Returns a boolean stating whether a Headers object contains a - * certain header. - * - * @param name The name of the HTTP header you want to test for. If the - * given name is not the name of an HTTP header, this method throws - * a TypeError. - */ - has(name: string): boolean; - - /** - * Sets a new value for an existing header inside a Headers object, or - * adds the header if it does not already exist. - * - * @param name The name of the HTTP header you want to set to a new value. - * If the given name is not the name of an HTTP header, this method throws - * a TypeError. - * @param value The new value you want to set. - */ - set(name: string, value: string): void; -} - -/** - * Represents the response to a request. - */ -interface Response extends Body { - new(): Response; - - /** - * Contains the type of the response (e.g., basic, cors). - * @readonly - */ - type: string; - - /** - * Contains the URL of the response. - * @readonly - */ - url: string; - - /** - * Contains a boolean stating whether this is the final URL of the response. - */ - useFinalURL: boolean; - - /** - * Contains the status code of the response (e.g., 200 for a success). - * @readonly - */ - status: number; - - /** - * Contains a boolean stating whether the response was successful - * (status in the range 200-299) or not. - * @readonly - */ - ok: boolean; - - /** - * Contains the status message corresponding to the status code - * (e.g., OK for 200). - * @readonly - */ - statusText: string; - - /** - * Contains the Headers object associated with the response. - * @readonly - */ - headers: Header; - - /** - * Creates a clone of a Response object. - */ - clone(): Response; - - /** - * Returns a new Response object associated with a network error. - */ - error(): Response; - - /** - * Creates a new response with a different URL. - */ - redirect(): Response; -} - -/** - * Represents a resource request. - */ -interface Request extends Body { - new(): Request; - - /** - * Contains the request's method (GET, POST, etc.). - * @readonly - */ - method: string; - - /** - * Contains the URL of the request. - * @readonly - */ - url: string; - - /** - * Contains the associated Headers object of the request. - * @readonly - */ - headers: Header; - - /** - * Contains the context of the request (e.g., audio, image, iframe, etc.). - * @readonly - */ - context: string; - - /** - * Contains the referrer of the request (e.g., client). - * @readonly - */ - referrer: string; - - /** - * Contains the mode of the request (e.g., cors, no-cors, same-origin). - * @readonly - */ - mode: string; - - /** - * Contains the credentials of the request (e.g., omit, same-origin). - * @readonly - */ - credentials: string; - - /** - * Contains the cache mode of the request (e.g., default, reload, no-cache). - * @readonly - */ - cache: string; - - /** - * Creates a copy of the current Request object. - */ - clone(): Request; -} +/// /** * An CacheOptions object allowing you to set specific control options for the @@ -278,7 +44,7 @@ interface Cache { * matching request in the Cache object. * * @param request The Request you are attempting to find in the Cache. - * @param {CacheOptions} options + * @param [options] An object that sets options for the match operation. */ match(request: Request | string, options?: CacheOptions): Promise; @@ -287,9 +53,9 @@ interface Cache { * the Cache object. * * @param request The Request you are attempting to find in the Cache. - * @param {CacheOptions} options + * @param [options] An object that sets options for the match operation. */ - matchAll(request: Request | string, options?: CacheOptions): Promise>; + matchAll(request: Request | string, options?: CacheOptions): Promise; /** * Returns a Promise that resolves to a new Cache entry whose key @@ -321,7 +87,7 @@ interface Cache { * entry is found, it returns false. * * @param request The Request you are looking to delete. - * @param {CacheOptions} options + * @param [options] An object that sets options for the match operation. */ delete(request: Request | string, options?: CacheOptions): Promise; @@ -329,9 +95,9 @@ interface Cache { * Returns a Promise that resolves to an array of Cache keys. * * @param request The Request want to return, if a specific key is desired. - * @param {CacheOptions} options + * @param [options] An object that sets options for the match operation. */ - keys(request?: Request, options?: CacheOptions): Promise>; + keys(request?: Request, options?: CacheOptions): Promise; } /** @@ -346,7 +112,7 @@ interface CacheStorage { * to that match. * * @param request The Request you are looking for a match for in the CacheStorage. - * @param {CacheOptions} options + * @param [options] An object that sets options for the match operation. */ match(request: Request | string, options?: CacheOptions): Promise; @@ -382,7 +148,7 @@ interface CacheStorage { * CacheStorage. Use this method to iterate over a list of all the * Cache objects. */ - keys(): Promise>; + keys(): Promise; } /** @@ -398,26 +164,23 @@ interface ServiceWorkerClient { * @param [transfer] A transferable object such as, for example, a reference * to a port. */ - postMessage(message: string, transfer?: Object): void; + postMessage(message: any, transfer?: any): void; /** * Indicates the type of browsing context of the current client. * This value can be one of auxiliary, top-level, nested, or none. - * @readonly */ - frameType: string; + readonly frameType: string; /** * Returns the id of the Client object. - * @readonly */ - id: string; + readonly id: string; /** * The URL of the current service worker client. - * @readonly */ - url: string; + readonly url: string; } interface WindowClient extends ServiceWorkerClient { @@ -428,16 +191,14 @@ interface WindowClient extends ServiceWorkerClient { /** * A boolean that indicates whether the current client has focus. - * @readonly */ - focused: boolean; + readonly focused: boolean; /** * Indicates the visibility of the current client. This value can be one of * hidden, visible, prerender, or unloaded. - * @readonly */ - visibilityState: string; + readonly visibilityState: string; } interface ServiceWorkerClientsMatchOptions { @@ -450,6 +211,12 @@ interface ServiceWorkerClientsMatchOptions { * the active service worker clients at the current origin. */ interface ServiceWorkerClients { + /** + * Gets a service worker client matching a given id and returns it in a Promise. + * @param clientId The ID of the client you want to get. + */ + get(clientId: string): Promise; + /** * Gets a list of service worker clients and returns them in a Promise. * Include the options parameter to return all service worker clients whose @@ -457,9 +224,9 @@ interface ServiceWorkerClients { * are not included, the method returns only the service worker clients * controlled by the service worker. * - * @param options + * @param [options] An options object allowing you to set options for the matching operation. */ - matchAll(options: ServiceWorkerClientsMatchOptions): Promise>; + matchAll(options?: ServiceWorkerClientsMatchOptions): Promise; /** * Opens a service worker Client in a new browser window. @@ -476,62 +243,6 @@ interface ServiceWorkerClients { claim(): Promise; } -/** - * Extends the lifetime of the install and activate events dispatched on the - * ServiceWorkerGlobalScope as part of the service worker lifecycle. This - * ensures that any functional events (like FetchEvent) are not dispatched to - * the ServiceWorker until it upgrades database schemas, deletes outdated cache - * entries, etc. - */ -interface ExtendableEvent extends Event { - /** - * Extends the lifetime of the event. - * It is intended to be called in the install EventHandler for the - * installing worker and on the active EventHandler for the active worker. - * - * @param all - */ - waitUntil(all: any): any; -} - -/** - * The parameter passed into the ServiceWorkerGlobalScope.onfetch handler, - * FetchEvent represents a fetch action that is dispatched on the - * ServiceWorkerGlobalScope of a ServiceWorker. It contains information about - * the request and resulting response, and provides the FetchEvent.respondWith() - * method, which allows us to provide an arbitrary response back to the - * controlled page. - */ -interface FetchEvent extends Event { - /** - * Returns a Boolean that is true if the event was dispatched with the - * user's intention for the page to reload, and false otherwise. Typically, - * pressing the refresh button in a browser is a reload, while clicking a - * link and pressing the back button is not. - * @readonly - */ - isReload: boolean; - - /** - * Returns the Request that triggered the event handler. - * @readonly - */ - request: Request; - - /** - * Returns the Client that the current service worker is controlling. - * @readonly - */ - client: ServiceWorkerClient; - - /** - * Resolves by returning a Response or a network error to Fetch. - * - * @param all - */ - respondWith(all: any): Response; -} - /** * Represents a service worker. Multiple browsing contexts (e.g. pages, workers, * etc.) can be associated with the same ServiceWorker object. @@ -541,24 +252,47 @@ interface ServiceWorker extends Worker { * Returns the ServiceWorker serialized script URL defined as part of * ServiceWorkerRegistration. The URL must be on the same origin as the * document that registers the ServiceWorker. - * @readonly */ - scriptURL: string; + readonly scriptURL: string; /** * Returns the state of the service worker. It returns one of the following * values: installing, installed, activating, activated, or redundant. - * @readonly */ - state: string; + readonly state: string; /** * An EventListener property called whenever an event of type statechange * is fired; it is basically fired anytime the ServiceWorker.state changes. - * - * @param [statechangeevent] */ - onstatechange: (statechangeevent?: any) => void; + onstatechange: (statechangeevent: Event) => void; +} + +/** + * The PushMessageData interface of the Push API provides + * methods which let you retrieve the push data sent by a server in various formats. + */ +interface PushMessageData { + /** + * Extracts the data as an ArrayBuffer object. + */ + arrayBuffer(): ArrayBuffer; + + /** + * Extracts the data as a Blob object. + */ + blob(): Blob; + + /** + * Extracts the data as a JSON object. + */ + json(): any; + json(): T; + + /** + * Extracts the data as a plain text string. + */ + text(): string; } /** @@ -568,15 +302,13 @@ interface ServiceWorker extends Worker { interface PushSubscription { /** * The endpoint associated with the push subscription. - * @readonly */ - endpoint: any; + readonly endpoint: any; /** * The subscription ID associated with the push subscription. - * @readonly */ - subscriptionId: any; + readonly subscriptionId: any; } /** @@ -586,17 +318,15 @@ interface PushSubscriptionOptions { /** * A boolean indicating that the returned push subscription will only be used for * messages whose effect is made visible to the user. - * @readonly */ - userVisibleOnly: boolean; + readonly userVisibleOnly: boolean; /** * A public key your push server will use to send messages to client apps via a push server. * This value is part of a signing key pair generated by your application server and usable * with elliptic curve digital signature (ECDSA) over the P-256 curve. - * @readonly */ - applicationServerKey?: Uint8Array; + readonly applicationServerKey?: Uint8Array; } /** @@ -609,6 +339,8 @@ interface PushManager { /** * Returns a promise that resolves to a PushSubscription with details of a * new push subscription. + * + * @param [options] An object containing optional configuration parameters. */ subscribe(options?: PushSubscriptionOptions): Promise; @@ -625,6 +357,168 @@ interface PushManager { hasPermission(): Promise; } +/////// Service Worker Events /////// + +/** + * Extends the lifetime of the install and activate events dispatched on the + * ServiceWorkerGlobalScope as part of the service worker lifecycle. This + * ensures that any functional events (like FetchEvent) are not dispatched to + * the ServiceWorker until it upgrades database schemas, deletes outdated cache + * entries, etc. + */ +interface ExtendableEvent extends Event { + /** + * Extends the lifetime of the event. + * It is intended to be called in the install EventHandler for the + * installing worker and on the active EventHandler for the active worker. + * + * @param promise + */ + waitUntil(promise: Promise): void; +} + +/** + * The parameter passed into the ServiceWorkerGlobalScope.onfetch handler, + * FetchEvent represents a fetch action that is dispatched on the + * ServiceWorkerGlobalScope of a ServiceWorker. It contains information about + * the request and resulting response, and provides the FetchEvent.respondWith() + * method, which allows us to provide an arbitrary response back to the + * controlled page. + */ +interface FetchEvent extends Event { + /** + * Returns a Boolean that is true if the event was dispatched with the + * user's intention for the page to reload, and false otherwise. Typically, + * pressing the refresh button in a browser is a reload, while clicking a + * link and pressing the back button is not. + */ + readonly isReload: boolean; + + /** + * Returns the Request that triggered the event handler. + */ + readonly request: Request; + + /** + * Returns the Client that the current service worker is controlling. + */ + readonly client: ServiceWorkerClient; + + /** + * Returns the id of the client that the current service worker is controlling. + */ + readonly clientId: string; + + /** + * Resolves by returning a Response or a network error to Fetch. + * + * @param all Any custom response-generating code. + */ + respondWith(all: any): Response; +} + +/** + * The ExtendableMessageEvent interface of the ServiceWorker API represents + * the event object of a message event fired on + * a service worker (when a channel message is received on + * the ServiceWorkerGlobalScope from another context) + * — extends the lifetime of such events. + */ +interface ExtendableMessageEvent extends ExtendableEvent { + /** + * Returns the event's data. It can be any data type. + */ + readonly data: any; + + /** + * Returns the origin of the ServiceWorkerClient that sent the message + */ + readonly origin: string; + + /** + * Represents, in server-sent events, the last event ID of the event source. + */ + readonly lastEventId: string; + + /** + * Returns a reference to the service worker that sent the message. + */ + readonly source: ServiceWorkerClient; + + /** + * Returns the array containing the MessagePort objects + * representing the ports of the associated message channel. + */ + readonly ports: MessagePort[]; +} + +/** + * The parameter passed into the oninstall handler, the InstallEvent interface + * represents an install action that is dispatched on the + * ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent, + * it ensures that functional events such as FetchEvent are not dispatched + * during installation. + */ +interface InstallEvent extends ExtendableEvent { + /** + * Returns the ServiceWorker that is currently actively controlling the page. + */ + readonly activeWorker: ServiceWorker; +} + +/** + * The parameter passed into the onnotificationclick handler, + * the NotificationEvent interface represents + * a notification click event that is dispatched on + * the ServiceWorkerGlobalScope of a ServiceWorker. + */ +interface NotificationEvent extends ExtendableEvent { + /** + * Returns a Notification object representing + * the notification that was clicked to fire the event. + */ + notification: any; // need to be replaced with `Notification` when possible + + /** + * Returns the string ID of the notification button the user clicked. + * This value returns undefined if the user clicked + * the notification somewhere other than an action button, + * or the notification does not have a button. + */ + action: string; +} + +/** + * The PushEvent interface of the Push API represents + * a push message that has been received. + * This event is sent to the global scope of a ServiceWorker. + * It contains the information sent from an application server to a PushSubscription. + */ +interface PushEvent extends ExtendableEvent { + /** + * Returns a reference to a PushMessageData object containing + * data sent to the PushSubscription. + */ + readonly data: PushMessageData; +} + +interface ServiceWorkerContainerEventMap { + "message": MessageEvent; + "error": ErrorEvent; + "controllerchange": Event; +} + +interface ServiceWorkerEventMap { + "activate": ExtendableEvent; + "fetch": FetchEvent; + "install": InstallEvent; + // "message": ExtendableMessageEvent; + "message": MessageEvent; + "notificationclick": NotificationEvent; + "push": PushEvent; + "pushsubscriptionchang": PushEvent; +} + /** * Represents a service worker registration. */ @@ -633,23 +527,20 @@ interface ServiceWorkerRegistration extends EventTarget { * Returns a unique identifier for a service worker registration. * This must be on the same origin as the document that registers * the ServiceWorker. - * @readonly */ - scope: any; + readonly scope: any; /** * Returns a service worker whose state is installing. This is initially * set to null. - * @readonly */ - installing: ServiceWorker; + readonly installing: ServiceWorker; /** * Returns a service worker whose state is installed. This is initially * set to null. - * @readonly */ - waiting: ServiceWorker; + readonly waiting: ServiceWorker; /** * Returns a service worker whose state is either activating or activated. @@ -657,17 +548,15 @@ interface ServiceWorkerRegistration extends EventTarget { * ServiceWorkerClient if the client's URL falls within the scope of the * registration (the scope option set when ServiceWorkerContainer.register * is first called). - * @readonly */ - active: ServiceWorker; + readonly active: ServiceWorker; /** * Returns an interface to for managing push subscriptions, including * subcribing, getting an anctive subscription, and accessing push * permission status. - * @readonly */ - pushManager: PushManager; + readonly pushManager: PushManager; /** * An EventListener property called whenever an event of type updatefound @@ -699,49 +588,41 @@ interface ServiceWorkerRegisterOptions { * service workers, and access the state of service workers * and their registrations. */ -interface ServiceWorkerContainer { +interface ServiceWorkerContainer extends EventTarget { /** * Returns a ServiceWorker object if its state is activated (the same object * returned by ServiceWorkerRegistration.active). This property returns null * if the request is a force refresh (Shift + refresh) or if there is no * active worker. - * @readonly */ - controller: ServiceWorker; + readonly controller: ServiceWorker; /** * Defines whether a service worker is ready to control a page or not. * It returns a Promise that will never reject, which resolves to a * ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker. - * @readonly */ - ready: Promise; + readonly ready: Promise; /** * An event handler fired whenever a controllerchange event occurs — when * the document's associated ServiceWorkerRegistration acquires a new * ServiceWorkerRegistration.active worker. - * - * @param [controllerchangeevent] */ - oncontrollerchange: (controllerchangeevent?: Event) => void; + oncontrollerchange: (controllerchangeevent: Event) => void; /** * An event handler fired whenever an error event occurs in the associated * service workers. - * - * @param [errorevent] */ - onerror: (errorevent?: ErrorEvent) => void; + onerror: (errorevent: ErrorEvent) => void; /** * An event handler fired whenever a message event occurs — when incoming * messages are received to the ServiceWorkerContainer object (e.g. via a * MessagePort.postMessage() call.) - * - * @param [messageevent] */ - onmessage: (messageevent?: MessageEvent) => void; + onmessage: (messageevent: MessageEvent) => void; /** * Creates or updates a ServiceWorkerRegistration for the given scriptURL. @@ -771,82 +652,50 @@ interface ServiceWorkerContainer { * ServiceWorkerContainer in an array. If the method can't return * ServiceWorkerRegistrations, it returns a Promise. */ - getRegistrations(): Promise>; + getRegistrations(): Promise; + + addEventListener( + type: K, + listener: (event: ServiceWorkerContainerEventMap[K]) => any, + useCapture?: boolean + ): void; } -/** - * The parameter passed into the oninstall handler, the InstallEvent interface - * represents an install action that is dispatched on the - * ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent, - * it ensures that functional events such as FetchEvent are not dispatched - * during installation. - */ -interface InstallEvent extends ExtendableEvent { +interface ServiceWorkerGlobalScope extends EventTarget { /** - * Returns the ServiceWorker that is currently actively controlling the page. - * @readonly + * Contains the CacheStorage object associated with the service worker. */ - activeWorker: ServiceWorker; -} - -interface ServiceWorkerGlobalScope { + readonly caches: CacheStorage; /** * Contains the Clients object associated with the service worker. - * @readonly */ - clients: ServiceWorkerClients; + readonly clients: ServiceWorkerClients; /** * Contains the ServiceWorkerRegistration object that represents the * service worker's registration. - * @readonly */ - registration: ServiceWorkerRegistration; + readonly registration: ServiceWorkerRegistration; /** * An event handler fired whenever an activate event occurs — when a * ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active * worker. - * - * @param [activateevent] */ - onactivate: (activateevent?: ExtendableEvent) => void; - - /** - * Not defined in the spec yet, but it looks like this will be fired when - * the device is nearly out of storage space, prompting the UA to start - * claiming back some space from web apps that are using client-side storage, - * and the current app is targeted. - * - * @param [beforeevictedevent] - */ - onbeforeevicted: (beforeevictedevent?: Event) => void; - - /** - * Not defined in the spec yet, but it looks like this will be fired when - * the device is out of storage space, and the UA claims back some space - * from the current app. - * - * @param [evictedevent] - */ - onevicted: (evictedevent?: Event) => void; + onactivate: (activateevent: ExtendableEvent) => void; /** * An event handler fired whenever a fetch event occurs — when a fetch() * is called. - * - * @param [fetchevent] */ - onfetch: (fetchevent?: FetchEvent) => void; + onfetch: (fetchevent: FetchEvent) => void; /** * An event handler fired whenever an install event occurs — when a * ServiceWorkerRegistration acquires a new * ServiceWorkerRegistration.installing worker. - * - * @param [installevent] */ - oninstall: (installevent?: InstallEvent) => void; + oninstall: (installevent: InstallEvent) => void; /** * An event handler fired whenever a message event occurs — when incoming @@ -856,34 +705,31 @@ interface ServiceWorkerGlobalScope { * MessagePort exposed in event.data.port, corresponding to the controlled * page. * - * @param [messageevent] + * `onmessage` is actually fired with `ExtendableMessageEvent`, but + * since we are merging the interface into `Window`, we should + * make sure it's compatible with `window.onmessage` */ - onmessage: (messageevent?: MessageEvent) => void; + // onmessage: (messageevent: ExtendableMessageEvent) => void; + onmessage: (messageevent: MessageEvent) => void; /** * An event handler fired whenever a notificationclick event occurs — when * a user clicks on a displayed notification. - * - * @param [notificationclickevent] */ - onnotificationclick: (notificationclickevent?: NotificationEvent) => void; + onnotificationclick: (notificationclickevent: NotificationEvent) => void; /** * An event handler fired whenever a push event occurs — when a server * push notification is received. - * - * @param [onpushevent] */ - onpush: (onpushevent?: Event) => void; + onpush: (onpushevent: PushEvent) => void; /** * An event handler fired whenever a pushsubscriptionchange event occurs — * when a push subscription has been invalidated, or is about to be * invalidated (e.g. when a push service sets an expiration time). - * - * @param [pushsubscriptionchangeevent] */ - onpushsubscriptionchange: (pushsubscriptionchangeevent?: Event) => void; + onpushsubscriptionchange: (pushsubscriptionchangeevent: PushEvent) => void; /** * Allows the current service worker registration to progress from waiting @@ -891,12 +737,11 @@ interface ServiceWorkerGlobalScope { */ skipWaiting(): Promise; - /** - * TODO GlobalFetch - * @param url - * @param init - */ - fetch(url: string | Request, init?: Object): Promise; + addEventListener( + type: K, + listener: (event: ServiceWorkerEventMap[K]) => any, + useCapture?: boolean + ): void; } interface Navigator { @@ -908,10 +753,5 @@ interface Navigator { serviceWorker: ServiceWorkerContainer; } -interface Window extends ServiceWorkerGlobalScope { - caches: CacheStorage; -} - -interface NotificationEvent extends Event, ExtendableEvent { - notification: any; -} +// tslint:disable-next-line no-empty-interface +interface Window extends ServiceWorkerGlobalScope {} diff --git a/service_worker_api/service_worker_api-test.ts b/service_worker_api/service_worker_api-test.ts index 3f160654c7..b2e183aa05 100644 --- a/service_worker_api/service_worker_api-test.ts +++ b/service_worker_api/service_worker_api-test.ts @@ -17,7 +17,7 @@ self.addEventListener('fetch', function(event: FetchEvent) { }); self.caches.open('v1').then(function(cache: Cache) { - cache.matchAll('/images/').then(function(response: Array) { + cache.matchAll('/images/').then(function(response: Response[]) { response.forEach(function(element, index, array) { cache.delete(element.url); }); @@ -86,7 +86,7 @@ self.caches.open('v1').then(function(cache: Cache) { self.caches.has('v1').then(function() { self.caches.delete('v1').then(function() { - + console.log('done'); }); }); @@ -95,16 +95,16 @@ self.addEventListener('activate', function(event: ExtendableEvent) { event.waitUntil( self.caches.keys().then(function(keyList) { - for(var i = 0; i < keyList.length; i++) { - if (cacheWhitelist.indexOf(keyList[i]) === -1) { - return self.caches.delete(keyList[i]); + for (var item of keyList) { + if (cacheWhitelist.indexOf(item) === -1) { + return self.caches.delete(item); } } }) ); }); -function sendMessage(message: string) { +function sendMessage(message: any) { return new Promise(function(resolve, reject) { var messageChannel = new MessageChannel(); messageChannel.port1.onmessage = function(event) { @@ -118,10 +118,18 @@ function sendMessage(message: string) { }); } +self.addEventListener('message', function(evt: ExtendableMessageEvent) { + evt.ports[0].postMessage(evt.source.id); +}); + +sendMessage('test').then(function(clientId: string) { + console.log(clientId); +}); + self.clients.matchAll({type: "test"}).then(function(clients) { - for(var i = 0 ; i < clients.length ; i++) { - if(clients[i].url === 'index.html') { - self.clients.openWindow(clients[i].url); + for (var cli of clients) { + if(cli.url === 'index.html') { + self.clients.openWindow(cli.url); // or do something else involving the matching client } } @@ -157,11 +165,11 @@ navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(functi }); navigator.serviceWorker.getRegistration('/app').then(function(registration: ServiceWorkerRegistration) { - + console.log(registration); }); -navigator.serviceWorker.getRegistrations().then(function(registrations: Array) { - +navigator.serviceWorker.getRegistrations().then(function(registrations: ServiceWorkerRegistration[]) { + console.log(registrations); }); self.registration.unregister(); @@ -179,9 +187,6 @@ self.addEventListener('notificationclick', function(event: NotificationEvent) { event.waitUntil(self.clients.matchAll({ type: "window" }).then(function(clientList) { - for (var i = 0; i < clientList.length; i++) { - var client = clientList[i]; - } if (self.clients.openWindow) return self.clients.openWindow('/'); })); diff --git a/service_worker_api/tslint.json b/service_worker_api/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/service_worker_api/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 26ced0acb9ddf27b71a2194bff47a28b2657e8e9 Mon Sep 17 00:00:00 2001 From: Colby Brown Date: Mon, 2 Jan 2017 16:31:10 -0600 Subject: [PATCH 27/45] Add contains to bootstrap-datepicker DatepickerOptions --- bootstrap-datepicker/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap-datepicker/index.d.ts b/bootstrap-datepicker/index.d.ts index a692b663bb..fcd24f19c4 100644 --- a/bootstrap-datepicker/index.d.ts +++ b/bootstrap-datepicker/index.d.ts @@ -42,6 +42,7 @@ interface DatepickerOptions { showOnFocus?: boolean; immediateUpdates?: boolean; title?: string; + contains?: string; } interface DatepickerCustomFormatOptions { From 266898f207a17497dd13b90bf0324ade2f0a48c4 Mon Sep 17 00:00:00 2001 From: Colby Date: Mon, 2 Jan 2017 16:41:47 -0600 Subject: [PATCH 28/45] Fix typo from 'contains' to 'container' --- bootstrap-datepicker/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-datepicker/index.d.ts b/bootstrap-datepicker/index.d.ts index fcd24f19c4..5a6e80f72e 100644 --- a/bootstrap-datepicker/index.d.ts +++ b/bootstrap-datepicker/index.d.ts @@ -42,7 +42,7 @@ interface DatepickerOptions { showOnFocus?: boolean; immediateUpdates?: boolean; title?: string; - contains?: string; + container?: string; } interface DatepickerCustomFormatOptions { From 0c56e6562c7f68b195601b8b2832deeb47bd5217 Mon Sep 17 00:00:00 2001 From: Michael Mrowetz Date: Tue, 3 Jan 2017 08:07:26 +0900 Subject: [PATCH 29/45] add swagger-sails-hook (#13676) * add Sails and Connect middleware test * add swagger-sails-hook * Fix indentation --- .../swagger-node-runner-tests.ts | 27 ++++++++- swagger-sails-hook/index.d.ts | 55 +++++++++++++++++++ .../swagger-sails-hook-tests.ts | 21 +++++++ swagger-sails-hook/tsconfig.json | 20 +++++++ swagger-sails-hook/tslint.json | 1 + 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 swagger-sails-hook/index.d.ts create mode 100644 swagger-sails-hook/swagger-sails-hook-tests.ts create mode 100644 swagger-sails-hook/tsconfig.json create mode 100644 swagger-sails-hook/tslint.json diff --git a/swagger-node-runner/swagger-node-runner-tests.ts b/swagger-node-runner/swagger-node-runner-tests.ts index 2d20ad21c8..49538d3825 100644 --- a/swagger-node-runner/swagger-node-runner-tests.ts +++ b/swagger-node-runner/swagger-node-runner-tests.ts @@ -1,7 +1,9 @@ import * as SwaggerNodeRunner from "swagger-node-runner"; import * as express from "express"; +import * as connect from "connect"; import * as Hapi from "hapi"; import * as restify from "restify"; +import * as sails from "sails.io.js"; let config: SwaggerNodeRunner.Config = { appRoot: __dirname @@ -21,6 +23,30 @@ SwaggerNodeRunner.create(config, (err, runner) => { }); +//Connect middleware +let connectApp = connect(); +SwaggerNodeRunner.create(config, (err, runner) => { + if (err) { throw err; } + + let conncetMiddleware = runner.connectMiddleware(); + + conncetMiddleware.register(connectApp); + var port = process.env.PORT || 10010; + connectApp.listen(port); +}); + + +// Sails Middleware (chain) test +SwaggerNodeRunner.create(config, (err, runner) => { + if (err) { throw err; } + + let sailsMw = runner.sailsMiddleware(); + if(typeof sailsMw.chain !== 'function' || !sailsMw.runner) { + // do nothing + } +}); + + //Hapi Middleware var hapiapp = new Hapi.Server(); SwaggerNodeRunner.create(config, function(err, runner) { @@ -47,7 +73,6 @@ SwaggerNodeRunner.create(config, function(err, runner) { // Restify Middelware - let app = restify.createServer(); SwaggerNodeRunner.create(config, function(err, runner) { if (err) { throw err; } diff --git a/swagger-sails-hook/index.d.ts b/swagger-sails-hook/index.d.ts new file mode 100644 index 0000000000..4ce957a6bf --- /dev/null +++ b/swagger-sails-hook/index.d.ts @@ -0,0 +1,55 @@ +// Type definitions for swagger-sails-hook 0.7 +// Project: https://github.com/apigee-127/swagger-sails#readme +// Definitions by: Michael Mrowetz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* =================== USAGE =================== +// Registers itself as sails hook, when added to the project via `npm install swagger-sails-hook`. +// see http://sailsjs.com/documentation/concepts/extending-sails/hooks + =============================================== */ + +import { Config, SailsMiddleware } from "swagger-node-runner"; + +export = SwaggerHook; + +/** + * Create a new `swagger-sails-hook` sails hook and register it with `sails` + * @param {any} sails - reference to the running sails instance + * @returns SailsHook - `swagger-sails-hook` object implementing the Sails' hook specification. + */ +declare function SwaggerHook(sails: any): SwaggerHook.SailsHook; + +declare namespace SwaggerHook { + /** + * `swagger-sails-hook` object implementing the Sails' hook specification. + * + * @see {@link http://sailsjs.com/documentation/concepts/extending-sails/hooks/hook-specification|Sails Hook Docs} + * @see {@link http://sailsjs.com/documentation/anatomy/api/hooks/my-hook/index-js|Sails Hook Example} + */ + export interface SailsHook { + + /** + * Perform startup tasks. + * All Sails configuration is guaranteed to be completed before a hook’s initialize function runs. + * @param {Function} done - called when `swagger-sails-hook`'s startup tasks have finished. + */ + initialize: (done: () => any) => void; + + /** + * `swagger-sails-hook` specific route bound to a Sails app at load time. + * + * It handles any unhandled requests (any routes that aren't bound in the app via a + * custom route configuration or a blueprint) via the swagger middleware. + */ + routes: { + /** routes specified in the `after` object will be bound after custom and blueprint routes */ + after: { + /** + * This route will match any routes that aren't bound in the app via a custom route configuration + * or a blueprint. + */ + "/*": (req: any, res: any, next: () => any) => any + } + }; + } +} diff --git a/swagger-sails-hook/swagger-sails-hook-tests.ts b/swagger-sails-hook/swagger-sails-hook-tests.ts new file mode 100644 index 0000000000..ee023047c3 --- /dev/null +++ b/swagger-sails-hook/swagger-sails-hook-tests.ts @@ -0,0 +1,21 @@ +import swaggerSailsHook = require("swagger-sails-hook"); +import * as express from "express"; + + +const mockSailsApp = { + models: {}, + conf: {}, + sockets: {}, + hooks: {}, + lift: () => { /* do nothing */ } +}; + +// create and register hook +let swaggerHookRef = swaggerSailsHook(mockSailsApp); +if(typeof swaggerHookRef.routes.after['/*'] === 'function') { + // right type +} + +swaggerHookRef.initialize(() => { + // do something, when initialized +}); diff --git a/swagger-sails-hook/tsconfig.json b/swagger-sails-hook/tsconfig.json new file mode 100644 index 0000000000..ac43d0e157 --- /dev/null +++ b/swagger-sails-hook/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "swagger-sails-hook-tests.ts" + ] +} diff --git a/swagger-sails-hook/tslint.json b/swagger-sails-hook/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/swagger-sails-hook/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From a0da31216510e8b99c4f11b7206841da9b540205 Mon Sep 17 00:00:00 2001 From: Jesse Sessler Date: Mon, 2 Jan 2017 18:15:20 -0500 Subject: [PATCH 30/45] Fix signature for onSelectionChange (#13685) --- react-native/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index 9e89306872..57e670575e 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -1223,7 +1223,7 @@ declare module "react" { /** * Callback that is called when the text input selection is changed. */ - onSelectionChange?: () => void + onSelectionChange?: (event: { nativeEvent: { selection: { start: number, end: number }, target: number } }) => void /** * Callback that is called when the text input's submit button is pressed. From f991a320e5a0a7391e6d73d888df25b7bb2f2943 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Tue, 3 Jan 2017 01:25:52 +0200 Subject: [PATCH 31/45] Add assert.containSubset method; refactor to follow latest style instructions (#13690) --- chai-subset/chai-subset-tests.ts | 3 +++ chai-subset/index.d.ts | 19 +++++++++++-------- chai-subset/tslint.json | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 chai-subset/tslint.json diff --git a/chai-subset/chai-subset-tests.ts b/chai-subset/chai-subset-tests.ts index d4c7ca3f2b..ded911ed19 100644 --- a/chai-subset/chai-subset-tests.ts +++ b/chai-subset/chai-subset-tests.ts @@ -29,6 +29,8 @@ function test_containSubset() { }); obj.should.containSubset({ a: 'b' }); + + assert.containSubset(obj, { a: 'b' }); } function test_notContainSubset() { @@ -52,6 +54,7 @@ function test_arrayContainSubset() { expect(list).to.containSubset([{a:'a', b: 'b'}]); list.should.containSubset([{a:'a', b: 'b'}]); + assert.containSubset(list, [{a:'a', b: 'b'}]); } function test_arrayNotContainSubset() { diff --git a/chai-subset/index.d.ts b/chai-subset/index.d.ts index 89ee553945..3e0818aa2b 100644 --- a/chai-subset/index.d.ts +++ b/chai-subset/index.d.ts @@ -1,17 +1,20 @@ -// Type definitions for chai-subset 1.0.0 +// Type definitions for chai-subset 1.3 // Project: https://github.com/e-conomic/chai-subset // Definitions by: Sam Noedel , Andrew Brown // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare namespace Chai { - interface Assertion { - containSubset(obj: Object): Assertion; +declare global { + namespace Chai { + interface Assertion { + containSubset(expected: any): Assertion; + } + interface Assert { + containSubset(val: any, exp: any, msg?: string): void; + } } } -declare module "chai-subset" { - function chaiSubset(chai: any, utils: any): void; - export = chaiSubset; -} +declare function chaiSubset(chai: any, utils: any): void; +export = chaiSubset; diff --git a/chai-subset/tslint.json b/chai-subset/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/chai-subset/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From b0d3f2601e3e1151f5568f69522996b7146dfb51 Mon Sep 17 00:00:00 2001 From: bumbleblym Date: Tue, 3 Jan 2017 08:56:14 +0800 Subject: [PATCH 32/45] Add html-webpack-template (#13680) * Add html-webpack-template * Add Attributes type --- .../html-webpack-template-tests.ts | 65 +++++++++++++ html-webpack-template/index.d.ts | 96 +++++++++++++++++++ html-webpack-template/tsconfig.json | 20 ++++ html-webpack-template/tslint.json | 1 + 4 files changed, 182 insertions(+) create mode 100644 html-webpack-template/html-webpack-template-tests.ts create mode 100644 html-webpack-template/index.d.ts create mode 100644 html-webpack-template/tsconfig.json create mode 100644 html-webpack-template/tslint.json diff --git a/html-webpack-template/html-webpack-template-tests.ts b/html-webpack-template/html-webpack-template-tests.ts new file mode 100644 index 0000000000..c24a9506d3 --- /dev/null +++ b/html-webpack-template/html-webpack-template-tests.ts @@ -0,0 +1,65 @@ +import HtmlWebpackPlugin = require('html-webpack-plugin'); +import template = require('html-webpack-template'); + +const configs: Array = [ + { + // Required + inject: false, + template, + // template: 'node_modules/html-webpack-template/index.ejs', + + // Optional + appMountId: 'app', + appMountIds: [ + 'root0', + 'root1', + ], + baseHref: 'http://example.com/awesome', + devServer: 'http://localhost:3001', + googleAnalytics: { + trackingId: 'UA-XXXX-XX', + pageViewOnLoad: true, + }, + links: [ + 'https://fonts.googleapis.com/css?family=Roboto', + { + href: '/apple-touch-icon.png', + rel: 'apple-touch-icon', + sizes: '180x180', + }, + { + href: '/favicon-32x32.png', + rel: 'icon', + sizes: '32x32', + type: 'image/png', + }, + ], + meta: [ + { + description: 'A better default template for html-webpack-plugin.', + }, + ], + mobile: true, + inlineManifestWebpackName: 'webpackManifest', + scripts: [ + 'http://example.com/somescript.js', + { + src: '/myModule.js', + type: 'module', + }, + ], + window: { + env: { + apiHost: 'http://myapi.com/api/v1', + }, + }, + + // And any other config options from html-webpack-plugin: + // https://github.com/ampedandwired/html-webpack-plugin#configuration + title: 'My App', + }, +]; + +const plugins: Array = configs.map(config => + new HtmlWebpackPlugin(config) +); diff --git a/html-webpack-template/index.d.ts b/html-webpack-template/index.d.ts new file mode 100644 index 0000000000..e224e96296 --- /dev/null +++ b/html-webpack-template/index.d.ts @@ -0,0 +1,96 @@ +// Type definitions for html-webpack-template 6.0 +// Project: https://github.com/jaketrent/html-webpack-template +// Definitions by: Benjamin Lim +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Config as HtmlWebpackPluginConfig } from 'html-webpack-plugin'; + +export = HtmlWebpackTemplate; + +declare const HtmlWebpackTemplate: string; + +declare namespace HtmlWebpackTemplate { + export interface GoogleAnalyticsConfig { + trackingId: string; + // Log a pageview event after the analytics code loads. + pageViewOnLoad?: boolean; + } + + export interface Attributes { + [name: string]: any; + } + + type Resource = string | Attributes; + + /** + * string: value is assigned to the href attribute and the rel attribute is + * set to "stylesheet" + * + * object: properties and values are used as the attribute names and values, + * respectively: + */ + export type Link = Resource; + + /** + * string: value is assigned to the src attribute and the type attribute is + * set to "text/javascript"; + * + * object: properties and values are used as the attribute names and values, + * respectively. + */ + export type Script = Resource; + + export interface Config extends HtmlWebpackPluginConfig { + /** + * Set to false. Controls asset addition to the template. This template + * takes care of that. + */ + inject: false; + + // Specify this module's index.ejs file. + template: string; + + // The
element id on which you plan to mount a JavaScript app. + appMountId?: string; + + // An array of application element ids. + appMountIds?: string[]; + + /** + * Adjust the URL for relative URLs in the document (MDN). + * https://developer.mozilla.org/en/docs/Web/HTML/Element/base + */ + baseHref?: string; + + /** + * Insert the webpack-dev-server hot reload script at this + * host:port/path; e.g., http://localhost:3000. + */ + devServer?: string; + + // Track usage of your site via Google Analytics. + googleAnalytics?: GoogleAnalyticsConfig; + + // Array of elements. + links?: Link[]; + + // Array of objects containing key value pairs to be included as meta tags. + meta?: Attributes[]; + + // Sets appropriate meta tag for page scaling. + mobile?: boolean; + + /** + * For use with inline-manifest-webpack-plugin. + * + * https://github.com/szrenwei/inline-manifest-webpack-plugin + */ + inlineManifestWebpackName?: string; + + // Array of external script imports to include on page. + scripts?: Script[]; + + // Object that defines data you need to bootstrap a JavaScript app. + window?: {}; + } +} diff --git a/html-webpack-template/tsconfig.json b/html-webpack-template/tsconfig.json new file mode 100644 index 0000000000..8e51dd1f5c --- /dev/null +++ b/html-webpack-template/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "html-webpack-template-tests.ts" + ] +} diff --git a/html-webpack-template/tslint.json b/html-webpack-template/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/html-webpack-template/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 88b2aae802c17fda4c82b52a14453abe6f97d45c Mon Sep 17 00:00:00 2001 From: Peter Safranek Date: Mon, 2 Jan 2017 17:03:06 -0800 Subject: [PATCH 33/45] Deprecate argon2. The lib has its own typings now. (#13696) * Add type definitions for koa-send. * Deprecate argon2 typings. They're included in the lib now. * Remove unneeded file (big upstream merge mistake). --- argon2/argon2-tests.ts | 35 ----------------------------------- argon2/index.d.ts | 39 --------------------------------------- argon2/tsconfig.json | 20 -------------------- argon2/tslint.json | 1 - notNeededPackages.json | 6 ++++++ 5 files changed, 6 insertions(+), 95 deletions(-) delete mode 100644 argon2/argon2-tests.ts delete mode 100644 argon2/index.d.ts delete mode 100644 argon2/tsconfig.json delete mode 100644 argon2/tslint.json diff --git a/argon2/argon2-tests.ts b/argon2/argon2-tests.ts deleted file mode 100644 index 566292b4fa..0000000000 --- a/argon2/argon2-tests.ts +++ /dev/null @@ -1,35 +0,0 @@ - -import { defaults, limits, hash, verify, generateSalt } from 'argon2'; - -main(); - -async function main() { - - const defaultTimeCost: number = defaults.timeCost; - const defaultMemoryCost: number = defaults.memoryCost; - const defaultParallelism: number = defaults.parallelism; - const defaultArgon2d: boolean = defaults.argon2d; - - const minMemoryCost: number = limits.memoryCost.min; - const maxMemoryCost: number = limits.memoryCost.max; - const minTimeCost: number = limits.timeCost.min; - const maxTimeCost: number = limits.timeCost.max; - const minParallelism: number = limits.parallelism.min; - const maxParallelism: number = limits.parallelism.max; - - const options = { - timeCost: 4, - memoryCost: 13, - parallelism: 2, - argon2d: true, - }; - - const hash1: string = await hash('secret', new Buffer(''), options); - const hash2: string = await hash('secret', new Buffer(''), {}); - const hash3: string = await hash('secret', new Buffer('')); - - const verified: boolean = await verify('long-hash', 'secret'); - - const salt1: Buffer = await generateSalt(); - const salt2: Buffer = await generateSalt(32); -} diff --git a/argon2/index.d.ts b/argon2/index.d.ts deleted file mode 100644 index 1cbf1a5156..0000000000 --- a/argon2/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Type definitions for argon2 0.14 -// Project: https://github.com/ranisalt/node-argon2#readme -// Definitions by: Peter Safranek -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -export var defaults: { - timeCost: number; - memoryCost: number; - parallelism: number; - argon2d: boolean; -}; - -export var limits: { - memoryCost: { - min: number; - max: number; - }; - timeCost: { - min: number; - max: number; - }; - parallelism: { - min: number; - max: number; - }; -}; - -export function hash(plain: string, salt: Buffer, options?: { - timeCost?: number; - memoryCost?: number; - parallelism?: number; - argon2d?: boolean; -}): Promise; - -export function verify(hash: string, plain: string): Promise; - -export function generateSalt(length?: number): Promise; diff --git a/argon2/tsconfig.json b/argon2/tsconfig.json deleted file mode 100644 index d58eaf4f82..0000000000 --- a/argon2/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "argon2-tests.ts" - ] -} \ No newline at end of file diff --git a/argon2/tslint.json b/argon2/tslint.json deleted file mode 100644 index 377cc837d4..0000000000 --- a/argon2/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../tslint.json" } diff --git a/notNeededPackages.json b/notNeededPackages.json index 7c695fee83..80dcb22e82 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -268,6 +268,12 @@ "typingsPackageName": "inversify-restify-utils", "sourceRepoURL": "https://github.com/inversify/inversify-restify-utils", "asOfVersion": "2.0.0" + }, + { + "libraryName": "Argon2", + "typingsPackageName": "argon2", + "sourceRepoURL": "https://github.com/ranisalt/node-argon2", + "asOfVersion": "0.15.0" } ] } \ No newline at end of file From 1776ecb31a881ac95d0a3c2766c3d81c276f6117 Mon Sep 17 00:00:00 2001 From: Tristan Jones Date: Mon, 2 Jan 2017 19:14:19 -0700 Subject: [PATCH 34/45] Added declarations for 'readline-sync'. --- readline-sync/index.d.ts | 67 ++++++++++++++++ readline-sync/readline-sync-tests.ts | 110 +++++++++++++++++++++++++++ readline-sync/tsconfig.json | 20 +++++ readline-sync/tslint.json | 1 + 4 files changed, 198 insertions(+) create mode 100644 readline-sync/index.d.ts create mode 100644 readline-sync/readline-sync-tests.ts create mode 100644 readline-sync/tsconfig.json create mode 100644 readline-sync/tslint.json diff --git a/readline-sync/index.d.ts b/readline-sync/index.d.ts new file mode 100644 index 0000000000..ce7d15d6a4 --- /dev/null +++ b/readline-sync/index.d.ts @@ -0,0 +1,67 @@ +// Type definitions for readline-sync 1.4 +// Project: https://github.com/anseki/readline-sync +// Definitions by: Tristan Jones +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type optionType = string | number | RegExp | ((input:string) => boolean); + +interface BasicOptions { + prompt?: any; + hideEchoBack?: boolean; + mask?: string; + limit?: optionType | Array; + limitMessage?: string; + defaultInput?: string; + trueValue?: optionType | Array; + falseValue?: optionType | Array; + caseSensitive?: boolean; + keepWhitespace?: boolean; + encoding?: string; + bufferSize?: number; + print?: ((display:string, encoding:string) => void); + history?: boolean; + cd?: boolean; + charlist?: string; + min?: any; + max?: any; + confirmMessage?: any; + unmatchMessage?: any; + exists?: any; + isFile?: boolean; + isDirectory?: boolean; + validate?: ((path:string) => boolean | string); + create?: boolean; + guide?: boolean; +} + +// Basic Functions +export function question(query?: any, options?: BasicOptions): string; +export function prompt(options?: BasicOptions): string; +export function keyIn(query?: any, options?: BasicOptions): string; +export function setDefaultOptions(options?: BasicOptions): BasicOptions; + +// Utility Functions +export function questionEMail(query?: any, options?: BasicOptions): string; +export function questionNewPassword(query?: any, options?: BasicOptions): string; +export function questionInt(query?: any, options?: BasicOptions): number; +export function questionFloat(query?: any, options?: BasicOptions): number; +export function questionPath(query?: any, options?: BasicOptions): string; + +export function promptCL(commandHandler?: { [id:string]: ((...args:string[]) => void) } | ((command:string, ...args:string[]) => void), options?: BasicOptions): string[]; +export function promptLoop(inputHandler: ((value:string) => boolean), options?: BasicOptions): void; +export function promptCLLoop(commandHandler?: { [id:string]: ((...args:string[]) => boolean | void) } | ((command:string, ...args:string[]) => boolean | void), options?: BasicOptions): void; +export function promptSimShell(options?: BasicOptions): string; + +export function keyInYN(query?: any, options?: BasicOptions): boolean | string; +export function keyInYNStrict(query?: any, options?: BasicOptions): boolean; +export function keyInPause(query?: any, options?: BasicOptions): void; +export function keyInSelect(items: string[], query?: any, options?: BasicOptions): number; + +export function getRawInput(): string; + +// Deprecated +export function setBufferSize(value: number): void; +export function setEncoding(value: string): void; +export function setMask(value: string): void; +export function setPrint(value: ((display:string, encoding:string) => void)): void; +export function setPrompt(value: any): void; \ No newline at end of file diff --git a/readline-sync/readline-sync-tests.ts b/readline-sync/readline-sync-tests.ts new file mode 100644 index 0000000000..a201659e7a --- /dev/null +++ b/readline-sync/readline-sync-tests.ts @@ -0,0 +1,110 @@ + + +import readlineSync = require('readline-sync'); + +let result:string = readlineSync.question('Which program starts do you want? ', { + defaultInput: 'firefox' +}); + +let result2:string = readlineSync.prompt({prompt: '$$'}); + +let result3:string = readlineSync.keyIn('Press a key', { limit: '$<1-5>' }); + +let result4:{} = readlineSync.setDefaultOptions({ + prompt: '$$', + hideEchoBack: true, + mask: '*', + limit: [ /^a|b$/, /[a-zA-Z]+/], + limitMessage: 'Limit reached', + defaultInput: 'English', + trueValue: 2, + falseValue: (value:string) => { return true; }, + caseSensitive: true, + keepWhitespace: true, + encoding: 'utf-8', + bufferSize: 12, + print: (display:string, encoding:string) => { console.log(display)}, + history: false, + cd: true, + charlist: 'abc', + min: 0, + max: 10, + confirmMessage: 'Yes', + unmatchMessage: new Date(), + exists: false, + isFile: true, + isDirectory: false, + validate: (path:string) => { return (path === '/usr/local/bin'); }, + create: true, + guide: false, +}); + +let result5:string = readlineSync.questionEMail('Enter email'); + +let result6:string = readlineSync.questionNewPassword('PASSWORD: ', {charlist: '$#$@%'}); + +let result7:number = readlineSync.questionInt('Enter an integer', { limitMessage: 'Enter a valid integer' }); + +let result8:number = readlineSync.questionFloat('Enter a float', { limitMessage: 'Enter a valid float' }); + +let result9:string = readlineSync.questionPath('Save to: ', { + isDirectory: true, + exists: null, + create: true +}); + +readlineSync.promptCL((command:string, arg1:string, arg2:string) => { + if (command === 'add') { + console.log(arg1 + ' is added.'); + } else if (command === 'copy') { + console.log(arg1 + ' is copied to ' + arg2 + '.'); + } +}); + +readlineSync.promptCL({ + add: (element:string) => { // It's called by also "ADD", "Add", "aDd", etc.. + console.log(element + ' is added.'); + }, + copy: (from:string, to:string) => { + console.log(from + ' is copied to ' + to + '.'); + } +}); + +readlineSync.promptLoop((input:string) => { + console.log('-- You said "' + input + '"'); + return input === 'bye'; +}); + +readlineSync.promptCLLoop({ + add: (element:string) => { + console.log(element + ' is added.'); + }, + copy: (from:string, to:string) => { + console.log(from + ' is copied to ' + to + '.'); + }, + bye: () => { return true; } +}); + +let result10:string = readlineSync.promptSimShell(); + +let result11:(boolean | string) = readlineSync.keyInYN('Do you want to install this?'); + +let result12:boolean = readlineSync.keyInYNStrict('Do you want to install this?', { guide: true }); + +readlineSync.keyInPause({ guide:true }); + +let frameworks = ['Express', 'hapi', 'flatiron', 'MEAN.JS', 'locomotive']; +let result13:number = readlineSync.keyInSelect(frameworks, 'Which framework?'); + +let result14:string = readlineSync.getRawInput(); + +readlineSync.setPrint((display:string, encoding:string) => { console.log(display) }); + +readlineSync.setPrompt(new Date()); + +readlineSync.setEncoding('utf-16'); + +readlineSync.setMask('%'); + +readlineSync.setBufferSize(128); + diff --git a/readline-sync/tsconfig.json b/readline-sync/tsconfig.json new file mode 100644 index 0000000000..144427ec3c --- /dev/null +++ b/readline-sync/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "readline-sync-tests.ts" + ] +} diff --git a/readline-sync/tslint.json b/readline-sync/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/readline-sync/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 1982f9cfaae81a6b2fb6bc6654e42d8a78e13556 Mon Sep 17 00:00:00 2001 From: Tristan Jones Date: Mon, 2 Jan 2017 19:22:17 -0700 Subject: [PATCH 35/45] Added fixes to pass linting --- readline-sync/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/readline-sync/index.d.ts b/readline-sync/index.d.ts index ce7d15d6a4..0307af5eda 100644 --- a/readline-sync/index.d.ts +++ b/readline-sync/index.d.ts @@ -3,22 +3,22 @@ // Definitions by: Tristan Jones // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -type optionType = string | number | RegExp | ((input:string) => boolean); +type optionType = string | number | RegExp | ((input: string) => boolean); interface BasicOptions { prompt?: any; hideEchoBack?: boolean; mask?: string; - limit?: optionType | Array; + limit?: optionType | optionType[]; limitMessage?: string; defaultInput?: string; - trueValue?: optionType | Array; - falseValue?: optionType | Array; + trueValue?: optionType | optionType[]; + falseValue?: optionType | optionType[]; caseSensitive?: boolean; keepWhitespace?: boolean; encoding?: string; bufferSize?: number; - print?: ((display:string, encoding:string) => void); + print?: ((display: string, encoding: string) => void); history?: boolean; cd?: boolean; charlist?: string; @@ -29,7 +29,7 @@ interface BasicOptions { exists?: any; isFile?: boolean; isDirectory?: boolean; - validate?: ((path:string) => boolean | string); + validate?: ((path: string) => boolean | string); create?: boolean; guide?: boolean; } @@ -47,9 +47,9 @@ export function questionInt(query?: any, options?: BasicOptions): number; export function questionFloat(query?: any, options?: BasicOptions): number; export function questionPath(query?: any, options?: BasicOptions): string; -export function promptCL(commandHandler?: { [id:string]: ((...args:string[]) => void) } | ((command:string, ...args:string[]) => void), options?: BasicOptions): string[]; -export function promptLoop(inputHandler: ((value:string) => boolean), options?: BasicOptions): void; -export function promptCLLoop(commandHandler?: { [id:string]: ((...args:string[]) => boolean | void) } | ((command:string, ...args:string[]) => boolean | void), options?: BasicOptions): void; +export function promptCL(commandHandler?: { [id: string]: ((...args: string[]) => void) } | ((command: string, ...args: string[]) => void), options?: BasicOptions): string[]; +export function promptLoop(inputHandler: ((value: string) => boolean), options?: BasicOptions): void; +export function promptCLLoop(commandHandler?: { [id: string]: ((...args: string[]) => boolean | void) } | ((command: string, ...args: string[]) => boolean | void), options?: BasicOptions): void; export function promptSimShell(options?: BasicOptions): string; export function keyInYN(query?: any, options?: BasicOptions): boolean | string; @@ -63,5 +63,5 @@ export function getRawInput(): string; export function setBufferSize(value: number): void; export function setEncoding(value: string): void; export function setMask(value: string): void; -export function setPrint(value: ((display:string, encoding:string) => void)): void; +export function setPrint(value: ((display: string, encoding: string) => void)): void; export function setPrompt(value: any): void; \ No newline at end of file From daf4d787ea7347674e177665fe7f10fa499e8591 Mon Sep 17 00:00:00 2001 From: Tristan Jones Date: Mon, 2 Jan 2017 22:01:28 -0700 Subject: [PATCH 36/45] Fixed capitalization of OptionTypes and extra parens around functions --- readline-sync/index.d.ts | 40 +++++++++++++++++++++------- readline-sync/readline-sync-tests.ts | 1 - 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/readline-sync/index.d.ts b/readline-sync/index.d.ts index 0307af5eda..78d7e313f9 100644 --- a/readline-sync/index.d.ts +++ b/readline-sync/index.d.ts @@ -3,22 +3,22 @@ // Definitions by: Tristan Jones // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -type optionType = string | number | RegExp | ((input: string) => boolean); +type OptionType = string | number | RegExp | ((input: string) => boolean); interface BasicOptions { prompt?: any; hideEchoBack?: boolean; mask?: string; - limit?: optionType | optionType[]; + limit?: OptionType | OptionType[]; limitMessage?: string; defaultInput?: string; - trueValue?: optionType | optionType[]; - falseValue?: optionType | optionType[]; + trueValue?: OptionType | OptionType[]; + falseValue?: OptionType | OptionType[]; caseSensitive?: boolean; keepWhitespace?: boolean; encoding?: string; bufferSize?: number; - print?: ((display: string, encoding: string) => void); + print?: (display: string, encoding: string) => void; history?: boolean; cd?: boolean; charlist?: string; @@ -29,7 +29,7 @@ interface BasicOptions { exists?: any; isFile?: boolean; isDirectory?: boolean; - validate?: ((path: string) => boolean | string); + validate?: (path: string) => boolean | string; create?: boolean; guide?: boolean; } @@ -47,9 +47,9 @@ export function questionInt(query?: any, options?: BasicOptions): number; export function questionFloat(query?: any, options?: BasicOptions): number; export function questionPath(query?: any, options?: BasicOptions): string; -export function promptCL(commandHandler?: { [id: string]: ((...args: string[]) => void) } | ((command: string, ...args: string[]) => void), options?: BasicOptions): string[]; -export function promptLoop(inputHandler: ((value: string) => boolean), options?: BasicOptions): void; -export function promptCLLoop(commandHandler?: { [id: string]: ((...args: string[]) => boolean | void) } | ((command: string, ...args: string[]) => boolean | void), options?: BasicOptions): void; +export function promptCL(commandHandler?: { [id: string]: (...args: string[]) => void } | ((command: string, ...args: string[]) => void), options?: BasicOptions): string[]; +export function promptLoop(inputHandler: (value: string) => boolean, options?: BasicOptions): void; +export function promptCLLoop(commandHandler?: { [id: string]: (...args: string[]) => boolean | void } | ((command: string, ...args: string[]) => boolean | void), options?: BasicOptions): void; export function promptSimShell(options?: BasicOptions): string; export function keyInYN(query?: any, options?: BasicOptions): boolean | string; @@ -60,8 +60,28 @@ export function keyInSelect(items: string[], query?: any, options?: BasicOptions export function getRawInput(): string; // Deprecated + +/** + * @deprecated Use the bufferSize option instead: readlineSync.setDefaultOptions({bufferSize: value}); + */ export function setBufferSize(value: number): void; + +/** + * @deprecated Use the encoding option instead: readlineSync.setDefaultOptions({encoding: value}); + */ export function setEncoding(value: string): void; + +/** + * @deprecated Use the mask option instead: readlineSync.setDefaultOptions({mask: value}); + */ export function setMask(value: string): void; -export function setPrint(value: ((display: string, encoding: string) => void)): void; + +/** + * @deprecated Use the print option instead: readlineSync.setDefaultOptions({print: value}); + */ +export function setPrint(value: (display: string, encoding: string) => void): void; + +/** + * @deprecated Use the prompt option instead: readlineSync.setDefaultOptions({prompt: value}); + */ export function setPrompt(value: any): void; \ No newline at end of file diff --git a/readline-sync/readline-sync-tests.ts b/readline-sync/readline-sync-tests.ts index a201659e7a..02c8d8e952 100644 --- a/readline-sync/readline-sync-tests.ts +++ b/readline-sync/readline-sync-tests.ts @@ -107,4 +107,3 @@ readlineSync.setEncoding('utf-16'); readlineSync.setMask('%'); readlineSync.setBufferSize(128); - From 1afa4639883c5b6334cf6cb16b826ff872e1ab18 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Tue, 3 Jan 2017 06:25:39 -0800 Subject: [PATCH 37/45] Add typings for expr-eval (#13628) * Add typings for expr-eval * Avoid use of Function type * Use (slightly) stricter typings for expr-eval * Update with more PR comments * Disable linter due to bugs, allow CI to pass --- expr-eval/expr-eval-tests.ts | 14 ++++++++++++++ expr-eval/index.d.ts | 37 ++++++++++++++++++++++++++++++++++++ expr-eval/tsconfig.json | 20 +++++++++++++++++++ expr-eval/tslint.json | 1 + 4 files changed, 72 insertions(+) create mode 100644 expr-eval/expr-eval-tests.ts create mode 100644 expr-eval/index.d.ts create mode 100644 expr-eval/tsconfig.json create mode 100644 expr-eval/tslint.json diff --git a/expr-eval/expr-eval-tests.ts b/expr-eval/expr-eval-tests.ts new file mode 100644 index 0000000000..53689ea6bd --- /dev/null +++ b/expr-eval/expr-eval-tests.ts @@ -0,0 +1,14 @@ +import { Parser, Expression } from 'expr-eval'; + +const expr = Parser.parse('2^2'); +Parser.evaluate('2^2'); +Parser.evaluate('2^x', { x: 2 }); +Parser.evaluate('x.toUpperCase()', { x: 'hello world' }); + +expr.evaluate({ x: 3 }); +expr.simplify(); +expr.simplify({ x: 2 }); +expr.variables().forEach(str => str.toUpperCase()); +expr.symbols().forEach(str => str.toUpperCase()); +expr.toJSFunction('y, x'); +expr.toJSFunction('y, z', { y: 2 })({ z: 3 }); diff --git a/expr-eval/index.d.ts b/expr-eval/index.d.ts new file mode 100644 index 0000000000..7f72eb6101 --- /dev/null +++ b/expr-eval/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for expr-eval 1.0 +// Project: https://github.com/silentmatt/expr-eval#readme +// Definitions by: Connor Peet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace exprEval { + type Value = number + | string + | ((...args: Value[]) => Value) + | { [propertyName: string]: Value }; + + interface Values { + [propertyName: string]: Value; + } + + export class Parser { + constructor(options?: { allowMemberAccess?: boolean }); + parse(expression: string): Expression; + evaluate(expression: string, values?: Value): number; + + // todo(connor4312): tslint is disabled on the following two lines, as + // thinks that the above instance methods are overloads for the static methods. + static parse(expression: string): Expression; // tslint:disable-line + static evaluate(expression: string, values?: Value): number; // tslint:disable-line + } + + export interface Expression { + simplify(values?: Values): Expression; + evaluate(values?: Values): number; + substitute(values: Values): Expression; + symbols(): string[]; + variables(): string[]; + toJSFunction(params: string, values?: Values): (...args: Value[]) => number; + } +} + +export = exprEval; diff --git a/expr-eval/tsconfig.json b/expr-eval/tsconfig.json new file mode 100644 index 0000000000..80230f8303 --- /dev/null +++ b/expr-eval/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "expr-eval-tests.ts" + ] +} diff --git a/expr-eval/tslint.json b/expr-eval/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/expr-eval/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 334e1d136358071b200163abb0a9b1db55b5b52e Mon Sep 17 00:00:00 2001 From: Ali Taheri Moghaddar Date: Tue, 3 Jan 2017 18:15:12 +0330 Subject: [PATCH 38/45] Add jalaali-js typings (#13702) * Add jalaali-js typings * Fix version and improve jsdoc formatting --- jalaali-js/index.d.ts | 142 +++++++++++++++++++++++++++++++++ jalaali-js/jalaali-js-tests.ts | 42 ++++++++++ jalaali-js/tsconfig.json | 20 +++++ jalaali-js/tslint.json | 3 + 4 files changed, 207 insertions(+) create mode 100644 jalaali-js/index.d.ts create mode 100644 jalaali-js/jalaali-js-tests.ts create mode 100644 jalaali-js/tsconfig.json create mode 100644 jalaali-js/tslint.json diff --git a/jalaali-js/index.d.ts b/jalaali-js/index.d.ts new file mode 100644 index 0000000000..be002bb60d --- /dev/null +++ b/jalaali-js/index.d.ts @@ -0,0 +1,142 @@ +// Type definitions for jalaali-js 1.1 +// Project: https://github.com/jalaali/jalaali-js +// Definitions by: Ali Taheri Moghaddar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Jalaali date parts + */ +export interface JalaaliDateObject { + /** Jalaali year */ + jy: number; + /** Jalaali month */ + jm: number; + /** Jalaali day */ + jd: number; +} + +/** + * Gregorian date parts + */ +export interface GregorianDateObject { + /** Gregorian year */ + gy: number; + /** Gregorian month */ + gm: number; + /** Gregorian day */ + gd: number; +} + +/** + * Object returned by jalCal function + */ +export interface JalCalResult { + /** Number of years since the last leap year (0 to 4) */ + leap: number; + /** Gregorian year of the beginning of Jalaali year */ + gy: number; + /** The March day of Farvardin the 1st (1st day of jy) */ + march: number; +} + +/** + * Converts a Gregorian date to Jalaali. + * @param gy Gregorian Calendar year (years BC numbered 0, -1, -2, ...) + * @param gm Gregorian Calendar month (1 to 12) + * @param gd Gregorian Calendar day of the month (1 to 28/29/30/31) + */ +export function toJalaali(gy: number, gm: number, gd: number): JalaaliDateObject; + +/** + * Converts a Gregorian Date object to Jalaali. + * @param date Gregorian Date object + */ +export function toJalaali(date: Date): JalaaliDateObject; + +/** + * Converts a Jalaali date to Gregorian. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + * @param jm Jalaali Calendar month (1 to 12) + * @param jd Jalaali Calendar day of the month (1 to 28/29/30/31) + */ +export function toGregorian(jy: number, jm: number, jd: number): GregorianDateObject; + +/** + * Checks whether a Jalaali date is valid or not. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + * @param jm Jalaali Calendar month (1 to 12) + * @param jd Jalaali Calendar day of the month (1 to 28/29/30/31) + */ +export function isValidJalaaliDate(jy: number, jm: number, jd: number): boolean; + +/** + * Check if this is a leap year. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + */ +export function isLeapJalaaliYear(jy: number): boolean; + +/** + * Number of days in a given month in a Jalaali year. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + * @param jm Jalaali Calendar month (1 to 12) + */ +export function jalaaliMonthLength(jy: number, jm: number): number; + +/** + * This function determines if the Jalaali (Persian) year is + * leap (366-day long) or is the common year (365 days), and + * finds the day in March (Gregorian calendar) of the first + * day of the Jalaali year (jy). + * @param jy Jalaali calendar year (-61 to 3177) + * @return + * leap: number of years since the last leap year (0 to 4) + * gy: Gregorian year of the beginning of Jalaali year + * march: the March day of Farvardin the 1st (1st day of jy) + * @see: http://www.astro.uni.torun.pl/~kb/Papers/EMP/PersianC-EMP.htm + * @see: http://www.fourmilab.ch/documents/calendar/ + */ +export function jalCal(jy: number): JalCalResult; + +/** + * Converts a date of the Jalaali calendar to the Julian Day number. + * @param jy Jalaali year (1 to 3100) + * @param jm Jalaali month (1 to 12) + * @param jd Jalaali day (1 to 29/31) + * @return Julian Day number + */ +export function j2d(jy: number, jm: number, jd: number): number; + +/** + * Converts the Julian Day number to a date in the Jalaali calendar. + * @param jdn Julian Day number + * @return + * jy: Jalaali Calendar year (1 to 3100) + * jm: Jalaali Calendar month (1 to 12) + * jd: Jalaali Calendar day (1 to 29/31) + */ +export function d2j(jdn: number): JalaaliDateObject; + +/** + * Calculates the Julian Day number from Gregorian or Julian + * calendar dates. This integer number corresponds to the noon of + * the date (i.e. 12 hours of Universal Time). + * The procedure was tested to be good since 1 March, -100100 (of both + * calendars) up to a few million years into the future. + * @param gy Gregorian Calendar year (years BC numbered 0, -1, -2, ...) + * @param gm Gregorian Calendar month (1 to 12) + * @param gd Gregorian Calendar day of the month (1 to 28/29/30/31) + * @return Julian Day number + */ +export function g2d(gy: number, gm: number, gd: number): number; + +/** + * Calculates Gregorian and Julian calendar dates from the Julian Day number + * (jdn) for the period since jdn=-34839655 (i.e. the year -100100 of both + * calendars) to some millions years ahead of the present. + * @param jdn Julian Day number + * @return + * gy: Gregorian Calendar year (years BC numbered 0, -1, -2, ...) + * gm: Gregorian Calendar month (1 to 12) + * gd: Gregorian Calendar day of the month M (1 to 28/29/30/31) + */ +export function d2g(jdn: number): GregorianDateObject; diff --git a/jalaali-js/jalaali-js-tests.ts b/jalaali-js/jalaali-js-tests.ts new file mode 100644 index 0000000000..4071d3ca28 --- /dev/null +++ b/jalaali-js/jalaali-js-tests.ts @@ -0,0 +1,42 @@ +import { + toJalaali, + toGregorian, + isValidJalaaliDate, + isLeapJalaaliYear, + jalaaliMonthLength, + jalCal, + j2d, + d2j, + g2d, + d2g, +} from 'jalaali-js'; + +toJalaali(2016, 4, 11); // { jy: 1395, jm: 1, jd: 23 } + +toJalaali(new Date(2016, 3, 11)); // { jy: 1395, jm: 1, jd: 23 } + +toGregorian(1395, 1, 23); // { gy: 2016, gm: 4, gd: 11 } + +isValidJalaaliDate(1394, 12, 30); // false +isValidJalaaliDate(1395, 12, 30); // true + +isLeapJalaaliYear(1394); // false +isLeapJalaaliYear(1395); // true + +jalaaliMonthLength(1394, 12); // 29 +jalaaliMonthLength(1395, 12); // 30 + +jalCal(1390); // { leap: 3, gy: 2011, march: 21 } +jalCal(1391); // { leap: 0, gy: 2012, march: 20 } +jalCal(1392); // { leap: 1, gy: 2013, march: 21 } +jalCal(1393); // { leap: 2, gy: 2014, march: 21 } +jalCal(1394); // { leap: 3, gy: 2015, march: 21 } +jalCal(1395); // { leap: 0, gy: 2016, march: 20 } + +j2d(1395, 1, 23); // 2457490 + +d2j(2457490); // { jy: 1395, jm: 1, jd: 23 } + +g2d(2016, 4, 11); // 2457490 + +d2g(2457490); // { gy: 2016, gm: 4, gd: 11 } diff --git a/jalaali-js/tsconfig.json b/jalaali-js/tsconfig.json new file mode 100644 index 0000000000..780ff29ad6 --- /dev/null +++ b/jalaali-js/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jalaali-js-tests.ts" + ] +} \ No newline at end of file diff --git a/jalaali-js/tslint.json b/jalaali-js/tslint.json new file mode 100644 index 0000000000..fdc7cdc370 --- /dev/null +++ b/jalaali-js/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From b43f9bced037e38c5b6d4166de1e4ff6fb2c9dda Mon Sep 17 00:00:00 2001 From: Brady Liles Date: Tue, 3 Jan 2017 07:58:01 -0700 Subject: [PATCH 39/45] Added Bootstrap-Validator (#13657) * Added Bootstrap-Validator * StrictNullChecks => true * Removed Patch Version --- .../bootstrap-validator-tests.ts | 14 +++++++++++++ bootstrap-validator/index.d.ts | 20 +++++++++++++++++++ bootstrap-validator/tsconfig.json | 20 +++++++++++++++++++ bootstrap-validator/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 bootstrap-validator/bootstrap-validator-tests.ts create mode 100644 bootstrap-validator/index.d.ts create mode 100644 bootstrap-validator/tsconfig.json create mode 100644 bootstrap-validator/tslint.json diff --git a/bootstrap-validator/bootstrap-validator-tests.ts b/bootstrap-validator/bootstrap-validator-tests.ts new file mode 100644 index 0000000000..07d4753ed1 --- /dev/null +++ b/bootstrap-validator/bootstrap-validator-tests.ts @@ -0,0 +1,14 @@ +/// + +$('#myForm').validator(); +$('#myForm').validator('update'); +$('#myForm').validator('validate'); +$('#myForm').validator('destroy'); +$('#myForm').validator({ + delay: 500, + html: false, + disable: false, + focus: true, + feedback: {}, + custom: {} +}); diff --git a/bootstrap-validator/index.d.ts b/bootstrap-validator/index.d.ts new file mode 100644 index 0000000000..92dee2c310 --- /dev/null +++ b/bootstrap-validator/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for bootstrap-validator 0.11 +// Project: https://github.com/1000hz/bootstrap-validator +// Definitions by: Brady Liles +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +interface ValidatorOptions { + delay?: number; + html?: boolean; + disable?: boolean; + focus?: boolean; + feedback?: any; + custom?: any; +} + +interface JQuery { + validator(options?: ValidatorOptions): JQuery; + validator(command: string): JQuery; +} diff --git a/bootstrap-validator/tsconfig.json b/bootstrap-validator/tsconfig.json new file mode 100644 index 0000000000..d5bde637e0 --- /dev/null +++ b/bootstrap-validator/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bootstrap-validator-tests.ts" + ] +} diff --git a/bootstrap-validator/tslint.json b/bootstrap-validator/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/bootstrap-validator/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 6b628df7b4730f405128bcddeed618a20828a8be Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 3 Jan 2017 12:53:50 -0500 Subject: [PATCH 40/45] Meow showHelp optional param (#13710) --- meow/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meow/index.d.ts b/meow/index.d.ts index d687f65611..fe208c83f5 100644 --- a/meow/index.d.ts +++ b/meow/index.d.ts @@ -22,7 +22,7 @@ declare namespace meow { flags: { [name: string]: any }; pkg: any; help: string; - showHelp(code: number): void; + showHelp(code?: number): void; } } From 4f8d89c52e204cba51c4d753d27bbc531cf400ce Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 3 Jan 2017 09:54:10 -0800 Subject: [PATCH 41/45] Revert #13423: Change `createBrowserHistory` back to `createHistory` (#13709) --- history/history-tests.ts | 18 +++++++++--------- history/index.d.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/history/history-tests.ts b/history/history-tests.ts index 454b223e09..1d6565838e 100644 --- a/history/history-tests.ts +++ b/history/history-tests.ts @@ -1,4 +1,4 @@ -import { createBrowserHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history' +import { createHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history' import { getUserConfirmation } from 'history/lib/DOMUtils' @@ -10,7 +10,7 @@ let doSomethingAsync: () => Promise; let input = { value: "" }; { - let history = createBrowserHistory() + let history = createHistory() // Listen for changes to the current location. The // listener is called once immediately. @@ -46,7 +46,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory() + let history = createHistory() // Pushing a path string. history.push('/the/path') @@ -63,7 +63,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory() + let history = createHistory() history.listenBefore(function(location) { if (input.value !== '') return 'Are you sure you want to leave this page?' @@ -75,7 +75,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory({ + let history = createHistory({ getUserConfirmation(message, callback) { callback(window.confirm(message)) // The default behavior } @@ -83,7 +83,7 @@ let input = { value: "" }; } { - let history = useBeforeUnload(createBrowserHistory)() + let history = useBeforeUnload(createHistory)() history.listenBeforeUnload(function() { return 'Are you sure you want to leave this page?' @@ -91,7 +91,7 @@ let input = { value: "" }; } { - let history = useQueries(createBrowserHistory)() + let history = useQueries(createHistory)() history.listen(function(location) { console.log(location.query) @@ -99,7 +99,7 @@ let input = { value: "" }; } { - let history = useQueries(createBrowserHistory)({ + let history = useQueries(createHistory)({ parseQueryString: function(queryString) { // TODO: return a parsed version of queryString return {}; @@ -116,7 +116,7 @@ let input = { value: "" }; { // Run our app under the /base URL. - let history = useBasename(createBrowserHistory)({ + let history = useBasename(createHistory)({ basename: '/base' }) diff --git a/history/index.d.ts b/history/index.d.ts index 5f719c2f0b..6b61fa1b77 100644 --- a/history/index.d.ts +++ b/history/index.d.ts @@ -127,7 +127,7 @@ export interface Module { }; } -export { default as createBrowserHistory } from "./lib/createBrowserHistory"; +export { default as createHistory } from "./lib/createBrowserHistory"; export { default as createHashHistory } from "./lib/createHashHistory"; export { default as createMemoryHistory } from "./lib/createMemoryHistory"; export { default as createLocation } from "./lib/createLocation"; From 3876a417cd0bb5ffd1e530d7768ac91612e5184d Mon Sep 17 00:00:00 2001 From: Alfy Date: Tue, 3 Jan 2017 21:02:50 +0300 Subject: [PATCH 42/45] Added types to functions for FlexSlider (#13708) * Changed noImplicitAny to true * Added any type to the functions * Fixed failing tests * Changed canAdvance to return a boolean --- flexslider/flexSlider-tests.ts | 4 ++-- flexslider/index.d.ts | 12 ++++++------ flexslider/tsconfig.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/flexslider/flexSlider-tests.ts b/flexslider/flexSlider-tests.ts index 2369ce9b31..591e874262 100644 --- a/flexslider/flexSlider-tests.ts +++ b/flexslider/flexSlider-tests.ts @@ -62,7 +62,7 @@ $(window).load(function() { var player = document.getElementById('player_1'); $(player).on('ready', ready); - function addEvent(element, eventName, callback) { + function addEvent(element:any, eventName:any, callback:any) { if (element.addEventListener) { element.addEventListener(eventName, callback, false) } else { @@ -70,7 +70,7 @@ $(window).load(function() { } } - function ready(player_id) { + function ready(player_id: any) { var froogaloop = $(player_id); froogaloop.on('play', function(data) { $('.flexslider').flexslider("pause"); diff --git a/flexslider/index.d.ts b/flexslider/index.d.ts index c15d5d59be..9767744919 100644 --- a/flexslider/index.d.ts +++ b/flexslider/index.d.ts @@ -18,11 +18,11 @@ interface SliderObject { //Object: The slider element itself directionNav: Object; //Object: The slider directionNav controlsContainer: Object; //Object: The controlsContainer element of the slider manualControls: Object; //Object: The manualControls element of the slider - flexAnimate(target, pause?); //Function: Move slider - (target, pause) parameters - pause(); //Function: Pause slider slideshow interval - resume(); //Function: Resume slider slideshow interval - canAdvance(target); //Function: returns boolean if slider can advance - (target) parameter - getTarget(dir); //Function: get target given a direction - "next" or "prev" parameter + flexAnimate(target:any, pause?: any) :any; //Function: Move slider - (target, pause) parameters + pause(): any; //Function: Pause slider slideshow interval + resume(): any; //Function: Resume slider slideshow interval + canAdvance(target:any): boolean; //Function: returns boolean if slider can advance - (target) parameter + getTarget(dir: any): any; //Function: get target given a direction - "next" or "prev" parameter } interface FlexSliderOptions { @@ -86,5 +86,5 @@ interface FlexSliderOptions { interface JQuery { - flexslider(options?: FlexSliderOptions); + flexslider(options?: FlexSliderOptions): any; } diff --git a/flexslider/tsconfig.json b/flexslider/tsconfig.json index c34db7d4d9..2319b11528 100644 --- a/flexslider/tsconfig.json +++ b/flexslider/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es6", - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "baseUrl": "../", From 18e96e67d7c60b226281a509e9dccb2f23bcecae Mon Sep 17 00:00:00 2001 From: a8775 Date: Tue, 3 Jan 2017 19:21:31 +0100 Subject: [PATCH 43/45] add HeapInfo interface to v8 module (#13677) * add HeapInfo interface to v8 module Documentation: https://nodejs.org/dist/latest-v7.x/docs/api/v8.html#v8_v8_getheapstatistics Changes: - add HeapInfo interface to the v8 module, add missing fields: malloced_memory, peak_malloced_memory, does_zap_garbage - change return type for the method: v8.getHeapStatistics() * change does_zap_garbage type to be 0|1 * add const enum DoesZapCodeSpaceFlag type --- node/index.d.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/node/index.d.ts b/node/index.d.ts index c7f481015c..54f9f53753 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -3961,7 +3961,25 @@ declare module "v8" { space_available_size: number; physical_space_size: number; } - export function getHeapStatistics(): { total_heap_size: number, total_heap_size_executable: number, total_physical_size: number, total_avaialble_size: number, used_heap_size: number, heap_size_limit: number }; + + const enum DoesZapCodeSpaceFlag { + Disabled = 0, + Enabled = 1 + } + + interface HeapInfo { + total_heap_size: number; + total_heap_size_executable: number; + total_physical_size: number; + total_available_size: number; + used_heap_size: number; + heap_size_limit: number; + malloced_memory: number; + peak_malloced_memory: number; + does_zap_garbage: DoesZapCodeSpaceFlag; + } + + export function getHeapStatistics(): HeapInfo; export function getHeapSpaceStatistics(): HeapSpaceInfo[]; export function setFlagsFromString(flags: string): void; } From 5f1f3ebb00568c016844d3a93b690fa1143aa2a2 Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Wed, 4 Jan 2017 05:17:41 +0900 Subject: [PATCH 44/45] Add extract-zip types (#13713) --- extract-zip/extract-zip-tests.ts | 20 ++++++++++++++++++++ extract-zip/index.d.ts | 21 +++++++++++++++++++++ extract-zip/tsconfig.json | 20 ++++++++++++++++++++ extract-zip/tslint.json | 1 + 4 files changed, 62 insertions(+) create mode 100644 extract-zip/extract-zip-tests.ts create mode 100644 extract-zip/index.d.ts create mode 100644 extract-zip/tsconfig.json create mode 100644 extract-zip/tslint.json diff --git a/extract-zip/extract-zip-tests.ts b/extract-zip/extract-zip-tests.ts new file mode 100644 index 0000000000..33b3a714af --- /dev/null +++ b/extract-zip/extract-zip-tests.ts @@ -0,0 +1,20 @@ +import * as extract from 'extract-zip'; + +let str = 'str'; +let num = 0; + +let options: extract.Options = { + dir: str, +}; +options = { + dir: str, + defaultFileMode: num, +}; + +extract(str, options, (err) => { + if (err) { + console.error(err); + return; + } + console.log('done'); +}); diff --git a/extract-zip/index.d.ts b/extract-zip/index.d.ts new file mode 100644 index 0000000000..52ce40094f --- /dev/null +++ b/extract-zip/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for extract-zip 1.6 +// Project: https://github.com/maxogden/extract-zip +// Definitions by: Mizunashi Mana +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace extract { + export interface Options { + dir?: string; + defaultDirMode?: number; + defaultFileMode?: number; + onEntry?: (entry: any, zipfile: any) => void; + } +} + +declare function extract( + zipPath: string, + opts: extract.Options, + cb: (err?: Error) => void, +): void; + +export = extract; diff --git a/extract-zip/tsconfig.json b/extract-zip/tsconfig.json new file mode 100644 index 0000000000..9a52a5d990 --- /dev/null +++ b/extract-zip/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "extract-zip-tests.ts" + ] +} diff --git a/extract-zip/tslint.json b/extract-zip/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/extract-zip/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From b784512c2e943d4b12b20a5f1337306e4d9d7c3b Mon Sep 17 00:00:00 2001 From: Matthew Clive Date: Tue, 3 Jan 2017 15:19:02 -0500 Subject: [PATCH 45/45] Update Configstore/index.d.ts with accurate definitions for 2.1.0 (#13714) * Fix whitespacing issue * Update index.d.ts * Add version number back * Forgot a line of the header * Update Configstore tests Configstore is a class now, and doesn't expose these properties * Create Configstore/tslint.json * Update index.d.ts * Remove JSDoc types per @andy-ms * Forgot the size property * Update index.d.ts --- configstore/configstore-tests.ts | 7 +-- configstore/index.d.ts | 92 ++++++++++++++++++++++---------- configstore/tslint.json | 3 ++ 3 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 configstore/tslint.json diff --git a/configstore/configstore-tests.ts b/configstore/configstore-tests.ts index 5a615ae9fa..0d8e777fe0 100644 --- a/configstore/configstore-tests.ts +++ b/configstore/configstore-tests.ts @@ -1,5 +1,6 @@ -import cs = require('configstore'); +import Configstore = require('configstore'); +var cs = new Configstore('foo'); var value: any; var key: string; @@ -9,9 +10,9 @@ var object:Object; cs.set(key, value); value = cs.get(key); -cs.del(key); +cs.delete(key); object = cs.all; cs.all = object; num = cs.size; -key = cs.path; \ No newline at end of file +key = cs.path; diff --git a/configstore/index.d.ts b/configstore/index.d.ts index 5d8463b45b..628a4a1d6c 100644 --- a/configstore/index.d.ts +++ b/configstore/index.d.ts @@ -1,37 +1,71 @@ -// Type definitions for configstore 0.3.0 +// Type definitions for configstore 2.1 // Project: https://github.com/yeoman/configstore -// Definitions by: Bart van der Schoor +// Definitions by: ArcticLight // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = Configstore; -/* - Set an item - */ -export declare function set(key: string, val: any): void; +declare class Configstore { + constructor(packageName: string, defaults?: any, options?: Configstore.ConfigstoreOptions); -/* - Get an item - */ -export declare function get(key: string): any; + /** + * Get the path to the config file. Can be used to show the user + * where it is, or better, open it for them. + */ + path: string; -/* - Delete an item - */ -export declare function del(key: string): void; + /** + * Get all items as an object or replace the current config with an object. + */ + all: any; -/* - Get all items as an object or replace the current config with an object: + /** + * Get the item count + */ + size: number; - conf.all = { - hello: 'world' - }; - */ -export declare var all: Object; -/* - Get the item count - */ -export declare var size: number; -/* - Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them. - */ -export declare var path: string; + /** + * Get an item + * @param key The string key to get + * @return The contents of the config from key $key + */ + get(key: string): any; + + /** + * Set an item + * @param key The string key + * @param val The value to set + */ + set(key: string, val: any): void; + + /** + * Set all key/value pairs declared in $values + * @param values The values object. + */ + set(values: any): void; + + /** + * Determines if a key is present in the config + * @param key The string key to test for + * @return True if the key is present + */ + has(key: string): boolean; + + /** + * Delete an item. + * @param key The key to delete + */ + delete(key: string): void; + + /** + * Clear the config. + * Equivalent to Configstore.all = {}; + */ + clear(): void; + } + +declare namespace Configstore { + export interface ConfigstoreOptions { + globalConfigPath?: boolean; + } +} diff --git a/configstore/tslint.json b/configstore/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/configstore/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +}