denoland/deno · error

Unable to convert type definition info: {:#}

Error message

Unable to convert type definition info: {:#}

What it means

Same conversion path as go-to-definition but for textDocument/typeDefinition: tsc's type-definition info is converted through DocumentSpan::collect_into_goto_definition_response and a failure is wrapped with this message. Root causes are span-to-range conversion failures in the target documents where the types are declared, not the mechanics of the request itself.

Source

Thrown at cli/lsp/ts_server.rs:596

      Self::Js(ts_server) => {
        let definition_info = ts_server
          .get_type_definition(
            snapshot.clone(),
            module,
            module.line_index.offset_tsc(position)?,
            token,
          )
          .await?;
        super::tsc::DocumentSpan::collect_into_goto_definition_response(
          definition_info
            .iter()
            .flatten()
            .map(|i| (&i.document_span, module)),
          snapshot,
          token,
        )
        .map_err(|err| {
          anyhow!("Unable to convert type definition info: {:#}", err)
        })
      }
    }
  }

  pub async fn provide_completion(
    &self,
    module: &DocumentModule,
    position: lsp::Position,
    context: Option<&lsp::CompletionContext>,
    language_server: &language_server::Inner,
    snapshot: Arc<StateSnapshot>,
    token: &CancellationToken,
  ) -> Result<Option<lsp::CompletionResponse>, AnyError> {
    match self {
      Self::Js(ts_server) => {
        let position = module.line_index.offset_tsc(position)?;
        let completion_info = ts_server

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Save the file(s) involved and retry the type-definition navigation.
  2. Run "Deno: Restart Language Server" when a specific target keeps failing.
  3. Update the Deno CLI and extension.
  4. Check the wrapped error after the colon in the Deno Language Server output panel.
Defensive patterns

Strategy: retry

Try / catch

// Type-definition conversion: same transient shape as definition — retry
// once before giving up.
async function typeDefinitionSafe(client, params) {
  try {
    return await client.sendRequest('textDocument/typeDefinition', params);
  } catch (err) {
    if (String(err?.message).includes('Unable to convert type definition info')) {
      await sleep(250);
      return await client.sendRequest('textDocument/typeDefinition', params);
    }
    throw err;
  }
}

Prevention

When it happens

Trigger: A textDocument/typeDefinition request where converting a returned document span fails — the target type-declaration file changed since the snapshot, or its span no longer maps to current content.

Common situations: Jumping to type definition right after editing the file that declares the type; targets in .d.ts or generated files with stale snapshots.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/6076b222570563f6. Report an issue: GitHub.