Skip to content

Commit 02fd11e

Browse files
committed
Accept new baselines
1 parent 54d35b9 commit 02fd11e

4 files changed

+582
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(5,5): error TS2564: Property 'b' has no initializer and is not definitely assigned in the constructor.
2+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(20,6): error TS1255: A definite assignment assertion '!' is not permitted in this context.
3+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(21,6): error TS1255: A definite assignment assertion '!' is not permitted in this context.
4+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(22,13): error TS1255: A definite assignment assertion '!' is not permitted in this context.
5+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(28,6): error TS1255: A definite assignment assertion '!' is not permitted in this context.
6+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(34,15): error TS1255: A definite assignment assertion '!' is not permitted in this context.
7+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(68,10): error TS1255: A definite assignment assertion '!' is not permitted in this context.
8+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(69,10): error TS1255: A definite assignment assertion '!' is not permitted in this context.
9+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(70,10): error TS1255: A definite assignment assertion '!' is not permitted in this context.
10+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(75,15): error TS1255: A definite assignment assertion '!' is not permitted in this context.
11+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(76,15): error TS1255: A definite assignment assertion '!' is not permitted in this context.
12+
13+
14+
==== tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts (11 errors) ====
15+
// Suppress strict property initialization check
16+
17+
class C1 {
18+
a!: number;
19+
b: string; // Error
20+
~
21+
!!! error TS2564: Property 'b' has no initializer and is not definitely assigned in the constructor.
22+
}
23+
24+
// Suppress definite assignment check in constructor
25+
26+
class C2 {
27+
a!: number;
28+
constructor() {
29+
let x = this.a;
30+
}
31+
}
32+
33+
// Definite assignment assertion requires type annotation, no initializer, no static modifier
34+
35+
class C3 {
36+
a! = 1;
37+
~
38+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
39+
b!: number = 1;
40+
~
41+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
42+
static c!: number;
43+
~
44+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
45+
}
46+
47+
// Definite assignment assertion not permitted in ambient context
48+
49+
declare class C4 {
50+
a!: number;
51+
~
52+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
53+
}
54+
55+
// Definite assignment assertion not permitted on abstract property
56+
57+
abstract class C5 {
58+
abstract a!: number;
59+
~
60+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
61+
}
62+
63+
// Suppress definite assignment check for variable
64+
65+
function f1() {
66+
let x!: number;
67+
let y = x;
68+
var a!: number;
69+
var b = a;
70+
}
71+
72+
function f2() {
73+
let x!: string | number;
74+
if (typeof x === "string") {
75+
let s: string = x;
76+
}
77+
else {
78+
let n: number = x;
79+
}
80+
}
81+
82+
function f3() {
83+
let x!: number;
84+
const g = () => {
85+
x = 1;
86+
}
87+
g();
88+
let y = x;
89+
}
90+
91+
// Definite assignment assertion requires type annotation and no initializer
92+
93+
function f4() {
94+
let a!;
95+
~
96+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
97+
let b! = 1;
98+
~
99+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
100+
let c!: number = 1;
101+
~
102+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
103+
}
104+
105+
// Definite assignment assertion not permitted in ambient context
106+
107+
declare let v1!: number;
108+
~
109+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
110+
declare var v2!: number;
111+
~
112+
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
113+
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
//// [definiteAssignmentAssertions.ts]
2+
// Suppress strict property initialization check
3+
4+
class C1 {
5+
a!: number;
6+
b: string; // Error
7+
}
8+
9+
// Suppress definite assignment check in constructor
10+
11+
class C2 {
12+
a!: number;
13+
constructor() {
14+
let x = this.a;
15+
}
16+
}
17+
18+
// Definite assignment assertion requires type annotation, no initializer, no static modifier
19+
20+
class C3 {
21+
a! = 1;
22+
b!: number = 1;
23+
static c!: number;
24+
}
25+
26+
// Definite assignment assertion not permitted in ambient context
27+
28+
declare class C4 {
29+
a!: number;
30+
}
31+
32+
// Definite assignment assertion not permitted on abstract property
33+
34+
abstract class C5 {
35+
abstract a!: number;
36+
}
37+
38+
// Suppress definite assignment check for variable
39+
40+
function f1() {
41+
let x!: number;
42+
let y = x;
43+
var a!: number;
44+
var b = a;
45+
}
46+
47+
function f2() {
48+
let x!: string | number;
49+
if (typeof x === "string") {
50+
let s: string = x;
51+
}
52+
else {
53+
let n: number = x;
54+
}
55+
}
56+
57+
function f3() {
58+
let x!: number;
59+
const g = () => {
60+
x = 1;
61+
}
62+
g();
63+
let y = x;
64+
}
65+
66+
// Definite assignment assertion requires type annotation and no initializer
67+
68+
function f4() {
69+
let a!;
70+
let b! = 1;
71+
let c!: number = 1;
72+
}
73+
74+
// Definite assignment assertion not permitted in ambient context
75+
76+
declare let v1!: number;
77+
declare var v2!: number;
78+
79+
80+
//// [definiteAssignmentAssertions.js]
81+
"use strict";
82+
// Suppress strict property initialization check
83+
var C1 = /** @class */ (function () {
84+
function C1() {
85+
}
86+
return C1;
87+
}());
88+
// Suppress definite assignment check in constructor
89+
var C2 = /** @class */ (function () {
90+
function C2() {
91+
var x = this.a;
92+
}
93+
return C2;
94+
}());
95+
// Definite assignment assertion requires type annotation, no initializer, no static modifier
96+
var C3 = /** @class */ (function () {
97+
function C3() {
98+
this.a = 1;
99+
this.b = 1;
100+
}
101+
return C3;
102+
}());
103+
// Definite assignment assertion not permitted on abstract property
104+
var C5 = /** @class */ (function () {
105+
function C5() {
106+
}
107+
return C5;
108+
}());
109+
// Suppress definite assignment check for variable
110+
function f1() {
111+
var x;
112+
var y = x;
113+
var a;
114+
var b = a;
115+
}
116+
function f2() {
117+
var x;
118+
if (typeof x === "string") {
119+
var s = x;
120+
}
121+
else {
122+
var n = x;
123+
}
124+
}
125+
function f3() {
126+
var x;
127+
var g = function () {
128+
x = 1;
129+
};
130+
g();
131+
var y = x;
132+
}
133+
// Definite assignment assertion requires type annotation and no initializer
134+
function f4() {
135+
var a;
136+
var b = 1;
137+
var c = 1;
138+
}
139+
140+
141+
//// [definiteAssignmentAssertions.d.ts]
142+
declare class C1 {
143+
a: number;
144+
b: string;
145+
}
146+
declare class C2 {
147+
a: number;
148+
constructor();
149+
}
150+
declare class C3 {
151+
a: number;
152+
b: number;
153+
static c: number;
154+
}
155+
declare class C4 {
156+
a: number;
157+
}
158+
declare abstract class C5 {
159+
abstract a: number;
160+
}
161+
declare function f1(): void;
162+
declare function f2(): void;
163+
declare function f3(): void;
164+
declare function f4(): void;
165+
declare let v1: number;
166+
declare var v2: number;

0 commit comments

Comments
 (0)