From 3e227f7973ddc8f6be17929dd86721b9d920bec5 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 1 Sep 2022 11:41:52 -0700 Subject: [PATCH] Rename test, check other CFA branch, test without strictNullChecks --- tests/baselines/reference/50527.symbols | 33 ----------------- ...antWithUnknown(strictnullchecks=false).js} | 12 ++++--- ...ithUnknown(strictnullchecks=false).symbols | 36 +++++++++++++++++++ ...tWithUnknown(strictnullchecks=false).types | 36 +++++++++++++++++++ ...inantWithUnknown(strictnullchecks=true).js | 23 ++++++++++++ ...WithUnknown(strictnullchecks=true).symbols | 36 +++++++++++++++++++ ...tWithUnknown(strictnullchecks=true).types} | 7 ++-- ... => undefinedAsDiscriminantWithUnknown.ts} | 5 ++- 8 files changed, 148 insertions(+), 40 deletions(-) delete mode 100644 tests/baselines/reference/50527.symbols rename tests/baselines/reference/{50527.js => undefinedAsDiscriminantWithUnknown(strictnullchecks=false).js} (64%) create mode 100644 tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).symbols create mode 100644 tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).types create mode 100644 tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).js create mode 100644 tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).symbols rename tests/baselines/reference/{50527.types => undefinedAsDiscriminantWithUnknown(strictnullchecks=true).types} (78%) rename tests/cases/compiler/{50527.ts => undefinedAsDiscriminantWithUnknown.ts} (81%) diff --git a/tests/baselines/reference/50527.symbols b/tests/baselines/reference/50527.symbols deleted file mode 100644 index 82e4f791e50aa..0000000000000 --- a/tests/baselines/reference/50527.symbols +++ /dev/null @@ -1,33 +0,0 @@ -=== tests/cases/compiler/50527.ts === -type S = ->S : Symbol(S, Decl(50527.ts, 0, 0)) - -| { type: 'string', value: string } ->type : Symbol(type, Decl(50527.ts, 1, 3)) ->value : Symbol(value, Decl(50527.ts, 1, 19)) - -| { type: 'number', value: number } ->type : Symbol(type, Decl(50527.ts, 2, 3)) ->value : Symbol(value, Decl(50527.ts, 2, 19)) - -| { type: 'unknown', value: unknown } ->type : Symbol(type, Decl(50527.ts, 3, 3)) ->value : Symbol(value, Decl(50527.ts, 3, 20)) - -| { value: undefined }; ->value : Symbol(value, Decl(50527.ts, 4, 3)) - -declare var s: S ->s : Symbol(s, Decl(50527.ts, 6, 11)) ->S : Symbol(S, Decl(50527.ts, 0, 0)) - -if (s.value !== undefined) { ->s.value : Symbol(value, Decl(50527.ts, 1, 19), Decl(50527.ts, 2, 19), Decl(50527.ts, 3, 20), Decl(50527.ts, 4, 3)) ->s : Symbol(s, Decl(50527.ts, 6, 11)) ->value : Symbol(value, Decl(50527.ts, 1, 19), Decl(50527.ts, 2, 19), Decl(50527.ts, 3, 20), Decl(50527.ts, 4, 3)) ->undefined : Symbol(undefined) - - s; ->s : Symbol(s, Decl(50527.ts, 6, 11)) -} - diff --git a/tests/baselines/reference/50527.js b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).js similarity index 64% rename from tests/baselines/reference/50527.js rename to tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).js index 464861a224d1e..c30c4d6723deb 100644 --- a/tests/baselines/reference/50527.js +++ b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).js @@ -1,4 +1,4 @@ -//// [50527.ts] +//// [undefinedAsDiscriminantWithUnknown.ts] type S = | { type: 'string', value: string } | { type: 'number', value: number } @@ -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; +} diff --git a/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).symbols b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).symbols new file mode 100644 index 0000000000000..13da7db0555c1 --- /dev/null +++ b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).symbols @@ -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)) +} diff --git a/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).types b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).types new file mode 100644 index 0000000000000..af09de9d3d839 --- /dev/null +++ b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=false).types @@ -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 +} diff --git a/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).js b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).js new file mode 100644 index 0000000000000..c30c4d6723deb --- /dev/null +++ b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).js @@ -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; +} diff --git a/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).symbols b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).symbols new file mode 100644 index 0000000000000..13da7db0555c1 --- /dev/null +++ b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).symbols @@ -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)) +} diff --git a/tests/baselines/reference/50527.types b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).types similarity index 78% rename from tests/baselines/reference/50527.types rename to tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).types index aef6d2fea0f85..69d640efe7337 100644 --- a/tests/baselines/reference/50527.types +++ b/tests/baselines/reference/undefinedAsDiscriminantWithUnknown(strictnullchecks=true).types @@ -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; } @@ -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; } +} diff --git a/tests/cases/compiler/50527.ts b/tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts similarity index 81% rename from tests/cases/compiler/50527.ts rename to tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts index 19f1753b421c2..6a6cf1007b0bb 100644 --- a/tests/cases/compiler/50527.ts +++ b/tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts @@ -1,4 +1,4 @@ -// @strict: true +// @strictNullChecks: true,false type S = | { type: 'string', value: string } @@ -11,3 +11,6 @@ declare var s: S if (s.value !== undefined) { s; } +else { + s; +} \ No newline at end of file