0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

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

This commit is contained in:
Nayeem Rahman 2022-06-15 17:26:43 +01:00 committed by GitHub
parent 0b90e966c5
commit 845d4754c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 44 additions and 30 deletions

View file

@ -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))
}

View file

@ -649,6 +649,7 @@ impl Inner {
"jsx": "react",
"lib": ["deno.ns", "deno.window"],
"module": "esnext",
"moduleDetection": "force",
"noEmit": true,
"resolveJsonModule": true,
"strict": true,

View file

@ -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(""),
});

View file

@ -1,6 +1,8 @@
declare namespace JSX {
interface IntrinsicElements {
[elemName: string]: any;
declare global {
export namespace JSX {
interface IntrinsicElements {
[elemName: string]: any;
}
}
}
const React = {

View file

@ -10,5 +10,3 @@ function handleConn(conn: Deno.Conn) {
event.respondWith(new Response("html", { status: 200 }));
}
}
export {};

View file

@ -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",

View file

@ -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": {

View file

@ -0,0 +1,3 @@
const a = 1;
await import("./module_detection_force_import.ts");
console.log(a);

View file

@ -0,0 +1,2 @@
const a = 2;
console.log(a);

View file

@ -2,8 +2,6 @@ declare global {
const polyfill: () => void;
}
export {};
// deno-lint-ignore no-explicit-any
(globalThis as any).polyfill = () => {
console.log("polyfill");

View file

@ -1,2 +1 @@
console.log("Hello world!");
export {}; // TODO(ry) This shouldn't be necessary.

View file

@ -2,5 +2,3 @@
const { printHello } = await import("../mod2.ts");
printHello();
})();
export {};

View file

@ -24,5 +24,3 @@ globalThis.addEventListener("unload", () => {
);
}
});
export {};

View file

@ -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,

View file

@ -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,