From 64f9155126b1cd14a46de58ae1654045cfacd150 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Thu, 5 Oct 2023 01:38:11 +0100 Subject: fix(lsp): show diagnostics for type imports from untyped deps (#20780) --- cli/tests/integration/lsp_tests.rs | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'cli/tests/integration') diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 11cb09994..433088fe9 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -7734,6 +7734,57 @@ fn lsp_diagnostics_refresh_dependents() { assert_eq!(client.queue_len(), 0); } +#[test] +fn lsp_npm_missing_type_imports_diagnostics() { + let context = TestContextBuilder::new() + .use_http_server() + .use_temp_cwd() + .build(); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": r#" + import colorName, { type RGB } from 'npm:color-name'; + const color: RGB = colorName.black; + console.log(color); + "#, + }, + })); + client.write_request( + "workspace/executeCommand", + json!({ + "command": "deno.cache", + "arguments": [[], "file:///a/file.ts"], + }), + ); + let diagnostics = client.read_diagnostics(); + assert_eq!( + json!( + diagnostics.messages_with_file_and_source("file:///a/file.ts", "deno-ts") + ), + json!({ + "uri": "file:///a/file.ts", + "diagnostics": [ + { + "range": { + "start": { "line": 1, "character": 33 }, + "end": { "line": 1, "character": 36 }, + }, + "severity": 1, + "code": 2305, + "source": "deno-ts", + "message": "Module '\"npm:color-name\"' has no exported member 'RGB'.", + }, + ], + "version": 1, + }) + ); +} + #[test] fn lsp_jupyter_diagnostics() { let context = TestContextBuilder::new().use_temp_cwd().build(); -- cgit v1.2.3