mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
fix(lsp): do sloppy resolution for node-to-node imports in byonm (#24481)
This commit is contained in:
parent
c11e2c74e8
commit
0087402094
2 changed files with 43 additions and 1 deletions
|
@ -682,7 +682,9 @@ impl Resolver for CliGraphResolver {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if referrer.scheme() == "file" {
|
||||
}
|
||||
|
||||
if referrer.scheme() == "file" {
|
||||
if let Some(node_resolver) = &self.node_resolver {
|
||||
let node_result = node_resolver.resolve_if_in_npm_package(
|
||||
specifier,
|
||||
|
|
|
@ -14275,6 +14275,46 @@ fn sloppy_imports_not_enabled() {
|
|||
client.shutdown();
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/denoland/deno/issues/24457.
|
||||
#[test]
|
||||
fn lsp_byonm_js_import_resolves_to_dts() {
|
||||
let context = TestContextBuilder::new()
|
||||
.use_http_server()
|
||||
.use_temp_cwd()
|
||||
.add_npm_env_vars()
|
||||
.build();
|
||||
let temp_dir = context.temp_dir();
|
||||
temp_dir.write(
|
||||
"deno.json",
|
||||
json!({
|
||||
"unstable": ["byonm"],
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
temp_dir.write(
|
||||
"package.json",
|
||||
json!({
|
||||
"dependencies": {
|
||||
"postcss": "*",
|
||||
},
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
context.run_npm("install");
|
||||
let mut client = context.new_lsp_command().build();
|
||||
client.initialize_default();
|
||||
let diagnostics = client.did_open(json!({
|
||||
"textDocument": {
|
||||
"uri": temp_dir.uri().join("node_modules/postcss/lib/comment.d.ts").unwrap(),
|
||||
"languageId": "typescript",
|
||||
"version": 1,
|
||||
"text": temp_dir.path().join("node_modules/postcss/lib/comment.d.ts").read_to_string(),
|
||||
}
|
||||
}));
|
||||
assert_eq!(json!(diagnostics.all()), json!([]));
|
||||
client.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decorators_tc39() {
|
||||
let context = TestContextBuilder::new().use_temp_cwd().build();
|
||||
|
|
Loading…
Reference in a new issue