SIGN IN SIGN UP
denoland / deno UNCLAIMED

A modern runtime for JavaScript and TypeScript.

0 0 30 Rust

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>
E
em committed
de5c8784a4f94cce518a17c09e2afad2e7e1882a
Parent: f455715
Committed by GitHub <noreply@github.com> on 5/30/2026, 9:42:05 AM