How can I Access/Reuse the Typescript Type Checker Information from Within my 3rd Party Visual Studio Code Extension?

Viewed 118

I am creating an extension for Visual Studio Code. When editing TypeScript and JavaScript files, I augment specific parts of the source code depending on the type of the related AST node.

To gain access to the type information required, I use createProgram of TypeScript as described here: https://learning-notes.mistermicheels.com/javascript/typescript/compiler-api/#getting-type-information

Even though I can work with this up to some extent, this solution is far from optimal: TypeScript code gets compiled at least twice:

  1. by vscode's own language server and
  2. by my extension in order to get type information.

I would like to circumvent this additional effort since, especially for larger projects, it means a lot of extra stress on the CPU.

Is there a way how 3rd party vscode extensions can access the AST and type information generated by vscode's own, built-in TypeScript language server?

1 Answers
Related