From 5b1aa827d29ccaeb4af8e20685cb6a84febf655b Mon Sep 17 00:00:00 2001 From: carl-coolblue Date: Mon, 11 Feb 2019 15:49:05 +0100 Subject: [PATCH 1/3] pickaday: add explicit null types to match usage for setStartRange, setDate and setEndRange --- types/pikaday/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/pikaday/index.d.ts b/types/pikaday/index.d.ts index 3adb7fc340..5a956cc504 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. From 766ab98213db96519bf75ab941370b424bc90d2c Mon Sep 17 00:00:00 2001 From: carl-coolblue Date: Mon, 11 Feb 2019 15:59:24 +0100 Subject: [PATCH 2/3] pikaday: Add missing definition for clear --- types/pikaday/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/pikaday/index.d.ts b/types/pikaday/index.d.ts index 5a956cc504..5fc8d0f33e 100644 --- a/types/pikaday/index.d.ts +++ b/types/pikaday/index.d.ts @@ -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 From 01365d6d2f9b88db76e288c77a1a9ea72218cf43 Mon Sep 17 00:00:00 2001 From: carl-coolblue Date: Fri, 15 Feb 2019 08:33:58 +0100 Subject: [PATCH 3/3] pikaday: Add tests for updated typings of setStartRange, setDate, setEndRange and clear --- types/pikaday/pikaday-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) 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(); })();