I am currently facing issues converting a renderless component in JavaScript to TypeScript. The problem arises when declaring the render
function within 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.
Below is an example of my TypeScript code snippet that is causing the issue:
import Vue from 'vue'
export default Vue.extend({
render() { // error occurs at this point. I attempted to type the render with :VNode
// and tried returning this.$scopedSlots.default({}), but the error persists
}
})
Is there a solution to resolve this issue?