mskocik / svelecte

Flexible autocomplete/select component written in Svelte,
https://svelecte.vercel.app
MIT License
469 stars 42 forks source link

type errors in options #167

Closed kewp closed 8 months ago

kewp commented 1 year ago

i'm getting type errors when using svelecte with typescript (in sveltekit):

<Svelecte 
    renderer='color-blocks'
</Svelecte>
Type 'string' is not assignable to type 'null | undefined'.ts(2322)
(property) renderer?: null | undefined
mskocik commented 1 year ago

Can you provide PR with fix?

On 11. 5. 2023 8:51, kewp wrote:

i'm getting type errors when using svelecte with typescript (in sveltekit):

<Svelecte
renderer='color-blocks' |Type 'string' is not assignable to type 'null | undefined'.ts(2322) (property) renderer?: null | undefined |

— Reply to this email directly, view it on GitHub https://github.com/mskocik/svelecte/issues/167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCU5FALSOLTZA6JHFVPXETXFSEAPANCNFSM6AAAAAAX5VH6JI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

kewp commented 1 year ago

I'm just getting started with typescript. Not sure how you make a library that works with typescript and without. Normally I start by putting lang='ts' at the top of my svelte files and then annotate everything like let renderer: string | null.

kewp commented 1 year ago

Struggling to get a hard link but if you go to Select.svelte.d.ts here you'll see how this library does it - should work with both normal JS imports and with typescript https://www.npmjs.com/package/svelte-select?activeTab=code

mskocik commented 1 year ago

I know these types can be generated from svelte-kit package command. But that's the thing, I would need to refactor the whole codebase to svelte-kit project. Which is scheduled for v4 with better docs etc. but I have no time for it now.

On 11. 5. 2023 10:25, kewp wrote:

Struggling to get a hard link but if you go to |Select.svelte.d.ts| here you'll see how this library does it - should work with both normal JS imports and with typescript https://www.npmjs.com/package/svelte-select?activeTab=code

— Reply to this email directly, view it on GitHub https://github.com/mskocik/svelecte/issues/167#issuecomment-1543559259, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCU5FHNT4TGY2Q7GHLHCJ3XFSO6TANCNFSM6AAAAAAX5VH6JI. You are receiving this because you commented.Message ID: @.***>

kewp commented 1 year ago

Don't you just need that one file i.e. Svelecte.d.ts ?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 3 days.