Skip to content

Commit

Permalink
Rename test, check other CFA branch, test without strictNullChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbranch committed Sep 1, 2022
1 parent 46ce0b2 commit 3e227f7
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 40 deletions.
33 changes: 0 additions & 33 deletions tests/baselines/reference/50527.symbols

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//// [50527.ts]
//// [undefinedAsDiscriminantWithUnknown.ts]
type S =
| { type: 'string', value: string }
| { type: 'number', value: number }
Expand All @@ -10,10 +10,14 @@ declare var s: S
if (s.value !== undefined) {
s;
}
else {
s;
}


//// [50527.js]
"use strict";
//// [undefinedAsDiscriminantWithUnknown.js]
if (s.value !== undefined) {
s;
}
else {
s;
}
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))
}
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
}
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;
}
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))
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/50527.ts ===
=== tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts ===
type S =
>S : { type: 'string'; value: string; } | { type: 'number'; value: number; } | { type: 'unknown'; value: unknown; } | { value: undefined; }

Expand Down Expand Up @@ -30,4 +30,7 @@ if (s.value !== undefined) {
s;
>s : { type: "string"; value: string; } | { type: "number"; value: number; } | { type: "unknown"; value: unknown; }
}

else {
s;
>s : { type: "unknown"; value: unknown; } | { value: undefined; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @strict: true
// @strictNullChecks: true,false

type S =
| { type: 'string', value: string }
Expand All @@ -11,3 +11,6 @@ declare var s: S
if (s.value !== undefined) {
s;
}
else {
s;
}

0 comments on commit 3e227f7

Please sign in to comment.