Closed jst-r closed 1 year ago
No worries about the documentation site, there is no rush and I can take care of it gradually if you don't have time.
I was wondering if it was possible - later - to export generic T type from DataHandler ? (maybe it's not relevant); So that we can simplify the composition of the showcase components
From:
<script lang="ts">
type T = $$Generic<{ [key: string]: unknown }>
import type { DtatHandler } from '$lib/core'
export let handler: DataHandler<T>
</script>
to:
<script lang="ts">
import type { DtatHandler, T } from '$lib/core'
export let handler: DataHandler<T>
</script>
I'm not aware of any ways to do it like that. Howerer, we can create an instance of handler on the module level, and import in in the example.
Like
// index.ts or something else
export const handler = new DataHandler(myData);
// Component.svelte
<script lang="ts">
import { handler } from "./index"
Ok i get it thx. That's fine as it is then, the type declaration inside components make it more explicit
I don't get why you don't appear as a contributor. Did I miss a step?
This PR adds generic type parameters to the
datatables
svelte library.Changes are explained in some level of detail in the issue #31. I feel that picture below illustrates the idea pretty well.![image showing type errors](https://github.com/vincjo/datatables/assets/58705474/21db9c87-2614-4616-bf39-ef0da375ed30)
Probably the easiest way to get a feel for the new feature is to clone the fork,
npm install
, andnpm run dev
. The datatables tab maps to thesrc/routes/examples
. There you can see the autocomplete and static checks in action.src/lib/core/Context.ts
is a good starting point to look at the implementation as it references almost everything else. It also contains some general type definitions, which isn't ideal, but probably fine for now.I haven't updated the documentation yet, but I'll try to do it today.