Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global and Ambient Dependencies - typings

I am really confused between the ambient and global dependencies. I understood the concept of global dependencies, which means that installing the dependencies globally. But coming to ambient dependencies, I did not understand what it is and now typings recently declared that ambient is now global. I am completely lost.

Can someone please help me clear this confusion.

like image 867
Baradwaj Aryasomayajula Avatar asked May 25 '16 19:05

Baradwaj Aryasomayajula


1 Answers

First off to put you mind somewhat at ease, ambient and global typings are the same thing, it's simply a name change as global better describes their function

As to what they are....

Global declarations, using the simplest definition are typings available in the projects global namespace.

An "external module" is a .d.ts file with a top level import or export. External modules are wrapped by Typings in declare module '....' and after some dependency magic you end up with declarations that do not pollute the projects global name space.

As to why that's important, you can run into conflicts with versions and or duplicate definitions.

Package A depends on version 1.4 of dependency X Package B depends on version 2.0 of dependency X

If the definitions of package A & package B are both global, that version conflict ( different definitions of the same dependency ) end up in the global namespace and the TypeScript compiler blows up.

It all comes down to what scope you want you type declarations to be available in.

like image 187
Joshua Wiens Avatar answered Sep 25 '22 01:09

Joshua Wiens