I am trying to supply generic type into vue component, but don't know how to supply that from the caller.
For example, for the component below
export default class Toggle<T> extends Vue {
@Prop({ default: {} }) private payload!: T;
@Prop(Function) private handleCallback!: (payload: T) => Promise<any>;
}
how would I supply type for T
when it is called as below?
<toggle :payload="{propOfT: 'value of T'}" :handleCallback='someCallbackFn'/>
maybe you can use
extend<Data, Methods, Computed, Props>(options?: ThisTypedComponentOptionsWithRecordProps<V, Data, Methods, Computed, Props>): ExtendedVue<V, Data, Methods, Computed, Props>;
interface Data {
dataProp: boolean
}
interface Methods {
methodOne: (name: Type) => Promise<void>
}
interface Props {
items: Item[]
}
export default Vue.extend<Data, Methods, {}, Props>({ ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With