mobal mobal - 4 months ago 13
TypeScript Question

possible bug in typescript JQuery.html()

example:

let $div = $("div");
let $p = $("p");
$div.html($p);


gives this error:

Supplied parameters do not match any signature of call target.

EDIT:
in plain js/jquery this is working. An equivalent (in final result) to the following (still in typescript):

let $div = $("div");
let $p = $("p");
$div.html("").append($p);


Does the typescript definition of
JQuery.html()
is wrong or did i made a mistake somewhere ?

Answer

Signature that you are looking for is missing in typescript definition (as it is not documented), but you can add it manually:

interface JQuery{
    html(obj:JQuery): JQuery;
}