From f82b9ba329856b9b52c831b456e4823fad62f858 Mon Sep 17 00:00:00 2001 From: Giorgi Rostomashvili Date: Mon, 6 Apr 2020 22:52:25 +0200 Subject: fix: fetch reference types for JS files (#4652) Fixes #4000 and fixes #4476. Now always tries to fetch reference types for JS files. Does not throw if it fails, since Typescript compiler will complain if the file is not there(it will try to fetch it again first) and people who just use JS should not be bothered by this error. Not sure about my test, it passes and catches the bug but maybe there is a better way to express it. --- cli/global_state.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cli/global_state.rs') diff --git a/cli/global_state.rs b/cli/global_state.rs index 129ab276a..c9383bd88 100644 --- a/cli/global_state.rs +++ b/cli/global_state.rs @@ -138,6 +138,18 @@ impl GlobalState { .compile(state1.clone(), &out, target_lib) .await } else { + if let Some(types_url) = out.types_url.clone() { + let types_specifier = ModuleSpecifier::from(types_url); + state1 + .file_fetcher + .fetch_source_file( + &types_specifier, + Some(module_specifier.clone()), + ) + .await + .ok(); + }; + state1.js_compiler.compile(out).await } } -- cgit v1.2.3