-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Component commits: 46ce0b2 Use bidirectional comparability (aka comparability) in narrowing 3e227f7 Rename test, check other CFA branch, test without strictNullChecks Co-authored-by: Andrew Branch <[email protected]>
- Loading branch information
1 parent
502a908
commit 10870b4
Showing
8 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// [undefinedAsDiscriminantWithUnknown.ts] | ||
type S = | ||
| { type: 'string', value: string } | ||
| { type: 'number', value: number } | ||
| { type: 'unknown', value: unknown } | ||
| { value: undefined }; | ||
|
||
declare var s: S | ||
|
||
if (s.value !== undefined) { | ||
s; | ||
} | ||
else { | ||
s; | ||
} | ||
|
||
//// [undefinedAsDiscriminantWithUnknown.js] | ||
if (s.value !== undefined) { | ||
s; | ||
} | ||
else { | ||
s; | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts === | ||
type S = | ||
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0)) | ||
|
||
| { type: 'string', value: string } | ||
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 3)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19)) | ||
|
||
| { type: 'number', value: number } | ||
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 3)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19)) | ||
|
||
| { type: 'unknown', value: unknown } | ||
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 3)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20)) | ||
|
||
| { value: undefined }; | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3)) | ||
|
||
declare var s: S | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0)) | ||
|
||
if (s.value !== undefined) { | ||
>s.value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3)) | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3)) | ||
>undefined : Symbol(undefined) | ||
|
||
s; | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
} | ||
else { | ||
s; | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts === | ||
type S = | ||
>S : { type: 'string'; value: string; } | { type: 'number'; value: number; } | { type: 'unknown'; value: unknown; } | { value: undefined; } | ||
|
||
| { type: 'string', value: string } | ||
>type : "string" | ||
>value : string | ||
|
||
| { type: 'number', value: number } | ||
>type : "number" | ||
>value : number | ||
|
||
| { type: 'unknown', value: unknown } | ||
>type : "unknown" | ||
>value : unknown | ||
|
||
| { value: undefined }; | ||
>value : undefined | ||
|
||
declare var s: S | ||
>s : S | ||
|
||
if (s.value !== undefined) { | ||
>s.value !== undefined : boolean | ||
>s.value : unknown | ||
>s : S | ||
>value : unknown | ||
>undefined : undefined | ||
|
||
s; | ||
>s : S | ||
} | ||
else { | ||
s; | ||
>s : S | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// [undefinedAsDiscriminantWithUnknown.ts] | ||
type S = | ||
| { type: 'string', value: string } | ||
| { type: 'number', value: number } | ||
| { type: 'unknown', value: unknown } | ||
| { value: undefined }; | ||
|
||
declare var s: S | ||
|
||
if (s.value !== undefined) { | ||
s; | ||
} | ||
else { | ||
s; | ||
} | ||
|
||
//// [undefinedAsDiscriminantWithUnknown.js] | ||
if (s.value !== undefined) { | ||
s; | ||
} | ||
else { | ||
s; | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts === | ||
type S = | ||
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0)) | ||
|
||
| { type: 'string', value: string } | ||
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 3)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19)) | ||
|
||
| { type: 'number', value: number } | ||
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 3)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19)) | ||
|
||
| { type: 'unknown', value: unknown } | ||
>type : Symbol(type, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 3)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20)) | ||
|
||
| { value: undefined }; | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3)) | ||
|
||
declare var s: S | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
>S : Symbol(S, Decl(undefinedAsDiscriminantWithUnknown.ts, 0, 0)) | ||
|
||
if (s.value !== undefined) { | ||
>s.value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3)) | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
>value : Symbol(value, Decl(undefinedAsDiscriminantWithUnknown.ts, 1, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 2, 19), Decl(undefinedAsDiscriminantWithUnknown.ts, 3, 20), Decl(undefinedAsDiscriminantWithUnknown.ts, 4, 3)) | ||
>undefined : Symbol(undefined) | ||
|
||
s; | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
} | ||
else { | ||
s; | ||
>s : Symbol(s, Decl(undefinedAsDiscriminantWithUnknown.ts, 6, 11)) | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts === | ||
type S = | ||
>S : { type: 'string'; value: string; } | { type: 'number'; value: number; } | { type: 'unknown'; value: unknown; } | { value: undefined; } | ||
|
||
| { type: 'string', value: string } | ||
>type : "string" | ||
>value : string | ||
|
||
| { type: 'number', value: number } | ||
>type : "number" | ||
>value : number | ||
|
||
| { type: 'unknown', value: unknown } | ||
>type : "unknown" | ||
>value : unknown | ||
|
||
| { value: undefined }; | ||
>value : undefined | ||
|
||
declare var s: S | ||
>s : S | ||
|
||
if (s.value !== undefined) { | ||
>s.value !== undefined : boolean | ||
>s.value : unknown | ||
>s : S | ||
>value : unknown | ||
>undefined : undefined | ||
|
||
s; | ||
>s : { type: "string"; value: string; } | { type: "number"; value: number; } | { type: "unknown"; value: unknown; } | ||
} | ||
else { | ||
s; | ||
>s : { type: "unknown"; value: unknown; } | { value: undefined; } | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @strictNullChecks: true,false | ||
|
||
type S = | ||
| { type: 'string', value: string } | ||
| { type: 'number', value: number } | ||
| { type: 'unknown', value: unknown } | ||
| { value: undefined }; | ||
|
||
declare var s: S | ||
|
||
if (s.value !== undefined) { | ||
s; | ||
} | ||
else { | ||
s; | ||
} |