Redefine window.console with typescript
typescript
Solution
A shorter solution is to just use a type assertion:
window.console = <any>{ log: function (msg) { } };
And even use a lambda:
window.console = <any>{ log: () => { } };
Problem
I had the following javascript in my error logging code, which defines `console.log` for certain browsers where it doesn't exist (IE doesn't/didn't have it defined unless the debug tools are open). ``` if (typeof console == "undefined") { window.console = { log: function (msg) { } }; } ``` The problem when trying to upgrade the js to Typescript is that `window.console` is defined as being of the `Console` interface type and since I'm not specifying everything it (obviously) doesn't compile. ``` interface Console { info(message?: any, ...optionalParams: any[]): void; profile(reportName?: string): void; assert(test?: boolean, message?: string, ...optionalParams: any[]): void; msIsIndependentlyComposed(element: Element): boolean; clear(): void; dir(value?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; error(message?: any, ...optionalParams: any[]): void; log(message?: any, ...optionalParams: any[]): void; profileEnd(): void; } ``` How can tell it to ignore this interface and just let me redefine `window.console`. My best effort guess doesn't work ``` window.console = { log: function (msg) { } } : any; ```