diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-05-06 16:54:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-06 23:54:52 +0000 |
commit | 672216d65a7e737256133615b0bf56092b57b87f (patch) | |
tree | 1ee7458192b2e61344fd7e3e2261be6790f5dcbc /cli/lsp/language_server.rs | |
parent | 8eb1f11112c3ced0ff4a35f3487a4da507db05c2 (diff) |
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.
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r-- | cli/lsp/language_server.rs | 10 |
1 files changed, 8 insertions, 2 deletions
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 |