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:
- by vscode's own language server and
- 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?