The behaviour is by design, it is intended to make writing library extensions and managing dependencies a bit easier. For example, if you were writing a jQuery plugin, you would want your .d.ts
file to contain all of your definitions, but not the jQuery definitions. For this reason the compiler won't add anything from "external" .d.ts
files into the combined .d.ts
file you generate.
If it did include these definitions, it would cause duplicate definition errors when people combine multiple libraries (i.e. the jQuery definitions would be duplicated in every plugin definition).
If you want code included in your single compiled .d.ts
file, it needs to originate from a .ts
file without the d-prefix. This does mean adding the declare
keyword to modules / classes inside the file - but actually that may become a requirement in version 0.9 anyway even for .d.ts
files so that isn't much overhead.
In essence, you could think of the file extensions as follows:
.ts
files are internal to the program.d.ts
files are external dependencies