46 lines
No EOL
1.8 KiB
Text
46 lines
No EOL
1.8 KiB
Text
==== tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts (8 errors) ====
|
|
interface Base {
|
|
[x: number]: { x: number; y: number; };
|
|
[x: string]: { x: number; }
|
|
}
|
|
|
|
interface Derived extends Base {
|
|
1: { y: number } // error
|
|
~~~~~~~~~~~~~~~~
|
|
!!! Property '1' of type '{ y: number; }' is not assignable to numeric index type '{ x: number; y: number; }'.
|
|
~~~~~~~~~~~~~~~~
|
|
!!! Property '1' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'.
|
|
}
|
|
|
|
interface Derived2 extends Base {
|
|
'1': { y: number } // error
|
|
~~~~~~~~~~~~~~~~~~
|
|
!!! Property ''1'' of type '{ y: number; }' is not assignable to numeric index type '{ x: number; y: number; }'.
|
|
~~~~~~~~~~~~~~~~~~
|
|
!!! Property ''1'' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'.
|
|
}
|
|
|
|
interface Derived3 extends Base {
|
|
foo: { y: number } // error
|
|
~~~~~~~~~~~~~~~~~~
|
|
!!! Property 'foo' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'.
|
|
}
|
|
|
|
interface Derived4 extends Base {
|
|
foo(): { x: number } // error
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
!!! Property 'foo' of type '() => { x: number; }' is not assignable to string index type '{ x: number; }'.
|
|
}
|
|
|
|
// satisifies string indexer but not numeric indexer
|
|
interface Derived5 extends Base {
|
|
1: { x: number } // error
|
|
~~~~~~~~~~~~~~~~
|
|
!!! Property '1' of type '{ x: number; }' is not assignable to numeric index type '{ x: number; y: number; }'.
|
|
}
|
|
|
|
interface Derived5 extends Base {
|
|
'1': { x: number } // error
|
|
~~~
|
|
!!! Duplicate identifier ''1''.
|
|
} |