summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2022-06-15 17:26:43 +0100
committerGitHub <noreply@github.com>2022-06-15 12:26:43 -0400
commit845d4754c6fb959d1404f5de4bba9e71667b8c89 (patch)
tree88e0ca591f1d055d274731d84e2dfe5bdf69b7d5 /cli
parent0b90e966c5e22b95c283a10407234cad37b8f19b (diff)
fix(check): use "moduleDetection": "force" (#14875)
Diffstat (limited to 'cli')
-rw-r--r--cli/emit.rs3
-rw-r--r--cli/lsp/language_server.rs1
-rw-r--r--cli/tests/integration/check_tests.rs5
-rw-r--r--cli/tests/testdata/046_jsx_test.tsx8
-rw-r--r--cli/tests/testdata/error_for_await.ts2
-rw-r--r--cli/tests/testdata/lsp/code_action_response_no_disabled.json20
-rw-r--r--cli/tests/testdata/lsp/code_action_response_refactor.json2
-rw-r--r--cli/tests/testdata/module_detection_force.ts3
-rw-r--r--cli/tests/testdata/module_detection_force_import.ts2
-rw-r--r--cli/tests/testdata/subdir/polyfill.ts2
-rw-r--r--cli/tests/testdata/subdir/single_module.ts1
-rw-r--r--cli/tests/testdata/subdir/subdir2/dynamic_import.ts2
-rw-r--r--cli/tests/testdata/worker_message_before_close.js2
-rw-r--r--cli/tools/test.rs2
-rw-r--r--cli/tsc/99_main_compiler.js19
15 files changed, 44 insertions, 30 deletions
diff --git a/cli/emit.rs b/cli/emit.rs
index 7a7b22707..1722cd881 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 d1afc9b41..fdda1aeec 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 f605a733a..dca41a1e4 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 a96e90baf..5ed3ff2fa 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 6e8c5203f..64c81abe4 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 c69bd1120..11d2136b5 100644
--- a/cli/tests/testdata/lsp/code_action_response_no_disabled.json
+++ b/cli/tests/testdata/lsp/code_action_response_no_disabled.json
@@ -1,5 +1,25 @@
[
{
+ "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",
"isPreferred": false,
diff --git a/cli/tests/testdata/lsp/code_action_response_refactor.json b/cli/tests/testdata/lsp/code_action_response_refactor.json
index c2797812e..d0d9fb0ee 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 000000000..7729ae366
--- /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 000000000..66b229870
--- /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 e1cd923cb..7af67c4c0 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 f41b0a4b5..940a3ff0e 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 573887b71..59beb64c3 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 13ca6c9c7..a8f5d09d5 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 6d1530f3e..ef4d35cce 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 c8dc56d5b..527a4964f 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,