Skip to content

Commit

Permalink
[jquery] Fix declaration of function parameter for .replaceWith().
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard-thieu committed Dec 9, 2018
1 parent 5c9f9cc commit 5001e2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions types/jquery/JQuery.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9839,7 +9839,6 @@ $( "<b>Paragraph. </b>" ).replaceAll( "p" );
```
*/
replaceAll(target: JQuery.Selector | JQuery | JQuery.TypeOrArray<Element>): this;
// TODO: Validate signature of `function`.
/**
* 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_function _&#x40;param_ `newContent_function`
Expand Down Expand Up @@ -9991,10 +9990,13 @@ $( "button" ).on( "click", function() {
```
*/
replaceWith(newContent_function: JQuery.htmlString |
JQuery |
JQuery<JQuery.Node> |
JQuery.TypeOrArray<Element> |
JQuery.Node |
((this: TElement) => any)): this;
((this: TElement, index: number, oldhtml: JQuery.htmlString) => JQuery.htmlString |
JQuery<JQuery.Node> |
JQuery.TypeOrArray<Element> |
JQuery.Node)): this;
/**
* Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.
* @param eventData An object containing data that will be passed to the event handler.
Expand Down
8 changes: 6 additions & 2 deletions types/jquery/jquery-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5550,11 +5550,15 @@ function JQuery() {
$('p').replaceWith(document.createComment('bar'));

// $ExpectType JQuery<HTMLElement>
$('p').replaceWith(function() {
$('p').replaceWith(function(index, oldhtml) {
// $ExpectType HTMLElement
this;
// $ExpectType number
index;
// $ExpectType string
oldhtml;

return this;
return undefined! as JQuery.htmlString | JQuery<JQuery.Node> | JQuery.TypeOrArray<Element> | JQuery.Node;
});
}

Expand Down

0 comments on commit 5001e2c

Please sign in to comment.