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

DayPickerInput.onDayChange wrong type in TypeScript definition? #622

Closed
thomastvedt opened this Issue Feb 14, 2018 · 2 comments

Comments

2 participants
@thomastvedt

thomastvedt commented Feb 14, 2018

I'm trying out the DayPickerInput component in TypeScript, but I can't access the modifiers in the onDayChange event. Are the TypeScript typings wrong? Or am I missing something?

From the docs:
http://react-day-picker.js.org/api/DayPickerInput

onDayChange (day: Date, modifiers: Object) ⇒ void
Handler function called when the user types a valid day (according to the format prop) or when a day is clicked on the calendar. If the day is not valid, day and modifiers arguments will be undefined (useful to display validation warnings).

From /types/props.d.ts:
onDayChange?(e: React.FocusEvent<HTMLDivElement>): void;

Should this be instead:
onDayChange?(day: Date | undefined, modifiers: {} | undefined): void;
?

Is there a type for Modifiers btw?

If I try to do this:
<DayPickerInput onDayChange={this.handleDayChange} />

this works:
handleDayChange = (e: any) => { console.log('this works, e is date, not focusevent');}

this should work (?), but does not..:
handleDayChange = (day: Date, modifiers: {} | undefined) => { console.log('error');}

@gpbl gpbl added the src:TypeScript label Feb 23, 2018

@gpbl gpbl added this to the next patch milestone Feb 23, 2018

@gpbl gpbl removed this from the next patch milestone Feb 23, 2018

@gpbl gpbl closed this in 210f253 Feb 25, 2018

gpbl added a commit that referenced this issue Feb 25, 2018

@gpbl gpbl added this to the v7.1.0 milestone Mar 5, 2018

@gpbl

This comment has been minimized.

Owner

gpbl commented Mar 5, 2018

Published as v7.1.0.

@thomastvedt

This comment has been minimized.

thomastvedt commented Mar 19, 2018

Great! Thank you 🌹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment