svelte-file-dropzone
svelte-file-dropzone copied to clipboard
Typescript support
Thanks for the great library port! Would be really helpful to add types for typescript users as well, I imagine they could be ported pretty much straight from the react-dropzone typings here: https://github.com/react-dropzone/react-dropzone/blob/master/typings/react-dropzone.d.ts
I currently don't have enough bandwidth on doing same. PRs are welcome. You can put a reference of any other third party component which provides support. Will help someone to add support.
The correct Svelte way is to use SvelteKit Packaging for the whole library.
The directory "Examples" should be under routes (except helper component in a different folder).
The code to be exported and the main component Dropzone.svelte should be under the directory $lib.
If you use also <script lang="ts">, then SvelteKit could then export you library with .d.ts file support for the Svelte component. You Svelte component would also be compiled to a "Pure" JS Svelte component without typescript.
Notice that the exported library could be used also outside from SvelteKit itself, e.g. on REPL.
Can do it by myself and push this PR, just want your approval before because it changes the repository structure completely.
@Tal500 feel free to look into that.
@Tal500 there is pending PR which you can takeover as well
https://github.com/thecodejack/svelte-file-dropzone/pull/97
So typescript support is something that's already there. If your host TypeScript project uses TypeScript, it was already infering the attributes and types for almost all of the props in the dropzone component. That said, I've enabled ts in there, and added a typing for the one prop that wasn't inferrable (as far as I can tell) which is accept.
2.0.5 should have this, and I confirmed that accept now shows up as string | string[] | undefined as opposed to any? like it was before.
I can't find how to type the function:
async function handleFilesSelect(e: any) {
…
}
in <Dropzone on:drop={handleFilesSelect} /> as I would get errors if I remove the any, am I missing something?