-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Why must two methods with the same name be identical when inheriting them from different interfaces? #2871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If they're not identical, we don't have any good way to "merge" them in an order that's predictable and meaningful. The workaround you posted is the intended one -- when two inherited properties aren't identical, the fix is to specify how they should be merged. |
@RyanCavanaugh Can you give an example, why merging declarations in this case can't be done in a predictable and meaningful way? Where is the conceptual difference to the merging described here: https://github.com/Microsoft/TypeScript/wiki/Declaration-Merging#merging-interfaces ? |
Or maybe, my question could be boiled down to: "Where can I find explained the difference between two interfaces with the same name getting merged and one interface extending two interfaces at a time" [EDIT]:
So when merging interfaces with the same name, only the first must (and should) contain the non-specialized call signature. The merging then takes place in the reverse order, putting the members of last declared interface first. In contrast, when merging interface members by extending two different interfaces at a time, both of them already must contain a non-specialized call signature for their specialized signatures. In this case, the simple rule of putting the members of the latter before the members of the first will not be satisfactory, as every specialized call signature that come after a matching non-specialized call signature will be ignored. That leads me to the following feature request: |
Last one wins, maybe? I would understand why this error is popping if there are conflicts between merged interfaces, but it's there even when they're not. |
Gives me:
Error:(16, 15) TS2320: Interface 'Both' cannot simultaneously extend types 'SubA' and 'SubB'.
Named properties 'set' of types 'SubA' and 'SubB' are not identical.
I'm working with Dojo, where
SubA
andSubB
are two Widgets andBoth
is the type of a mixin.Ironically, this prevents the error:
The text was updated successfully, but these errors were encountered: