From 56e3daa19b1a0718bbcea2beae737ce8845ceac2 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 26 Jul 2023 18:52:31 -0400 Subject: fix(lsp): handle import mapped `node:` specifier (#19956) Closes https://github.com/denoland/vscode_deno/issues/805 --- cli/tests/integration/lsp_tests.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'cli/tests/integration/lsp_tests.rs') diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index dc68ab514..15ede69ea 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -610,6 +610,39 @@ fn lsp_import_map_config_file_auto_discovered_symlink() { client.shutdown(); } +#[test] +fn lsp_import_map_node_specifiers() { + let context = TestContextBuilder::for_npm().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + + temp_dir.write("deno.json", r#"{ "imports": { "fs": "node:fs" } }"#); + + // cache @types/node + context + .new_command() + .args("cache npm:@types/node") + .run() + .skip_output_check() + .assert_exit_code(0); + + let mut client = context.new_lsp_command().build(); + client.initialize(|builder| { + builder.set_config("./deno.json"); + }); + + let diagnostics = client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("a.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": "import fs from \"fs\";\nconsole.log(fs);" + } + })); + assert_eq!(diagnostics.all(), vec![]); + + client.shutdown(); +} + #[test] fn lsp_deno_task() { let context = TestContextBuilder::new().use_temp_cwd().build(); -- cgit v1.2.3