diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index be3bc6efc6..8fd1a331e4 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -154,7 +154,11 @@ impl SourceFileFetcher { permissions: Permissions, ) -> Result { let module_url = specifier.as_url().to_owned(); - debug!("fetch_source_file specifier: {} ", &module_url); + debug!( + "fetch_source_file specifier: {} maybe_referrer: {:#?}", + &module_url, + maybe_referrer.as_ref() + ); // Check if this file was already fetched and can be retrieved from in-process cache. let maybe_cached_file = self.source_file_cache.get(specifier.to_string()); diff --git a/cli/swc_util.rs b/cli/swc_util.rs index eb41fbc348..77ac6d083b 100644 --- a/cli/swc_util.rs +++ b/cli/swc_util.rs @@ -504,19 +504,11 @@ pub fn analyze_dependencies_and_references( }) .map(|desc| { let location = parser.get_span_location(desc.span); - if desc.kind == DependencyKind::Import { - let deno_types = get_deno_types(&parser, desc.span); - ImportDescriptor { - specifier: desc.specifier.to_string(), - deno_types, - location: location.into(), - } - } else { - ImportDescriptor { - specifier: desc.specifier.to_string(), - deno_types: None, - location: location.into(), - } + let deno_types = get_deno_types(&parser, desc.span); + ImportDescriptor { + specifier: desc.specifier.to_string(), + deno_types, + location: location.into(), } }) .collect(); diff --git a/cli/tests/export_type_def.ts b/cli/tests/export_type_def.ts new file mode 100644 index 0000000000..e33b70a644 --- /dev/null +++ b/cli/tests/export_type_def.ts @@ -0,0 +1,2 @@ +// @deno-types="./type_definitions/foo.d.ts" +export { foo } from "./type_definitions/foo.js"; diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index d70527881c..c62a9a5012 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1729,6 +1729,12 @@ itest!(type_definitions { output: "type_definitions.ts.out", }); +itest!(type_definitions_for_export { + args: "run --reload type_definitions_for_export.ts", + output: "type_definitions_for_export.ts.out", + exit_code: 1, +}); + itest!(type_directives_01 { args: "run --reload -L debug type_directives_01.ts", output: "type_directives_01.ts.out", diff --git a/cli/tests/type_definitions_for_export.ts b/cli/tests/type_definitions_for_export.ts new file mode 100644 index 0000000000..e9eb6b139f --- /dev/null +++ b/cli/tests/type_definitions_for_export.ts @@ -0,0 +1,7 @@ +import { foo } from "./export_type_def.ts"; + +function bar(a: number): void { + console.log(a); +} + +bar(foo); diff --git a/cli/tests/type_definitions_for_export.ts.out b/cli/tests/type_definitions_for_export.ts.out new file mode 100644 index 0000000000..81f0167c55 --- /dev/null +++ b/cli/tests/type_definitions_for_export.ts.out @@ -0,0 +1,5 @@ +Compile [WILDCARD]type_definitions_for_export.ts +error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'number'. +bar(foo); + ~~~ + at [WILDCARD]type_definitions_for_export.ts:7:5 diff --git a/cli/tests/type_directives_js_main.js.out b/cli/tests/type_directives_js_main.js.out index 714dbd0b77..2ccecc9048 100644 --- a/cli/tests/type_directives_js_main.js.out +++ b/cli/tests/type_directives_js_main.js.out @@ -1,3 +1,3 @@ [WILDCARD] -fetch_source_file specifier: file:[WILDCARD]cli/tests/subdir/type_reference.d.ts +fetch_source_file specifier: file:[WILDCARD]cli/tests/subdir/type_reference.d.ts [WILDCARD] [WILDCARD] \ No newline at end of file