-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Mixin pattern issues when "declaration:true" is used - tsc cannot infer class def properly #14597
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
Labels
Duplicate
An existing issue was already created
Comments
The issue is that .d.ts files can't contain expression code, and the |
Right, are there any plans to improve this in the future? For anyone else the fix is simple enough ( although it took me quite a lot time to figure it out :D ) ++const TaggedPerson = Tagged(Person);
--export class Customer extends Tagged(Person) {
++export class Customer extends TaggedPerson {
accountBalance: number;
onFoo() {
return this.isTagged() ? this.tag : 'ups';
}
} also fixed here wc-catalogue/blaze-elements@d5d435e |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
TypeScript Version: 2.2.1
Code
Demo you have to download and run it on your machine with
declaration: true
Expected behavior:
No errors when using
declaration:true
and proper type inference of returned mixin class from functionActual behavior:
Provided code works without errors, but when we want generate type definitions via
declaration:true
tsc will error out.Problem is that TSC is not able to infer the returned class type definition when generating ambient definitions ( so that's why I explicitly provide return type
export function Tagged<T extends Constructor<{}>>(Base: T): Constructor<TaggedProps> & T {
)Although that is not the exact type that TSC inferes when
declaration
is not turned on:Infered type definition:
The text was updated successfully, but these errors were encountered: