@@ -25,6 +25,7 @@ use deno_core::unsync::spawn_blocking;
25
25
use deno_core:: unsync:: JoinHandle ;
26
26
use deno_core:: url:: Url ;
27
27
use deno_core:: ModuleSpecifier ;
28
+ use deno_graph:: source:: ResolutionKind ;
28
29
use deno_graph:: source:: ResolveError ;
29
30
use deno_graph:: Resolution ;
30
31
use deno_graph:: ResolutionError ;
@@ -40,6 +41,7 @@ use import_map::ImportMap;
40
41
use import_map:: ImportMapErrorKind ;
41
42
use log:: error;
42
43
use lsp_types:: Uri ;
44
+ use node_resolver:: NodeResolutionKind ;
43
45
use tokio:: sync:: mpsc;
44
46
use tokio:: sync:: Mutex as AsyncMutex ;
45
47
use tokio:: time:: Duration ;
@@ -1577,10 +1579,12 @@ fn maybe_ambient_specifier_resolution_err(
1577
1579
}
1578
1580
}
1579
1581
1582
+ #[ allow( clippy:: too_many_arguments) ]
1580
1583
fn diagnose_resolution (
1581
1584
snapshot : & language_server:: StateSnapshot ,
1582
1585
dependency_key : & str ,
1583
1586
resolution : & Resolution ,
1587
+ resolution_kind : ResolutionKind ,
1584
1588
is_dynamic : bool ,
1585
1589
maybe_assert_type : Option < & str > ,
1586
1590
referrer_module : & DocumentModule ,
@@ -1647,6 +1651,7 @@ fn diagnose_resolution(
1647
1651
. npm_to_file_url (
1648
1652
& pkg_ref,
1649
1653
& referrer_module. specifier ,
1654
+ NodeResolutionKind :: from_deno_graph ( resolution_kind) ,
1650
1655
referrer_module. resolution_mode ,
1651
1656
)
1652
1657
. is_none ( )
@@ -1774,22 +1779,27 @@ fn diagnose_dependency(
1774
1779
. includes ( i. specifier_range . range . start )
1775
1780
. is_some ( )
1776
1781
} ) ;
1777
-
1782
+ let resolution;
1783
+ let resolution_kind;
1784
+ if dependency. maybe_code . is_none ( )
1785
+ // If not @ts-types, diagnose the types if the code errored because
1786
+ // it's likely resolving into the node_modules folder, which might be
1787
+ // erroring correctly due to resolution only being for bundlers. Let this
1788
+ // fail at runtime if necessary, but don't bother erroring in the editor
1789
+ || !is_types_deno_types && matches ! ( dependency. maybe_type, Resolution :: Ok ( _) )
1790
+ && matches ! ( dependency. maybe_code, Resolution :: Err ( _) )
1791
+ {
1792
+ resolution = & dependency. maybe_type ;
1793
+ resolution_kind = ResolutionKind :: Types ;
1794
+ } else {
1795
+ resolution = & dependency. maybe_code ;
1796
+ resolution_kind = ResolutionKind :: Execution ;
1797
+ } ;
1778
1798
let ( resolution_diagnostics, deferred) = diagnose_resolution (
1779
1799
snapshot,
1780
1800
dependency_key,
1781
- if dependency. maybe_code . is_none ( )
1782
- // If not @ts-types, diagnose the types if the code errored because
1783
- // it's likely resolving into the node_modules folder, which might be
1784
- // erroring correctly due to resolution only being for bundlers. Let this
1785
- // fail at runtime if necessary, but don't bother erroring in the editor
1786
- || !is_types_deno_types && matches ! ( dependency. maybe_type, Resolution :: Ok ( _) )
1787
- && matches ! ( dependency. maybe_code, Resolution :: Err ( _) )
1788
- {
1789
- & dependency. maybe_type
1790
- } else {
1791
- & dependency. maybe_code
1792
- } ,
1801
+ resolution,
1802
+ resolution_kind,
1793
1803
dependency. is_dynamic ,
1794
1804
dependency. maybe_attribute_type . as_deref ( ) ,
1795
1805
referrer_module,
@@ -1825,6 +1835,7 @@ fn diagnose_dependency(
1825
1835
snapshot,
1826
1836
dependency_key,
1827
1837
& dependency. maybe_type ,
1838
+ ResolutionKind :: Types ,
1828
1839
dependency. is_dynamic ,
1829
1840
dependency. maybe_attribute_type . as_deref ( ) ,
1830
1841
referrer_module,
0 commit comments