Skip to content

Commit a95de48

Browse files
committed
Merge branch 'main' into improveIntersectionReduction
2 parents ffe147e + 90b1321 commit a95de48

File tree

748 files changed

+8493
-3405
lines changed

Some content is hidden

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

748 files changed

+8493
-3405
lines changed

package-lock.json

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "https://www.typescriptlang.org/",
5-
"version": "4.7.0",
5+
"version": "4.8.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [

scripts/build/tests.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
122122

123123
try {
124124
setNodeEnvToDevelopment();
125-
const { exitCode } = await exec("node", args, { cancelToken });
125+
const { exitCode } = await exec(process.execPath, args, {
126+
cancelToken,
127+
});
126128
if (exitCode !== 0) {
127129
errorStatus = exitCode;
128130
error = new Error(`Process exited with status code ${errorStatus}.`);

src/compiler/checker.ts

Lines changed: 169 additions & 51 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ namespace ts {
8181
["es2021.intl", "lib.es2021.intl.d.ts"],
8282
["es2022.array", "lib.es2022.array.d.ts"],
8383
["es2022.error", "lib.es2022.error.d.ts"],
84+
["es2022.intl", "lib.es2022.intl.d.ts"],
8485
["es2022.object", "lib.es2022.object.d.ts"],
8586
["es2022.string", "lib.es2022.string.d.ts"],
8687
["esnext.array", "lib.es2022.array.d.ts"],
@@ -423,7 +424,7 @@ namespace ts {
423424
es2020: ModuleKind.ES2020,
424425
es2022: ModuleKind.ES2022,
425426
esnext: ModuleKind.ESNext,
426-
node12: ModuleKind.Node12,
427+
node16: ModuleKind.Node16,
427428
nodenext: ModuleKind.NodeNext,
428429
})),
429430
affectsModuleResolution: true,
@@ -781,7 +782,7 @@ namespace ts {
781782
type: new Map(getEntries({
782783
node: ModuleResolutionKind.NodeJs,
783784
classic: ModuleResolutionKind.Classic,
784-
node12: ModuleResolutionKind.Node12,
785+
node16: ModuleResolutionKind.Node16,
785786
nodenext: ModuleResolutionKind.NodeNext,
786787
})),
787788
affectsModuleResolution: true,
@@ -1263,7 +1264,7 @@ namespace ts {
12631264
affectsModuleResolution: true,
12641265
description: Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
12651266
category: Diagnostics.Language_and_Environment,
1266-
defaultValueDescription: Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules,
1267+
defaultValueDescription: Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules,
12671268
}
12681269
];
12691270

@@ -2325,7 +2326,7 @@ namespace ts {
23252326
function filterSameAsDefaultInclude(specs: readonly string[] | undefined) {
23262327
if (!length(specs)) return undefined;
23272328
if (length(specs) !== 1) return specs;
2328-
if (specs![0] === "**/*") return undefined;
2329+
if (specs![0] === defaultIncludeSpec) return undefined;
23292330
return specs;
23302331
}
23312332

@@ -2626,6 +2627,9 @@ namespace ts {
26262627
return getDirectoryPath(getNormalizedAbsolutePath(fileName, basePath));
26272628
}
26282629

2630+
/*@internal*/
2631+
export const defaultIncludeSpec = "**/*";
2632+
26292633
/**
26302634
* Parse the contents of a config file from json or json source file (tsconfig.json).
26312635
* @param json The contents of the config file to parse
@@ -2704,6 +2708,7 @@ namespace ts {
27042708
let includeSpecs = toPropValue(getSpecsFromRaw("include"));
27052709

27062710
const excludeOfRaw = getSpecsFromRaw("exclude");
2711+
let isDefaultIncludeSpec = false;
27072712
let excludeSpecs = toPropValue(excludeOfRaw);
27082713
if (excludeOfRaw === "no-prop" && raw.compilerOptions) {
27092714
const outDir = raw.compilerOptions.outDir;
@@ -2715,7 +2720,8 @@ namespace ts {
27152720
}
27162721

27172722
if (filesSpecs === undefined && includeSpecs === undefined) {
2718-
includeSpecs = ["**/*"];
2723+
includeSpecs = [defaultIncludeSpec];
2724+
isDefaultIncludeSpec = true;
27192725
}
27202726
let validatedIncludeSpecs: readonly string[] | undefined, validatedExcludeSpecs: readonly string[] | undefined;
27212727

@@ -2739,6 +2745,7 @@ namespace ts {
27392745
validatedIncludeSpecs,
27402746
validatedExcludeSpecs,
27412747
pathPatterns: undefined, // Initialized on first use
2748+
isDefaultIncludeSpec,
27422749
};
27432750
}
27442751

src/compiler/corePublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace ts {
22
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
33
// If changing the text in this section, be sure to test `configurePrerelease` too.
4-
export const versionMajorMinor = "4.7";
4+
export const versionMajorMinor = "4.8";
55
// The following is baselined as a literal template type without intervention
66
/** The version of the TypeScript compiler release */
77
// eslint-disable-next-line @typescript-eslint/no-inferrable-types

src/compiler/diagnosticMessages.json

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@
435435
"category": "Error",
436436
"code": 1144
437437
},
438+
"'{' or JSX element expected.": {
439+
"category": "Error",
440+
"code": 1145
441+
},
438442
"Declaration expected.": {
439443
"category": "Error",
440444
"code": 1146
@@ -900,6 +904,10 @@
900904
"category": "Error",
901905
"code": 1308
902906
},
907+
"The current file is a CommonJS module and cannot use 'await' at the top level.": {
908+
"category": "Error",
909+
"code": 1309
910+
},
903911
"Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.": {
904912
"category": "Error",
905913
"code": 1312
@@ -944,11 +952,11 @@
944952
"category": "Error",
945953
"code": 1322
946954
},
947-
"Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.": {
955+
"Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.": {
948956
"category": "Error",
949957
"code": 1323
950958
},
951-
"Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'.": {
959+
"Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.": {
952960
"category": "Error",
953961
"code": 1324
954962
},
@@ -1016,7 +1024,7 @@
10161024
"category": "Error",
10171025
"code": 1342
10181026
},
1019-
"The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'.": {
1027+
"The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.": {
10201028
"category": "Error",
10211029
"code": 1343
10221030
},
@@ -1140,7 +1148,7 @@
11401148
"category": "Message",
11411149
"code": 1377
11421150
},
1143-
"Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
1151+
"Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
11441152
"category": "Error",
11451153
"code": 1378
11461154
},
@@ -1348,7 +1356,7 @@
13481356
"category": "Error",
13491357
"code": 1431
13501358
},
1351-
"Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
1359+
"Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
13521360
"category": "Error",
13531361
"code": 1432
13541362
},
@@ -1420,7 +1428,7 @@
14201428
"category": "Error",
14211429
"code": 1451
14221430
},
1423-
"Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`.": {
1431+
"Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.": {
14241432
"category": "Error",
14251433
"code": 1452
14261434
},
@@ -1440,6 +1448,10 @@
14401448
"category": "Error",
14411449
"code": 1456
14421450
},
1451+
"Matched by default include pattern '**/*'": {
1452+
"category": "Message",
1453+
"code": 1457
1454+
},
14431455

14441456
"The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.": {
14451457
"category": "Error",
@@ -1465,7 +1477,7 @@
14651477
"category": "Message",
14661478
"code": 1475
14671479
},
1468-
"\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules.": {
1480+
"\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules.": {
14691481
"category": "Message",
14701482
"code": 1476
14711483
},
@@ -1507,6 +1519,15 @@
15071519
"code": 2207
15081520
},
15091521

1522+
"The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate.": {
1523+
"category": "Error",
1524+
"code": 2209
1525+
},
1526+
"The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate.": {
1527+
"category": "Error",
1528+
"code": 2210
1529+
},
1530+
15101531
"Duplicate identifier '{0}'.": {
15111532
"category": "Error",
15121533
"code": 2300
@@ -3418,11 +3439,11 @@
34183439
"category": "Error",
34193440
"code": 2833
34203441
},
3421-
"Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path.": {
3442+
"Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.": {
34223443
"category": "Error",
34233444
"code": 2834
34243445
},
3425-
"Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?": {
3446+
"Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?": {
34263447
"category": "Error",
34273448
"code": 2835
34283449
},
@@ -3438,6 +3459,10 @@
34383459
"category": "Error",
34393460
"code": 2838
34403461
},
3462+
"This condition will always return '{0}' since JavaScript compares objects by reference, not value.": {
3463+
"category": "Error",
3464+
"code": 2839
3465+
},
34413466

34423467
"Import declaration '{0}' is using private name '{1}'.": {
34433468
"category": "Error",
@@ -3867,6 +3892,10 @@
38673892
"category": "Error",
38683893
"code": 4124
38693894
},
3895+
"Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'.": {
3896+
"category": "Error",
3897+
"code": 4125
3898+
},
38703899

38713900
"The current host does not support the '{0}' option.": {
38723901
"category": "Error",
@@ -6106,10 +6135,6 @@
61066135
"category": "Error",
61076136
"code": 7061
61086137
},
6109-
"JSON imports are experimental in ES module mode imports.": {
6110-
"category": "Error",
6111-
"code": 7062
6112-
},
61136138

61146139
"You cannot rename this element.": {
61156140
"category": "Error",

src/compiler/factory/nodeFactory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4964,7 +4964,7 @@ namespace ts {
49644964
}
49654965

49664966
// @api
4967-
function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined) {
4967+
function createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined) {
49684968
const node = createBaseNode<JsxAttribute>(SyntaxKind.JsxAttribute);
49694969
node.name = name;
49704970
node.initializer = initializer;
@@ -4976,7 +4976,7 @@ namespace ts {
49764976
}
49774977

49784978
// @api
4979-
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) {
4979+
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined) {
49804980
return node.name !== name
49814981
|| node.initializer !== initializer
49824982
? update(createJsxAttribute(name, initializer), node)
@@ -5275,7 +5275,7 @@ namespace ts {
52755275
hasNoDefaultLib: boolean,
52765276
libReferences: readonly FileReference[]
52775277
) {
5278-
const node = baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile) as Mutable<SourceFile>;
5278+
const node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile)) as Mutable<SourceFile>;
52795279
for (const p in source) {
52805280
if (p === "emitNode" || hasProperty(node, p) || !hasProperty(source, p)) continue;
52815281
(node as any)[p] = (source as any)[p];

0 commit comments

Comments
 (0)