I have a renderless component in JavaScript that I am trying to convert to TypeScript. I'm running into errors declaring the render
function in a Vue.extend
-ed component:
(method) ComponentOptions<Vue, unknown, unknown, unknown, never[], Record<never, any>>.render?(createElement: CreateElement, hack: RenderContext<Record<never, any>>): VNode
No overload matches this call.
The last overload gave the following error.
Argument of type '{ render(): void; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.
Types of property 'render' are incompatible.
Type '() => void' is not assignable to type '(createElement: CreateElement, hack: RenderContext<Record<string, any>>) => VNode'.
Type 'void' is not assignable to type 'VNode'.ts(2769)
vue.d.ts(90, 3): The last overload is declared here.
This is an example of what I am trying to do in TypeScript:
import Vue from 'vue'
export default Vue.extend({
render() { // error happens when I add this. I tried typing the render with :VNode
// and returning this.$scopedSlots.default({}), but error still occurs
}
})
How do I fix this?