How to pass plugin props dynamically into an external component. #201
Unanswered
dawidseipold
asked this question in
Q&A
Replies: 1 comment
-
Hey @dawidseipold, the plugin state's types are derived dynamically from One solution to do so is to create the table in a separate function and export types from that function: // myTable.ts
import { Table, createTable } from 'svelte-headless-table';
import { addSortBy, type PluginStates } from 'svelte-headless-table/plugins';
import type { Writable } from 'svelte/store';
export function createMyTable<T>(data: Writable<T[]>) {
return createTable(data, {
sort: addSortBy(),
});
}
type MyPlugins = ReturnType<typeof createMyTable> extends Table<
unknown,
infer Plugins
>
? Plugins
: never;
export type MyPluginsState = PluginStates<MyPlugins>; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi. How can I create a type that would have all of the plugins types in it? I want type safety in my
Toolbar
, but can't seem to get this working. I can't just create a type based ontypeof PluginStates
since I don't have any way to export it from the svelte component then. So how can I do it? Am I missing something?This what my
pluginSates
type looks like:And here's my component's
index.ts
:Instead of
AnyPlugins
I would like the approach from above.Beta Was this translation helpful? Give feedback.
All reactions