Skip to content

Commit 69bcbc4

Browse files
authored
Merge branch 'main' into fix/enum-computed-keys
2 parents 74055e7 + a9f534f commit 69bcbc4

File tree

660 files changed

+14129
-3815
lines changed

Some content is hidden

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

660 files changed

+14129
-3815
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24893,7 +24893,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2489324893

2489424894
function discriminateTypeByDiscriminableItems(target: UnionType, discriminators: (readonly [() => Type, __String])[], related: (source: Type, target: Type) => boolean | Ternary) {
2489524895
const types = target.types;
24896-
const include: Ternary[] = types.map(t => t.flags & TypeFlags.Primitive ? Ternary.False : Ternary.True);
24896+
const include: Ternary[] = types.map(t => t.flags & TypeFlags.Primitive || getReducedType(t).flags & TypeFlags.Never ? Ternary.False : Ternary.True);
2489724897
for (const [getDiscriminatingType, propertyName] of discriminators) {
2489824898
// If the remaining target types include at least one with a matching discriminant, eliminate those that
2489924899
// have non-matching discriminants. This ensures that we ignore erroneous discriminators and gradually

src/compiler/program.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4484,7 +4484,7 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
44844484
createDeprecatedDiagnostic("charset");
44854485
}
44864486
if (options.out) {
4487-
createDeprecatedDiagnostic("out", /*value*/ undefined, "outFile");
4487+
createDeprecatedDiagnostic("out");
44884488
}
44894489
if (options.importsNotUsedAsValues) {
44904490
createDeprecatedDiagnostic("importsNotUsedAsValues", /*value*/ undefined, "verbatimModuleSyntax");
@@ -4510,6 +4510,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
45104510
if (options.allowSyntheticDefaultImports === false) {
45114511
createDeprecatedDiagnostic("allowSyntheticDefaultImports", "false", /*useInstead*/ undefined, /*related*/ undefined);
45124512
}
4513+
if (options.outFile) {
4514+
createDeprecatedDiagnostic("outFile");
4515+
}
45134516
if (options.module === ModuleKind.None || options.module === ModuleKind.AMD || options.module === ModuleKind.UMD || options.module === ModuleKind.System) {
45144517
createDeprecatedDiagnostic("module", ModuleKind[options.module], /*useInstead*/ undefined, /*related*/ undefined);
45154518
}

src/harness/harnessUtils.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ export function evalFile(fileContents: string, fileName: string, nodeContext?: a
1515
}
1616
}
1717

18-
/** Splits the given string on \r\n, or on only \n if that fails, or on only \r if *that* fails. */
18+
const newlineRegex = /\r?\n/;
19+
20+
/**
21+
* Splits the given string on the two reasonable line terminators (\r\n or \n).
22+
* Does NOT split on `\r` alone, \u2028, or \u2029.
23+
*/
1924
export function splitContentByNewlines(content: string): string[] {
2025
// Split up the input file by line
21-
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
22-
// we have to use string-based splitting instead and try to figure out the delimiting chars
23-
let lines = content.split("\r\n");
24-
if (lines.length === 1) {
25-
lines = content.split("\n");
26-
27-
if (lines.length === 1) {
28-
lines = content.split("\r");
29-
}
30-
}
26+
const lines = content.split(newlineRegex);
3127
return lines;
3228
}
3329

tests/baselines/reference/2dArrays.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ class Cell {
55
}
66

77
class Ship {
8-
isSunk: boolean;
8+
isSunk: boolean = false;
99
}
1010

1111
class Board {
12-
ships: Ship[];
13-
cells: Cell[];
12+
ships: Ship[] = [];
13+
cells: Cell[] = [];
1414

1515
private allShipsSunk() {
1616
return this.ships.every(function (val) { return val.isSunk; });
@@ -25,11 +25,14 @@ var Cell = /** @class */ (function () {
2525
}());
2626
var Ship = /** @class */ (function () {
2727
function Ship() {
28+
this.isSunk = false;
2829
}
2930
return Ship;
3031
}());
3132
var Board = /** @class */ (function () {
3233
function Board() {
34+
this.ships = [];
35+
this.cells = [];
3336
}
3437
Board.prototype.allShipsSunk = function () {
3538
return this.ships.every(function (val) { return val.isSunk; });

tests/baselines/reference/2dArrays.symbols

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ class Cell {
88
class Ship {
99
>Ship : Symbol(Ship, Decl(2dArrays.ts, 1, 1))
1010

11-
isSunk: boolean;
11+
isSunk: boolean = false;
1212
>isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
1313
}
1414

1515
class Board {
1616
>Board : Symbol(Board, Decl(2dArrays.ts, 5, 1))
1717

18-
ships: Ship[];
18+
ships: Ship[] = [];
1919
>ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13))
2020
>Ship : Symbol(Ship, Decl(2dArrays.ts, 1, 1))
2121

22-
cells: Cell[];
23-
>cells : Symbol(Board.cells, Decl(2dArrays.ts, 8, 18))
22+
cells: Cell[] = [];
23+
>cells : Symbol(Board.cells, Decl(2dArrays.ts, 8, 23))
2424
>Cell : Symbol(Cell, Decl(2dArrays.ts, 0, 0))
2525

2626
private allShipsSunk() {
27-
>allShipsSunk : Symbol(Board.allShipsSunk, Decl(2dArrays.ts, 9, 18))
27+
>allShipsSunk : Symbol(Board.allShipsSunk, Decl(2dArrays.ts, 9, 23))
2828

2929
return this.ships.every(function (val) { return val.isSunk; });
3030
>this.ships.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

tests/baselines/reference/2dArrays.types

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,28 @@ class Ship {
1010
>Ship : Ship
1111
> : ^^^^
1212

13-
isSunk: boolean;
13+
isSunk: boolean = false;
1414
>isSunk : boolean
1515
> : ^^^^^^^
16+
>false : false
17+
> : ^^^^^
1618
}
1719

1820
class Board {
1921
>Board : Board
2022
> : ^^^^^
2123

22-
ships: Ship[];
24+
ships: Ship[] = [];
2325
>ships : Ship[]
2426
> : ^^^^^^
27+
>[] : undefined[]
28+
> : ^^^^^^^^^^^
2529

26-
cells: Cell[];
30+
cells: Cell[] = [];
2731
>cells : Cell[]
2832
> : ^^^^^^
33+
>[] : undefined[]
34+
> : ^^^^^^^^^^^
2935

3036
private allShipsSunk() {
3137
>allShipsSunk : () => boolean

tests/baselines/reference/APISample_Watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function watchMain() {
5151
// You can technically override any given hook on the host, though you probably don't need to.
5252
// Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all.
5353
const origCreateProgram = host.createProgram;
54-
host.createProgram = (rootNames: ReadonlyArray<string>, options, host, oldProgram) => {
54+
host.createProgram = (rootNames: ReadonlyArray<string> | undefined, options, host, oldProgram) => {
5555
console.log("** We're about to create the program! **");
5656
return origCreateProgram(rootNames, options, host, oldProgram);
5757
}

tests/baselines/reference/abstractPropertyBasics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class C extends B {
1919
set prop(v) { }
2020
raw = "edge";
2121
readonly ro = "readonly please";
22-
readonlyProp: string; // don't have to give a value, in fact
22+
readonlyProp!: string;
2323
m() { }
2424
}
2525

tests/baselines/reference/abstractPropertyBasics.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class C extends B {
5353
readonly ro = "readonly please";
5454
>ro : Symbol(C.ro, Decl(abstractPropertyBasics.ts, 16, 17))
5555

56-
readonlyProp: string; // don't have to give a value, in fact
56+
readonlyProp!: string;
5757
>readonlyProp : Symbol(C.readonlyProp, Decl(abstractPropertyBasics.ts, 17, 36))
5858

5959
m() { }
60-
>m : Symbol(C.m, Decl(abstractPropertyBasics.ts, 18, 25))
60+
>m : Symbol(C.m, Decl(abstractPropertyBasics.ts, 18, 26))
6161
}

tests/baselines/reference/abstractPropertyBasics.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class C extends B {
7474
>"readonly please" : "readonly please"
7575
> : ^^^^^^^^^^^^^^^^^
7676

77-
readonlyProp: string; // don't have to give a value, in fact
77+
readonlyProp!: string;
7878
>readonlyProp : string
7979
> : ^^^^^^
8080

0 commit comments

Comments
 (0)