react-date-range
react-date-range copied to clipboard
Support Typescript
Do you support this version for typescript?
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
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.
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
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
@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.
Has somebody from authors considered creating PR in https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-date-range for current version?
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
@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!
Thank you very much. I have been using typescript for a year and use it everyday in my coding, just never came across this issue before. I’m happy to learn something new! Thank you! Jeremy
On Apr 12, 2021, at 7:48 AM, Jan Peša @.***> wrote:
@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!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Isn't this s stale issue? I think this can be marked as closed, no?