react-date-range icon indicating copy to clipboard operation
react-date-range copied to clipboard

Support Typescript

Open Lizonchik opened this issue 7 years ago • 9 comments
trafficstars

Do you support this version for typescript?

Lizonchik avatar Nov 20 '18 13:11 Lizonchik

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

onionhammer avatar Mar 05 '20 16:03 onionhammer

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.

smajl avatar Mar 12 '20 19:03 smajl

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

futurify-ydang avatar Apr 06 '20 08:04 futurify-ydang

@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.

smajl avatar Apr 08 '20 09:04 smajl

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

lukas-sojka avatar May 27 '20 10:05 lukas-sojka

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 avatar Apr 06 '21 19:04 Therapychild

@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!

smajl avatar Apr 12 '21 14:04 smajl

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.

Therapychild avatar Apr 12 '21 15:04 Therapychild

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

philippe-solosegment avatar Jan 26 '22 20:01 philippe-solosegment