在TypeScript程序中应该声明全局变量文档和窗口吗?

Ric*_*uhr 1 typescript

在我第一次尝试使用TypeScript编程时,我一直在使用全局变量文档和窗口,而没有声明它们的类型.有没有推荐的做法?例如,建议声明如下内容:

var document:Document; var窗口:窗口;

bas*_*rat 5

有没有推荐的做法?例如,建议声明如下内容: var document : Document; var window : Window;

没有.它们由编译器使用名为的文件包含在您的编译上下文中lib.d.ts.

更多

https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html