T
TanStack3y ago
flat-fuchsia

Svelte table flexRender gives type error

<svelte:component this={flexRender(cell.column.columnDef.cell, cell.getContext())} />
<svelte:component this={flexRender(cell.column.columnDef.cell, cell.getContext())} />
this line causes typescript to give me this error
Argument of type '{ render: (props?: {} | undefined, { $$slots, context }?: { $$slots?: {} | undefined; context?: Map<any, any> | undefined; } | undefined) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; } | (new (options: any) => ...' is not assignable to parameter of type 'ConstructorOfATypedSvelteComponent | null | undefined'.
Type '{ render: (props?: {} | undefined, { $$slots, context }?: { $$slots?: {} | undefined; context?: Map<any, any> | undefined; } | undefined) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; }' is not assignable to type 'ConstructorOfATypedSvelteComponent'.
Type '{ render: (props?: {} | undefined, { $$slots, context }?: { $$slots?: {} | undefined; context?: Map<any, any> | undefined; } | undefined) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; }' provides no match for the signature 'new (args: { target: any; props?: any; }): ATypedSvelteComponent'.
Argument of type '{ render: (props?: {} | undefined, { $$slots, context }?: { $$slots?: {} | undefined; context?: Map<any, any> | undefined; } | undefined) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; } | (new (options: any) => ...' is not assignable to parameter of type 'ConstructorOfATypedSvelteComponent | null | undefined'.
Type '{ render: (props?: {} | undefined, { $$slots, context }?: { $$slots?: {} | undefined; context?: Map<any, any> | undefined; } | undefined) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; }' is not assignable to type 'ConstructorOfATypedSvelteComponent'.
Type '{ render: (props?: {} | undefined, { $$slots, context }?: { $$slots?: {} | undefined; context?: Map<any, any> | undefined; } | undefined) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; }' provides no match for the signature 'new (args: { target: any; props?: any; }): ATypedSvelteComponent'.
It works as expected but the error is annoying
3 Replies
flat-fuchsia
flat-fuchsiaOP3y ago
would be cool to just have a function something like cell.renderComponent() instead of introducing a new function
automatic-azure
automatic-azure3y ago
Same problem got any solutin?
foreign-sapphire
foreign-sapphire3y ago
Any updates on this?

Did you find this page helpful?