[@types/jquery] fix: let jQuery's insertAfter / insertBefore accept Node and JQuery<Node> (#27404)

* fix: let jQuery's insertAfter / insertBefore accept JQuery<HTMLElement> as well as HTMLElement

* jquery now requires typescript 2.4

* fix jQuery dts to compile on TypeScript 2.3
This commit is contained in:
FUJI Goro 2018-07-21 09:56:39 +09:00 committed by Wesley Wigham
parent 37c8afcfa9
commit 9fa7394da1
2 changed files with 14 additions and 2 deletions

View File

@ -4327,7 +4327,7 @@ interface JQuery<TElement = HTMLElement> extends Iterable<TElement> {
* @see \`{@link https://api.jquery.com/insertAfter/ }\`
* @since 1.0
*/
insertAfter(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray<Element> | JQuery): this;
insertAfter(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray<Node> | JQuery<Node>): this;
/**
* Insert every element in the set of matched elements before the target.
*
@ -4336,7 +4336,7 @@ interface JQuery<TElement = HTMLElement> extends Iterable<TElement> {
* @see \`{@link https://api.jquery.com/insertBefore/ }\`
* @since 1.0
*/
insertBefore(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray<Element> | JQuery): this;
insertBefore(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray<Node> | JQuery<Node>): this;
/**
* 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.

View File

@ -5681,6 +5681,12 @@ function JQuery() {
// $ExpectType JQuery<HTMLElement>
$('span').insertAfter($('p'));
// $ExpectType JQuery<HTMLElement>
$('span').insertAfter(new Text('hello!'));
// $ExpectType JQuery<HTMLElement>
$('span').insertAfter($(new Text('hello!')));
}
function insertBefore() {
@ -5698,6 +5704,12 @@ function JQuery() {
// $ExpectType JQuery<HTMLElement>
$('span').insertBefore($('p'));
// $ExpectType JQuery<HTMLElement>
$('span').insertBefore(new Text('hello!'));
// $ExpectType JQuery<HTMLElement>
$('span').insertBefore($(new Text('hello!')));
}
function prependTo() {