How to provide types for VS Code extension exported API?

Viewed 187

I'm developing a VS Code extension (in TypeScript) with the primary goal being to provide an API to other extensions. The extension has no user-facing functionality. However, I can't find a well documented way to provide types to other extensions who use this API.

I'm exporting the API through the method specified here: https://code.visualstudio.com/api/references/vscode-api#extensions

I've played around with consuming this extension in development, and the only way I've found to keep types so far is manually declaring the interfaces in the consumer extension and then typecasting extension.exports.

One idea I had is to create an NPM package which wraps around vscode.extensions.getExtension(...) to provide the API as a module and includes types. This is fine, but I was just wondering if I'm missing something that would allow me to provide types in a cleaner way.

0 Answers
Related