You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That was a mouthful. This arises in getLog(), findElOrEls, etc.
The problem is that a subclass cannot both extend a base class with some method foo()and an interface with some method foo()unlessfoo() is exactly the same, if we are to mix interfaces into subclasses (e.g., like FakeDriver).
Without the mixin interfaces applied to the subclasses via declaration merging, getLog() and such can provide more narrow types. I'm unsure if this is specific to declaration merging. It seems there will always be tradeoffs, no matter the route we go.
I don't know of a "fix", but if narrowed types are needed (e.g., getLog() returns something besides any, which it should) the workaround would be to move any method implemented by BaseDriver into the subclass proper and out of whatever mixin it's in. e.g., FakeDriver's getLog() should move into FakeDriver proper.
There may be room for some incremental improvements. Since BaseDriver'sfindElOrEls only exists because a convenience function expects it to be there, declaring BaseDriver as abstract and making findElOrEls an abstract function might allow for some leeway. But I don't see any general solution to getLog() at this time, since it needs to be implemented in BaseDriver.
unsure if this needs to be an issue or is more of a public service announcement. that announcement? classical inheritance is bad actually 😝
The text was updated successfully, but these errors were encountered:
boneskull
added
the
DX
developer experience (extension authoring, contributing, etc.)
label
Jun 13, 2023
That was a mouthful. This arises in
getLog()
,findElOrEls
, etc.The problem is that a subclass cannot both extend a base class with some method
foo()
and an interface with some methodfoo()
unlessfoo()
is exactly the same, if we are to mix interfaces into subclasses (e.g., likeFakeDriver
).Without the mixin interfaces applied to the subclasses via declaration merging,
getLog()
and such can provide more narrow types. I'm unsure if this is specific to declaration merging. It seems there will always be tradeoffs, no matter the route we go.I don't know of a "fix", but if narrowed types are needed (e.g.,
getLog()
returns something besidesany
, which it should) the workaround would be to move any method implemented byBaseDriver
into the subclass proper and out of whatever mixin it's in. e.g.,FakeDriver
'sgetLog()
should move intoFakeDriver
proper.There may be room for some incremental improvements. Since
BaseDriver's
findElOrEls
only exists because a convenience function expects it to be there, declaringBaseDriver
asabstract
and makingfindElOrEls
an abstract function might allow for some leeway. But I don't see any general solution togetLog()
at this time, since it needs to be implemented inBaseDriver
.unsure if this needs to be an issue or is more of a public service announcement. that announcement? classical inheritance is bad actually 😝
The text was updated successfully, but these errors were encountered: