Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(check): Use "moduleDetection": "force" #14875

Merged
merged 3 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
1 change: 1 addition & 0 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ impl Inner {
"jsx": "react",
"lib": ["deno.ns", "deno.window"],
"module": "esnext",
"moduleDetection": "force",
"noEmit": true,
"resolveJsonModule": true,
"strict": true,
Expand Down
5 changes: 5 additions & 0 deletions cli/tests/integration/check_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(""),
});
8 changes: 5 additions & 3 deletions cli/tests/testdata/046_jsx_test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
declare namespace JSX {
interface IntrinsicElements {
[elemName: string]: any;
declare global {
export namespace JSX {
interface IntrinsicElements {
[elemName: string]: any;
}
}
}
const React = {
Expand Down
2 changes: 0 additions & 2 deletions cli/tests/testdata/error_for_await.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ function handleConn(conn: Deno.Conn) {
event.respondWith(new Response("html", { status: 200 }));
}
}

export {};
20 changes: 20 additions & 0 deletions cli/tests/testdata/lsp/code_action_response_no_disabled.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/testdata/lsp/code_action_response_refactor.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions cli/tests/testdata/module_detection_force.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const a = 1;
await import("./module_detection_force_import.ts");
console.log(a);
2 changes: 2 additions & 0 deletions cli/tests/testdata/module_detection_force_import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const a = 2;
console.log(a);
2 changes: 0 additions & 2 deletions cli/tests/testdata/subdir/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ declare global {
const polyfill: () => void;
}

export {};

// deno-lint-ignore no-explicit-any
(globalThis as any).polyfill = () => {
console.log("polyfill");
Expand Down
1 change: 0 additions & 1 deletion cli/tests/testdata/subdir/single_module.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
console.log("Hello world!");
export {}; // TODO(ry) This shouldn't be necessary.
2 changes: 0 additions & 2 deletions cli/tests/testdata/subdir/subdir2/dynamic_import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
const { printHello } = await import("../mod2.ts");
printHello();
})();

export {};
2 changes: 0 additions & 2 deletions cli/tests/testdata/worker_message_before_close.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ globalThis.addEventListener("unload", () => {
);
}
});

export {};
2 changes: 0 additions & 2 deletions cli/tools/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 4 additions & 15 deletions cli/tsc/99_main_compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", "+", "/",
];

Expand Down Expand Up @@ -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,
Expand Down