mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
71 lines
4.9 KiB
Plaintext
71 lines
4.9 KiB
Plaintext
conditionalOperatorWithoutIdenticalBCT.ts(2,27): error TS2564: Property 'propertyX1' has no initializer and is not definitely assigned in the constructor.
|
|
conditionalOperatorWithoutIdenticalBCT.ts(2,47): error TS2564: Property 'propertyX2' has no initializer and is not definitely assigned in the constructor.
|
|
conditionalOperatorWithoutIdenticalBCT.ts(3,21): error TS2564: Property 'propertyA' has no initializer and is not definitely assigned in the constructor.
|
|
conditionalOperatorWithoutIdenticalBCT.ts(4,21): error TS2564: Property 'propertyB' has no initializer and is not definitely assigned in the constructor.
|
|
conditionalOperatorWithoutIdenticalBCT.ts(15,5): error TS2322: Type 'A | B' is not assignable to type 'A'.
|
|
Property 'propertyA' is missing in type 'B' but required in type 'A'.
|
|
conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type 'A | B' is not assignable to type 'B'.
|
|
Property 'propertyB' is missing in type 'A' but required in type 'B'.
|
|
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'.
|
|
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'.
|
|
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'.
|
|
|
|
|
|
==== conditionalOperatorWithoutIdenticalBCT.ts (9 errors) ====
|
|
//Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type
|
|
class X { propertyX: any; propertyX1: number; propertyX2: string };
|
|
~~~~~~~~~~
|
|
!!! error TS2564: Property 'propertyX1' has no initializer and is not definitely assigned in the constructor.
|
|
~~~~~~~~~~
|
|
!!! error TS2564: Property 'propertyX2' has no initializer and is not definitely assigned in the constructor.
|
|
class A extends X { propertyA: number };
|
|
~~~~~~~~~
|
|
!!! error TS2564: Property 'propertyA' has no initializer and is not definitely assigned in the constructor.
|
|
class B extends X { propertyB: string };
|
|
~~~~~~~~~
|
|
!!! error TS2564: Property 'propertyB' has no initializer and is not definitely assigned in the constructor.
|
|
|
|
declare var x: X;
|
|
declare var a: A;
|
|
declare 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: Property 'propertyA' is missing in type 'B' but required in type 'A'.
|
|
!!! related TS2728 conditionalOperatorWithoutIdenticalBCT.ts:3:21: 'propertyA' is declared here.
|
|
var result3: B = true ? a : b;
|
|
~~~~~~~
|
|
!!! error TS2322: Type 'A | B' is not assignable to type 'B'.
|
|
!!! error TS2322: Property 'propertyB' is missing in type 'A' but required in type 'B'.
|
|
!!! related TS2728 conditionalOperatorWithoutIdenticalBCT.ts:4:21: 'propertyB' is declared here.
|
|
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;
|
|
|