Skip to content
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

How to use it in typescript? #33

Open
zhaoyi0113 opened this issue Apr 30, 2019 · 5 comments
Open

How to use it in typescript? #33

zhaoyi0113 opened this issue Apr 30, 2019 · 5 comments

Comments

@zhaoyi0113
Copy link

I get an error Could not find a declaration file for module 'react-dragula' when using react-dragula in typescript. Where can I find the type definition for this component?

@AntiMoron
Copy link

Would you support typescript if it's possible? @bevacqua

@AdrianMrn
Copy link

AdrianMrn commented Mar 3, 2020

Simply create an index.d.ts file and add these lines:

declare module 'react-dragula' {
    export default function(
        containers: Array<HTMLElement>,
        options: import('dragula').DragulaOptions
    ): import('dragula').Drake;
}

and run yarn add @types/dragula --dev or npm install @types/dragula --save-dev

@JoshMcCullough
Copy link

It'd be great if this was just included in the package!

@AdrianMrn
Copy link

AdrianMrn commented Aug 21, 2020

@JoshMcCullough your comment gave me the idea to add the type definition to the DefinitelyTyped repository. My PR just got merged: DefinitelyTyped/DefinitelyTyped#46828 (comment)

So now you can just run yarn add @types/react-dragula or npm install @types/react-dragula --save, and it should work 🎉

@JoshMcCullough
Copy link

@AdrianMrn Great, thanks!

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

No branches or pull requests

4 participants