Typings
Astute readers might be wondering what happens when TypeScript programmers needto interface with JavaScript modules that have no type information. TypeScriptrecognizes files labelled *.d.ts
as definition files. These files aremeant to use TypeScript to describe interfaces presented by JavaScriptlibraries.
There are communities of people dedicated to creating typings for JavaScriptprojects. There is also a utility called typings
(npm install —save-dev typings
) that can be used to manage third party typings from a variety of sources. (Deprecated in TypeScript 2.0)
In TypeScript 2.0, users can get type files directly from @types
through npm
(for example, npm install —save @types/lodash
will install lodash
type file).
原文: https://angular-2-training-book.rangle.io/handout/features/typings.html