khokm
khokm

Reputation: 63

Why does vscode source code contains vscode.d.ts file which is written manually?

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

Answers (1)

tamuratak
tamuratak

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:

https://github.com/microsoft/vscode/blob/b449c95a8460443ee6bf985bb6c8db63d395e6e6/src/vs/workbench/api/common/extHost.api.impl.ts#L1065

If they do not implement something defined in the interface, the compilation fails. You can try it deleting the property version.

Upvotes: 1

Related Questions