Skip to content

Commit 87a8d41

Browse files
committed
Accept new baselines
1 parent 82fd5a8 commit 87a8d41

4 files changed

+144
-1
lines changed

tests/baselines/reference/strictPropertyInitialization.errors.txt

+22-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitial
22
tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts(6,5): error TS2564: Property 'c' has no initializer and is not definitely assigned in the constructor.
33
tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts(48,5): error TS2564: Property 'a' has no initializer and is not definitely assigned in the constructor.
44
tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts(71,5): error TS2564: Property 'a' has no initializer and is not definitely assigned in the constructor.
5+
tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts(93,22): error TS2565: Property 'a' is used before being assigned.
6+
tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts(94,23): error TS2565: Property 'b' is used before being assigned.
57

68

7-
==== tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts (4 errors) ====
9+
==== tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts (6 errors) ====
810
// Properties with non-undefined types require initialization
911

1012
class C1 {
@@ -96,4 +98,23 @@ tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitial
9698
abstract c: number | null;
9799
abstract d?: number;
98100
}
101+
102+
// Properties with non-undefined types must be assigned before they can be accessed
103+
// within their constructor
104+
105+
class C10 {
106+
a: number;
107+
b: number;
108+
c?: number;
109+
constructor() {
110+
let x = this.a; // Error
111+
~
112+
!!! error TS2565: Property 'a' is used before being assigned.
113+
this.a = this.b; // Error
114+
~
115+
!!! error TS2565: Property 'b' is used before being assigned.
116+
this.b = x;
117+
let y = this.c;
118+
}
119+
}
99120

tests/baselines/reference/strictPropertyInitialization.js

+32
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ abstract class C9 {
8282
abstract c: number | null;
8383
abstract d?: number;
8484
}
85+
86+
// Properties with non-undefined types must be assigned before they can be accessed
87+
// within their constructor
88+
89+
class C10 {
90+
a: number;
91+
b: number;
92+
c?: number;
93+
constructor() {
94+
let x = this.a; // Error
95+
this.a = this.b; // Error
96+
this.b = x;
97+
let y = this.c;
98+
}
99+
}
85100

86101

87102
//// [strictPropertyInitialization.js]
@@ -146,6 +161,17 @@ var C9 = /** @class */ (function () {
146161
}
147162
return C9;
148163
}());
164+
// Properties with non-undefined types must be assigned before they can be accessed
165+
// within their constructor
166+
var C10 = /** @class */ (function () {
167+
function C10() {
168+
var x = this.a; // Error
169+
this.a = this.b; // Error
170+
this.b = x;
171+
var y = this.c;
172+
}
173+
return C10;
174+
}());
149175

150176

151177
//// [strictPropertyInitialization.d.ts]
@@ -195,3 +221,9 @@ declare abstract class C9 {
195221
abstract c: number | null;
196222
abstract d?: number;
197223
}
224+
declare class C10 {
225+
a: number;
226+
b: number;
227+
c?: number;
228+
constructor();
229+
}

tests/baselines/reference/strictPropertyInitialization.symbols

+44
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,47 @@ abstract class C9 {
163163
>d : Symbol(C9.d, Decl(strictPropertyInitialization.ts, 80, 30))
164164
}
165165

166+
// Properties with non-undefined types must be assigned before they can be accessed
167+
// within their constructor
168+
169+
class C10 {
170+
>C10 : Symbol(C10, Decl(strictPropertyInitialization.ts, 82, 1))
171+
172+
a: number;
173+
>a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 87, 11))
174+
175+
b: number;
176+
>b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 88, 14))
177+
178+
c?: number;
179+
>c : Symbol(C10.c, Decl(strictPropertyInitialization.ts, 89, 14))
180+
181+
constructor() {
182+
let x = this.a; // Error
183+
>x : Symbol(x, Decl(strictPropertyInitialization.ts, 92, 11))
184+
>this.a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 87, 11))
185+
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 82, 1))
186+
>a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 87, 11))
187+
188+
this.a = this.b; // Error
189+
>this.a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 87, 11))
190+
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 82, 1))
191+
>a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 87, 11))
192+
>this.b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 88, 14))
193+
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 82, 1))
194+
>b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 88, 14))
195+
196+
this.b = x;
197+
>this.b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 88, 14))
198+
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 82, 1))
199+
>b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 88, 14))
200+
>x : Symbol(x, Decl(strictPropertyInitialization.ts, 92, 11))
201+
202+
let y = this.c;
203+
>y : Symbol(y, Decl(strictPropertyInitialization.ts, 95, 11))
204+
>this.c : Symbol(C10.c, Decl(strictPropertyInitialization.ts, 89, 14))
205+
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 82, 1))
206+
>c : Symbol(C10.c, Decl(strictPropertyInitialization.ts, 89, 14))
207+
}
208+
}
209+

tests/baselines/reference/strictPropertyInitialization.types

+46
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,49 @@ abstract class C9 {
178178
>d : number | undefined
179179
}
180180

181+
// Properties with non-undefined types must be assigned before they can be accessed
182+
// within their constructor
183+
184+
class C10 {
185+
>C10 : C10
186+
187+
a: number;
188+
>a : number
189+
190+
b: number;
191+
>b : number
192+
193+
c?: number;
194+
>c : number | undefined
195+
196+
constructor() {
197+
let x = this.a; // Error
198+
>x : number
199+
>this.a : number
200+
>this : this
201+
>a : number
202+
203+
this.a = this.b; // Error
204+
>this.a = this.b : number
205+
>this.a : number
206+
>this : this
207+
>a : number
208+
>this.b : number
209+
>this : this
210+
>b : number
211+
212+
this.b = x;
213+
>this.b = x : number
214+
>this.b : number
215+
>this : this
216+
>b : number
217+
>x : number
218+
219+
let y = this.c;
220+
>y : number | undefined
221+
>this.c : number | undefined
222+
>this : this
223+
>c : number | undefined
224+
}
225+
}
226+

0 commit comments

Comments
 (0)