Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMixins lost the type information when type is generic. #289
Comments
Unfortunately, I think there is no way to specify it with mixins helper as the mixin constructors are passed as value. If anyone come up with the idea to handle this, feel free to put it this thread |
In recent version, passing type information to mixin helper like this worked. import Vue from 'vue'
import Component, { mixins } from 'vue-class-component'
@Component
class MyMixin extends mixins<GenericMixin<string>>(GenericMixin) {
created() {
console.log(this.value('hello'))
}
}
@Component
class GenericMixin<T=any> extends Vue {
value(value: T): T {
return value
}
} |
If think the only way to state the type you are expecting as @garypippi did. So the TS will surely know about what type it should expect since the generic parameter it's not the only one in the mixin types. |
thanks~ |
Closing as the solution is provided. Thank you for making this discussion! |
I used the vue-property-decorator, it seems export mixins as Mixins.
So i asked there.
Is there any way to mixins other vue class but reserve the generic parameter?