From ef7bc5e0a62e1e362704fd2becb5629a7f9f60ba Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Thu, 23 Jun 2022 17:18:32 +0100 Subject: [PATCH] fix(check): ignore TS2306 (#14940) Fixes a regression where this type checking error was being surfaced in certain scenarios. --- cli/tests/integration/check_tests.rs | 6 ++++++ .../testdata/declaration_header_file_with_no_exports.ts | 2 ++ .../declaration_header_file_with_no_exports_js.d.ts | 0 .../testdata/declaration_header_file_with_no_exports_js.js | 1 + cli/tsc/99_main_compiler.js | 4 ++++ 5 files changed, 13 insertions(+) create mode 100644 cli/tests/testdata/declaration_header_file_with_no_exports.ts create mode 100644 cli/tests/testdata/declaration_header_file_with_no_exports_js.d.ts create mode 100644 cli/tests/testdata/declaration_header_file_with_no_exports_js.js diff --git a/cli/tests/integration/check_tests.rs b/cli/tests/integration/check_tests.rs index dca41a1e45af8f..8000ddc9d2f2db 100644 --- a/cli/tests/integration/check_tests.rs +++ b/cli/tests/integration/check_tests.rs @@ -37,3 +37,9 @@ itest!(module_detection_force { args: "check --quiet module_detection_force.ts", output_str: Some(""), }); + +// Regression test for https://github.com/denoland/deno/issues/14937. +itest!(declaration_header_file_with_no_exports { + args: "check --quiet declaration_header_file_with_no_exports.ts", + output_str: Some(""), +}); diff --git a/cli/tests/testdata/declaration_header_file_with_no_exports.ts b/cli/tests/testdata/declaration_header_file_with_no_exports.ts new file mode 100644 index 00000000000000..ef5da7a38c7889 --- /dev/null +++ b/cli/tests/testdata/declaration_header_file_with_no_exports.ts @@ -0,0 +1,2 @@ +import * as foo from "./declaration_header_file_with_no_exports_js.js"; +console.log(foo); diff --git a/cli/tests/testdata/declaration_header_file_with_no_exports_js.d.ts b/cli/tests/testdata/declaration_header_file_with_no_exports_js.d.ts new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/cli/tests/testdata/declaration_header_file_with_no_exports_js.js b/cli/tests/testdata/declaration_header_file_with_no_exports_js.js new file mode 100644 index 00000000000000..b8ae2bcefdda1e --- /dev/null +++ b/cli/tests/testdata/declaration_header_file_with_no_exports_js.js @@ -0,0 +1 @@ +/// diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index 527a4964fcaf57..7650ff95bdf728 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -188,6 +188,10 @@ delete Object.prototype.__proto__; /** Diagnostics that are intentionally ignored when compiling TypeScript in * Deno, as they provide misleading or incorrect information. */ const IGNORED_DIAGNOSTICS = [ + // TS2306: File '.../index.d.ts' is not a module. + // We get this for `x-typescript-types` declaration files which don't export + // anything. We prefer to treat these as modules with no exports. + 2306, // TS2688: Cannot find type definition file for '...'. // We ignore because type defintion files can end with '.ts'. 2688,