typescript 打字稿定义文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13118051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TypeScript definition files
提问by Robert Larsen
I'm playing with TypesScript, but the compiler complains when I use browser types such as 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.
我正在使用 TypesScript,但是当我使用诸如 HTMLCanvasElement 之类的浏览器类型时,编译器会抱怨。我想我需要这些类型的定义文件。我敢打赌有一个 DOM 和大多数流行框架的定义文件存储库,但谷歌无法帮助我找到它。
Do you guys know of such a repository?
你们知道这样的存储库吗?
回答by Jude Fisher
In addition to what @Christoffer has said for the DOM, @Boris Yankov has a really useful repository here: https://github.com/borisyankov/DefinitelyTypedwith definition files for more than thirty, one hundred and thirtyclose to two hundredlibraries(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/(Do not follow: link is now NSFW spam)
现在甚至还有一个类型定义文件的管理器:http: //definelytyped.org/tsd/(不要关注:链接现在是 NSFW 垃圾邮件)
AND: Quite a lot of definition files are now on nuget: http://www.nuget.org/packages?q=TypeScript
并且:nuget 上现在有很多定义文件:http://www.nuget.org/packages?q =TypeScript
回答by Christoffer
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. If you are using Visual Studio, you should consider downloading the tools which includes a template where lib.d.ts
is bundled.
该lib.d.ts
包含在源(http://typescript.codeplex.com/SourceControl/changeset/view/fe3bc0bfce1f#bin%2flib.d.ts)包含了大部分的DOM相关的东西的定义。如果您使用的是 Visual Studio,则应考虑下载包含lib.d.ts
捆绑模板的工具。
If anything is missing, I think you can use the declare
syntax.
如果缺少任何内容,我认为您可以使用declare
语法。