TypeScript无法识别Firebug的window.console.debug

时间:2013-03-06 16:33:26

标签: firebug typescript

我需要什么TypeScript定义才能让TypeScript编译器识别Firebug的

window.console.debug

识别

window.console.log

没有任何问题。我找不到特定于Firebug的定义文件(我甚至不确定我可以生成定义文件的.js文件。)

3 个答案:

答案 0 :(得分:5)

不推荐使用console.debug方法(因为Gecko 5),所以最好切换到console.log - 这也是跨浏览器。双赢!

值得注意的是,console.debug只是console.log的别名,所以你不会因切换到console.log而丢失任何东西。

https://developer.mozilla.org/en-US/docs/DOM/console

答案 1 :(得分:3)

您可以为Console创建一个界面并参考声明。

// firebug.d.ts
interface Console {
  debug(message: any, ...optionalParams: any[]): void;
}

Console是核心lib.d.ts使用的接口。

(我不知道Firebug的console.debug需要哪些具体参数,因此如果它们与console.log不同,您必须更改我提供的参数。)

答案 2 :(得分:0)

不要假设始终定义console.log。 除非您打开调试工具,否则它可能不在Internet Explorer中。

请参阅'console' is undefined error for Internet Explorer

我的问题 Redefine window.console with typescript

相关问题