deno
de5c8784 - fix(lsp): preserve URL extensions in `typeof import(...)` hovers (#34565)

Commit
50 days ago
fix(lsp): preserve URL extensions in `typeof import(...)` hovers (#34565) ## Summary When hovering over a value whose type is a remote module namespace, vscode displayed `typeof import('https://.../mod')` instead of the URL the user actually wrote (`typeof import('https://.../mod.ts')`). The cause was that the LSP's custom document registry (`cli/tsc/98_lsp.js`) built source files via `ts.createLanguageServiceSourceFile` but never set `sourceFile.moduleName`. Without `moduleName`, tsc's `getSpecifierForModuleSymbol` falls through to `getModuleSpecifiers`, which strips `.ts` from URL specifiers. The CLI path (`cli/tsc/97_ts_host.js`) already sets `moduleName = specifier` after creating a source file, so this only affects the LSP. Mirror that behavior on the LSP side by assigning `moduleName` in both `acquireDocumentWithKey` and `updateDocumentWithKey`, but only for non-`file:` specifiers. Skipping `file:` keeps tsc's relative-path computation for local files and prevents the internal `/$node_modules/` rewrite from leaking into hovers for npm packages. Fixes #16058. Closes denoland/orchid#320 ## Test plan - [x] `cargo test -p deno --lib lsp::tsc::tests` — the existing `test_modify_sources` already exercises this exact code path through a `Property X does not exist on type 'typeof import("URL")'` diagnostic; its expected message is updated to keep `.ts`. - [x] Outdated comment block in `display_parts_to_string` that documented the stripped-extension behavior as a tsc limitation has been removed (#16058 is fixed). Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Author
Parents
Loading