Repository navigation
Description
🔎 Search Terms
Title: workspace/willRenameFiles panics with "changes overlap" when the renamed file is loaded by import() with a .ts specifier
Description
Renaming or moving a file that another file loads with a dynamic import("./file.ts") (under
allowImportingTsExtensions) makes the language server panic and exit. The specifier's edit seems to be produced twice
for the same range, once per kind of import, and applying the two overlapping edits panics.
Repro
tsconfig.json:
{
"compilerOptions": {
"strict": true,
"module": "esnext",
"moduleResolution": "bundler",
"target": "es2022",
"noEmit": true,
"allowImportingTsExtensions": true
}
}imported.ts:
export const value = 1;loads.ts:
export const load = () => import("./imported.ts");Open loads.ts, then rename imported.ts to sub/moved.ts (VS Code with the native preview: drag it into a new
folder sub and accept the import update; over LSP: workspace/willRenameFiles with
{ oldUri: ".../imported.ts", newUri: ".../sub/moved.ts" }).
Actual
On macOS arm64, typescript@7.1.0-dev.20261114.1 (tsc --lsp --stdio), the server panics and exits with status 2:
panic: changes overlap: {{0 34} {0 47}} and {{0 34} {0 47}}
goroutine 7 [running]:
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 6
The range {0 34}–{0 47} is the specifier "./imported.ts" in loads.ts. A static import of a .js specifier
(import { z } from "./c.js"), or an import("./c.js"), renamed the same way gets its one edit, and the server keeps
running.
Expected
One edit, import("./sub/moved.ts"), and the server keeps running.
🕗 Version & Regression Information
- This changed between versions 6.0.3 and 7.0.2: TypeScript 6.0.3's tsserver (
getEditsForFileRename) rewrites the
import()and keeps running. - 7.0.2, 7.1.0-beta and 7.1.0-dev.20261114.1 (the latest nightly) all panic with the same message (macOS arm64,
tsc --lsp --stdio).
⏯ Playground Link
No response
💻 Code
tsconfig.json:
{
"compilerOptions": {
"strict": true,
"module": "esnext",
"moduleResolution": "bundler",
"target": "es2022",
"noEmit": true,
"allowImportingTsExtensions": true
}
}imported.ts:
export const value = 1;loads.ts:
export const load = () => import("./imported.ts");Open loads.ts. Then rename imported.ts to sub/moved.ts: in VS Code with TypeScript 7, drag it into a new folder
sub and accept the import update. Over LSP, send workspace/willRenameFiles with
{ "files": [{ "oldUri": "file:///…/imported.ts", "newUri": "file:///…/sub/moved.ts" }] }.
🙁 Actual behavior
The language server panics and exits with status 2 (observed over LSP; the VS Code steps above are untested):
panic: changes overlap: {{0 34} {0 47}} and {{0 34} {0 47}}
goroutine 7 [running]:
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 6
The range {0 34}–{0 47} is the specifier "./imported.ts" in loads.ts. The edit for that one specifier seems to
be produced twice, and applying the two overlapping edits panics.
The same rename with a .js specifier and moduleResolution: nodenext (import("./c.js"), or a static
import { z } from "./c.js") gets its one edit, and the server keeps running.
🙂 Expected behavior
One edit, "./imported.ts" → "./sub/moved.ts", as TypeScript 6's getEditsForFileRename gives, and the server
keeps running.
Additional information about the issue
Found while moving files with TypeScript 7's workspace/willRenameFiles from a tool. That tool now asks a TypeScript 6
tsserver for file moves instead.
Activity