diff --git a/tests/baselines/reference/unknownType2.js b/tests/baselines/reference/unknownType2.js index 59a63b1bd94..a1305e823b8 100644 --- a/tests/baselines/reference/unknownType2.js +++ b/tests/baselines/reference/unknownType2.js @@ -13,7 +13,7 @@ if (u === 5) { const y = u.toString(10); } -if (u === true || u === false) { +if (u === true || u === false) { const someBool: boolean = u; } @@ -25,29 +25,30 @@ if (u === null) { const someNull: null = u; } -if(u === symb) { +if (u === symb) { const symbolAlias: typeof symb = u; } if (!(u === 42)) { - u // u should still be `unknown` here + type A = isTrue> + } if (u !== 42) { - type A = isTrue> -} - -if (u == 42) { type B = isTrue> } -if (u == true) { +if (u == 42) { type C = isTrue> } -if (u == Object) { +if (u == true) { type D = isTrue> } + +if (u == Object) { + type E = isTrue> +} //// [unknownType2.js] @@ -70,7 +71,6 @@ if (u === symb) { var symbolAlias = u; } if (!(u === 42)) { - u; // u should still be `unknown` here } if (u !== 42) { } diff --git a/tests/baselines/reference/unknownType2.symbols b/tests/baselines/reference/unknownType2.symbols index 0cd1ded5d83..8c3f8a6e04a 100644 --- a/tests/baselines/reference/unknownType2.symbols +++ b/tests/baselines/reference/unknownType2.symbols @@ -38,7 +38,7 @@ if (u === 5) { >toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) } -if (u === true || u === false) { +if (u === true || u === false) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) @@ -64,7 +64,7 @@ if (u === null) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) } -if(u === symb) { +if (u === symb) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) >symb : Symbol(symb, Decl(unknownType2.ts, 8, 13)) @@ -77,15 +77,19 @@ if(u === symb) { if (!(u === 42)) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) - u // u should still be `unknown` here + type A = isTrue> +>A : Symbol(A, Decl(unknownType2.ts, 30, 18)) +>isTrue : Symbol(isTrue, Decl(unknownType2.ts, 0, 53)) +>isUnknown : Symbol(isUnknown, Decl(unknownType2.ts, 0, 0)) >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) + } if (u !== 42) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) - type A = isTrue> ->A : Symbol(A, Decl(unknownType2.ts, 34, 15)) + type B = isTrue> +>B : Symbol(B, Decl(unknownType2.ts, 35, 15)) >isTrue : Symbol(isTrue, Decl(unknownType2.ts, 0, 53)) >isUnknown : Symbol(isUnknown, Decl(unknownType2.ts, 0, 0)) >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) @@ -94,8 +98,8 @@ if (u !== 42) { if (u == 42) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) - type B = isTrue> ->B : Symbol(B, Decl(unknownType2.ts, 38, 14)) + type C = isTrue> +>C : Symbol(C, Decl(unknownType2.ts, 39, 14)) >isTrue : Symbol(isTrue, Decl(unknownType2.ts, 0, 53)) >isUnknown : Symbol(isUnknown, Decl(unknownType2.ts, 0, 0)) >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) @@ -104,8 +108,8 @@ if (u == 42) { if (u == true) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) - type C = isTrue> ->C : Symbol(C, Decl(unknownType2.ts, 42, 16)) + type D = isTrue> +>D : Symbol(D, Decl(unknownType2.ts, 43, 16)) >isTrue : Symbol(isTrue, Decl(unknownType2.ts, 0, 53)) >isUnknown : Symbol(isUnknown, Decl(unknownType2.ts, 0, 0)) >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) @@ -115,8 +119,8 @@ if (u == Object) { >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) >Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - type D = isTrue> ->D : Symbol(D, Decl(unknownType2.ts, 46, 18)) + type E = isTrue> +>E : Symbol(E, Decl(unknownType2.ts, 47, 18)) >isTrue : Symbol(isTrue, Decl(unknownType2.ts, 0, 53)) >isUnknown : Symbol(isUnknown, Decl(unknownType2.ts, 0, 0)) >u : Symbol(u, Decl(unknownType2.ts, 6, 5)) diff --git a/tests/baselines/reference/unknownType2.types b/tests/baselines/reference/unknownType2.types index 41743b0c499..6f9195b7994 100644 --- a/tests/baselines/reference/unknownType2.types +++ b/tests/baselines/reference/unknownType2.types @@ -49,7 +49,7 @@ if (u === 5) { >10 : 10 } -if (u === true || u === false) { +if (u === true || u === false) { >u === true || u === false : boolean >u === true : boolean >u : unknown @@ -84,7 +84,7 @@ if (u === null) { >u : null } -if(u === symb) { +if (u === symb) { >u === symb : boolean >u : unknown >symb : unique symbol @@ -102,23 +102,15 @@ if (!(u === 42)) { >u : unknown >42 : 42 - u // u should still be `unknown` here + type A = isTrue> +>A : true >u : unknown + } if (u !== 42) { >u !== 42 : boolean >u : unknown ->42 : 42 - - type A = isTrue> ->A : true ->u : unknown -} - -if (u == 42) { ->u == 42 : boolean ->u : unknown >42 : 42 type B = isTrue> @@ -126,13 +118,23 @@ if (u == 42) { >u : unknown } +if (u == 42) { +>u == 42 : boolean +>u : unknown +>42 : 42 + + type C = isTrue> +>C : true +>u : unknown +} + if (u == true) { >u == true : boolean >u : unknown >true : true - type C = isTrue> ->C : true + type D = isTrue> +>D : true >u : unknown } @@ -141,8 +143,8 @@ if (u == Object) { >u : unknown >Object : ObjectConstructor - type D = isTrue> ->D : true + type E = isTrue> +>E : true >u : unknown } diff --git a/tests/cases/conformance/types/unknown/unknownType2.ts b/tests/cases/conformance/types/unknown/unknownType2.ts index b644700044c..c0da9a4e782 100644 --- a/tests/cases/conformance/types/unknown/unknownType2.ts +++ b/tests/cases/conformance/types/unknown/unknownType2.ts @@ -14,7 +14,7 @@ if (u === 5) { const y = u.toString(10); } -if (u === true || u === false) { +if (u === true || u === false) { const someBool: boolean = u; } @@ -26,26 +26,27 @@ if (u === null) { const someNull: null = u; } -if(u === symb) { +if (u === symb) { const symbolAlias: typeof symb = u; } if (!(u === 42)) { - u // u should still be `unknown` here + type A = isTrue> + } if (u !== 42) { - type A = isTrue> -} - -if (u == 42) { type B = isTrue> } -if (u == true) { +if (u == 42) { type C = isTrue> } -if (u == Object) { +if (u == true) { type D = isTrue> } + +if (u == Object) { + type E = isTrue> +}