From fc2e00152b162280e78b06028d51274e33275629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 24 Jan 2023 15:05:54 +0100 Subject: feat: support node built-in module imports (#17264) Co-authored-by: David Sherret --- cli/tools/check.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/check.rs b/cli/tools/check.rs index 2ab4fe498..d669a736f 100644 --- a/cli/tools/check.rs +++ b/cli/tools/check.rs @@ -232,10 +232,16 @@ fn get_tsc_roots( graph_data: &GraphData, check_js: bool, ) -> Vec<(ModuleSpecifier, MediaType)> { - graph_data - .entries() - .into_iter() - .filter_map(|(specifier, module_entry)| match module_entry { + let mut result = Vec::new(); + if graph_data.has_node_builtin_specifier() { + // inject a specifier that will resolve node types + result.push(( + ModuleSpecifier::parse("asset:///node_types.d.ts").unwrap(), + MediaType::Dts, + )); + } + result.extend(graph_data.entries().into_iter().filter_map( + |(specifier, module_entry)| match module_entry { ModuleEntry::Module { media_type, code, .. } => match media_type { @@ -252,8 +258,9 @@ fn get_tsc_roots( _ => None, }, _ => None, - }) - .collect() + }, + )); + result } /// Matches the `@ts-check` pragma. -- cgit v1.2.3