@typescript/vfs: createVirtualTypeScriptEnvironment stores a duplicate SourceFile per file that the language service never reads
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- tooling
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.
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.
- Dominant language
- TypeScript
- Stars
- 2.6k
- Forks
- 1.5k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 5
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.
More from microsoft/TypeScript-Website
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
microsoft/TypeScript-Website#3611 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/TypeScript-Website#3607 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
microsoft/TypeScript-Website#3039 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/TypeScript-Website#2998 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
microsoft/TypeScript-Website#3650 ·
All issues in microsoft/TypeScript-Website
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·