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
should not compile, as callbackfn requires a Base, not a Child. It is not correct that value is a child. If Child does not extend Base, then this causes a compile error as expected. However, if we add no explicit hierarchy between the classes, but change the example to
then the code still compiles. Both of these are errors that should hopefully be caught at compile time. It looks like typescript only checks to see if a callback parameter is valid if the classes have common members. This should be changed to a subset.
The text was updated successfully, but these errors were encountered:
@arknave this is by design. It allows you to type event handler arguments easily e.g. e:MouseEvent when the original signature is only e:Event. Its allowed as long as a is subtype of b or b is subtype of a
Typescript is too lenient when accepting sub-classes in inherited types. For example:
should not compile, as
callbackfn
requires a Base, not a Child. It is not correct that value is a child. If Child does not extend Base, then this causes a compile error as expected. However, if we add no explicit hierarchy between the classes, but change the example tothen the code still compiles. Both of these are errors that should hopefully be caught at compile time. It looks like typescript only checks to see if a callback parameter is valid if the classes have common members. This should be changed to a subset.
The text was updated successfully, but these errors were encountered: