volarjs/volar.js

[Feature Request] exposing the `FileRegistry` in 2.0

zcf0508 opened this issue · 0 comments

Hi, I'm working on a vscode extension ts-type-explorer that provides a view to know a type in the js or ts file and I added support for Vue files to this extension. See zcf0508/ts-type-explorer@c306370#diff-0d574bd7891645b07141f9f400e0830e391153bc3d2e7618245fcd8e86bd42fb .

I see that volar.js 2.0 is released recently, and I try to make my code compatible with it. See zcf0508/ts-type-explorer@e62e1cc#diff-0d574bd7891645b07141f9f400e0830e391153bc3d2e7618245fcd8e86bd42fb .

I used the program.__vue.langaugeContext to get the virtualFile and then calculate the new offset in the first commit.

But when I update the volar.js to 2.0, the program no longer exposes the languageContext and virtualFile. So I consider returning the FileRegistry when using proxyCreateProgram to create the program.Like thie.

// https://github.com/volarjs/volar.js/blob/v2.0.0/packages/typescript/lib/node/proxyCreateProgram.ts#L131

const program = Reflect.apply(target, thisArg, [options]);
decorateProgram(files, program);

+ program.files = files

return program;

@johnsoncodehk

If you have a plan to expose the FileRegistry or the other relevant object in other ways, I will wait for you to finish before continuing with further modifications. Alternatively, I can submit a pr according to the above plan.