Skip to content

Commit 3e227f7

Browse files
committed
Rename test, check other CFA branch, test without strictNullChecks
1 parent 46ce0b2 commit 3e227f7

8 files changed

+148
-40
lines changed

tests/baselines/reference/50527.symbols

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//// [50527.ts]
1+
//// [undefinedAsDiscriminantWithUnknown.ts]
22
type S =
33
| { type: 'string', value: string }
44
| { type: 'number', value: number }
@@ -10,10 +10,14 @@ declare var s: S
1010
if (s.value !== undefined) {
1111
s;
1212
}
13+
else {
14+
s;
15+
}
1316

14-
15-
//// [50527.js]
16-
"use strict";
17+
//// [undefinedAsDiscriminantWithUnknown.js]
1718
if (s.value !== undefined) {
1819
s;
1920
}
21+
else {
22+
s;
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts ===
2+
type S =
3+
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0))
4+
5+
| { type: 'string', value: string }
6+
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 3))
7+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19))
8+
9+
| { type: 'number', value: number }
10+
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 3))
11+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19))
12+
13+
| { type: 'unknown', value: unknown }
14+
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 3))
15+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20))
16+
17+
| { value: undefined };
18+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3))
19+
20+
declare var s: S
21+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
22+
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0))
23+
24+
if (s.value !== undefined) {
25+
>s.value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3))
26+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
27+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3))
28+
>undefined : Symbol(undefined)
29+
30+
s;
31+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
32+
}
33+
else {
34+
s;
35+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts ===
2+
type S =
3+
>S : { type: 'string'; value: string; } | { type: 'number'; value: number; } | { type: 'unknown'; value: unknown; } | { value: undefined; }
4+
5+
| { type: 'string', value: string }
6+
>type : "string"
7+
>value : string
8+
9+
| { type: 'number', value: number }
10+
>type : "number"
11+
>value : number
12+
13+
| { type: 'unknown', value: unknown }
14+
>type : "unknown"
15+
>value : unknown
16+
17+
| { value: undefined };
18+
>value : undefined
19+
20+
declare var s: S
21+
>s : S
22+
23+
if (s.value !== undefined) {
24+
>s.value !== undefined : boolean
25+
>s.value : unknown
26+
>s : S
27+
>value : unknown
28+
>undefined : undefined
29+
30+
s;
31+
>s : S
32+
}
33+
else {
34+
s;
35+
>s : S
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [undefinedAsDiscriminantWithUnknown.ts]
2+
type S =
3+
| { type: 'string', value: string }
4+
| { type: 'number', value: number }
5+
| { type: 'unknown', value: unknown }
6+
| { value: undefined };
7+
8+
declare var s: S
9+
10+
if (s.value !== undefined) {
11+
s;
12+
}
13+
else {
14+
s;
15+
}
16+
17+
//// [undefinedAsDiscriminantWithUnknown.js]
18+
if (s.value !== undefined) {
19+
s;
20+
}
21+
else {
22+
s;
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts ===
2+
type S =
3+
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0))
4+
5+
| { type: 'string', value: string }
6+
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 3))
7+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19))
8+
9+
| { type: 'number', value: number }
10+
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 3))
11+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19))
12+
13+
| { type: 'unknown', value: unknown }
14+
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 3))
15+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20))
16+
17+
| { value: undefined };
18+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3))
19+
20+
declare var s: S
21+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
22+
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0))
23+
24+
if (s.value !== undefined) {
25+
>s.value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3))
26+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
27+
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3))
28+
>undefined : Symbol(undefined)
29+
30+
s;
31+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
32+
}
33+
else {
34+
s;
35+
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11))
36+
}

tests/baselines/reference/50527.types renamed to tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).types

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
=== tests/cases/compiler/50527.ts ===
1+
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts ===
22
type S =
33
>S : { type: 'string'; value: string; } | { type: 'number'; value: number; } | { type: 'unknown'; value: unknown; } | { value: undefined; }
44

@@ -30,4 +30,7 @@ if (s.value !== undefined) {
3030
s;
3131
>s : { type: "string"; value: string; } | { type: "number"; value: number; } | { type: "unknown"; value: unknown; }
3232
}
33-
33+
else {
34+
s;
35+
>s : { type: "unknown"; value: unknown; } | { value: undefined; }
36+
}

tests/cases/compiler/50527.ts renamed to tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @strict: true
1+
// @strictNullChecks: true,false
22

33
type S =
44
| { type: 'string', value: string }
@@ -11,3 +11,6 @@ declare var s: S
1111
if (s.value !== undefined) {
1212
s;
1313
}
14+
else {
15+
s;
16+
}

0 commit comments

Comments
 (0)