-
Notifications
You must be signed in to change notification settings - Fork 12.8k
strictFunctionTypes shouldn't prevent method overriding #19004
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
I may well be missing something but it seems that if I were to have const c: C = new D;
c.a(() => new C); And if the implementation of a(f: (a: D) => D) {
const otherD = f(new D);
this.p = otherD.p;
} I would say LSP is violated since |
I think compiler should throw an error with that assignment Another, this error is caused on declare class C {
a(f: (a: C) => C): void;
}
declare class D extends C {
p: void;
a(f: (a: D) => D): void; // no error, but should be an error
} |
I drop this issue. Thanks @aluanhaddad . |
As another point of #18963,
strictFunctionTypes
prevents some method overriding. TypeScript should relaxstrictFunctionTypes
checks of method overriding. The current restriction is excessive on object-oriented programming.cc @ahejlsberg
TypeScript Version: master
Code
Expected behavior:
no error
Actual behavior:
The text was updated successfully, but these errors were encountered: