denoland/deno · error
Unable to convert refactor info: {:#}
Error message
Unable to convert refactor info: {:#} What it means
After tsc returns applicable refactor infos, each is converted into LSP code actions via refactor_info.to_code_actions; this wraps a conversion failure for one entry. Causes include refactor spans that fail to map through the module's line index (stale snapshot) and refactor metadata whose shape the server does not expect from the embedded TypeScript version.
Source
Thrown at cli/lsp/ts_server.rs:448
snapshot.clone(),
module,
module.line_index.offset_tsc(range.start)?
..module.line_index.offset_tsc(range.end)?,
context.trigger_kind,
only,
token,
)
.await
.map_err(|err| {
anyhow!("Unable to get refactor info from TypeScript: {:#}", err)
})?;
let refactor_actions = refactor_infos
.into_iter()
.map(|refactor_info| {
refactor_info
.to_code_actions(&module.uri, &range, token)
.map_err(|err| {
anyhow!("Unable to convert refactor info: {:#}", err)
})
})
.collect::<Result<Vec<_>, _>>()?
.into_iter()
.flatten();
actions.extend(
refactor::prune_invalid_actions(refactor_actions, 5)
.into_iter()
.map(lsp::CodeActionOrCommand::CodeAction),
);
if !snapshot.config.client_provided_organize_imports_capable()
&& context.only.as_ref().is_none_or(|o| {
o.contains(&lsp::CodeActionKind::SOURCE_ORGANIZE_IMPORTS)
})
{
let organize_imports_edit = ts_server
.organize_imports(snapshot.clone(), module, token)View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Save the file and retry the refactoring after edits settle.
- Ensure the Deno CLI and IDE extension are both current and matched — refactor info shapes change between tsc versions.
- Run "Deno: Restart Language Server" if the failure persists.
- Inspect the wrapped error after the colon in the language server output.
Defensive patterns
Strategy: fallback
Try / catch
// One bad refactor entry aborts the whole conversion on the server;
// fall back to offering no server refactors for that invocation.
try {
actions = await collectRefactorActions(client, params);
} catch (err) {
if (String(err?.message).includes('Unable to convert refactor info')) {
actions = []; // user can still rename/extract manually; log for triage
} else {
throw err;
}
} Prevention
- Save before opening the refactor menu so spans map onto the current snapshot
- Keep Deno CLI and VS Code extension versions aligned — refactor info shapes change with tsc
- Restart the language server if the failure persists for a specific selection
When it happens
Trigger: A code action request over a range where one refactor info entry fails conversion — spans that do not map onto the current document snapshot, or a tsc/server version mismatch in the expected refactor JSON shape.
Common situations: Requesting refactorings right after rapid edits; mixing an outdated VS Code extension with a newer Deno CLI (or vice versa).
Related errors
- Unable to get refactor info from TypeScript: {:#}
- Unable to convert fix: {:#}
- Unable to get organize imports edit from TypeScript: {:#}
- Error getting navigation tree for "{}": {:#}
- Unable to convert document highlights: {:#}
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/c20f09f924d4742b.
Report an issue: GitHub.