vincjo / datatables

A toolkit for creating datatable components with Svelte
https://vincjo.fr/datatables
MIT License
363 stars 15 forks source link

[Bug] Datahandler Type Error #74

Closed tngrj closed 8 months ago

tngrj commented 8 months ago

I have the following error

Type 'DataHandler<{ id: string; (some other columns) startDate: Date; endDate: Date; (more columns) ... 7 more ...; }>' is missing the following properties from type 'DataHandler': triggerHandler, onChange, invalidate, setTotalRows

I have redacted some of the database information in the above error message and the sample table below but otherwise it's only happening for the RowsPerPage and Pagination Component. Both components came from here. It doesn't affect the overall use of it, it's just a nagging error. Let me know if you need more info.

<div class="table-compact">
<header>
    <div class="flex flex-row mt-4 mb-4">
        <Search {handler} />
        <RowsPerPage {handler} /> // issue here

    </div>
</header>
<table class="table table-hover">
    <thead>
        <tr>
            <Th {handler} orderBy="placeholder">placeholder/Th>
            <Th {handler} orderBy="placeholder">placeholder/Th>
            <th />
        </tr>
    </thead>
    <tbody>
        {#each $rows as row}
            <tr>
                <td>{row.placeholder}</td>
                <td>{row.placeholder}</td>
                <td>
                    <a href="/projects/{row.id}">
                        <span class="chip variant-filled-tertiary">More info</span>
                    </a>
                </td>
            </tr>
        {/each}
    </tbody>
</table>

<footer class="flex justify-between mt-4">
    <RowCount {handler} />
    <Pagination {handler} /> // issue here
</footer>
</div>
vincjo commented 8 months ago

Ty

At first glance, I think the pb comes from a mix between server-side and client-side components. It is not possible to mix @vincjo/datatables and @vincjo/datatables/remote namespaces in import.

But i may be wrong

tngrj commented 8 months ago

Oh you would be correct. After I remove the remote and the handler.invalidate(); from both files, the error goes away.