diff --git a/types/pikaday/index.d.ts b/types/pikaday/index.d.ts index fad074ae33..2233fa9b4c 100644 --- a/types/pikaday/index.d.ts +++ b/types/pikaday/index.d.ts @@ -44,7 +44,7 @@ declare class Pikaday { * can optionally be passed as the second parameter to prevent triggering * of the onSelect callback, allowing the date to be set silently. */ - setDate(date: string | Date, preventOnSelect?: boolean): void; + setDate(date: string | Date | null, preventOnSelect?: boolean): void; /** * Returns a Moment.js object for the selected date (Moment must be @@ -101,13 +101,13 @@ declare class Pikaday { * Update the range start date. For using two Pikaday instances to * select a date range. */ - setStartRange(date: Date): void; + setStartRange(date: Date | null): void; /** * Update the range end date. For using two Pikaday instances to select * a date range. */ - setEndRange(date: Date): void; + setEndRange(date: Date | null): void; /** * Update the HTML. @@ -138,6 +138,11 @@ declare class Pikaday { * Hide the picker and remove all event listeners - no going back! */ destroy(): void; + + /** + * Clear and reset the date + */ + clear(): void; } // merge the Pikaday class declaration with a module diff --git a/types/pikaday/pikaday-tests.ts b/types/pikaday/pikaday-tests.ts index 7a532efb6f..230104daf7 100644 --- a/types/pikaday/pikaday-tests.ts +++ b/types/pikaday/pikaday-tests.ts @@ -31,6 +31,8 @@ new Pikaday({field: $('#datepicker')[0]}); picker.getDate(); picker.setDate('2015-01-01'); picker.setDate('2015-01-01', true); + picker.setDate(null); + picker.setDate(null, true); picker.getMoment(); picker.setMoment(moment('14th February 2014', 'DDo MMMM YYYY')); picker.setMoment(moment('14th February 2014', 'DDo MMMM YYYY'), true); @@ -45,11 +47,14 @@ new Pikaday({field: $('#datepicker')[0]}); picker.setMinDate(null); picker.setMaxDate(null); picker.setStartRange(new Date()); + picker.setStartRange(null); picker.setEndRange(new Date()); + picker.setEndRange(null); picker.isVisible(); picker.show(); picker.adjustPosition(); picker.hide(); + picker.clear(); picker.destroy(); })();