Accept new baselines

This commit is contained in:
Anders Hejlsberg
2016-07-18 13:16:45 -07:00
parent c48cd4a93b
commit 32f4cbb58a
20 changed files with 151 additions and 144 deletions

View File

@@ -24,9 +24,9 @@ foo(5);
foo(E.A);
>foo(E.A) : void
>foo : <T extends number>(x: T) => void
>E.A : E.A
>E.A : E
>E : typeof E
>A : E.A
>A : E
class A { a }
>A : A

View File

@@ -1,11 +1,11 @@
=== tests/cases/conformance/types/literal/booleanLiteralTypes1.ts ===
type A1 = true | false;
>A1 : true | false
>A1 : boolean
>true : true
>false : false
type A2 = false | true;
>A2 : false | true
>A2 : boolean
>false : false
>true : true
@@ -13,67 +13,67 @@ function f1() {
>f1 : () => void
var a: A1;
>a : true | false
>A1 : true | false
>a : boolean
>A1 : boolean
var a: A2;
>a : true | false
>A2 : false | true
>a : boolean
>A2 : boolean
var a: true | false;
>a : true | false
>a : boolean
>true : true
>false : false
var a: false | true;
>a : true | false
>a : boolean
>false : false
>true : true
}
function f2(a: true | false, b: boolean) {
>f2 : (a: true | false, b: boolean) => void
>a : true | false
>f2 : (a: boolean, b: boolean) => void
>a : boolean
>true : true
>false : false
>b : boolean
a = b;
>a = b : boolean
>a : true | false
>a : boolean
>b : boolean
b = a;
>b = a : true | false
>b = a : boolean
>b : boolean
>a : true | false
>a : boolean
}
function f3(a: true | false, b: true | false) {
>f3 : (a: true | false, b: true | false) => void
>a : true | false
>f3 : (a: boolean, b: boolean) => void
>a : boolean
>true : true
>false : false
>b : true | false
>b : boolean
>true : true
>false : false
var x = a || b;
>x : true | false
>a || b : true | false
>a : true | false
>b : true | false
>x : boolean
>a || b : boolean
>a : boolean
>b : boolean
var x = a && b;
>x : true | false
>a && b : true | false
>a : true | false
>b : true | false
>x : boolean
>a && b : boolean
>a : boolean
>b : boolean
var x = !a;
>x : true | false
>!a : true | false
>a : true | false
>x : boolean
>!a : boolean
>a : boolean
}
function f4(t: true, f: false) {
@@ -96,8 +96,8 @@ function f4(t: true, f: false) {
>t : true
var x3 = t || f;
>x3 : true | false
>t || f : true | false
>x3 : boolean
>t || f : boolean
>t : true
>f : false
@@ -166,13 +166,13 @@ function assertNever(x: never): never {
}
function f10(x: true | false) {
>f10 : (x: true | false) => string
>x : true | false
>f10 : (x: boolean) => string
>x : boolean
>true : true
>false : false
switch (x) {
>x : true | false
>x : boolean
case true: return "true";
>true : true
@@ -185,13 +185,13 @@ function f10(x: true | false) {
}
function f11(x: true | false) {
>f11 : (x: true | false) => string
>x : true | false
>f11 : (x: boolean) => string
>x : boolean
>true : true
>false : false
switch (x) {
>x : true | false
>x : boolean
case true: return "true";
>true : true
@@ -208,32 +208,32 @@ function f11(x: true | false) {
}
function f12(x: true | false) {
>f12 : (x: true | false) => void
>x : true | false
>f12 : (x: boolean) => void
>x : boolean
>true : true
>false : false
if (x) {
>x : true | false
>x : boolean
x;
>x : true
}
else {
x;
>x : true | false
>x : boolean
}
}
function f13(x: true | false) {
>f13 : (x: true | false) => void
>x : true | false
>f13 : (x: boolean) => void
>x : boolean
>true : true
>false : false
if (x === true) {
>x === true : boolean
>x : true | false
>x : boolean
>true : true
x;
@@ -264,9 +264,9 @@ function f20(x: Item) {
>Item : { kind: true; a: string; } | { kind: false; b: string; }
switch (x.kind) {
>x.kind : true | false
>x.kind : boolean
>x : { kind: true; a: string; } | { kind: false; b: string; }
>kind : true | false
>kind : boolean
case true: return x.a;
>true : true
@@ -288,9 +288,9 @@ function f21(x: Item) {
>Item : { kind: true; a: string; } | { kind: false; b: string; }
switch (x.kind) {
>x.kind : true | false
>x.kind : boolean
>x : { kind: true; a: string; } | { kind: false; b: string; }
>kind : true | false
>kind : boolean
case true: return x.a;
>true : true

View File

@@ -1,12 +1,12 @@
=== tests/cases/conformance/types/literal/booleanLiteralTypes2.ts ===
type A1 = true | false;
>A1 : true | false
>A1 : boolean
>true : true
>false : false
type A2 = false | true;
>A2 : false | true
>A2 : boolean
>false : false
>true : true
@@ -14,67 +14,67 @@ function f1() {
>f1 : () => void
var a: A1;
>a : true | false
>A1 : true | false
>a : boolean
>A1 : boolean
var a: A2;
>a : true | false
>A2 : false | true
>a : boolean
>A2 : boolean
var a: true | false;
>a : true | false
>a : boolean
>true : true
>false : false
var a: false | true;
>a : true | false
>a : boolean
>false : false
>true : true
}
function f2(a: true | false, b: boolean) {
>f2 : (a: true | false, b: boolean) => void
>a : true | false
>f2 : (a: boolean, b: boolean) => void
>a : boolean
>true : true
>false : false
>b : boolean
a = b;
>a = b : boolean
>a : true | false
>a : boolean
>b : boolean
b = a;
>b = a : true | false
>b = a : boolean
>b : boolean
>a : true | false
>a : boolean
}
function f3(a: true | false, b: true | false) {
>f3 : (a: true | false, b: true | false) => void
>a : true | false
>f3 : (a: boolean, b: boolean) => void
>a : boolean
>true : true
>false : false
>b : true | false
>b : boolean
>true : true
>false : false
var x = a || b;
>x : true | false
>a || b : true | false
>a : true | false
>b : true | false
>x : boolean
>a || b : boolean
>a : boolean
>b : boolean
var x = a && b;
>x : true | false
>a && b : true | false
>a : true | false
>b : true | false
>x : boolean
>a && b : boolean
>a : boolean
>b : boolean
var x = !a;
>x : true | false
>!a : true | false
>a : false | true
>x : boolean
>!a : boolean
>a : boolean
}
function f4(t: true, f: false) {
@@ -167,13 +167,13 @@ function assertNever(x: never): never {
}
function f10(x: true | false) {
>f10 : (x: true | false) => string
>x : true | false
>f10 : (x: boolean) => string
>x : boolean
>true : true
>false : false
switch (x) {
>x : true | false
>x : boolean
case true: return "true";
>true : true
@@ -186,13 +186,13 @@ function f10(x: true | false) {
}
function f11(x: true | false) {
>f11 : (x: true | false) => string
>x : true | false
>f11 : (x: boolean) => string
>x : boolean
>true : true
>false : false
switch (x) {
>x : true | false
>x : boolean
case true: return "true";
>true : true
@@ -209,13 +209,13 @@ function f11(x: true | false) {
}
function f12(x: true | false) {
>f12 : (x: true | false) => void
>x : true | false
>f12 : (x: boolean) => void
>x : boolean
>true : true
>false : false
if (x) {
>x : true | false
>x : boolean
x;
>x : true
@@ -227,14 +227,14 @@ function f12(x: true | false) {
}
function f13(x: true | false) {
>f13 : (x: true | false) => void
>x : true | false
>f13 : (x: boolean) => void
>x : boolean
>true : true
>false : false
if (x === true) {
>x === true : boolean
>x : true | false
>x : boolean
>true : true
x;
@@ -265,9 +265,9 @@ function f20(x: Item) {
>Item : { kind: true; a: string; } | { kind: false; b: string; }
switch (x.kind) {
>x.kind : true | false
>x.kind : boolean
>x : { kind: true; a: string; } | { kind: false; b: string; }
>kind : true | false
>kind : boolean
case true: return x.a;
>true : true
@@ -289,9 +289,9 @@ function f21(x: Item) {
>Item : { kind: true; a: string; } | { kind: false; b: string; }
switch (x.kind) {
>x.kind : true | false
>x.kind : boolean
>x : { kind: true; a: string; } | { kind: false; b: string; }
>kind : true | false
>kind : boolean
case true: return x.a;
>true : true

View File

@@ -12,12 +12,12 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(32,18): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,26): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,28): error TS2304: Cannot find name 'bfs'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(36,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(36,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(39,17): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,28): error TS2304: Cannot find name 'bfs'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,41): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,45): error TS1002: Unterminated string literal.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(42,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(42,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(48,17): error TS2304: Cannot find name 'console'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(50,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(54,13): error TS2304: Cannot find name 'console'.
@@ -38,6 +38,9 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(160,30): error T
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(160,31): error TS2304: Cannot find name 'Property'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(167,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(181,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(182,13): error TS2322: Type 'boolean' is not assignable to type 'true | number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(184,13): error TS2322: Type 'boolean' is not assignable to type 'true | number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(192,13): error TS2322: Type 'boolean' is not assignable to type 'true | number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(206,28): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(214,16): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(219,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
@@ -83,7 +86,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,55): error T
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS1128: Declaration or statement expected.
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (83 errors) ====
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (86 errors) ====
declare module "fs" {
export class File {
@@ -152,7 +155,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS
!!! error TS2304: Cannot find name 'bfs'.
if (retValue != 0) {
~~~~~~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'.
!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'.
return 1 &&
}
@@ -168,7 +171,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS
!!! error TS1002: Unterminated string literal.
if (retValue != 0) {
~~~~~~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'.
!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'.
return 1;
}
@@ -349,8 +352,12 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS
~~~~~~~~~~~~
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
b = !b;/*!*/
~
!!! error TS2322: Type 'boolean' is not assignable to type 'true | number'.
i = ~i;/*~i*/
b = i < (i - 1) && (i + 1) > i;/*< && >*/
~
!!! error TS2322: Type 'boolean' is not assignable to type 'true | number'.
var f = true ? 1 : 0;/*? :*/ // YES :
i++;/*++*/
i--;/*--*/
@@ -359,6 +366,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS
i = i >> 5;/*>>*/
var j = i;
b = i == j && i != j && i <= j && i >= j;/*= == && != <= >=*/
~
!!! error TS2322: Type 'boolean' is not assignable to type 'true | number'.
i += <number>5.0;/*+=*/
i -= i;/*-=*/
i *= i;/**=*/

View File

@@ -2,7 +2,7 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS232
Types of property 'pop' are incompatible.
Type '() => number | string | boolean' is not assignable to type '() => number | string'.
Type 'number | string | boolean' is not assignable to type 'number | string'.
Type 'boolean' is not assignable to type 'number | string'.
Type 'true' is not assignable to type 'number | string'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
Types of property '0' are incompatible.
@@ -32,7 +32,7 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23
!!! error TS2322: Types of property 'pop' are incompatible.
!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number | string'.
!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number | string'.
!!! error TS2322: Type 'boolean' is not assignable to type 'number | string'.
!!! error TS2322: Type 'true' is not assignable to type 'number | string'.
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];

View File

@@ -25,7 +25,7 @@ x = "";
>"" : string
cond || (x = 0);
>cond || (x = 0) : boolean | number
>cond || (x = 0) : true | number
>cond : boolean
>(x = 0) : number
>x = 0 : number

View File

@@ -20,7 +20,7 @@ if (x /* RegExp */, (x = true)) {
>true : boolean
x; // boolean
>x : boolean
>x : true
x = "";
>x = "" : string

View File

@@ -8,10 +8,10 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(46,17): error
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
Type 'boolean' is not assignable to type 'string | number'.
Type 'true' is not assignable to type 'string | number'.
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
Type 'boolean' is not assignable to type 'string | number'.
Type 'true' is not assignable to type 'string | number'.
==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (8 errors) ====
@@ -108,7 +108,7 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error
!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
~
!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
!!! error TS2345: Type 'true' is not assignable to type 'string | number'.
x = y + 1;
x;
}
@@ -124,7 +124,7 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error
!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
~
!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
!!! error TS2345: Type 'true' is not assignable to type 'string | number'.
x = y + 1;
x;
}

View File

@@ -148,7 +148,7 @@ function f() {
>cond : boolean
if (cond) {
>cond : boolean
>cond : true
x = 42;
>x = 42 : number
@@ -158,7 +158,7 @@ function f() {
break;
}
if (cond) {
>cond : boolean
>cond : true
x = true;
>x = true : boolean

View File

@@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup
Types of property 'pop' are incompatible.
Type '() => string | number | boolean' is not assignable to type '() => string | number'.
Type 'string | number | boolean' is not assignable to type 'string | number'.
Type 'boolean' is not assignable to type 'string | number'.
Type 'true' is not assignable to type 'string | number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'.
Type '{ a: string; }' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'.
@@ -33,7 +33,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup
!!! error TS2322: Types of property 'pop' are incompatible.
!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => string | number'.
!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'string | number'.
!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'.
!!! error TS2322: Type 'true' is not assignable to type 'string | number'.
var e3 = i1.tuple1[2]; // {}
i1.tuple1[3] = { a: "string" };
~~~~~~~~~~~~

View File

@@ -180,7 +180,7 @@ function f5(x: string | number | boolean) {
>true : true
x;
>x : boolean
>x : true
break;
case "hello":
@@ -195,6 +195,6 @@ function f5(x: string | number | boolean) {
break;
default:
x;
>x : string | number | boolean
>x : string | number | false
}
}

View File

@@ -203,7 +203,7 @@ const b4 = b && b;
>b4 : boolean
>b && b : boolean
>b : boolean
>b : boolean
>b : true
const b5 = b && v;
>b5 : void | false

View File

@@ -103,7 +103,7 @@ var rb2 = a2 && a2;
>rb2 : boolean
>a2 && a2 : boolean
>a2 : boolean
>a2 : boolean
>a2 : true
var rb3 = a3 && a2;
>rb3 : boolean

View File

@@ -163,8 +163,8 @@ var rc1 = a1 || a3; // any || number is any
>a3 : number
var rc2 = a2 || a3; // boolean || number is boolean | number
>rc2 : boolean | number
>a2 || a3 : boolean | number
>rc2 : true | number
>a2 || a3 : true | number
>a2 : boolean
>a3 : number
@@ -223,8 +223,8 @@ var rd1 = a1 || a4; // any || string is any
>a4 : string
var rd2 = a2 || a4; // boolean || string is boolean | string
>rd2 : boolean | string
>a2 || a4 : boolean | string
>rd2 : true | string
>a2 || a4 : true | string
>a2 : boolean
>a4 : string
@@ -283,8 +283,8 @@ var re1 = a1 || a5; // any || void is any
>a5 : void
var re2 = a2 || a5; // boolean || void is boolean | void
>re2 : boolean | void
>a2 || a5 : boolean | void
>re2 : true | void
>a2 || a5 : true | void
>a2 : boolean
>a5 : void
@@ -343,8 +343,8 @@ var rg1 = a1 || a6; // any || enum is any
>a6 : E
var rg2 = a2 || a6; // boolean || enum is boolean | enum
>rg2 : boolean | E
>a2 || a6 : boolean | E
>rg2 : true | E
>a2 || a6 : true | E
>a2 : boolean
>a6 : E
@@ -403,8 +403,8 @@ var rh1 = a1 || a7; // any || object is any
>a7 : { a: string; }
var rh2 = a2 || a7; // boolean || object is boolean | object
>rh2 : boolean | { a: string; }
>a2 || a7 : boolean | { a: string; }
>rh2 : true | { a: string; }
>a2 || a7 : true | { a: string; }
>a2 : boolean
>a7 : { a: string; }
@@ -463,8 +463,8 @@ var ri1 = a1 || a8; // any || array is any
>a8 : string[]
var ri2 = a2 || a8; // boolean || array is boolean | array
>ri2 : boolean | string[]
>a2 || a8 : boolean | string[]
>ri2 : true | string[]
>a2 || a8 : true | string[]
>a2 : boolean
>a8 : string[]
@@ -523,8 +523,8 @@ var rj1 = a1 || null; // any || null is any
>null : null
var rj2 = a2 || null; // boolean || null is boolean
>rj2 : boolean
>a2 || null : boolean
>rj2 : true
>a2 || null : true
>a2 : boolean
>null : null
@@ -583,8 +583,8 @@ var rf1 = a1 || undefined; // any || undefined is any
>undefined : undefined
var rf2 = a2 || undefined; // boolean || undefined is boolean
>rf2 : boolean
>a2 || undefined : boolean
>rf2 : true
>a2 || undefined : true
>a2 : boolean
>undefined : undefined

View File

@@ -44,7 +44,7 @@ function sq(n?: number): number {
>n*n : number
>n : number
>n : number
>0 : 0
>0 : number
return r;
>r : number

View File

@@ -16,9 +16,9 @@ let abcOrXyz: "ABC" | "XYZ" = abc || xyz;
let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100;
>abcOrXyzOrNumber : "ABC" | "XYZ" | number
>abcOrXyz || 100 : "ABC" | "XYZ" | 100
>abcOrXyz || 100 : "ABC" | "XYZ" | number
>abcOrXyz : "ABC" | "XYZ"
>100 : 100
>100 : number
let a = "" + abc;
>a : string

View File

@@ -1,7 +1,6 @@
tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithIntersectionTypes01.ts(19,10): error TS2678: Type 'number & boolean' is not comparable to type 'string & number'.
Type 'number & boolean' is not comparable to type 'string'.
tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithIntersectionTypes01.ts(23,10): error TS2678: Type 'boolean' is not comparable to type 'string & number'.
Type 'boolean' is not comparable to type 'string'.
==== tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithIntersectionTypes01.ts (2 errors) ====
@@ -33,6 +32,5 @@ tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithInterse
case bool:
~~~~
!!! error TS2678: Type 'boolean' is not comparable to type 'string & number'.
!!! error TS2678: Type 'boolean' is not comparable to type 'string'.
break;
}

View File

@@ -223,7 +223,7 @@ let union2: C | B;
let union3: boolean | B = isA(union2) || union2;
>union3 : boolean | B
>B : B
>isA(union2) || union2 : boolean | B
>isA(union2) || union2 : true | B
>isA(union2) : boolean
>isA : (p1: any) => p1 is A
>union2 : C | B

View File

@@ -14,7 +14,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri
>strOrBool : boolean
>typeof strOrBool === 'string' : boolean
>typeof strOrBool : string
>strOrBool : string | boolean
>strOrBool : string | true
>'string' : "string"
let label: string = (typeof strOrBool === 'string') ? strOrBool : "string";
@@ -74,7 +74,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole
>strOrBool : boolean
>typeof strOrBool !== 'boolean' : boolean
>typeof strOrBool : string
>strOrBool : string | boolean
>strOrBool : string | true
>'boolean' : "boolean"
let label: string = (typeof strOrBool === 'string') ? strOrBool : "string";

View File

@@ -19,12 +19,12 @@ function foo(x: number | string) {
>10 : 10
}
function foo2(x: number | string) {
>foo2 : (x: number | string) => boolean | number
>foo2 : (x: number | string) => true | number
>x : number | string
// modify x in right hand operand
return typeof x !== "string" || ((x = 10) || x); // string | number
>typeof x !== "string" || ((x = 10) || x) : boolean | number
>typeof x !== "string" || ((x = 10) || x) : true | number
>typeof x !== "string" : boolean
>typeof x : string
>x : number | string
@@ -38,12 +38,12 @@ function foo2(x: number | string) {
>x : number
}
function foo3(x: number | string) {
>foo3 : (x: number | string) => boolean | string
>foo3 : (x: number | string) => true | string
>x : number | string
// modify x in right hand operand with string type itself
return typeof x !== "string" || ((x = "hello") || x); // string | number
>typeof x !== "string" || ((x = "hello") || x) : boolean | string
>typeof x !== "string" || ((x = "hello") || x) : true | string
>typeof x !== "string" : boolean
>typeof x : string
>x : number | string
@@ -138,7 +138,7 @@ function foo6(x: number | string | boolean) {
>10 : 10
}
function foo7(x: number | string | boolean) {
>foo7 : (x: number | string | boolean) => boolean | number | string
>foo7 : (x: number | string | boolean) => true | number | string
>x : number | string | boolean
var y: number| boolean | string;
@@ -149,15 +149,15 @@ function foo7(x: number | string | boolean) {
// Mixing typeguard narrowing
return typeof x === "string"
>typeof x === "string" || ((z = x) // number | boolean || (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString()))) : boolean | number | string
>typeof x === "string" || ((z = x) // number | boolean || (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString()))) : true | number | string
>typeof x === "string" : boolean
>typeof x : string
>x : number | string | boolean
>"string" : "string"
|| ((z = x) // number | boolean
>((z = x) // number | boolean || (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString()))) : number | boolean | string
>(z = x) // number | boolean || (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString())) : number | boolean | string
>((z = x) // number | boolean || (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString()))) : number | true | string
>(z = x) // number | boolean || (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString())) : number | true | string
>(z = x) : number | boolean
>z = x : number | boolean
>z : number | boolean | string