-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
mixin properties not checked #26286
Comments
This is true of Typescript as well: function mix<T extends new (...args: any[]) => any>(S: T) {
return class extends S {
f() { return 0; }
}
};
class Base {}
const Mixed = mix(Base);
export const m = new Mixed();
m.f(); // Correctly typed in signature help
m.j(); // should error here, but doesn't |
Looks like it has to do with the type |
Well, the reason that you see the apparent type of T is that the any comes from |
I think the problem then is that we force the user to write |
I though about using function mix<T extends new (...args: any[]) => InstanceType<T>>(S: T) {
return class extends S { // Throws: Base constructor return type 'InstanceType<T>' is not a class or interface type.
f() { return 0; }
}
};
class Base {}
const Mixed = mix(Base);
export const m = new Mixed();
m.f(); // Correctly typed in signature help
m.j(); // Throws: Property 'j' does not exist on type 'mix<typeof Base>.(Anonymous class) & Base'. Maybe I'm using |
TypeScript Version: master (as of #26283)
Code
Run with
allowJs
,checkJs
, andstrict
.Expected behavior:
Error at
meshod
.Actual behavior:
No error.
The text was updated successfully, but these errors were encountered: