Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Commit 6fb4ab6

Browse files
committed
fix Handler component typing
1 parent a683a13 commit 6fb4ab6

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/ErrorMessage.vue

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<template>
32
<template v-if="error">
43
<span>{{ error }}</span>
@@ -11,10 +10,10 @@ import { DeepReadonly, computed } from '@vue/runtime-core'
1110
import { FormState, InjectionKey } from './types'
1211
1312
const props = defineProps<{
14-
name:string;
15-
formState?: DeepReadonly<FormState<Record<string,any>>>;
16-
injectionKey?: InjectionKey;
17-
}>();
13+
name: string
14+
formState?: DeepReadonly<FormState<Record<string, any>>>
15+
injectionKey?: InjectionKey
16+
}>()
1817
1918
const usableFormState = computed(() =>
2019
props.formState
@@ -25,6 +24,4 @@ const usableFormState = computed(() =>
2524
const error = computed(() => usableFormState.value?.errors[props.name])
2625
</script>
2726

28-
<style scoped>
29-
30-
</style>
27+
<style scoped></style>

src/FormHandler.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
2-
<slot v-if="$slots['default']" v-bind="useFormHandler($props)"></slot>
2+
<slot v-if="$slots['default']" v-bind="useFormHandler($props)"></slot>
33
</template>
44

55
<script setup lang="ts">
6-
import { FormHandlerParams } from './types';
7-
import {useFormHandler} from './useFormHandler'
6+
import { FormHandlerParams } from './types'
7+
import { useFormHandler } from './useFormHandler'
88
9-
defineProps<FormHandlerParams<Record<string,any>>>()
10-
</script>
9+
defineProps<FormHandlerParams>()
10+
</script>

src/types/formHandler.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export type SubmitValidation = (
9797

9898
export type InjectionKey = string | Symbol
9999

100-
export interface FormHandlerParams<TForm, TInitial> {
100+
export interface FormHandlerParams<
101+
TForm extends Record<string, any> = Record<string, any>,
102+
TInitial extends Record<string, any> = Record<string, any>,
103+
> {
101104
/** Values to initialize the form */
102105
initialValues?: ComputableUnion<TInitial>
103106

0 commit comments

Comments
 (0)