Open
Description
TanStack Table version
8.20.5
Framework/Library version
Svelte 5.0.0
Describe the bug and the steps to reproduce it
Hi guys,
I think there some issues with the
export interface GlobalFilterTableState {
globalFilter: any;
}
Definitions. When used with TableState this any is poisoning everything. It turns out that run-time behaviour expects that the tableState look something like:
// createSvelteTable calls createTable. This is shadcn writing an adapter.
const table = createSvelteTable({
...otherProps,
state: {
get globalFilter() {
// this should return a string to filter on! But since TableState extends from (among others) GlobalFilterTableState the return value can be `any`.
return globalFilter.globalFilter;
}
},
});
This was a pretty big problem as I thought I could just return something shaped like a GlobalFilterTableState:
let myGlobalFilterState= $derived.by(() => {
return { globalFilter: params.q } satisfies GlobalFilterTableState; // THIS IS A TYPE ERROR IN THE LIB... I SPENT 1 HOUR FINDING THIS....
});
const table = createSvelteTable({
...otherProps,
state: {
get globalFilter() {
// this should return a string to filter on! But since TableState extends from (among others) GlobalFilterTableState the return value can be `any`.
return myGlobalFilterState; // this passes typescript but gives unexpected results at runtime! It should be a string here!
}
},
});
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Metadata
Metadata
Assignees
Labels
No labels
Activity