Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are typescript typings?

I just started playing with angular 2, and I saw that many projects that are available on the web have a folder called typings. Digging more into the problem I found that it has something to do with https://www.npmjs.com/package/typings package. I read their documentation but I didn't understand exactly why do we need typings. Can you provide some example where typings are needed or helpful. Thanks

like image 456
Doua Beri Avatar asked Jan 04 '16 11:01

Doua Beri


People also ask

What is Typings in angular?

Typings is an NPM package to handle the type definitions associated with third-party libraries. This way the tooling will be aware of the types used inside the application. After explaining the typings library, Scott summarizes the different coding syntax options with Angular 2.

What are TypeScript declaration files?

Declaration files, if you're not familiar, are just files that describe the shape of an existing JavaScript codebase to TypeScript. By using declaration files (also called . d. ts files), you can avoid misusing libraries and get things like completions in your editor.

Where does TypeScript look for Typings?

The . d. ts file is usually placed adjacent to the . ts file, it is providing the typings for.


1 Answers

AFAIK this allows you to use JS libraries like they had type annotations like fully typed TypeScript code. If they are provided for a JS library you get proper autocompletion support and lint checks, ...

See also

  • https://blog.mariusschulz.com/2014/05/19/using-typescripts-type-definition-files-to-get-tooling-support-for-plain-javascript
  • Are typescript type definitions required?
  • How do you produce a .d.ts "typings" definition file from an existing JavaScript library?
like image 169
Günter Zöchbauer Avatar answered Oct 08 '22 09:10

Günter Zöchbauer