43 lines
No EOL
1.9 KiB
Text
43 lines
No EOL
1.9 KiB
Text
tests/cases/compiler/interfacePropertiesWithSameName2.ts(10,11): error TS2320: Interface 'MoverShaker' cannot simultaneously extend types 'Mover' and 'Shaker'.
|
|
Named properties 'getStatus' of types 'Mover' and 'Shaker' are not identical.
|
|
tests/cases/compiler/interfacePropertiesWithSameName2.ts(26,11): error TS2320: Interface 'MoverShaker2' cannot simultaneously extend types 'Mover' and 'Shaker'.
|
|
Named properties 'getStatus' of types 'Mover' and 'Shaker' are not identical.
|
|
|
|
|
|
==== tests/cases/compiler/interfacePropertiesWithSameName2.ts (2 errors) ====
|
|
interface Mover {
|
|
move(): void;
|
|
getStatus(): { speed: number; };
|
|
}
|
|
interface Shaker {
|
|
shake(): void;
|
|
getStatus(): { frequency: number; };
|
|
}
|
|
|
|
interface MoverShaker extends Mover, Shaker {
|
|
~~~~~~~~~~~
|
|
!!! error TS2320: Interface 'MoverShaker' cannot simultaneously extend types 'Mover' and 'Shaker'.
|
|
!!! error TS2320: Named properties 'getStatus' of types 'Mover' and 'Shaker' are not identical.
|
|
|
|
}
|
|
|
|
// Inside a module
|
|
declare module MoversAndShakers {
|
|
export class Mover {
|
|
move(): void;
|
|
getStatus(): { speed: number; };
|
|
}
|
|
export interface Shaker {
|
|
shake(): void;
|
|
getStatus(): { frequency: number; };
|
|
}
|
|
}
|
|
|
|
interface MoverShaker2 extends MoversAndShakers.Mover, MoversAndShakers.Shaker { } // error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2320: Interface 'MoverShaker2' cannot simultaneously extend types 'Mover' and 'Shaker'.
|
|
!!! error TS2320: Named properties 'getStatus' of types 'Mover' and 'Shaker' are not identical.
|
|
|
|
interface MoverShaker3 extends MoversAndShakers.Mover, MoversAndShakers.Shaker {
|
|
getStatus(): { speed: number; frequency: number; }; // ok because this getStatus overrides the conflicting ones above
|
|
} |