You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functiontest(element: HTMLElement);functiontest(selector: string);functiontest(elementOrSelector: HTMLElement|string){varelement: HTMLElement,initialText='';if(typeofelementOrSelector==='string'){element=<any>document.querySelector(elementOrSelector);}elseif(elementOrSelectorinstanceofHTMLElement){element=elementOrSelector;}else{thrownewTypeError('elementOrSelector must be either an HTML element or a CSS selector (e.g. passing document.getElementById("element") and "#element" is equivalent)');}}functionreplace(element: HTMLElement);functionreplace(selector: string);functionreplace(elementOrSelector: HTMLElement|string){returntest(elementOrSelector);}
TypeScript throws an error on line 18 (return test(elementOrSelector);):
Argument of type 'string | HTMLElement' is not assignable to parameter of type 'string'. Type 'HTMLElement' is not assignable to type 'string'.
(parameter) elementOrSelector: string | HTMLElement
The text was updated successfully, but these errors were encountered:
Example
TypeScript throws an error on line 18 (
return test(elementOrSelector);
):The text was updated successfully, but these errors were encountered: