summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-05-21 17:54:15 +0100
committerGitHub <noreply@github.com>2024-05-21 17:54:15 +0100
commita5111fbc4d7daaa9056d0e4b21b3d54a009a7f99 (patch)
tree628e1181d9b7e33d351bf16eeda966a6cabb335d /tests
parent54eb930e8c5eb3ae5b780c08592ae625bbd62f4d (diff)
fix(cli): use CliNodeResolver::resolve() for managed node_modules (#23902)
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/lsp_tests.rs49
-rw-r--r--tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.d.mts1
-rw-r--r--tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.mjs0
-rw-r--r--tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/index.d.mts1
-rw-r--r--tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/package.json5
5 files changed, 56 insertions, 0 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 1f7758a9d..347324899 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -7188,6 +7188,55 @@ fn lsp_npm_completions_auto_import_and_quick_fix_no_import_map() {
client.shutdown();
}
+// Regression test for https://github.com/denoland/deno/issues/23895.
+#[test]
+fn lsp_npm_types_nested_js_dts() {
+ let context = TestContextBuilder::new()
+ .use_http_server()
+ .use_temp_cwd()
+ .build();
+ let temp_dir = context.temp_dir();
+ let file = source_file(
+ temp_dir.path().join("file.ts"),
+ r#"
+ import { someString } from "npm:@denotest/types-nested-js-dts";
+ const someNumber: number = someString;
+ console.log(someNumber);
+ "#,
+ );
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+ client.write_request(
+ "workspace/executeCommand",
+ json!({
+ "command": "deno.cache",
+ "arguments": [[], file.uri()],
+ }),
+ );
+ let diagnostics = client.did_open_file(&file);
+ assert_eq!(
+ json!(diagnostics.all()),
+ json!([
+ {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 12,
+ },
+ "end": {
+ "line": 2,
+ "character": 22,
+ },
+ },
+ "severity": 1,
+ "code": 2322,
+ "source": "deno-ts",
+ "message": "Type 'string' is not assignable to type 'number'.",
+ },
+ ])
+ );
+}
+
#[test]
fn lsp_completions_using_decl() {
let context = TestContextBuilder::new().use_temp_cwd().build();
diff --git a/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.d.mts b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.d.mts
new file mode 100644
index 000000000..435448424
--- /dev/null
+++ b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.d.mts
@@ -0,0 +1 @@
+export const someString: string;
diff --git a/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.mjs b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.mjs
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/import.mjs
diff --git a/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/index.d.mts b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/index.d.mts
new file mode 100644
index 000000000..c5ec00e5b
--- /dev/null
+++ b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/index.d.mts
@@ -0,0 +1 @@
+export { someString } from "./import.mjs";
diff --git a/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/package.json b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/package.json
new file mode 100644
index 000000000..a37f8556c
--- /dev/null
+++ b/tests/registry/npm/@denotest/types-nested-js-dts/1.0.0/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "@denotest/types-nested-js-dts",
+ "version": "1.0.0",
+ "types": "./index.d.mts"
+}