Add in-memory strict language server #67
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementation of approach that I described in #62. TL;DR: Create a strict
LanguageService
in memory andgetSemanticDiagnostics
from it for all strict files.The
create
method in a plugin returns aLanguageService
, and aLanguageService
's entire view of the world is through aLanguageServiceHost
. By proxying onlygetCompilationSettings
onLanguageServiceHost
to addstrict: true
and creating a newLanguageService
from it, we create a perfect mirror of the stockLanguageService
but with strict enabled.Proxying the
LanguageServiceHost
was more difficult than the language server, asObject.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 aProxy
seems to have done the trick, and I'm successfully using this in my work repo now.I also proxied
dispose
andcleanupSemanticCache
as they seemed important to theLanguageService
lifecycle. I have no idea if they're necessary.