typescript - Infer the type of object keys -
is possible in typescript declare structure type of function
assigned error
key in jquery.ajax
inferred? report on type mismatch if 1 tries assign wrong function signature.
$.ajax({ type: "post", url: listurl, jsonp: 'jsonp', datatype: "jsonp", success: onsuccescall, error: onerrorcall }); function onerrorcall(jqxhr, textstatus, errorthrown) { ... }
this should done already, limited extent (limited the definition using , jquery api full of optionality).
var listurl = 'http://www.example.com/'; function onsuccesscall (data, thing: boolean, another: boolean) { // implementation } function onerrorcall () { // implementation } $.ajax({ type: "post", url: listurl, jsonp: 'jsonp', datatype: "jsonp", success: onsuccesscall, error: onerrorcall });
in above example, onsuccesscall
cause typescript issue warning not have signature compatible success property, expects (data:any, textstatus: string, jqxhr: jqueryxhr) => any
.
note supply function omits of these , compatible (because don't have argument passed).
Comments
Post a Comment