Skip to content

Commit 02e93fd

Browse files
committed
Merge branch 'main' into decorators-stage-3
2 parents b0020f6 + 10c7c45 commit 02e93fd

File tree

193 files changed

+6810
-1311
lines changed

Some content is hidden

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

193 files changed

+6810
-1311
lines changed

package-lock.json

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

src/compiler/binder.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ import {
172172
isJSDocTypeAlias,
173173
isJsonSourceFile,
174174
isLeftHandSideExpression,
175+
isLogicalOrCoalescingAssignmentExpression,
175176
isLogicalOrCoalescingAssignmentOperator,
177+
isLogicalOrCoalescingBinaryExpression,
178+
isLogicalOrCoalescingBinaryOperator,
176179
isModuleAugmentationExternal,
177180
isModuleBlock,
178181
isModuleDeclaration,
@@ -1377,17 +1380,13 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
13771380
node = (node as PrefixUnaryExpression).operand;
13781381
}
13791382
else {
1380-
return node.kind === SyntaxKind.BinaryExpression && (
1381-
(node as BinaryExpression).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken ||
1382-
(node as BinaryExpression).operatorToken.kind === SyntaxKind.BarBarToken ||
1383-
(node as BinaryExpression).operatorToken.kind === SyntaxKind.QuestionQuestionToken);
1383+
return isLogicalOrCoalescingBinaryExpression(node);
13841384
}
13851385
}
13861386
}
13871387

13881388
function isLogicalAssignmentExpression(node: Node) {
1389-
node = skipParentheses(node);
1390-
return isBinaryExpression(node) && isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind);
1389+
return isLogicalOrCoalescingAssignmentExpression(skipParentheses(node));
13911390
}
13921391

13931392
function isTopLevelLogicalExpression(node: Node): boolean {
@@ -1859,10 +1858,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
18591858
// we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too
18601859
// For now, though, since the common cases are chained `+`, leaving it recursive is fine
18611860
const operator = node.operatorToken.kind;
1862-
if (operator === SyntaxKind.AmpersandAmpersandToken ||
1863-
operator === SyntaxKind.BarBarToken ||
1864-
operator === SyntaxKind.QuestionQuestionToken ||
1865-
isLogicalOrCoalescingAssignmentOperator(operator)) {
1861+
if (isLogicalOrCoalescingBinaryOperator(operator) || isLogicalOrCoalescingAssignmentOperator(operator)) {
18661862
if (isTopLevelLogicalExpression(node)) {
18671863
const postExpressionLabel = createBranchLabel();
18681864
bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel);

src/compiler/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ function convertToReusableCompilerOptionValue(option: CommandLineOption | undefi
11631163
if (option) {
11641164
Debug.assert(option.type !== "listOrElement");
11651165
if (option.type === "list") {
1166-
const values = value as readonly (string | number)[];
1166+
const values = value as readonly string[];
11671167
if (option.element.isFilePath && values.length) {
11681168
return values.map(relativeToBuildInfo);
11691169
}

src/compiler/checker.ts

Lines changed: 124 additions & 69 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ const libEntries: [string, string][] = [
156156
["es2020", "lib.es2020.d.ts"],
157157
["es2021", "lib.es2021.d.ts"],
158158
["es2022", "lib.es2022.d.ts"],
159+
["es2023", "lib.es2023.d.ts"],
159160
["esnext", "lib.esnext.d.ts"],
160161
// Host only
161162
["dom", "lib.dom.d.ts"],
@@ -209,7 +210,8 @@ const libEntries: [string, string][] = [
209210
["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
210211
["es2022.string", "lib.es2022.string.d.ts"],
211212
["es2022.regexp", "lib.es2022.regexp.d.ts"],
212-
["esnext.array", "lib.es2022.array.d.ts"],
213+
["es2023.array", "lib.es2023.array.d.ts"],
214+
["esnext.array", "lib.es2023.array.d.ts"],
213215
["esnext.symbol", "lib.es2019.symbol.d.ts"],
214216
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
215217
["esnext.intl", "lib.esnext.intl.d.ts"],
@@ -1091,7 +1093,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
10911093
{
10921094
name: "allowImportingTsExtensions",
10931095
type: "boolean",
1094-
affectsModuleResolution: true,
1096+
affectsSemanticDiagnostics: true,
10951097
category: Diagnostics.Modules,
10961098
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
10971099
defaultValueDescription: false,
@@ -2881,7 +2883,7 @@ export function convertToOptionsWithAbsolutePaths(options: CompilerOptions, toAb
28812883
function convertToOptionValueWithAbsolutePaths(option: CommandLineOption | undefined, value: CompilerOptionsValue, toAbsolutePath: (path: string) => string) {
28822884
if (option && !isNullOrUndefined(value)) {
28832885
if (option.type === "list") {
2884-
const values = value as readonly (string | number)[];
2886+
const values = value as readonly string[];
28852887
if (option.element.isFilePath && values.length) {
28862888
return values.map(toAbsolutePath);
28872889
}
@@ -3280,7 +3282,7 @@ function parseOwnConfigOfJson(
32803282
json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
32813283
let extendedConfigPath: string | string[] | undefined;
32823284

3283-
if (json.extends) {
3285+
if (json.extends || json.extends === "") {
32843286
if (!isCompilerOptionsValue(extendsOptionDeclaration, json.extends)) {
32853287
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", getCompilerOptionValueTypeString(extendsOptionDeclaration)));
32863288
}
@@ -3294,7 +3296,7 @@ function parseOwnConfigOfJson(
32943296
for (const fileName of json.extends as unknown[]) {
32953297
if (isString(fileName)) {
32963298
extendedConfigPath = append(extendedConfigPath, getExtendsConfigPath(fileName, host, newBase, errors, createCompilerDiagnostic));
3297-
}
3299+
}
32983300
else {
32993301
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", getCompilerOptionValueTypeString(extendsOptionDeclaration.element)));
33003302
}
@@ -3429,7 +3431,12 @@ function getExtendsConfigPath(
34293431
if (resolved.resolvedModule) {
34303432
return resolved.resolvedModule.resolvedFileName;
34313433
}
3432-
errors.push(createDiagnostic(Diagnostics.File_0_not_found, extendedConfig));
3434+
if (extendedConfig === "") {
3435+
errors.push(createDiagnostic(Diagnostics.Compiler_option_0_cannot_be_given_an_empty_string, "extends"));
3436+
}
3437+
else {
3438+
errors.push(createDiagnostic(Diagnostics.File_0_not_found, extendedConfig));
3439+
}
34333440
return undefined;
34343441
}
34353442

@@ -3842,7 +3849,8 @@ function validateSpecs(specs: readonly string[], errors: Push<Diagnostic>, disal
38423849
}
38433850
}
38443851

3845-
function specToDiagnostic(spec: string, disallowTrailingRecursion?: boolean): [DiagnosticMessage, string] | undefined {
3852+
function specToDiagnostic(spec: CompilerOptionsValue, disallowTrailingRecursion?: boolean): [DiagnosticMessage, string] | undefined {
3853+
Debug.assert(typeof spec === "string");
38463854
if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
38473855
return [Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
38483856
}

src/compiler/core.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ export function intersperse<T>(input: T[], element: T): T[] {
142142
*
143143
* @internal
144144
*/
145+
export function every<T, U extends T>(array: readonly T[], callback: (element: T, index: number) => element is U): array is readonly U[];
146+
/** @internal */
147+
export function every<T, U extends T>(array: readonly T[] | undefined, callback: (element: T, index: number) => element is U): array is readonly U[] | undefined;
148+
/** @internal */
149+
export function every<T>(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean;
145150
export function every<T>(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean {
146151
if (array) {
147152
for (let i = 0; i < array.length; i++) {
@@ -478,7 +483,7 @@ export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | reado
478483
/** @internal */
479484
export function sameFlatMap<T>(array: readonly T[], mapfn: (x: T, i: number) => T | readonly T[]): readonly T[];
480485
/** @internal */
481-
export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | T[]): T[] {
486+
export function sameFlatMap<T>(array: readonly T[], mapfn: (x: T, i: number) => T | readonly T[]): readonly T[] {
482487
let result: T[] | undefined;
483488
if (array) {
484489
for (let i = 0; i < array.length; i++) {
@@ -703,11 +708,19 @@ export function concatenate<T>(array1: T[], array2: T[]): T[];
703708
/** @internal */
704709
export function concatenate<T>(array1: readonly T[], array2: readonly T[]): readonly T[];
705710
/** @internal */
706-
export function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[];
711+
export function concatenate<T>(array1: T[], array2: T[] | undefined): T[]; // eslint-disable-line @typescript-eslint/unified-signatures
712+
/** @internal */
713+
export function concatenate<T>(array1: T[] | undefined, array2: T[]): T[]; // eslint-disable-line @typescript-eslint/unified-signatures
714+
/** @internal */
715+
export function concatenate<T>(array1: readonly T[], array2: readonly T[] | undefined): readonly T[]; // eslint-disable-line @typescript-eslint/unified-signatures
716+
/** @internal */
717+
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[]): readonly T[]; // eslint-disable-line @typescript-eslint/unified-signatures
707718
/** @internal */
708-
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[];
719+
export function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[] | undefined;
709720
/** @internal */
710-
export function concatenate<T>(array1: T[], array2: T[]): T[] {
721+
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[] | undefined;
722+
/** @internal */
723+
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[] | undefined {
711724
if (!some(array2)) return array1;
712725
if (!some(array1)) return array2;
713726
return [...array1, ...array2];
@@ -856,7 +869,7 @@ export function detectSortCaseSensitivity(array: readonly string[], useEslintOrd
856869
/** @internal */
857870
export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrdering: boolean, getString: (element: T) => string): SortKind;
858871
/** @internal */
859-
export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrdering: boolean, getString?: (element: T) => string): SortKind {
872+
export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrdering?: boolean, getString?: (element: T) => string): SortKind {
860873
let kind = SortKind.Both;
861874
if (array.length < 2) return kind;
862875
const caseSensitiveComparer = getString
@@ -915,7 +928,7 @@ export function compact<T>(array: T[]): T[]; // eslint-disable-line @typescript-
915928
/** @internal */
916929
export function compact<T>(array: readonly T[]): readonly T[]; // eslint-disable-line @typescript-eslint/unified-signatures
917930
/** @internal */
918-
export function compact<T>(array: T[]): T[] {
931+
export function compact<T>(array: readonly T[]): readonly T[] {
919932
let result: T[] | undefined;
920933
if (array) {
921934
for (let i = 0; i < array.length; i++) {
@@ -998,11 +1011,12 @@ export function append<T>(to: T[] | undefined, value: T | undefined): T[] | unde
9981011
/** @internal */
9991012
export function append<T>(to: Push<T>, value: T | undefined): void;
10001013
/** @internal */
1001-
export function append<T>(to: T[], value: T | undefined): T[] | undefined {
1002-
if (value === undefined) return to;
1014+
export function append<T>(to: Push<T> | T[] | undefined, value: T | undefined): T[] | undefined {
1015+
// If to is Push<T>, return value is void, so safe to cast to T[].
1016+
if (value === undefined) return to as T[];
10031017
if (to === undefined) return [value];
10041018
to.push(value);
1005-
return to;
1019+
return to as T[];
10061020
}
10071021

10081022
/**
@@ -1315,7 +1329,7 @@ export function reduceLeft<T, U>(array: readonly T[] | undefined, f: (memo: U, v
13151329
/** @internal */
13161330
export function reduceLeft<T>(array: readonly T[], f: (memo: T, value: T, i: number) => T): T | undefined;
13171331
/** @internal */
1318-
export function reduceLeft<T>(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T | undefined {
1332+
export function reduceLeft<T>(array: readonly T[] | undefined, f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T | undefined {
13191333
if (array && array.length > 0) {
13201334
const size = array.length;
13211335
if (size > 0) {
@@ -1883,11 +1897,7 @@ export function isNumber(x: unknown): x is number {
18831897
}
18841898

18851899
/** @internal */
1886-
export function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined;
1887-
/** @internal */
1888-
export function tryCast<T>(value: T, test: (value: T) => boolean): T | undefined;
1889-
/** @internal */
1890-
export function tryCast<T>(value: T, test: (value: T) => boolean): T | undefined {
1900+
export function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined {
18911901
return value !== undefined && test(value) ? value : undefined;
18921902
}
18931903

src/compiler/debug.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ export namespace Debug {
275275
export function assertEachNode<T extends Node, U extends T>(nodes: readonly T[], test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[];
276276
export function assertEachNode<T extends Node, U extends T>(nodes: NodeArray<T> | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray<U> | undefined;
277277
export function assertEachNode<T extends Node, U extends T>(nodes: readonly T[] | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[] | undefined;
278-
export function assertEachNode(nodes: readonly Node[], test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction): void;
279-
export function assertEachNode(nodes: readonly Node[] | undefined, test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction) {
278+
export function assertEachNode(nodes: readonly Node[], test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void;
279+
export function assertEachNode(nodes: readonly Node[] | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) {
280280
if (shouldAssertFunction(AssertionLevel.Normal, "assertEachNode")) {
281281
assert(
282282
test === undefined || every(nodes, test),
283283
message || "Unexpected node.",
284-
() => `Node array did not pass test '${getFunctionName(test)}'.`,
284+
() => `Node array did not pass test '${getFunctionName(test!)}'.`,
285285
stackCrawlMark || assertEachNode);
286286
}
287287
}

src/compiler/diagnosticMessages.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4237,7 +4237,7 @@
42374237
"category": "Error",
42384238
"code": 5095
42394239
},
4240-
"Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'bundler' and either 'noEmit' or 'emitDeclarationOnly' is set.": {
4240+
"Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.": {
42414241
"category": "Error",
42424242
"code": 5096
42434243
},
@@ -7644,5 +7644,9 @@
76447644
"The value '{0}' cannot be used here.": {
76457645
"category": "Error",
76467646
"code": 18050
7647+
},
7648+
"Compiler option '{0}' cannot be given an empty string.": {
7649+
"category": "Error",
7650+
"code": 18051
76477651
}
76487652
}

0 commit comments

Comments
 (0)