Open
Description
let's have the following (Svelte4) generic component called Table.svelte
<script lang="ts" generics="T extends { selected?: boolean; name?: string }">
export let data: T[];
</script>
Let's have our table.spec.ts
import '@testing-library/jest-dom/vitest';
import { fireEvent, render, screen, within } from '@testing-library/svelte';
// Import our generic component
import { Table } from '/@/lib';
// let's create an Item interface
interface Item {
id: string;
name?: string;
}
test('type issue', async () => {
render<Table<Item>>(Table, {
kind: 'demo',
data: [
{
id: '1',
name: 'foo',
},
{
id: '2',
name: 'foo',
},
],
});
});
Got the following error
packages/ui/src/lib/table/Table.spec.ts:463:37 - error TS2315: Type 'Comp' is not generic.
463 const { getAllByRole } = render<Table<Item>>(Table, {
Trying something different
- render<Table<Item>>(Table, {
+ render(Table<Item>, {
Got the following error
packages/ui/src/lib/table/Table.spec.ts:463:37 - error TS2345: Argument of type '{}' is not assignable to parameter of type 'Component<any, any, string> | (new (...args: any[]) => SvelteComponent<any, any, any>)'.
463 const { getAllByRole } = render(Table<Item>, {
~~~~~~~~~~~
packages/ui/src/lib/table/Table.spec.ts:463:43 - error TS2635: Type 'LegacyComponentType' has no signatures for which the type argument list is applicable.
463 const { getAllByRole } = render(Table<Item>, {
If am not specifying the I've got the following error in my IDE (not typecheck)
TS2353: Object literal may only specify known properties, and id does not exist in type