mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[@types/jquery] Improve type for find function (#43857)
This commit is contained in:
parent
1186f63e5f
commit
2b7681ee6c
4
types/jquery/JQuery.d.ts
vendored
4
types/jquery/JQuery.d.ts
vendored
@ -4133,7 +4133,9 @@ $( "p" )
|
||||
</html>
|
||||
```
|
||||
*/
|
||||
find(selector_element: JQuery.Selector | Element | JQuery): this;
|
||||
find<K extends keyof HTMLElementTagNameMap>(selector_element: K | JQuery<K>): JQuery<HTMLElementTagNameMap[K]>;
|
||||
find<K extends keyof SVGElementTagNameMap>(selector_element: K | JQuery<K>): JQuery<SVGElementTagNameMap[K]>;
|
||||
find<E extends HTMLElement>(selector_element: JQuery.Selector | E | JQuery<E>): JQuery<E>;
|
||||
/**
|
||||
* 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.
|
||||
|
||||
1
types/jquery/index.d.ts
vendored
1
types/jquery/index.d.ts
vendored
@ -22,6 +22,7 @@
|
||||
// Dick van den Brink <https://github.com/DickvdBrink>
|
||||
// Thomas Schulz <https://github.com/King2500>
|
||||
// Terry Mun <https://github.com/terrymun>
|
||||
// Martin Badin <https://github.com/martin-badin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
@ -5849,14 +5849,26 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function find() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<HTMLSpanElement>
|
||||
$('p').find('span');
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').find('.class-name');
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').find(new HTMLElement());
|
||||
|
||||
// $ExpectType JQuery<HTMLSpanElement>
|
||||
$('p').find(new HTMLSpanElement());
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').find($('span'));
|
||||
|
||||
// $ExpectType JQuery<HTMLSpanElement>
|
||||
$('p').find($<HTMLSpanElement>('.class-name'));
|
||||
|
||||
// $ExpectType JQuery<HTMLSpanElement>
|
||||
$('p').find<HTMLSpanElement>($('.class-name'));
|
||||
}
|
||||
|
||||
function addBack() {
|
||||
@ -5897,11 +5909,17 @@ function JQuery() {
|
||||
function first() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').first();
|
||||
|
||||
// $ExpectType JQuery<HTMLSpanElement>
|
||||
$('p').find('span').first();
|
||||
}
|
||||
|
||||
function last() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').last();
|
||||
|
||||
// $ExpectType JQuery<HTMLSpanElement>
|
||||
$('p').find('span').first();
|
||||
}
|
||||
|
||||
function offsetParent() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user