microsoft / microsoft/TypeScript-Website
@typescript/vfs: createVirtualTypeScriptEnvironment stores a duplicate SourceFile per file that the language service never reads
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.6k
- Forks
- 1.5k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 7
Description
Page URL: https://github.com/microsoft/TypeScript-Website/blob/v2/packages/typescript-vfs/src/index.ts (@typescript/vfs)
Issue:
createVirtualTypeScriptEnvironment permanently stores a second parsed AST for every file, roughly doubling per-file memory.
Where the duplicates are created:
- The env's
createFile/updateFileparse aSourceFile(ts.createSourceFile/ts.updateSourceFile) and pass it down tocreateVirtualCompilerHost'supdateFile, which saves it in its internalsourceFilesmap. - The language service never reads that map — its host's
getScriptSnapshotreads text fromsys, and the language service parses and caches its ownSourceFiles from those snapshots.
So the ASTs in the compiler-host map are write-only: every file that goes through env.createFile/env.updateFile is held as two full ASTs (the language service's copy plus the map's copy), and the map's copy is never released for the lifetime of the env.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/typescript-vfs/src/index.ts and trace createVirtualTypeScriptEnvironment's createFile/updateFile calls into createVirtualCompilerHost's updateFile. Confirm how the sourceFiles map is populated and whether the language service reads it. Done means eliminating the unused duplicate SourceFile storage without changing language-service behavior; run the package's existing tests if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100