Reputation: 63
Writing .d.ts files manually usually makes sense only if you deal with already existing .js files. If your project written in TypeScript you shouldn't write .d.ts
by hand - the compiler with --declaration
option will generate them.
In this question i mentioned file https://github.com/microsoft/vscode/blob/master/src/vs/vscode.d.ts as example of writing .d.ts file manually. This project is fully implemented in TypeScript. So, why vscode dev team decided to use such an unusual way to make API declaration, instead of generating it from source code?
Upvotes: 1
Views: 451
Reputation: 71
That's because they want to define the interface, vscode.d.ts
, separately from the implementation. You can find the implementation of the vscode
module here:
If they do not implement something defined in the interface, the compilation fails. You can try it deleting the property version
.
Upvotes: 1