Skip to content

v7.2.4 breaks "Mixins" decorator usage #435

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

Closed
Ky6uk opened this issue Jul 21, 2020 · 4 comments · Fixed by #436
Closed

v7.2.4 breaks "Mixins" decorator usage #435

Ky6uk opened this issue Jul 21, 2020 · 4 comments · Fixed by #436

Comments

@Ky6uk
Copy link

Ky6uk commented Jul 21, 2020

After upgrading from v7.2.3 to v7.2.4 I'm getting a lot of different TypeScript compilation errors because of using Mixins decorator as generics. Something like

Type 'MixinName<Data>' does not satisfy the constraint 'VueClass<Vue>[]'.

I'm using mixins like that

@Component
export class MixinName<T> extends Vue {
  // ...
}
export default class Page extends Mixins<MixinName<Data>>(MixinName) {
  // ...
}

It looks like breaking changes has been introduced in v7.2.4, but I have no idea what wrong exactly. v7.2.3 works perfectly.

@Ky6uk
Copy link
Author

Ky6uk commented Jul 21, 2020

Opened different issue kaorun343/vue-property-decorator#335

@Ky6uk Ky6uk closed this as completed Jul 21, 2020
@wangziling
Copy link

wangziling commented Jul 23, 2020

Yes. I had encountered this issue.
If you Mixins as Mixins-ed Component.

class A extends Mixins(B) {
  get a () {
     // This will come up an issue that `b` is nonexistent in `A`
     return this.b;
  }
}

class B extends Mixins(C) {
    b!: number;
}

class C extend Vue {}

I think this may be an issue about the declarition type for Mixins method.
In previous version, Mixins used the declarition merging.

export declare function mixins<A, B>(CtorA: VueClass<A>, CtorB: VueClass<B>): VueClass<A & B>;

But now using the infer keyword.

export declare type MixedVueClass<Mixins extends VueClass<Vue>[]> = Mixins extends (infer T)[] ? VueClass<UnionToIntersection<ExtractInstance<T>>> : never;

export declare function mixins<T extends VueClass<Vue>[]>(...Ctors: T): MixedVueClass<T>;

I just recognized by my ts coding experiences, that here maybe a little problem when using infer in typescript. It is not very smart and accurate, sometimes it cannot infer a type with a deep and complex logic correctly...

@wangziling
Copy link

This will not encountered in 7.2.3 version.

@Ky6uk
Copy link
Author

Ky6uk commented Jul 23, 2020

It looks the breaking change has been introduced in this PR #433 @ktsn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants