From 40122d7f2a867660900612980dfc75eece0d5e29 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Tue, 19 Sep 2023 16:37:27 +0100 Subject: fix(lsp): force correct media type detection from tsc (#20562) --- cli/tests/integration/lsp_tests.rs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'cli/tests') diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 8b265f911..c211bbae4 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -7847,6 +7847,40 @@ fn lsp_json_no_diagnostics() { client.shutdown(); } +#[test] +fn lsp_json_import_with_query_string() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + temp_dir.write("data.json", r#"{"k": "v"}"#); + temp_dir.write( + "main.ts", + r#" + import data from "./data.json?1" with { type: "json" }; + console.log(data); + "#, + ); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("data.json").unwrap(), + "languageId": "json", + "version": 1, + "text": temp_dir.read_to_string("data.json"), + } + })); + let diagnostics = client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("main.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": temp_dir.read_to_string("main.ts"), + } + })); + assert_eq!(diagnostics.all(), vec![]); + client.shutdown(); +} + #[test] fn lsp_format_markdown() { let context = TestContextBuilder::new().use_temp_cwd().build(); @@ -9198,7 +9232,7 @@ fn lsp_data_urls_with_jsx_compiler_option() { "end": { "line": 1, "character": 1 } } }, { - "uri": "deno:/ed0224c51f7e2a845dfc0941ed6959675e5e3e3d2a39b127f0ff569c1ffda8d8/data_url.ts", + "uri": "deno:/5c42b5916c4a3fb55be33fdb0c3b1f438639420592d150fca1b6dc043c1df3d9/data_url.ts", "range": { "start": { "line": 0, "character": 7 }, "end": {"line": 0, "character": 14 }, -- cgit v1.2.3