Skip to content

Commit 8923c9e

Browse files
committed
Resolve conflict with upstream/main
2 parents 3aaa32d + dd1e258 commit 8923c9e

594 files changed

Lines changed: 38811 additions & 820 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ In general, things we find useful when reviewing suggestions are:
4949

5050
## What You'll Need
5151

52-
0. [A bug or feature you want to work on](https://github.com/microsoft/TypeScript/labels/help%20wanted)!
52+
0. [A bug or feature you want to work on](https://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20label%3A%22Help%20Wanted%22)!
5353
1. [A GitHub account](https://github.com/join).
5454
2. A copy of the TypeScript code. See the next steps for instructions.
5555
3. [Node](https://nodejs.org), which runs JavaScript locally. Current or LTS will both work.

src/compiler/checker.ts

Lines changed: 203 additions & 202 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = {
603603
esnext: ModuleKind.ESNext,
604604
node16: ModuleKind.Node16,
605605
node18: ModuleKind.Node18,
606+
node20: ModuleKind.Node20,
606607
nodenext: ModuleKind.NodeNext,
607608
preserve: ModuleKind.Preserve,
608609
})),

src/compiler/diagnosticMessages.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,11 +1031,11 @@
10311031
"category": "Error",
10321032
"code": 1322
10331033
},
1034-
"Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', 'node18', or 'nodenext'.": {
1034+
"Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', 'node18', 'node20', or 'nodenext'.": {
10351035
"category": "Error",
10361036
"code": 1323
10371037
},
1038-
"Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'nodenext', or 'preserve'.": {
1038+
"Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.": {
10391039
"category": "Error",
10401040
"code": 1324
10411041
},
@@ -1103,7 +1103,7 @@
11031103
"category": "Error",
11041104
"code": 1341
11051105
},
1106-
"The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', 'node18', or 'nodenext'.": {
1106+
"The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', 'node18', 'node20', or 'nodenext'.": {
11071107
"category": "Error",
11081108
"code": 1343
11091109
},
@@ -1223,7 +1223,7 @@
12231223
"category": "Message",
12241224
"code": 1377
12251225
},
1226-
"Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": {
1226+
"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.": {
12271227
"category": "Error",
12281228
"code": 1378
12291229
},
@@ -1427,7 +1427,7 @@
14271427
"category": "Error",
14281428
"code": 1431
14291429
},
1430-
"Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": {
1430+
"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.": {
14311431
"category": "Error",
14321432
"code": 1432
14331433
},
@@ -3799,15 +3799,15 @@
37993799
"category": "Error",
38003800
"code": 2820
38013801
},
3802-
"Import assertions are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'.": {
3802+
"Import assertions are only supported when the '--module' option is set to 'esnext', 'node18', 'node20', 'nodenext', or 'preserve'.": {
38033803
"category": "Error",
38043804
"code": 2821
38053805
},
38063806
"Import assertions cannot be used with type-only imports or exports.": {
38073807
"category": "Error",
38083808
"code": 2822
38093809
},
3810-
"Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'.": {
3810+
"Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'node20', 'nodenext', or 'preserve'.": {
38113811
"category": "Error",
38123812
"code": 2823
38133813
},
@@ -3887,7 +3887,7 @@
38873887
"category": "Error",
38883888
"code": 2853
38893889
},
3890-
"Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": {
3890+
"Top-level 'await using' statements 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.": {
38913891
"category": "Error",
38923892
"code": 2854
38933893
},

src/compiler/parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8392,7 +8392,10 @@ namespace Parser {
83928392
phaseModifier = SyntaxKind.TypeKeyword;
83938393
identifier = isIdentifier() ? parseIdentifier() : undefined;
83948394
}
8395-
else if (identifier?.escapedText === "defer" && token() !== SyntaxKind.FromKeyword) {
8395+
else if (
8396+
identifier?.escapedText === "defer" &&
8397+
(token() === SyntaxKind.FromKeyword ? !lookAhead(nextTokenIsStringLiteral) : token() !== SyntaxKind.CommaToken && token() !== SyntaxKind.EqualsToken)
8398+
) {
83968399
phaseModifier = SyntaxKind.DeferKeyword;
83978400
identifier = isIdentifier() ? parseIdentifier() : undefined;
83988401
}

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4986,8 +4986,8 @@ function updateHostForUseSourceOfProjectReferenceRedirect(host: HostForUseSource
49864986

49874987
function fileOrDirectoryExistsUsingSource(fileOrDirectory: string, isFile: boolean): boolean {
49884988
const fileOrDirectoryExistsUsingSource = isFile ?
4989-
(file: string) => fileExistsIfProjectReferenceDts(file) :
4990-
(dir: string) => directoryExistsIfProjectReferenceDeclDir(dir);
4989+
fileExistsIfProjectReferenceDts :
4990+
directoryExistsIfProjectReferenceDeclDir;
49914991
// Check current directory or file
49924992
const result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
49934993
if (result !== undefined) return result;

src/compiler/transformer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory<Source
8787
case ModuleKind.ES2015:
8888
case ModuleKind.Node16:
8989
case ModuleKind.Node18:
90+
case ModuleKind.Node20:
9091
case ModuleKind.NodeNext:
9192
case ModuleKind.CommonJS:
9293
// Wraps `transformModule` and `transformECMAScriptModule` and

src/compiler/types.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6539,7 +6539,7 @@ export const enum ObjectFlags {
65396539
CouldContainTypeVariablesComputed = 1 << 19, // CouldContainTypeVariables flag has been computed
65406540
/** @internal */
65416541
CouldContainTypeVariables = 1 << 20, // Type could contain a type variable
6542-
6542+
SingleSignatureType = 1 << 27, // A single signature type extracted from a potentially broader type
65436543
ClassOrInterface = Class | Interface,
65446544
/** @internal */
65456545
RequiresWidening = ContainsWideningType | ContainsObjectOrArrayLiteral,
@@ -6555,7 +6555,6 @@ export const enum ObjectFlags {
65556555
ContainsSpread = 1 << 21, // Object literal contains spread operation
65566556
ObjectRestType = 1 << 22, // Originates in object rest declaration
65576557
InstantiationExpressionType = 1 << 23, // Originates in instantiation expression
6558-
SingleSignatureType = 1 << 27, // A single signature type extracted from a potentially broader type
65596558
/** @internal */
65606559
IsClassInstanceClone = 1 << 24, // Type is a clone of a class instance type
65616560
// Flags that require TypeFlags.Object and ObjectFlags.Reference
@@ -6770,12 +6769,6 @@ export interface AnonymousType extends ObjectType {
67706769
instantiations?: Map<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
67716770
}
67726771

6773-
/** @internal */
6774-
// A SingleSignatureType may have bespoke outer type parameters to handle free type variable inferences
6775-
export interface SingleSignatureType extends AnonymousType {
6776-
outerTypeParameters?: TypeParameter[];
6777-
}
6778-
67796772
/** @internal */
67806773
export interface InstantiationExpressionType extends AnonymousType {
67816774
node: NodeWithTypeArguments;
@@ -7061,8 +7054,6 @@ export interface Signature {
70617054
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
70627055
/** @internal */
70637056
instantiations?: Map<string, Signature>; // Generic signature instantiation cache
7064-
/** @internal */
7065-
implementationSignatureCache?: Signature; // Copy of the signature with fresh type parameters to use in checking the body of a potentially self-referential generic function (deferred)
70667057
}
70677058

70687059
export const enum IndexKind {
@@ -7170,6 +7161,7 @@ export interface InferenceContext {
71707161
mapper: TypeMapper; // Mapper that fixes inferences
71717162
nonFixingMapper: TypeMapper; // Mapper that doesn't fix inferences
71727163
returnMapper?: TypeMapper; // Type mapper for inferences from return types (if any)
7164+
outerReturnMapper?: TypeMapper; // Type mapper for inferences from return types of outer function (if any)
71737165
inferredTypeParameters?: readonly TypeParameter[]; // Inferred type parameters for function result
71747166
intraExpressionInferenceSites?: IntraExpressionInferenceSite[];
71757167
}
@@ -7606,6 +7598,7 @@ export enum ModuleKind {
76067598
// Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext
76077599
Node16 = 100,
76087600
Node18 = 101,
7601+
Node20 = 102,
76097602
NodeNext = 199,
76107603

76117604
// Emit as written

src/compiler/utilities.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8964,6 +8964,7 @@ const _computedOptions = createComputedCompilerOptions({
89648964
return target ??
89658965
((compilerOptions.module === ModuleKind.Node16 && ScriptTarget.ES2022) ||
89668966
(compilerOptions.module === ModuleKind.Node18 && ScriptTarget.ES2022) ||
8967+
(compilerOptions.module === ModuleKind.Node20 && ScriptTarget.ES2023) ||
89678968
(compilerOptions.module === ModuleKind.NodeNext && ScriptTarget.ESNext) ||
89688969
ScriptTarget.ES5);
89698970
},
@@ -8987,6 +8988,7 @@ const _computedOptions = createComputedCompilerOptions({
89878988
break;
89888989
case ModuleKind.Node16:
89898990
case ModuleKind.Node18:
8991+
case ModuleKind.Node20:
89908992
moduleResolution = ModuleResolutionKind.Node16;
89918993
break;
89928994
case ModuleKind.NodeNext:
@@ -9030,6 +9032,7 @@ const _computedOptions = createComputedCompilerOptions({
90309032
switch (_computedOptions.module.computeValue(compilerOptions)) {
90319033
case ModuleKind.Node16:
90329034
case ModuleKind.Node18:
9035+
case ModuleKind.Node20:
90339036
case ModuleKind.NodeNext:
90349037
case ModuleKind.Preserve:
90359038
return true;
@@ -9092,6 +9095,14 @@ const _computedOptions = createComputedCompilerOptions({
90929095
if (compilerOptions.resolveJsonModule !== undefined) {
90939096
return compilerOptions.resolveJsonModule;
90949097
}
9098+
switch (_computedOptions.module.computeValue(compilerOptions)) {
9099+
// TODO in 6.0: uncomment
9100+
// case ModuleKind.Node16:
9101+
// case ModuleKind.Node18:
9102+
case ModuleKind.Node20:
9103+
case ModuleKind.NodeNext:
9104+
return true;
9105+
}
90959106
return _computedOptions.moduleResolution.computeValue(compilerOptions) === ModuleResolutionKind.Bundler;
90969107
},
90979108
},

0 commit comments

Comments
 (0)