π Search Terms
virtual file
setVirtualFile
RequestFileSystem
openClientFiles
didOpen didClose
temporary file update
β
Viability Checklist
β Suggestion
Add an overlay mechanism over the LSP server interface (tsgo --lsp) to push in-memory file contents directly into TS-Go's VFS (for example, a custom notification like ts/setVirtualFile with { path, content }, where null clears the overlay) without treating the files as client-opened documents.
π Motivating Example
We're using tsgo --lsp (with the API session pipe) as our backend diagnostics and type-checking engine for the Angular Language Service. To type-check templates, Angular generates synthetic in-memory TypeScript files containing Type Check Blocks (like app.component.ngtypecheck.ts) that TS-Go needs to type-check alongside user code.
Right now, we feed these into TS-Go by sending synthetic textDocument/didOpen and textDocument/didChange notifications. While that works, treating these files as client-opened documents pollutes openClientFiles, artificially bumps project retention ref-counts in ProjectService, and forces us to manage synthetic open/close lifecycle bookkeeping for files that aren't actually open in the editor.
The API client already has some support for layered VFS snapshots (RequestFileSystem with { kind: "layer" } and runWithTemporaryFileUpdate), but we don't have an equivalent way to push un-opened virtual files over the LSP connection.
An overlay notification over LSP (something like setVirtualFile(path, content | null)) would let us push our generated type-check files directly into TS-Go's VFS without openClientFiles pollution or open/close bookkeeping.
π» Use Cases
- What do you want to use this for?
To feed Angular's generated template type-checking code (.ngtypecheck.ts files containing Type Check Blocks) into TS-Go in memory.
We run tsgo --lsp as an out-of-proc semantic and diagnostics engine for both our dev server and our separate Angular Language Server. As users edit templates, we generate and update these synthetic .ngtypecheck.ts files so TS-Go can type-check them alongside the user's TypeScript code and answer semantic queries (hover, definition, completions). None of these synthetic files exist on disk, and they change frequently as templates are edited.
- What shortcomings exist with current approaches?
Over LSP, the only current way to provide in-memory content is via textDocument/didOpen and textDocument/didChange. Because didOpen is built for user-facing editor buffers, using it for internal synthetic files causes a few headaches:
- It registers the files in
openClientFiles, adding unnecessary tracking overhead for files the user never opened.
- It inflates
ProjectService retention ref-counts, keeping configured projects alive longer than they should be or creating awkward project lifecycle behavior.
- We have to build our own synthetic
didOpen / didClose bookkeeping layer just to keep TS-Go's internal project state clean.
The API client recently added layered snapshot file systems (RequestFileSystem with { kind: "layer" } and runWithTemporaryFileUpdate), but that's scoped to immutable snapshots in the Node API client rather than a long-running tsgo --lsp server session answering standard LSP requests.
- What workarounds are you using in the meantime?
In our language service facade, we currently fake the document lifecycle: we track synthetic version numbers, send textDocument/didOpen when generating a TCB, textDocument/didChange as the template updates, and send textDocument/didClose when components are removed or projects unload. It works functionally, but it's fragile and forces us to manage artificial lifecycle bookkeeping for purely ephemeral compiler artifacts.
π Search Terms
virtual file
setVirtualFile
RequestFileSystem
openClientFiles
didOpen didClose
temporary file update
β Viability Checklist
β Suggestion
Add an overlay mechanism over the LSP server interface (
tsgo --lsp) to push in-memory file contents directly into TS-Go's VFS (for example, a custom notification likets/setVirtualFilewith{ path, content }, wherenullclears the overlay) without treating the files as client-opened documents.π Motivating Example
We're using
tsgo --lsp(with the API session pipe) as our backend diagnostics and type-checking engine for the Angular Language Service. To type-check templates, Angular generates synthetic in-memory TypeScript files containing Type Check Blocks (likeapp.component.ngtypecheck.ts) that TS-Go needs to type-check alongside user code.Right now, we feed these into TS-Go by sending synthetic
textDocument/didOpenandtextDocument/didChangenotifications. While that works, treating these files as client-opened documents pollutesopenClientFiles, artificially bumps project retention ref-counts inProjectService, and forces us to manage synthetic open/close lifecycle bookkeeping for files that aren't actually open in the editor.The API client already has some support for layered VFS snapshots (
RequestFileSystemwith{ kind: "layer" }andrunWithTemporaryFileUpdate), but we don't have an equivalent way to push un-opened virtual files over the LSP connection.An overlay notification over LSP (something like
setVirtualFile(path, content | null)) would let us push our generated type-check files directly into TS-Go's VFS withoutopenClientFilespollution or open/close bookkeeping.π» Use Cases
To feed Angular's generated template type-checking code (
.ngtypecheck.tsfiles containing Type Check Blocks) into TS-Go in memory.We run
tsgo --lspas an out-of-proc semantic and diagnostics engine for both our dev server and our separate Angular Language Server. As users edit templates, we generate and update these synthetic.ngtypecheck.tsfiles so TS-Go can type-check them alongside the user's TypeScript code and answer semantic queries (hover, definition, completions). None of these synthetic files exist on disk, and they change frequently as templates are edited.Over LSP, the only current way to provide in-memory content is via
textDocument/didOpenandtextDocument/didChange. BecausedidOpenis built for user-facing editor buffers, using it for internal synthetic files causes a few headaches:openClientFiles, adding unnecessary tracking overhead for files the user never opened.ProjectServiceretention ref-counts, keeping configured projects alive longer than they should be or creating awkward project lifecycle behavior.didOpen/didClosebookkeeping layer just to keep TS-Go's internal project state clean.The API client recently added layered snapshot file systems (
RequestFileSystemwith{ kind: "layer" }andrunWithTemporaryFileUpdate), but that's scoped to immutable snapshots in the Node API client rather than a long-runningtsgo --lspserver session answering standard LSP requests.In our language service facade, we currently fake the document lifecycle: we track synthetic version numbers, send
textDocument/didOpenwhen generating a TCB,textDocument/didChangeas the template updates, and sendtextDocument/didClosewhen components are removed or projects unload. It works functionally, but it's fragile and forces us to manage artificial lifecycle bookkeeping for purely ephemeral compiler artifacts.