Skip to content

Commit

Permalink
chore: add more type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn committed Jan 9, 2025
1 parent 677c5a9 commit 016c9e3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/form-core/tests/FieldApi.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,38 @@ it('should have the correct types returned from field validators', () => {

assertType<'123' | undefined>(field.state.meta.errorMap.onChange)
})

it('should have the correct types returned from field validators in array', () => {
const form = new FormApi({
defaultValues: {
name: 'test',
},
} as const)

const field = new FieldApi({
form,
name: 'name',
validators: {
onChange: () => {
return '123' as const
},
},
})

assertType<Array<'123' | undefined>>(field.state.meta.errors)
})

it('should have the correct types returned from form validators in array', () => {
const form = new FormApi({
defaultValues: {
name: 'test',
},
validators: {
onChange: () => {
return '123' as const
},
},
} as const)

assertType<Array<'123' | undefined>>(form.state.errors)
})

0 comments on commit 016c9e3

Please sign in to comment.