2014-10-28 08:28:59 +01:00
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(15,5): error TS2323: Type 'A | B' is not assignable to type 'A'.
Type 'B' is not assignable to type 'A'.
2014-10-10 23:41:14 +02:00
Property 'propertyA' is missing in type 'B'.
2014-10-28 08:28:59 +01:00
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2323: Type 'A | B' is not assignable to type 'B'.
Type 'A' is not assignable to type 'B'.
2014-10-10 23:41:14 +02:00
Property 'propertyB' is missing in type 'A'.
2014-11-04 01:25:09 +01:00
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2323: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number'.
2014-10-28 08:28:59 +01:00
Type '(n: X) => string' is not assignable to type '(t: X) => number'.
2014-10-10 23:41:14 +02:00
Type 'string' is not assignable to type 'number'.
2014-11-04 01:25:09 +01:00
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2323: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string'.
2014-10-28 08:28:59 +01:00
Type '(m: X) => number' is not assignable to type '(t: X) => string'.
2014-10-10 23:41:14 +02:00
Type 'number' is not assignable to type 'string'.
2014-11-04 01:25:09 +01:00
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,5): error TS2323: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean'.
2014-10-28 08:28:59 +01:00
Type '(m: X) => number' is not assignable to type '(t: X) => boolean'.
2014-10-10 23:41:14 +02:00
Type 'number' is not assignable to type 'boolean'.
2014-09-12 22:35:07 +02:00
2014-10-10 23:41:14 +02:00
==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (5 errors) ====
2014-07-13 01:04:16 +02:00
//Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type
class X { propertyX: any; propertyX1: number; propertyX2: string };
class A extends X { propertyA: number };
class B extends X { propertyB: string };
var x: X;
var a: A;
var b: B;
2014-10-10 23:41:14 +02:00
// No errors anymore, uses union types
2014-07-13 01:04:16 +02:00
true ? a : b;
var result1 = true ? a : b;
2014-10-10 23:41:14 +02:00
//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target
2014-07-13 01:04:16 +02:00
var result2: A = true ? a : b;
2014-07-19 02:30:06 +02:00
~~~~~~~
2014-10-28 08:28:59 +01:00
!!! error TS2323: Type 'A | B' is not assignable to type 'A'.
!!! error TS2323: Type 'B' is not assignable to type 'A'.
!!! error TS2323: Property 'propertyA' is missing in type 'B'.
2014-07-13 01:04:16 +02:00
var result3: B = true ? a : b;
2014-07-19 02:30:06 +02:00
~~~~~~~
2014-10-28 08:28:59 +01:00
!!! error TS2323: Type 'A | B' is not assignable to type 'B'.
!!! error TS2323: Type 'A' is not assignable to type 'B'.
!!! error TS2323: Property 'propertyB' is missing in type 'A'.
2014-11-04 01:25:09 +01:00
var result31: A | B = true ? a : b;
2014-07-13 01:04:16 +02:00
var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
2014-07-19 02:30:06 +02:00
~~~~~~~
2014-10-28 08:28:59 +01:00
!!! error TS2323: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number'.
!!! error TS2323: Type '(n: X) => string' is not assignable to type '(t: X) => number'.
!!! error TS2323: Type 'string' is not assignable to type 'number'.
2014-07-13 01:04:16 +02:00
var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
2014-07-19 02:30:06 +02:00
~~~~~~~
2014-10-28 08:28:59 +01:00
!!! error TS2323: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string'.
!!! error TS2323: Type '(m: X) => number' is not assignable to type '(t: X) => string'.
!!! error TS2323: Type 'number' is not assignable to type 'string'.
2014-07-13 01:04:16 +02:00
var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
2014-07-19 02:30:06 +02:00
~~~~~~~
2014-10-28 08:28:59 +01:00
!!! error TS2323: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean'.
!!! error TS2323: Type '(m: X) => number' is not assignable to type '(t: X) => boolean'.
2014-11-04 01:25:09 +01:00
!!! error TS2323: Type 'number' is not assignable to type 'boolean'.
var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;