Commit de5c878
fix(lsp): preserve URL extensions in
## 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>typeof import(...) hovers (#34565)1 parent f455715 commit de5c878
2 files changed
Lines changed: 24 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2076 | 2076 | | |
2077 | 2077 | | |
2078 | 2078 | | |
2079 | | - | |
2080 | | - | |
2081 | | - | |
2082 | | - | |
2083 | | - | |
2084 | | - | |
2085 | | - | |
2086 | | - | |
2087 | | - | |
2088 | | - | |
2089 | | - | |
2090 | | - | |
2091 | | - | |
2092 | | - | |
2093 | | - | |
2094 | | - | |
2095 | | - | |
2096 | | - | |
2097 | | - | |
2098 | | - | |
2099 | | - | |
2100 | | - | |
2101 | | - | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
2105 | | - | |
2106 | | - | |
2107 | | - | |
2108 | | - | |
2109 | 2079 | | |
2110 | 2080 | | |
2111 | 2081 | | |
| |||
6578 | 6548 | | |
6579 | 6549 | | |
6580 | 6550 | | |
6581 | | - | |
| 6551 | + | |
6582 | 6552 | | |
6583 | 6553 | | |
6584 | 6554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
45 | 61 | | |
46 | 62 | | |
47 | 63 | | |
| |||
105 | 121 | | |
106 | 122 | | |
107 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
108 | 130 | | |
109 | 131 | | |
110 | 132 | | |
| |||
170 | 192 | | |
171 | 193 | | |
172 | 194 | | |
| 195 | + | |
173 | 196 | | |
174 | 197 | | |
175 | 198 | | |
| |||
0 commit comments