简体   繁体   English

TypeScript定义文件

[英]TypeScript definition files

I'm playing with TypesScript, but the compiler complains when I use browser types such as HTMLCanvasElement. 我正在使用TypesScript,但是当我使用浏览器类型(如HTMLCanvasElement)时,编译器会抱怨。 I guess I need definition files for these types. 我想我需要这些类型的定义文件。 I bet there is a repository of definition files for the DOM and for most popular frameworks, but Google has not been able to help me find it. 我打赌有一个DOM和大多数流行框架的定义文件存储库,但谷歌无法帮助我找到它。

Do you guys know of such a repository? 你们知道这样的存储库吗?

In addition to what @Christoffer has said for the DOM, @Boris Yankov has a really useful repository here: https://github.com/borisyankov/DefinitelyTyped with definition files for more than thirty, one hundred and thirty close to two hundred libraries(and counting!). 除了@Christoffer对DOM所说的内容之外,@ Boris Yankov还有一个非常有用的存储库: https//github.com/borisyankov/DefinitelyTyped ,定义文件 超过三十,一百三十个 接近二百个库(并计数!)。

There's even a manager for the type definition files now: http://definitelytyped.org/tsd/ 现在甚至还有一个类型定义文件管理器: http//definitelytyped.org/tsd/

AND : Quite a lot of definition files are now on nuget: http://www.nuget.org/packages?q=TypeScript AND :现在有很多定义文件在nuget上: http ://www.nuget.org/packages?q = TypeScript

The lib.d.ts that is included in the source ( http://typescript.codeplex.com/SourceControl/changeset/view/fe3bc0bfce1f#bin%2flib.d.ts ) contains definitions for most of the DOM related stuff. 源代码中包含的lib.d.tshttp://typescript.codeplex.com/SourceControl/changeset/view/fe3bc0bfce1f#bin%2flib.d.ts )包含大多数DOM相关内容的定义。 If you are using Visual Studio, you should consider downloading the tools which includes a template where lib.d.ts is bundled. 如果您使用的是Visual Studio,则应考虑下载包含捆绑了lib.d.ts的模板的工具。

If anything is missing, I think you can use the declare syntax. 如果遗漏了任何内容,我认为你可以使用declare语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM