Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are the definitions files loaded in typescript

Tags:

typescript

in the past, d.ts files in typescript were only loaded when specifically required with a ///<reference path="... statement. However, it's my understanding that this has changed recently and the compiler is now able to automatically load some local definition files. I have tried to find the rules for this by googling and browsing the TS specifications but with no success for the moment.

Anyone would be kind enough to explain theses rules or to point me in the right direction ?

like image 719
Vincent J Avatar asked Jun 04 '15 10:06

Vincent J


People also ask

What are DTS files TypeScript?

The "d. ts" file is used to provide typescript type information about an API that's written in JavaScript. The idea is that you're using something like jQuery or underscore, an existing javascript library. You want to consume those from your typescript code.

What is D ts file in react?

d. ts files. Those files are called declaration files and provide typescript type information about APIs of a package.


1 Answers

These days everyone uses tsconfig.json, either original or atom-flavored (in Atom editor).

When using tsconfig.json, you can omit files list and typescript compiler will compile all *.ts files it will find in any subdirectory, including *.d.ts.

Excluding files via exclude is on the way, as well as files globbing.

If you don't want to use tsconfig.json or need files globbing right now, you can achieve similar behavior using gulp with gulp-typescript and gulp-filter.

like image 62
zlumer Avatar answered Sep 23 '22 05:09

zlumer