Skip to content

Commit 64d1978

Browse files
More strictness prep (microsoft#62984)
1 parent 631affd commit 64d1978

File tree

109 files changed

+1472
-500
lines changed

Some content is hidden

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

109 files changed

+1472
-500
lines changed

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

tests/baselines/reference/controlFlowInstanceof.symbols

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,22 @@ function f4(s: Set<string> | Set<number>) {
111111

112112
// More tests
113113

114-
class A { a: string }
114+
class A { a: string = "" }
115115
>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1))
116116
>a : Symbol(A.a, Decl(controlFlowInstanceof.ts, 45, 9))
117117

118-
class B extends A { b: string }
119-
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21))
118+
class B extends A { b: string = "" }
119+
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26))
120120
>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1))
121121
>b : Symbol(B.b, Decl(controlFlowInstanceof.ts, 46, 19))
122122

123-
class C extends A { c: string }
124-
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31))
123+
class C extends A { c: string = "" }
124+
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36))
125125
>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1))
126126
>c : Symbol(C.c, Decl(controlFlowInstanceof.ts, 47, 19))
127127

128128
function foo(x: A | undefined) {
129-
>foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 47, 31))
129+
>foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 47, 36))
130130
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
131131
>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1))
132132

@@ -135,9 +135,9 @@ function foo(x: A | undefined) {
135135

136136
if (x instanceof B || x instanceof C) {
137137
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
138-
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21))
138+
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26))
139139
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
140-
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31))
140+
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36))
141141

142142
x; // B | C
143143
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
@@ -147,9 +147,9 @@ function foo(x: A | undefined) {
147147

148148
if (x instanceof B && x instanceof C) {
149149
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
150-
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21))
150+
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26))
151151
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
152-
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31))
152+
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36))
153153

154154
x; // B & C
155155
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
@@ -167,14 +167,14 @@ function foo(x: A | undefined) {
167167

168168
if (x instanceof B) {
169169
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
170-
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21))
170+
>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26))
171171

172172
x; // B
173173
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
174174

175175
if (x instanceof C) {
176176
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
177-
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31))
177+
>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36))
178178

179179
x; // B & C
180180
>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13))
@@ -200,14 +200,14 @@ function foo(x: A | undefined) {
200200
interface X {
201201
>X : Symbol(X, Decl(controlFlowInstanceof.ts, 77, 1))
202202

203-
x?: string;
203+
x?: string
204204
>x : Symbol(X.x, Decl(controlFlowInstanceof.ts, 82, 13))
205205
}
206206

207207
class Y {
208208
>Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 84, 1))
209209

210-
y: string;
210+
y: string = "";
211211
>y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9))
212212
}
213213

@@ -251,26 +251,29 @@ if (x instanceof ctor) {
251251

252252
// Repro from #27550 (based on uglify code)
253253
=== uglify.js ===
254-
/** @constructor */
254+
/**
255+
* @constructor
256+
* @param {any} val
257+
*/
255258
function AtTop(val) { this.val = val }
256259
>AtTop : Symbol(AtTop, Decl(uglify.js, 0, 0))
257-
>val : Symbol(val, Decl(uglify.js, 1, 15))
258-
>this.val : Symbol(AtTop.val, Decl(uglify.js, 1, 21))
260+
>val : Symbol(val, Decl(uglify.js, 4, 15))
261+
>this.val : Symbol(AtTop.val, Decl(uglify.js, 4, 21))
259262
>this : Symbol(AtTop, Decl(uglify.js, 0, 0))
260-
>val : Symbol(AtTop.val, Decl(uglify.js, 1, 21))
261-
>val : Symbol(val, Decl(uglify.js, 1, 15))
263+
>val : Symbol(AtTop.val, Decl(uglify.js, 4, 21))
264+
>val : Symbol(val, Decl(uglify.js, 4, 15))
262265

263266
/** @type {*} */
264267
var v = 1;
265-
>v : Symbol(v, Decl(uglify.js, 3, 3))
268+
>v : Symbol(v, Decl(uglify.js, 6, 3))
266269

267270
if (v instanceof AtTop) {
268-
>v : Symbol(v, Decl(uglify.js, 3, 3))
271+
>v : Symbol(v, Decl(uglify.js, 6, 3))
269272
>AtTop : Symbol(AtTop, Decl(uglify.js, 0, 0))
270273

271274
v.val
272-
>v.val : Symbol(AtTop.val, Decl(uglify.js, 1, 21))
273-
>v : Symbol(v, Decl(uglify.js, 3, 3))
274-
>val : Symbol(AtTop.val, Decl(uglify.js, 1, 21))
275+
>v.val : Symbol(AtTop.val, Decl(uglify.js, 4, 21))
276+
>v : Symbol(v, Decl(uglify.js, 6, 3))
277+
>val : Symbol(AtTop.val, Decl(uglify.js, 4, 21))
275278
}
276279

tests/baselines/reference/controlFlowInstanceof.types

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,27 +171,33 @@ function f4(s: Set<string> | Set<number>) {
171171

172172
// More tests
173173

174-
class A { a: string }
174+
class A { a: string = "" }
175175
>A : A
176176
> : ^
177177
>a : string
178178
> : ^^^^^^
179+
>"" : ""
180+
> : ^^
179181

180-
class B extends A { b: string }
182+
class B extends A { b: string = "" }
181183
>B : B
182184
> : ^
183185
>A : A
184186
> : ^
185187
>b : string
186188
> : ^^^^^^
189+
>"" : ""
190+
> : ^^
187191

188-
class C extends A { c: string }
192+
class C extends A { c: string = "" }
189193
>C : C
190194
> : ^
191195
>A : A
192196
> : ^
193197
>c : string
194198
> : ^^^^^^
199+
>"" : ""
200+
> : ^^
195201

196202
function foo(x: A | undefined) {
197203
>foo : (x: A | undefined) => void
@@ -310,7 +316,7 @@ function foo(x: A | undefined) {
310316
// Y is assignable to X, but not a subtype of X
311317

312318
interface X {
313-
x?: string;
319+
x?: string
314320
>x : string | undefined
315321
> : ^^^^^^^^^^^^^^^^^^
316322
}
@@ -319,9 +325,11 @@ class Y {
319325
>Y : Y
320326
> : ^
321327

322-
y: string;
328+
y: string = "";
323329
>y : string
324330
> : ^^^^^^
331+
>"" : ""
332+
> : ^^
325333
}
326334

327335
function goo(x: X) {
@@ -382,7 +390,10 @@ if (x instanceof ctor) {
382390

383391
// Repro from #27550 (based on uglify code)
384392
=== uglify.js ===
385-
/** @constructor */
393+
/**
394+
* @constructor
395+
* @param {any} val
396+
*/
386397
function AtTop(val) { this.val = val }
387398
>AtTop : typeof AtTop
388399
> : ^^^^^^^^^^^^

0 commit comments

Comments
 (0)