Posts

Showing posts from December, 2017

typescript ambient declarations, global.d.ts, lib and typeRoot.md

typescript ambient declarations, global.d.ts, lib and typeRoot.md When using typescript, you may have global ambient declarations you need to add. For example, my HTML defines several variables prior to my main .js file being loaded and executed. The .js file, packed using webscript and written in typescript, needs access to those variables. Accesing the HTML variables is much like accessing “window” inside of a .ts file. The typescript compiler declares a window object for us and makes it available without import in our .ts files. We clearly need something like that. google searching did not yield alot of insight, but the key thoughts you need to know are: typescript reads all your files in your compiler path e.g. src then compiles the file you want to compile and output. typescript has a search path algorithm that is used when importing modules. This search path is not relevant to solving the global ambient problem. Global ambient can be declared in a g