Skip to content

Typescript support #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
madeleineostoja opened this issue Mar 6, 2022 · 6 comments · Fixed by #107
Closed

Typescript support #89

madeleineostoja opened this issue Mar 6, 2022 · 6 comments · Fixed by #107

Comments

@madeleineostoja
Copy link

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

@thecodejack
Copy link
Owner

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.

@Tal500
Copy link
Contributor

Tal500 commented Jul 30, 2022

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.

@thecodejack
Copy link
Owner

@Tal500 feel free to look into that.

@thecodejack
Copy link
Owner

@Tal500 there is pending PR which you can takeover as well

#97

@arackaf
Copy link
Collaborator

arackaf commented Apr 6, 2024

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.

@tobiasBora
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants