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
LanguageServicein memory andgetSemanticDiagnosticsfrom it for all strict files.The
createmethod in a plugin returns aLanguageService, and aLanguageService's entire view of the world is through aLanguageServiceHost. By proxying onlygetCompilationSettingsonLanguageServiceHostto addstrict: trueand creating a newLanguageServicefrom it, we create a perfect mirror of the stockLanguageServicebut with strict enabled.Proxying the
LanguageServiceHostwas 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 aProxyseems to have done the trick, and I'm successfully using this in my work repo now.I also proxied
disposeandcleanupSemanticCacheas they seemed important to theLanguageServicelifecycle. I have no idea if they're necessary.