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
|
tests/cases/compiler/stringIndexerAssignments2.ts(19,1): error TS2322: Type 'C2' is not assignable to type 'C1'.
Index signature is missing in type 'C2'.
tests/cases/compiler/stringIndexerAssignments2.ts(20,1): error TS2322: Type 'C3' is not assignable to type 'C1'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/stringIndexerAssignments2.ts (2 errors) ====
class C1 {
[index: string]: string
one: string;
}
class C2 {
one: string;
}
class C3 {
one: number;
two: string;
}
var x: C1;
var a: C2;
var b: C3;
x = a;
~
!!! error TS2322: Type 'C2' is not assignable to type 'C1'.
!!! error TS2322: Index signature is missing in type 'C2'.
x = b;
~
!!! error TS2322: Type 'C3' is not assignable to type 'C1'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|