From f604becaba0c747fdf8dd9d0d744c7bd19322e41 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Mon, 27 Jan 2020 05:59:41 +1100 Subject: Improve support of type definitions (#3755) --- cli/ops/compiler.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'cli/ops') diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs index d2a2a1d58..2934c79ee 100644 --- a/cli/ops/compiler.rs +++ b/cli/ops/compiler.rs @@ -109,8 +109,20 @@ fn op_fetch_source_files( let files = try_join_all(futures).await?; // We want to get an array of futures that resolves to - let v = files.into_iter().map(|file| { + let v = files.into_iter().map(|f| { async { + // if the source file contains a `types_url` we need to replace + // the module with the type definition when requested by the compiler + let file = match f.types_url { + Some(types_url) => { + let types_specifier = ModuleSpecifier::from(types_url); + global_state + .file_fetcher + .fetch_source_file_async(&types_specifier, ref_specifier.clone()) + .await? + } + _ => f, + }; // Special handling of Wasm files: // compile them into JS first! // This allows TS to do correct export types. -- cgit v1.2.3