40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
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'.
|
|
|
|
|
|
==== 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
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
}
|
|
|
|
// Other way
|
|
class H {
|
|
[n: number]: A
|
|
}
|
|
class I extends H {
|
|
[s: string]: B
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
}
|
|
|
|
// With hidden indexer
|
|
class J {
|
|
[n: number]: {}
|
|
}
|
|
|
|
class K extends J {
|
|
[n: number]: A;
|
|
~~~~~~~~~~~~~~~
|
|
!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'.
|
|
[s: string]: B;
|
|
} |