Skip to content

fix(typescript-vfs): avoid storing duplicate SourceFiles in language service host - #3713

Open
Umut (saiv0n) wants to merge 1 commit into
microsoft:v2from
saiv0n:fix/vfs-duplicate-sourcefile
Open

Umut (saiv0n) wants to merge 1 commit into
microsoft:v2from
saiv0n:fix/vfs-duplicate-sourcefile

Conversation

@saiv0n

Copy link
Copy Markdown

createVirtualLanguageServiceHost previously delegated updateFile/deleteFile to an internal createVirtualCompilerHost, whose sourceFiles map was never read by the language service (since getScriptSnapshot reads directly from sys). At the same time, createVirtualTypeScriptEnvironment's createFile/updateFile parsed throwaway SourceFiles only to pass { fileName, text } down to that host.

This change:

  • Builds languageServiceHost directly on top of sys without allocating an unused createVirtualCompilerHost and its sourceFiles map.
  • Writes/deletes file text directly via sys in createVirtualLanguageServiceHost's updateFile/deleteFile.
  • Stops parsing throwaway SourceFiles in createVirtualTypeScriptEnvironment's createFile/updateFile.
  • Adds a regression test verifying createFile and updateFile update the language service without invoking ts.createSourceFile/ts.updateSourceFile outside it.

Fixes #3614

This branch has not been deployed

No deployments
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.

@typescript/vfs: createVirtualTypeScriptEnvironment stores a duplicate SourceFile per file that the language service never reads

1 participant