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
DanielRosenwasser
added
Canonical
This issue contains a lengthy and complete description of a particular problem, solution, or design
Duplicate
An existing issue was already created
and removed
Canonical
This issue contains a lengthy and complete description of a particular problem, solution, or design
labels
Sep 13, 2018
@DanielRosenwasser Sorry, I forgot to specify in the original post that this occurs when --strictFunctionTypes is enabled. I've edited the post to reflect this.
TypeScript Version: 3.1.0-dev.20180912
Search Terms: class extends assignability method parameters override
Code
Expected behavior:
An error on the method definition, or an error when
value
is assigned, when --strictFunctionTypes is enabled.Actual behavior:
No error when --strictFunctionTypes is enabled.
As demonstrated, this means we can pass strings to
value.foo
, even thoughDerived.prototype.foo
doesn't accept strings.This issue precludes fixing #27047, as this bug breaks the contract it relies on.
Playground Link:
http://www.typescriptlang.org/play/#src=class%20Base%0D%0A%7B%0D%0A%09public%20foo%20(x%3A%20number%20%7C%20string)%20%7B%7D%0D%0A%7D%0D%0A%0D%0Aclass%20Derived%20extends%20Base%0D%0A%7B%0D%0A%09public%20foo%20(x%3A%20number)%20%7B%7D%0D%0A%7D%0D%0A%0D%0Aconst%20v%3A%20Base%20%3D%20new%20Derived()%3B%0D%0Av.foo('')%3B
The text was updated successfully, but these errors were encountered: