diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-01-24 15:05:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 09:05:54 -0500 |
commit | fc2e00152b162280e78b06028d51274e33275629 (patch) | |
tree | ee567a99cabc6633454de231939f7d898146f1d8 /cli/tools/check.rs | |
parent | cadeaae045d2489fe125286b8c2c641c6d973c3f (diff) |
feat: support node built-in module imports (#17264)
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/tools/check.rs')
-rw-r--r-- | cli/tools/check.rs | 19 |
1 files changed, 13 insertions, 6 deletions
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. |