Skip to content

Commit

Permalink
fix Handler component typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dbssman committed Sep 14, 2023
1 parent a683a13 commit 6fb4ab6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
13 changes: 5 additions & 8 deletions src/ErrorMessage.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<template>
<template v-if="error">
<span>{{ error }}</span>
Expand All @@ -11,10 +10,10 @@ import { DeepReadonly, computed } from '@vue/runtime-core'
import { FormState, InjectionKey } from './types'
const props = defineProps<{
name:string;
formState?: DeepReadonly<FormState<Record<string,any>>>;
injectionKey?: InjectionKey;
}>();
name: string
formState?: DeepReadonly<FormState<Record<string, any>>>
injectionKey?: InjectionKey
}>()
const usableFormState = computed(() =>
props.formState
Expand All @@ -25,6 +24,4 @@ const usableFormState = computed(() =>
const error = computed(() => usableFormState.value?.errors[props.name])
</script>

<style scoped>
</style>
<style scoped></style>
10 changes: 5 additions & 5 deletions src/FormHandler.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<slot v-if="$slots['default']" v-bind="useFormHandler($props)"></slot>
<slot v-if="$slots['default']" v-bind="useFormHandler($props)"></slot>
</template>

<script setup lang="ts">
import { FormHandlerParams } from './types';
import {useFormHandler} from './useFormHandler'
import { FormHandlerParams } from './types'
import { useFormHandler } from './useFormHandler'
defineProps<FormHandlerParams<Record<string,any>>>()
</script>
defineProps<FormHandlerParams>()
</script>
5 changes: 4 additions & 1 deletion src/types/formHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export type SubmitValidation = (

export type InjectionKey = string | Symbol

export interface FormHandlerParams<TForm, TInitial> {
export interface FormHandlerParams<
TForm extends Record<string, any> = Record<string, any>,
TInitial extends Record<string, any> = Record<string, any>,
> {
/** Values to initialize the form */
initialValues?: ComputableUnion<TInitial>

Expand Down

0 comments on commit 6fb4ab6

Please sign in to comment.