diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-01-27 05:59:41 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2020-01-26 13:59:41 -0500 |
commit | f604becaba0c747fdf8dd9d0d744c7bd19322e41 (patch) | |
tree | 5a7d2391182c2385f297579ab35667189640eda8 /cli/ops | |
parent | ec44be0760d647b3d005387d2f44ad0336d01024 (diff) |
Improve support of type definitions (#3755)
Diffstat (limited to 'cli/ops')
-rw-r--r-- | cli/ops/compiler.rs | 14 |
1 files changed, 13 insertions, 1 deletions
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. |