From 672216d65a7e737256133615b0bf56092b57b87f Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Mon, 6 May 2024 16:54:52 -0700 Subject: fix(lsp): Pass diagnostic codes to TSC as numbers (#23720) Fixes the `Debug Failure` errors described in https://github.com/denoland/deno/issues/23643#issuecomment-2094552765 . The issue here was that we were passing diagnostic codes as strings but TSC expects the codes to be numbers. This resulted in some quick fixes not working (as illustrated by the test added here which fails before this PR). The first commit is the actual fix. The rest are just test related. --- cli/lsp/language_server.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cli/lsp/language_server.rs') diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 367be2c3b..5879a7491 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1550,8 +1550,14 @@ impl Inner { match diagnostic.source.as_deref() { Some("deno-ts") => { let code = match diagnostic.code.as_ref().unwrap() { - NumberOrString::String(code) => code.to_string(), - NumberOrString::Number(code) => code.to_string(), + NumberOrString::String(code) => match code.parse() { + Ok(c) => c, + Err(e) => { + lsp_warn!("Invalid diagnostic code {code}: {e}"); + continue; + } + }, + NumberOrString::Number(code) => *code, }; let codes = vec![code]; let actions = self -- cgit v1.2.3