2014-09-12 22:35:07 +02:00
|
|
|
tests/cases/compiler/indexerConstraints.ts(17,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
|
|
tests/cases/compiler/indexerConstraints.ts(25,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
|
|
tests/cases/compiler/indexerConstraints.ts(33,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
|
|
tests/cases/compiler/indexerConstraints.ts(41,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/indexerConstraints.ts (4 errors) ====
|
|
|
|
interface A { a: number; }
|
|
|
|
interface B extends A { b: number; }
|
|
|
|
|
|
|
|
// Good case
|
|
|
|
interface D {
|
|
|
|
[s: string]: A;
|
|
|
|
}
|
|
|
|
interface D {
|
|
|
|
[n: number]: B;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bad case
|
|
|
|
interface E {
|
|
|
|
[s: string]: B;
|
|
|
|
}
|
|
|
|
interface E {
|
|
|
|
[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
|
|
|
}
|
|
|
|
|
|
|
|
// Inheritance
|
|
|
|
interface F {
|
|
|
|
[s: string]: B;
|
|
|
|
}
|
|
|
|
interface 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
|
|
|
|
interface H {
|
|
|
|
[n: number]: A;
|
|
|
|
}
|
|
|
|
interface 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
|
|
|
|
interface J {
|
|
|
|
[n: number]: {};
|
|
|
|
}
|
|
|
|
interface 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;
|
|
|
|
}
|