Skip to content
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = {
nodenext: ModuleKind.NodeNext,
preserve: ModuleKind.Preserve,
})),
deprecatedKeys: new Set(["none", "amd", "system", "umd"]),
affectsSourceFile: true,
affectsModuleResolution: true,
affectsEmit: true,
Expand Down Expand Up @@ -1071,13 +1072,13 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
nodenext: ModuleResolutionKind.NodeNext,
bundler: ModuleResolutionKind.Bundler,
})),
deprecatedKeys: new Set(["node"]),
deprecatedKeys: new Set(["node", "node10", "classic"]),
affectsSourceFile: true,
affectsModuleResolution: true,
paramType: Diagnostics.STRATEGY,
category: Diagnostics.Modules,
description: Diagnostics.Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier,
defaultValueDescription: Diagnostics.module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node,
defaultValueDescription: Diagnostics.nodenext_if_module_is_nodenext_node16_if_module_is_node16_or_node18_otherwise_bundler,
},
{
name: "baseUrl",
Expand Down
7 changes: 2 additions & 5 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6587,10 +6587,7 @@
"category": "Message",
"code": 6903
},
"module === \"system\" or esModuleInterop": {
"category": "Message",
"code": 6904
},

"`false`, unless `strict` is set": {
"category": "Message",
"code": 6905
Expand All @@ -6611,7 +6608,7 @@
"category": "Message",
"code": 6909
},
"module === `AMD` or `UMD` or `System` or `ES6`, then `Classic`, Otherwise `Node`": {
"`nodenext` if `module` is `nodenext`; `node16` if `module` is `node16` or `node18`; otherwise, `bundler`.": {
"category": "Message",
"code": 69010
},
Expand Down
6 changes: 6 additions & 0 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4498,6 +4498,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
if (options.moduleResolution === ModuleResolutionKind.Node10) {
createDeprecatedDiagnostic("moduleResolution", "node10", /*useInstead*/ undefined, Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information);
}
if (options.moduleResolution === ModuleResolutionKind.Classic) {
createDeprecatedDiagnostic("moduleResolution", "classic", /*useInstead*/ undefined, /*related*/ undefined);
}
if (options.baseUrl !== undefined) {
createDeprecatedDiagnostic("baseUrl", /*value*/ undefined, /*useInstead*/ undefined, Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information);
}
Expand All @@ -4507,6 +4510,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
if (options.allowSyntheticDefaultImports === false) {
createDeprecatedDiagnostic("allowSyntheticDefaultImports", "false", /*useInstead*/ undefined, /*related*/ undefined);
}
if (options.module === ModuleKind.None || options.module === ModuleKind.AMD || options.module === ModuleKind.UMD || options.module === ModuleKind.System) {
createDeprecatedDiagnostic("module", ModuleKind[options.module], /*useInstead*/ undefined, /*related*/ undefined);
}
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7313,6 +7313,7 @@ export function diagnosticCategoryName(d: { category: DiagnosticCategory; }, low
}

export enum ModuleResolutionKind {
/** @deprecated */
Classic = 1,
/**
* @deprecated
Expand Down Expand Up @@ -7576,10 +7577,14 @@ export interface TypeAcquisition {
}

export enum ModuleKind {
/** @deprecated */
None = 0,
CommonJS = 1,
/** @deprecated */
AMD = 2,
/** @deprecated */
UMD = 3,
/** @deprecated */
System = 4,

// NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind.
Expand Down
40 changes: 18 additions & 22 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9015,27 +9015,23 @@ const _computedOptions = createComputedCompilerOptions({
moduleResolution: {
dependencies: ["module", "target"],
computeValue: (compilerOptions): ModuleResolutionKind => {
let moduleResolution = compilerOptions.moduleResolution;
if (moduleResolution === undefined) {
switch (_computedOptions.module.computeValue(compilerOptions)) {
case ModuleKind.Node16:
case ModuleKind.Node18:
case ModuleKind.Node20:
moduleResolution = ModuleResolutionKind.Node16;
break;
case ModuleKind.NodeNext:
moduleResolution = ModuleResolutionKind.NodeNext;
break;
case ModuleKind.CommonJS:
case ModuleKind.Preserve:
moduleResolution = ModuleResolutionKind.Bundler;
break;
default:
moduleResolution = ModuleResolutionKind.Classic;
break;
}
if (compilerOptions.moduleResolution !== undefined) {
return compilerOptions.moduleResolution;
}
return moduleResolution;
const moduleKind = _computedOptions.module.computeValue(compilerOptions);
switch (moduleKind) {
case ModuleKind.None:
case ModuleKind.AMD:
case ModuleKind.UMD:
case ModuleKind.System:
return ModuleResolutionKind.Classic;
case ModuleKind.NodeNext:
return ModuleResolutionKind.NodeNext;
}
if (ModuleKind.Node16 <= moduleKind && moduleKind < ModuleKind.NodeNext) {
return ModuleResolutionKind.Node16;
}
return ModuleResolutionKind.Bundler;
},
},
moduleDetection: {
Expand Down Expand Up @@ -9075,7 +9071,7 @@ const _computedOptions = createComputedCompilerOptions({
},
},
resolvePackageJsonExports: {
dependencies: ["moduleResolution"],
dependencies: ["moduleResolution", "module", "target"],
computeValue: (compilerOptions): boolean => {
const moduleResolution = _computedOptions.moduleResolution.computeValue(compilerOptions);
if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
Expand All @@ -9094,7 +9090,7 @@ const _computedOptions = createComputedCompilerOptions({
},
},
resolvePackageJsonImports: {
dependencies: ["moduleResolution", "resolvePackageJsonExports"],
dependencies: ["moduleResolution", "resolvePackageJsonExports", "module", "target"],
computeValue: (compilerOptions): boolean => {
const moduleResolution = _computedOptions.moduleResolution.computeValue(compilerOptions);
if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
Expand Down
10 changes: 5 additions & 5 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export const enum SymbolOriginInfoKind {
ComputedPropertyName = 1 << 9,

SymbolMemberNoExport = SymbolMember,
SymbolMemberExport = SymbolMember | Export,
SymbolMemberExport = SymbolMember | ResolvedExport,
}

/** @internal */
Expand Down Expand Up @@ -535,7 +535,7 @@ function originIsExport(origin: SymbolOriginInfo | undefined): origin is SymbolO
}

function originIsResolvedExport(origin: SymbolOriginInfo | undefined): origin is SymbolOriginInfoResolvedExport {
return !!(origin && origin.kind === SymbolOriginInfoKind.ResolvedExport);
return !!(origin && origin.kind & SymbolOriginInfoKind.ResolvedExport);
}

function originIncludesSymbolName(origin: SymbolOriginInfo | undefined): origin is SymbolOriginInfoExport | SymbolOriginInfoResolvedExport | SymbolOriginInfoComputedPropertyName {
Expand Down Expand Up @@ -2621,12 +2621,12 @@ function isRecommendedCompletionMatch(localSymbol: Symbol, recommendedCompletion
}

function getSourceFromOrigin(origin: SymbolOriginInfo | undefined): string | undefined {
if (originIsExport(origin)) {
return stripQuotes(origin.moduleSymbol.name);
}
if (originIsResolvedExport(origin)) {
return origin.moduleSpecifier;
}
if (originIsExport(origin)) {
return stripQuotes(origin.moduleSymbol.name);
}
if (origin?.kind === SymbolOriginInfoKind.ThisType) {
return CompletionSource.ThisProperty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ describe("unittests:: evaluation:: awaitUsingDeclarations", () => {
export const y = 2;
output.push("after export y");
`,
{ target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.System },
{ target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.System, ignoreDeprecations: "6.0" },
);

assert.strictEqual(x, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("unittests:: evaluation:: updateExpressionInModule", () => {
},
rootFiles: ["/.src/main.ts"],
main: "/.src/main.ts",
}, { module: ts.ModuleKind.System });
}, { module: ts.ModuleKind.System, ignoreDeprecations: "6.0" });
assert.equal(result.a, 2);
assert.equal(result.b, 2);
});
Expand Down Expand Up @@ -67,7 +67,7 @@ describe("unittests:: evaluation:: updateExpressionInModule", () => {
rootFiles: ["/.src/main.ts"],
main: "/.src/main.ts",
},
{ module: ts.ModuleKind.System },
{ module: ts.ModuleKind.System, ignoreDeprecations: "6.0" },
{ BigInt },
);
assert.equal(result.a, BigInt(2));
Expand Down Expand Up @@ -99,7 +99,7 @@ describe("unittests:: evaluation:: updateExpressionInModule", () => {
},
rootFiles: ["/.src/main.ts"],
main: "/.src/main.ts",
}, { module: ts.ModuleKind.System });
}, { module: ts.ModuleKind.System, ignoreDeprecations: "6.0" });
assert.equal(result.a, 2);
assert.equal(result.b, 1);
});
Expand Down Expand Up @@ -135,7 +135,7 @@ describe("unittests:: evaluation:: updateExpressionInModule", () => {
rootFiles: ["/.src/main.ts"],
main: "/.src/main.ts",
},
{ module: ts.ModuleKind.System },
{ module: ts.ModuleKind.System, ignoreDeprecations: "6.0" },
{ BigInt },
);
assert.equal(result.a, BigInt(2));
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/evaluation/usingDeclarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ describe("unittests:: evaluation:: usingDeclarations", () => {
export const y = 2;
output.push("after export y");
`,
{ target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.AMD },
{ target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.AMD, ignoreDeprecations: "6.0" },
);

assert.strictEqual(x, 1);
Expand Down Expand Up @@ -1624,7 +1624,7 @@ describe("unittests:: evaluation:: usingDeclarations", () => {
export const y = 2;
output.push("after export y");
`,
{ target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.System },
{ target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.System, ignoreDeprecations: "6.0" },
);

assert.strictEqual(x, 1);
Expand Down
5 changes: 3 additions & 2 deletions src/testRunner/unittests/tscWatch/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe("unittests:: tscWatch:: incremental:: emit file --incremental", () => {
};
const config: File = {
path: configFile.path,
content: jsonToReadableText({ compilerOptions: { incremental: true, module: "amd" } }),
content: jsonToReadableText({ compilerOptions: { incremental: true, module: "amd", ignoreDeprecations: "6.0" } }),
};

verifyIncrementalWatchEmit({
Expand Down Expand Up @@ -202,6 +202,7 @@ describe("unittests:: tscWatch:: incremental:: emit file --incremental", () => {
incremental: true,
module: ts.ModuleKind.AMD,
configFilePath: config.path,
ignoreDeprecations: "6.0",
});

assert.equal(ts.arrayFrom(builderProgram.state.referencedMap!.keys()).length, 0);
Expand All @@ -228,7 +229,7 @@ describe("unittests:: tscWatch:: incremental:: emit file --incremental", () => {
verifyIncrementalWatchEmit({
files: () => [file1, file2, {
path: configFile.path,
content: jsonToReadableText({ compilerOptions: { incremental: true, module: "amd", outFile: "out.js" } }),
content: jsonToReadableText({ compilerOptions: { incremental: true, module: "amd", outFile: "out.js", ignoreDeprecations: "6.0" } }),
}],
subScenario: "module compilation/with --out",
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== SystemModuleForStatementNoInitializer.ts (0 errors) ====
export { };

let i = 0;
let limit = 10;

for (; i < limit; ++i) {
break;
}

for (; ; ++i) {
break;
}

for (; ;) {
break;
}

2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasesInSystemModule1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
aliasesInSystemModule1.ts(1,24): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?


!!! error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== aliasesInSystemModule1.ts (1 errors) ====
import alias = require('foo');
~~~~~
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasesInSystemModule2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
aliasesInSystemModule2.ts(1,21): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?


!!! error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== aliasesInSystemModule2.ts (1 errors) ====
import {alias} from "foo";
~~~~~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
error TS5107: Option 'moduleResolution=classic' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
/c.ts(1,16): error TS2792: Cannot find module './thisfiledoesnotexist.ts'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?


!!! error TS5107: Option 'moduleResolution=classic' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== /ts.ts (0 errors) ====
export {};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error TS5107: Option 'moduleResolution=classic' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'moduleResolution=classic' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== /types.d.ts (0 errors) ====
export declare type User = {
name: string;
}

==== /a.ts (0 errors) ====
import type { User } from "./types.d.ts";
export type { User } from "./types.d.ts";

export const user: User = { name: "John" };

export function getUser(): import("./types.d.ts").User {
return user;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error TS5107: Option 'moduleResolution=classic' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'moduleResolution=classic' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== /types.d.ts (0 errors) ====
export declare type User = {
name: string;
}

==== /a.ts (0 errors) ====
import type { User } from "./types.d.ts";
export type { User } from "./types.d.ts";

export const user: User = { name: "John" };

export function getUser(): import("./types.d.ts").User {
return user;
}

12 changes: 12 additions & 0 deletions tests/baselines/reference/allowSyntheticDefaultImports2.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== a.ts (0 errors) ====
import Namespace from "./b";
export var x = new Namespace.Foo();

==== b.d.ts (0 errors) ====
export class Foo {
member: string;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error TS5107: Option 'allowSyntheticDefaultImports=false' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
a.ts(1,8): error TS1192: Module '"b"' has no default export.


!!! error TS5107: Option 'allowSyntheticDefaultImports=false' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
!!! error TS5107: Option 'module=System' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== a.ts (1 errors) ====
import Namespace from "./b";
~~~~~~~~~
Expand Down
Loading
Loading