Open History to see the last commit
1import * as React from 'react'
2import { assertType, it } from 'vitest'
3import { useForm } from '../src/index'
4β
5it('should type onSubmit properly', () => {
6 function Comp() {
7 const form = useForm({
8 defaultValues: {
9 firstName: 'test',
10 age: 84,
11 // as const is required here
12 } as const,
13 onSubmit({ value }) {
14 assertType<84>(value.age)
15 },
16 })
17 }
18})
19β
20it('should type a validator properly', () => {
21 function Comp() {
22 const form = useForm({
23 defaultValues: {
24 firstName: 'test',
25 age: 84,
26 // as const is required here
27 } as const,
28 validators: {
29 onChange({ value }) {
30 assertType<84>(value.age)
31 return undefined
32 },
33 },
34 })
35 }
36})