1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction2.ts(19,1): error TS2322: Type 'Property' is not assignable to type 'Class'.
Types of property 'parent' are incompatible.
Type 'Module | Class' is not assignable to type 'Namespace'.
Property 'members' is missing in type 'Class' but required in type 'Namespace'.
tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction2.ts(20,1): error TS2322: Type 'Class' is not assignable to type 'Property'.
Types of property 'parent' are incompatible.
Type 'Namespace' is not assignable to type 'Module | Class'.
Type 'Namespace' is not assignable to type 'Module'.
Types of property 'members' are incompatible.
Type '(Class | Property)[]' is not assignable to type 'Class[]'.
Type 'Class | Property' is not assignable to type 'Class'.
Type 'Property' is not assignable to type 'Class'.
==== tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction2.ts (2 errors) ====
class Module {
public members: Class[];
}
class Namespace {
public members: (Class | Property)[];
}
class Class {
public parent: Namespace;
}
class Property {
public parent: Module | Class;
}
var c: Class;
var p: Property;
c = p;
~
!!! error TS2322: Type 'Property' is not assignable to type 'Class'.
!!! error TS2322: Types of property 'parent' are incompatible.
!!! error TS2322: Type 'Module | Class' is not assignable to type 'Namespace'.
!!! error TS2322: Property 'members' is missing in type 'Class' but required in type 'Namespace'.
!!! related TS2728 tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction2.ts:6:12: 'members' is declared here.
p = c;
~
!!! error TS2322: Type 'Class' is not assignable to type 'Property'.
!!! error TS2322: Types of property 'parent' are incompatible.
!!! error TS2322: Type 'Namespace' is not assignable to type 'Module | Class'.
!!! error TS2322: Type 'Namespace' is not assignable to type 'Module'.
!!! error TS2322: Types of property 'members' are incompatible.
!!! error TS2322: Type '(Class | Property)[]' is not assignable to type 'Class[]'.
!!! error TS2322: Type 'Class | Property' is not assignable to type 'Class'.
!!! error TS2322: Type 'Property' is not assignable to type 'Class'.
|