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

Support Typescript #260

Open
Lizonchik opened this issue Nov 20, 2018 · 9 comments
Open

Support Typescript #260

Lizonchik opened this issue Nov 20, 2018 · 9 comments

Comments

@Lizonchik
Copy link

Do you support this version for typescript?

@onionhammer
Copy link
Collaborator

There is a @types/react-date-range package, but there have been a lot of type changes since it was last update 9 months ago

@smajl
Copy link

smajl commented Mar 12, 2020

Just a heads-up. Do NOT install @types/react-date-range 0.x for the latest 1.x version of this lib. They are heavily out of sync. Use classic declare module 'react-date-range; as a temp solution.

@futurify-ydang
Copy link

declare module 'react-date-range;

Hi @smajl I just use the declare module 'react-date-range'; for types. I also want to use locale module so I put another declare in types.d.ts like this
image
But React throw an error that there is no module react-date-range/locale/vi.
How can i resolve it? Please give me an advice.
Thanks

@smajl
Copy link

smajl commented Apr 8, 2020

@futurify-ydang Maybe because there is no such file as react-date-range/locale/vi? You have two options, either use:

declare module 'react-date-range/dist/locale'; // the correct path
import { vi } from 'react-date-range/dist/locale';

or import directly from date-fns

import vi from 'date-fns/locale/vi';
// or
import { vi } from 'date-fns/locale';

and then pass it into locale property.

@lukas-sojka
Copy link

Has somebody from authors considered creating PR in https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-date-range for current version?

@Therapychild
Copy link

Therapychild commented Apr 6, 2021

I'm newish it Typescript. I use it when writing JavaScript, but don't know a lot about manipulating d.ts files. Could you please be more specific as to where I use the "declare module 'react-date-range'" line of code? Or at least point me in the direction or where I can read about it? I have searched online, searched my node-modules folder for an example, but I can't find any that looks like it will do what I need. Any help is greatly appreciated.

BTW, I LOVE this module. Thank you so much for all the hard work, and maybe I can help out in some way in the near future!

Jeremy Antoine

@smajl
Copy link

smajl commented Apr 12, 2021

@Therapychild Hi Jeremy, all you need is e.g. here: https://github.com/typescript-cheatsheets/react#the-types-i-need-dont-exist
And the rest of that cheatsheet should be also very helpful, I recommend you read it. Enjoy coding!

@Therapychild
Copy link

Therapychild commented Apr 12, 2021 via email

@philippe-solosegment
Copy link

philippe-solosegment commented Jan 26, 2022

Isn't this s stale issue? I think this can be marked as closed, no?

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

7 participants