TypeScript: view on playground
alert = (function (origAlert) {
return function (...messages: any[]) {
origAlert(messages.join(" "))
}
})(alert)
// Example
alert(1, 2)
I want to overwrite / redefine the function alert(message?: any) which has already been declared in lib.d.ts before: declare function alert(message?: any): void;
But alert = function... throws "Invalid left-hand side of assignment expression."
The point is that, function alert(...messages: any[]) { /* ... */ } would work* does not even work as well, but I need to use the original alert. And I'd dislike to define an extra const origAlert = alert before the function.
How can I do this?
Note that the compiled JavaScript in the Playground works as intended.
*on TypeScript Playground it works, but in Visual Studio it throws "Overload signatures must all be ambient or non-ambient"
console.log(). Otherwise, it's a bad idea to redefine native functions, often it backfires.