In the example below (Typescript, 1.7+), what would I have to change to allow B.callback
to have a different signature than A.callback
?
class A {
callback(result: number) {
}
}
class B extends A {
callback(result: number, option: number) {
}
}
Currently this gives test.ts(7,7): error TS2415: Class 'B' incorrectly extends base class 'A'.
In the real world my example is more complex, but I can dynamically (more or less) guarantee (based on some configuration) that the requested parameters will be there.
a.callback(123)
would still be a valid method call tob
. – Postmistress