summaryrefslogtreecommitdiff
path: root/cli/module_graph.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r--cli/module_graph.rs31
1 files changed, 29 insertions, 2 deletions
diff --git a/cli/module_graph.rs b/cli/module_graph.rs
index 7a6d68086..9b3d79a94 100644
--- a/cli/module_graph.rs
+++ b/cli/module_graph.rs
@@ -1154,11 +1154,21 @@ impl Graph {
.roots
.iter()
.map(|ms| {
+ // if the root module has a types specifier, we should be sending that
+ // to tsc instead of the original specifier
+ let specifier = self.resolve_specifier(ms);
+ let module = self.get_module(specifier).unwrap();
+ let specifier = if let Some((_, types_specifier)) = &module.maybe_types
+ {
+ self.resolve_specifier(types_specifier)
+ } else {
+ specifier
+ };
(
// root modules can be redirects, so before we pass it to tsc we need
// to resolve the redirect
- self.resolve_specifier(ms).clone(),
- self.get_media_type(ms).unwrap(),
+ specifier.clone(),
+ self.get_media_type(specifier).unwrap(),
)
})
.collect()
@@ -1935,6 +1945,23 @@ pub mod tests {
}
#[tokio::test]
+ async fn fix_graph_check_types_root() {
+ let specifier = ModuleSpecifier::resolve_url_or_path("file:///typesref.js")
+ .expect("could not resolve module");
+ let (graph, _) = setup(specifier).await;
+ let result_info = graph
+ .check(CheckOptions {
+ debug: false,
+ emit: false,
+ lib: TypeLib::DenoWindow,
+ maybe_config_path: None,
+ reload: false,
+ })
+ .expect("should have checked");
+ assert!(result_info.diagnostics.is_empty());
+ }
+
+ #[tokio::test]
async fn test_graph_check_user_config() {
let specifier =
ModuleSpecifier::resolve_url_or_path("file:///tests/checkwithconfig.ts")