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

Add in-memory strict language server #67

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

heyimalex
Copy link
Contributor

Implementation of approach that I described in #62. TL;DR: Create a strict LanguageService in memory and getSemanticDiagnostics from it for all strict files.

The create method in a plugin returns a LanguageService, and a LanguageService's entire view of the world is through a LanguageServiceHost. By proxying only getCompilationSettings on LanguageServiceHost to add strict: true and creating a new LanguageService from it, we create a perfect mirror of the stock LanguageService but with strict enabled.

Proxying the LanguageServiceHost was more difficult than the language server, as Object.keys(host) did not return all required methods. I tried grabbing the methods to proxy by walking up the prototype chain, but ultimately I couldn't figure it out; every time I'd be missing some other property and get some variant of a "cant access x on undefined" exception in the tsserver logs. Using a Proxy seems to have done the trick, and I'm successfully using this in my work repo now.

I also proxied dispose and cleanupSemanticCache as they seemed important to the LanguageService lifecycle. I have no idea if they're necessary.

@kamkry
Copy link
Collaborator

kamkry commented Jan 25, 2024

Thank you for your contribution! It's working well on my machine. Can you please bump up the version in your pull request? Great work!

@heyimalex
Copy link
Contributor Author

Version bumped 👍

@KostkaBrukowa
Copy link
Collaborator

Published 2.2.2-beta.4 version with this change

@KostkaBrukowa KostkaBrukowa merged commit ef0fe25 into allegro:master Jan 29, 2024
3 checks passed
@KostkaBrukowa
Copy link
Collaborator

published with 2.3.0 version on npm. Thanks for contribution!!!

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 this pull request may close these issues.

3 participants