From bfd9912e1faa30a92472252b77878714e668a3d4 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 27 Oct 2022 08:12:40 -0400 Subject: fix(typescript): allow synthetic default imports when using `ModuleKind.ESNext` (#16438) Closes #16437 --- cli/tests/integration/check_tests.rs | 5 +++++ cli/tests/testdata/check/export_equals_declaration_file/main.ts | 6 ++++++ .../testdata/check/export_equals_declaration_file/other.d.ts | 9 +++++++++ cli/tests/testdata/check/export_equals_declaration_file/other.js | 3 +++ cli/tsc/00_typescript.js | 2 +- 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cli/tests/testdata/check/export_equals_declaration_file/main.ts create mode 100644 cli/tests/testdata/check/export_equals_declaration_file/other.d.ts create mode 100644 cli/tests/testdata/check/export_equals_declaration_file/other.js (limited to 'cli') diff --git a/cli/tests/integration/check_tests.rs b/cli/tests/integration/check_tests.rs index f42cd4a7a..03a5c932c 100644 --- a/cli/tests/integration/check_tests.rs +++ b/cli/tests/integration/check_tests.rs @@ -57,6 +57,11 @@ itest!(check_npm_install_diagnostics { exit_code: 1, }); +itest!(check_export_equals_declaration_file { + args: "check --quiet check/export_equals_declaration_file/main.ts", + exit_code: 0, +}); + #[test] fn cache_switching_config_then_no_config() { let deno_dir = util::new_deno_dir(); diff --git a/cli/tests/testdata/check/export_equals_declaration_file/main.ts b/cli/tests/testdata/check/export_equals_declaration_file/main.ts new file mode 100644 index 000000000..e20a735d5 --- /dev/null +++ b/cli/tests/testdata/check/export_equals_declaration_file/main.ts @@ -0,0 +1,6 @@ +// @deno-types="./other.d.ts" +import Test, { type Attributes } from "./other.js"; + +const other: Attributes = {}; +console.log(Test()); +console.log(other); diff --git a/cli/tests/testdata/check/export_equals_declaration_file/other.d.ts b/cli/tests/testdata/check/export_equals_declaration_file/other.d.ts new file mode 100644 index 000000000..5e1274fa5 --- /dev/null +++ b/cli/tests/testdata/check/export_equals_declaration_file/other.d.ts @@ -0,0 +1,9 @@ +export = other; + +declare function other(): string; + +declare namespace other { + interface Attributes { + [attr: string]: string; + } +} diff --git a/cli/tests/testdata/check/export_equals_declaration_file/other.js b/cli/tests/testdata/check/export_equals_declaration_file/other.js new file mode 100644 index 000000000..f66c03162 --- /dev/null +++ b/cli/tests/testdata/check/export_equals_declaration_file/other.js @@ -0,0 +1,3 @@ +export default function other() { + return "test"; +} diff --git a/cli/tsc/00_typescript.js b/cli/tsc/00_typescript.js index c39e70e24..01377c8b5 100644 --- a/cli/tsc/00_typescript.js +++ b/cli/tsc/00_typescript.js @@ -51163,7 +51163,7 @@ var ts; var usageMode = file && getUsageModeForExpression(usage); if (file && usageMode !== undefined) { var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat); - if (usageMode === ts.ModuleKind.ESNext || result) { + if (result) { return result; } // fallthrough on cjs usages so we imply defaults for interop'd imports, too -- cgit v1.2.3