61 lines
3.9 KiB
Plaintext
61 lines
3.9 KiB
Plaintext
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(15,5): error TS2322: Type 'A | B' is not assignable to type 'A'.
|
|
Type 'B' is not assignable to type 'A'.
|
|
Property 'propertyA' is missing in type 'B'.
|
|
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type 'A | B' is not assignable to type 'B'.
|
|
Type 'A' is not assignable to type 'B'.
|
|
Property 'propertyB' is missing in type 'A'.
|
|
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number'.
|
|
Type '(n: X) => string' is not assignable to type '(t: X) => number'.
|
|
Type 'string' is not assignable to type 'number'.
|
|
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string'.
|
|
Type '(m: X) => number' is not assignable to type '(t: X) => string'.
|
|
Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean'.
|
|
Type '(m: X) => number' is not assignable to type '(t: X) => boolean'.
|
|
Type 'number' is not assignable to type 'boolean'.
|
|
|
|
|
|
==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (5 errors) ====
|
|
//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;
|
|
|
|
// No errors anymore, uses union types
|
|
true ? a : b;
|
|
var result1 = true ? a : b;
|
|
|
|
//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target
|
|
var result2: A = true ? a : b;
|
|
~~~~~~~
|
|
!!! error TS2322: Type 'A | B' is not assignable to type 'A'.
|
|
!!! error TS2322: Type 'B' is not assignable to type 'A'.
|
|
!!! error TS2322: Property 'propertyA' is missing in type 'B'.
|
|
var result3: B = true ? a : b;
|
|
~~~~~~~
|
|
!!! error TS2322: Type 'A | B' is not assignable to type 'B'.
|
|
!!! error TS2322: Type 'A' is not assignable to type 'B'.
|
|
!!! error TS2322: Property 'propertyB' is missing in type 'A'.
|
|
var result31: A | B = true ? a : b;
|
|
|
|
var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
|
|
~~~~~~~
|
|
!!! error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number'.
|
|
!!! error TS2322: Type '(n: X) => string' is not assignable to type '(t: X) => number'.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
|
|
~~~~~~~
|
|
!!! error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string'.
|
|
!!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => string'.
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
|
|
~~~~~~~
|
|
!!! error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean'.
|
|
!!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => boolean'.
|
|
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
|
|
var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
|
|
|