From 363bed40a93d8c8a3b0b79a1040736da3f9d618b Mon Sep 17 00:00:00 2001 From: Nathan Reyes Date: Tue, 31 Jan 2023 11:49:43 -0600 Subject: [PATCH] Fix input value types --- src/use/datePicker.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/use/datePicker.ts b/src/use/datePicker.ts index 463855145..99c464816 100644 --- a/src/use/datePicker.ts +++ b/src/use/datePicker.ts @@ -52,6 +52,7 @@ const contextKey = '__vc_date_picker_context__'; export type DateModes = 'date' | 'datetime' | 'time'; export type ValueTarget = 'none' | 'start' | 'end' | 'both'; +export type InputValueTarget = 'start' | 'end'; export interface UpdateOptions { config: any; @@ -237,7 +238,7 @@ export function createDatePicker( }); const inputEvents = computed(() => { - const events = (['start', 'end']).map(target => ({ + const events = (['start', 'end'] as const).map(target => ({ input: onInputInput(target), change: onInputChange(target), keyup: onInputKeyup, @@ -542,7 +543,7 @@ export function createDatePicker( function onInputUpdate( inputValue: string, - target: ValueTarget, + target: InputValueTarget, opts: Partial, ) { inputValues.value.splice(target === 'start' ? 0 : 1, 1, inputValue); @@ -565,7 +566,7 @@ export function createDatePicker( }); } - function onInputInput(target: ValueTarget) { + function onInputInput(target: InputValueTarget) { return (e: InputEvent) => { if (!props.updateOnInput) return; onInputUpdate((e.currentTarget).value, target, { @@ -576,7 +577,7 @@ export function createDatePicker( }; } - function onInputChange(target: ValueTarget) { + function onInputChange(target: InputValueTarget) { return (e: InputEvent) => { onInputUpdate((e.currentTarget).value, target, { formatInput: true,