2014-09-12 22:35:07 +02:00
|
|
|
tests/cases/compiler/indexerConstraints2.ts(9,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
|
|
tests/cases/compiler/indexerConstraints2.ts(17,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
|
|
tests/cases/compiler/indexerConstraints2.ts(26,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
|
|
|
|
|
|
|
2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/indexerConstraints2.ts (3 errors) ====
|
|
|
|
class A { a: number; }
|
|
|
|
class B extends A { b: number; }
|
|
|
|
|
|
|
|
// Inheritance
|
|
|
|
class F {
|
|
|
|
[s: string]: B
|
|
|
|
}
|
|
|
|
class G extends F {
|
|
|
|
[n: number]: A
|
|
|
|
~~~~~~~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Other way
|
|
|
|
class H {
|
|
|
|
[n: number]: A
|
|
|
|
}
|
|
|
|
class I extends H {
|
|
|
|
[s: string]: B
|
|
|
|
~~~~~~~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// With hidden indexer
|
|
|
|
class J {
|
|
|
|
[n: number]: {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class K extends J {
|
|
|
|
[n: number]: A;
|
|
|
|
~~~~~~~~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
2014-07-13 01:04:16 +02:00
|
|
|
[s: string]: B;
|
|
|
|
}
|