diff --git a/cli/emit.rs b/cli/emit.rs index 7a7b227074c753..1722cd88124584 100644 --- a/cli/emit.rs +++ b/cli/emit.rs @@ -197,6 +197,9 @@ pub fn get_ts_config( } else { ts_config.merge_tsconfig_from_config_file(maybe_config_file)? }; + ts_config.merge(&json!({ + "moduleDetection": "force", + })); Ok((ts_config, maybe_ignored_options)) } diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index d1afc9b410a726..fdda1aeecd85f6 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -649,6 +649,7 @@ impl Inner { "jsx": "react", "lib": ["deno.ns", "deno.window"], "module": "esnext", + "moduleDetection": "force", "noEmit": true, "resolveJsonModule": true, "strict": true, diff --git a/cli/tests/integration/check_tests.rs b/cli/tests/integration/check_tests.rs index f605a733a3cac2..dca41a1e45af8f 100644 --- a/cli/tests/integration/check_tests.rs +++ b/cli/tests/integration/check_tests.rs @@ -32,3 +32,8 @@ itest!(check_all_local { output_str: Some(""), http_server: true, }); + +itest!(module_detection_force { + args: "check --quiet module_detection_force.ts", + output_str: Some(""), +}); diff --git a/cli/tests/testdata/046_jsx_test.tsx b/cli/tests/testdata/046_jsx_test.tsx index a96e90bafd69e8..5ed3ff2fabe715 100644 --- a/cli/tests/testdata/046_jsx_test.tsx +++ b/cli/tests/testdata/046_jsx_test.tsx @@ -1,6 +1,8 @@ -declare namespace JSX { - interface IntrinsicElements { - [elemName: string]: any; +declare global { + export namespace JSX { + interface IntrinsicElements { + [elemName: string]: any; + } } } const React = { diff --git a/cli/tests/testdata/error_for_await.ts b/cli/tests/testdata/error_for_await.ts index 6e8c5203f4532a..64c81abe4f46f3 100644 --- a/cli/tests/testdata/error_for_await.ts +++ b/cli/tests/testdata/error_for_await.ts @@ -10,5 +10,3 @@ function handleConn(conn: Deno.Conn) { event.respondWith(new Response("html", { status: 200 })); } } - -export {}; diff --git a/cli/tests/testdata/lsp/code_action_response_no_disabled.json b/cli/tests/testdata/lsp/code_action_response_no_disabled.json index c69bd1120fb2c3..11d2136b5e3030 100644 --- a/cli/tests/testdata/lsp/code_action_response_no_disabled.json +++ b/cli/tests/testdata/lsp/code_action_response_no_disabled.json @@ -1,4 +1,24 @@ [ + { + "title": "Extract to function in module scope", + "kind": "refactor.extract.function", + "isPreferred": false, + "data": { + "specifier": "file:///a/file.ts", + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 14, + "character": 0 + } + }, + "refactorName": "Extract Symbol", + "actionName": "function_scope_0" + } + }, { "title": "Move to a new file", "kind": "refactor.move.newFile", diff --git a/cli/tests/testdata/lsp/code_action_response_refactor.json b/cli/tests/testdata/lsp/code_action_response_refactor.json index c2797812e9cbb9..d0d9fb0ee2e36d 100644 --- a/cli/tests/testdata/lsp/code_action_response_refactor.json +++ b/cli/tests/testdata/lsp/code_action_response_refactor.json @@ -1,6 +1,6 @@ [ { - "title": "Extract to function in global scope", + "title": "Extract to function in module scope", "kind": "refactor.extract.function", "isPreferred": false, "data": { diff --git a/cli/tests/testdata/module_detection_force.ts b/cli/tests/testdata/module_detection_force.ts new file mode 100644 index 00000000000000..7729ae366c3fbf --- /dev/null +++ b/cli/tests/testdata/module_detection_force.ts @@ -0,0 +1,3 @@ +const a = 1; +await import("./module_detection_force_import.ts"); +console.log(a); diff --git a/cli/tests/testdata/module_detection_force_import.ts b/cli/tests/testdata/module_detection_force_import.ts new file mode 100644 index 00000000000000..66b229870debb7 --- /dev/null +++ b/cli/tests/testdata/module_detection_force_import.ts @@ -0,0 +1,2 @@ +const a = 2; +console.log(a); diff --git a/cli/tests/testdata/subdir/polyfill.ts b/cli/tests/testdata/subdir/polyfill.ts index e1cd923cbc4611..7af67c4c0320b3 100644 --- a/cli/tests/testdata/subdir/polyfill.ts +++ b/cli/tests/testdata/subdir/polyfill.ts @@ -2,8 +2,6 @@ declare global { const polyfill: () => void; } -export {}; - // deno-lint-ignore no-explicit-any (globalThis as any).polyfill = () => { console.log("polyfill"); diff --git a/cli/tests/testdata/subdir/single_module.ts b/cli/tests/testdata/subdir/single_module.ts index f41b0a4b545ed4..940a3ff0ec2025 100644 --- a/cli/tests/testdata/subdir/single_module.ts +++ b/cli/tests/testdata/subdir/single_module.ts @@ -1,2 +1 @@ console.log("Hello world!"); -export {}; // TODO(ry) This shouldn't be necessary. diff --git a/cli/tests/testdata/subdir/subdir2/dynamic_import.ts b/cli/tests/testdata/subdir/subdir2/dynamic_import.ts index 573887b7118da8..59beb64c33a153 100644 --- a/cli/tests/testdata/subdir/subdir2/dynamic_import.ts +++ b/cli/tests/testdata/subdir/subdir2/dynamic_import.ts @@ -2,5 +2,3 @@ const { printHello } = await import("../mod2.ts"); printHello(); })(); - -export {}; diff --git a/cli/tests/testdata/worker_message_before_close.js b/cli/tests/testdata/worker_message_before_close.js index 13ca6c9c7449f3..a8f5d09d510049 100644 --- a/cli/tests/testdata/worker_message_before_close.js +++ b/cli/tests/testdata/worker_message_before_close.js @@ -24,5 +24,3 @@ globalThis.addEventListener("unload", () => { ); } }); - -export {}; diff --git a/cli/tools/test.rs b/cli/tools/test.rs index 6d1530f3e7dba0..ef4d35cce39f73 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -884,8 +884,6 @@ fn extract_files_from_regex_blocks( file_source.push_str(&format!("{}\n", text.as_str())); } - file_source.push_str("export {};"); - let file_specifier = deno_core::resolve_url_or_path(&format!( "{}${}-{}{}", specifier, diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index c8dc56d5b9c091..527a4964fcaf57 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -83,10 +83,10 @@ delete Object.prototype.__proto__; // deno-fmt-ignore const base64abc = [ - "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", - "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", - "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", - "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", + "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", + "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", + "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/", ]; @@ -188,17 +188,6 @@ delete Object.prototype.__proto__; /** Diagnostics that are intentionally ignored when compiling TypeScript in * Deno, as they provide misleading or incorrect information. */ const IGNORED_DIAGNOSTICS = [ - // TS1208: All files must be modules when the '--isolatedModules' flag is - // provided. We can ignore because we guarantee that all files are - // modules. - 1208, - // TS1375: 'await' expressions are only allowed at the top level of a file - // when that file is a module, but this file has no imports or exports. - // Consider adding an empty 'export {}' to make this file a module. - 1375, - // TS2306: File 'file:///Users/rld/src/deno/cli/tests/testdata/subdir/amd_like.js' is - // not a module. - 2306, // TS2688: Cannot find type definition file for '...'. // We ignore because type defintion files can end with '.ts'. 2688,