[RL-67] tsserver Language Service plugin for live .rs types (Milestone 3) - #44
Merged
Conversation
Ship a TypeScript Language Service plugin (`rust-wasmpack-loader/tsserver`) that gives `.rs` imports their precise wasm-bindgen types live in any tsserver-based editor, with no editor extension. It proxies the language-service host: a `.rs` file resolves as a declaration and its snapshot is the generated `.d.ts`. The generator is slow (a wasm-pack build), so synchronous calls never block - they serve the cached, on-disk, or floor types and run the build in the background, then bump the script version and refresh so the editor repaints. The plugin never writes to disk; it seeds from the M1/M2 sidecar. - src/tsserver.js + root tsserver.js re-export: the plugin - generateTypes: extract `buildTypedDts` so the plugin types without writing - ci: run the loader's src unit tests (incl. the plugin's programmatic LS proof) in the matrix; they had no CI coverage before - example/typed-imports: the `plugins` tsconfig entry + a .vscode workspace-TS nudge The live editor-refresh and per-IDE loading run only inside a real tsserver, so they are documented in the plugin header rather than CI-gated. Refs: RL-67
`node --test` runs test files in parallel, and several src tests spawn a wasm-pack/cargo build; on a cold cargo cache (CI) the concurrent builds wedge on the registry lock. Run with `--test-concurrency=1` so one build runs at a time, add `--test-force-exit` against any lingering handle, and force-kill the `--watch` test child with a bounded wait so teardown cannot hang. Refs: RL-67
`Promise.allSettled` accepts an iterable, so spreading the Map values into an array first is unnecessary (SonarCloud S7747). Refs: RL-67
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



What
Milestone 3 of typed
.rsimports (RL-67): a TypeScript Language Service plugin (rust-wasmpack-loader/tsserver) that gives.rsimports their precise wasm-bindgen types live in any tsserver-based editor (VS Code, JetBrains, Neovim) with no editor extension - just atsconfig.jsonpluginsentry.How
typescript-plugin-css-modulespattern): a.rsfile resolves as a declaration,getScriptKindreports it as TS, andgetScriptSnapshotserves the generated.d.ts.markAsDirty()+refreshDiagnostics()fire, so the editor repaints with precise types.tsc/CI/cold-start); it only reads that sidecar to warm its cache. It uses thetypescriptinstance tsserver passes in.generateTypesis split intobuildTypedDts(raw.d.ts, no write) + the sidecar write, so the plugin types without touching disk.Verified in CI (this PR also fixes a coverage gap)
The loader's
src/unit tests had no CI coverage before - the matrix only ran example tests, andtscignoresplugins, so the plugin was untested in CI. This PR adds a rootnpm testand a.matrix entry, so all 31 src tests run across the matrix, including:ts.createLanguageServicesees the floor (0 diagnostics) before the build, then precise types after -lib.fibonacci(1)accepted,lib.nope()flagged.Locally (GNU toolchain): 31/31 src tests,
example/typed-imports2/2, eslint clean, SonarCloud-safe.Documented, not CI-gated (per the agreed scope)
An LS plugin only runs inside a live tsserver, so the editor repaint reaction to
refreshDiagnostics()and per-IDE loading (VS Code's one-time "Use Workspace Version") can't be tested in CI. Both are documented in thesrc/tsserver.jsheader and the example's.vscode/settings.json.Scope
Milestone 3 of the epic. Remaining: classes/structs typing, then docs.