You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the Mixins working (from #91) - thanks! great feature!
in my solution I need multiple Vue hooks, e.g. multiple created. This is working (all 3 created are called), but is it supported/by-design? If it's breaks, then I have a big issue ;)
Thanks in advance!
Code example:
//---------------- BEGIN mixin helpers --------------/** * Created by jsons on 2017/5/27. */import{Vue}from'vue/types/vue'import{ComponentOptions,FunctionalComponentOptions}from'vue/types/options'import{componentFactory}from"vue-class-component/lib/component";import{Component}from"vue-property-decorator";functionComponentForMixin<V,UextendsVue>(options: ComponentOptions<U>|V): any{if(typeofoptions==='function'){returncomponentFactory(optionsasany)}returnfunction(Component: V){returncomponentFactory(Componentasany,options)}}typeVClass<TextendsVue>={new(): Textend(option: ComponentOptions<Vue>|FunctionalComponentOptions): typeofVue}functionMixin<TextendsVue>(parent: typeofVue, ...traits: (typeofVue)[]): VClass<T>{returnparent.extend({mixins: traits})asany}//---------------- END mixin helpers --------------
@ComponentclassPenextendsVue{created(): void{// <-------- created 1console.log("created Pen")}}
@ComponentclassAppleextendsVue{created(): void{//<-------- created 2console.log("created Apple")}}interfaceIApplePenTraitextendsPen,Apple{//in my solution I also need here: // created(): void//otherwise I get the error://TS2320: Interface 'IApplePenTrait' cannot simultaneously extend types 'Pen' and 'Apple'.//Named properties 'created' of types 'Pen' and 'Apple' are not identical.//Dunno why not needed here}// compiles under TS2.2
@ComponentForMixin({template: `<span @click="Uh"> click show</span>`})exportdefaultclassApplePenextendsMixin<IApplePenTrait>(Apple,Pen){created(): void{//<-------- created 3console.log("created ApplePen")}}
PS I would like to set-up a code pen, but I can't get the imports working.
The text was updated successfully, but these errors were encountered:
You say that your code is working but what is your issue?
Well I'm not sure if it works "by accident" or "by-design".
In the code example the same method, created, with another body, is included. If those were really Typescript mixins, that would be a compile error? (or just overwrite it with the "latest" definition)
Let me know if it's still not clear, then I will try to explain it differently.
Uh oh!
There was an error while loading. Please reload this page.
I have the Mixins working (from #91) - thanks! great feature!
in my solution I need multiple Vue hooks, e.g. multiple
created
. This is working (all 3created
are called), but is it supported/by-design? If it's breaks, then I have a big issue ;)Thanks in advance!
Code example:
PS I would like to set-up a code pen, but I can't get the
import
s working.The text was updated successfully, but these errors were encountered: