Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] exposing the FileRegistry in 2.0 #127

Closed
zcf0508 opened this issue Jan 29, 2024 · 0 comments · Fixed by #128
Closed

[Feature Request] exposing the FileRegistry in 2.0 #127

zcf0508 opened this issue Jan 29, 2024 · 0 comments · Fixed by #128

Comments

@zcf0508
Copy link
Contributor

zcf0508 commented Jan 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants