mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 03:09:39 -06:00
Update implied default for module based on target (#63076)
This commit is contained in:
parent
1fd0c5389d
commit
97d51a7448
@ -9000,9 +9000,23 @@ const _computedOptions = createComputedCompilerOptions({
|
||||
module: {
|
||||
dependencies: ["target"],
|
||||
computeValue: (compilerOptions): ModuleKind => {
|
||||
return typeof compilerOptions.module === "number" ?
|
||||
compilerOptions.module :
|
||||
_computedOptions.target.computeValue(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
|
||||
if (typeof compilerOptions.module === "number") {
|
||||
return compilerOptions.module;
|
||||
}
|
||||
const target = _computedOptions.target.computeValue(compilerOptions);
|
||||
if (target === ScriptTarget.ESNext) {
|
||||
return ModuleKind.ESNext;
|
||||
}
|
||||
if (target >= ScriptTarget.ES2022) {
|
||||
return ModuleKind.ES2022;
|
||||
}
|
||||
if (target >= ScriptTarget.ES2020) {
|
||||
return ModuleKind.ES2020;
|
||||
}
|
||||
if (target >= ScriptTarget.ES2015) {
|
||||
return ModuleKind.ES2015;
|
||||
}
|
||||
return ModuleKind.CommonJS;
|
||||
},
|
||||
},
|
||||
moduleResolution: {
|
||||
|
||||
@ -12,11 +12,9 @@ awaitInNonAsyncFunction.ts(30,9): error TS1103: 'for await' loops are only allow
|
||||
awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.
|
||||
awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules.
|
||||
awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.
|
||||
awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'node20', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'node20', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitInNonAsyncFunction.ts (16 errors) ====
|
||||
==== awaitInNonAsyncFunction.ts (14 errors) ====
|
||||
// https://github.com/Microsoft/TypeScript/issues/26586
|
||||
|
||||
function normalFunc(p: Promise<number>) {
|
||||
@ -96,8 +94,4 @@ awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions ar
|
||||
}
|
||||
|
||||
for await (const _ of []);
|
||||
~~~~~
|
||||
!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'node20', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
await null;
|
||||
~~~~~
|
||||
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'node20', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
await null;
|
||||
Loading…
x
Reference in New Issue
Block a user