Skip to content

Commit

Permalink
Fixed types for vue and svelte as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Verox001 committed Feb 1, 2025
1 parent a0adb50 commit ac52082
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/svelte/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface InertiaFormProps<TForm extends FormDataType> {
reset(...fields: (keyof TForm)[]): this
clearErrors(...fields: (keyof TForm)[]): this
setError(field: keyof TForm, value: string): this
setError(errors: Errors): this
setError(errors: Partial<Errors>): this
submit(method: Method, url: string, options?: FormOptions): void
get(url: string, options?: FormOptions): void
post(url: string, options?: FormOptions): void
Expand Down Expand Up @@ -120,10 +120,10 @@ export default function useForm<TForm extends FormDataType>(

return this
},
setError(fieldOrFields: keyof TForm | Errors, maybeValue?: string) {
setError(fieldOrFields: keyof TForm | Partial<Errors>, maybeValue?: string) {
this.setStore('errors', {
...this.errors,
...((typeof fieldOrFields === 'string' ? { [fieldOrFields]: maybeValue } : fieldOrFields) as Errors),
...((typeof fieldOrFields === 'string' ? { [fieldOrFields]: maybeValue } : fieldOrFields) as Partial<Errors>),
})

return this
Expand Down
4 changes: 2 additions & 2 deletions packages/vue3/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface InertiaFormProps<TForm extends FormDataType> {
reset(...fields: (keyof TForm)[]): this
clearErrors(...fields: (keyof TForm)[]): this
setError(field: keyof TForm, value: string): this
setError(errors: Record<keyof TForm, string>): this
setError(errors: Partial<Record<keyof TForm, string>>): this
submit(method: Method, url: string, options?: FormOptions): void
get(url: string, options?: FormOptions): void
post(url: string, options?: FormOptions): void
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function useForm<TForm extends FormDataType>(

return this
},
setError(fieldOrFields: keyof TForm | Record<keyof TForm, string>, maybeValue?: string) {
setError(fieldOrFields: keyof TForm | Partial<Record<keyof TForm, string>>, maybeValue?: string) {
Object.assign(this.errors, typeof fieldOrFields === 'string' ? { [fieldOrFields]: maybeValue } : fieldOrFields)

this.hasErrors = Object.keys(this.errors).length > 0
Expand Down

0 comments on commit ac52082

Please sign in to comment.