mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[jquery] Fix ArrayLike handling for call signature.
This commit is contained in:
parent
4c5e88a266
commit
1caac6ef59
17
types/jquery/JQueryStatic.d.ts
vendored
17
types/jquery/JQueryStatic.d.ts
vendored
@ -148,21 +148,26 @@ $( "div", xml.responseXML );
|
||||
$( document.body ).css( "background", "black" );
|
||||
```
|
||||
*/
|
||||
// Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810)
|
||||
<T extends Element>(element: T): JQuery<T>;
|
||||
// NOTE: `HTMLSelectElement` is both an Element and an Array-Like Object but jQuery treats it as an Element.
|
||||
(element: HTMLSelectElement): JQuery<HTMLSelectElement>;
|
||||
/**
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string.
|
||||
* @param elementArray An array containing a set of DOM elements to wrap in a jQuery object.
|
||||
* @param element_elementArray _@param_ `element_elementArray`
|
||||
* <br>
|
||||
* * `element` — A DOM element to wrap in a jQuery object. <br>
|
||||
* * `elementArray` — An array containing a set of DOM elements to wrap in a jQuery object.
|
||||
* @see \`{@link https://api.jquery.com/jQuery/ }\`
|
||||
* @since 1.0
|
||||
* @example ````Set the background color of the page to black.
|
||||
```javascript
|
||||
$( document.body ).css( "background", "black" );
|
||||
```
|
||||
* @example ````Hide all the input elements within a form.
|
||||
```javascript
|
||||
$( myForm.elements ).hide();
|
||||
```
|
||||
*/
|
||||
// Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810)
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
<T extends Element>(elementArray: T[]): JQuery<T>;
|
||||
<T extends Element>(element_elementArray: T | ArrayLike<T>): JQuery<T>;
|
||||
/**
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string.
|
||||
* @param selection An existing jQuery object to clone.
|
||||
|
||||
@ -160,6 +160,9 @@ function JQueryStatic() {
|
||||
// $ExpectType JQuery<HTMLSelectElement>
|
||||
$([new HTMLSelectElement()]);
|
||||
|
||||
// $ExpectType JQuery<HTMLParagraphElement>
|
||||
$(document.querySelectorAll('p'));
|
||||
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432
|
||||
function issue_19597_378218432() {
|
||||
const myDiv = $(document.createElement('div'));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user