11import { mount } from 'enzyme' ;
22import { resetWarned } from 'rc-util/lib/warning' ;
33import React from 'react' ;
4+ import type { FormInstance } from '../src' ;
45import Form , { Field , useForm } from '../src' ;
56import { changeValue , getField , matchError } from './common' ;
67import InfoField , { Input } from './common/InfoField' ;
@@ -406,7 +407,7 @@ describe('Form.Basic', () => {
406407 </ div > ,
407408 ) ;
408409
409- expect ( wrapper . find ( '.anything' ) . props ( ) . light ) . toEqual ( 'bamboo' ) ;
410+ expect ( ( wrapper . find ( '.anything' ) . props ( ) as any ) . light ) . toEqual ( 'bamboo' ) ;
410411 } ) ;
411412
412413 describe ( 'shouldUpdate' , ( ) => {
@@ -514,7 +515,7 @@ describe('Form.Basic', () => {
514515
515516 it ( 'should trigger by setField' , ( ) => {
516517 const triggerUpdate = jest . fn ( ) ;
517- const formRef = React . createRef ( ) ;
518+ const formRef = React . createRef < FormInstance > ( ) ;
518519
519520 const wrapper = mount (
520521 < div >
@@ -632,6 +633,7 @@ describe('Form.Basic', () => {
632633 mount (
633634 < div >
634635 < Form >
636+ { /* @ts -ignore */ }
635637 < Field >
636638 < h1 key = "1" > Light</ h1 >
637639 < h2 key = "2" > Bamboo</ h2 >
@@ -706,7 +708,7 @@ describe('Form.Basic', () => {
706708 } ) ;
707709
708710 it ( 'should not crash when return value contains target field' , async ( ) => {
709- const CustomInput = ( { value, onChange } ) => {
711+ const CustomInput : React . FC < any > = ( { value, onChange } ) => {
710712 const onInputChange = e => {
711713 onChange ( {
712714 value : e . target . value ,
@@ -749,7 +751,7 @@ describe('Form.Basic', () => {
749751 autoComplete = "off"
750752 >
751753 < Form . List name = "users" >
752- { ( fields , { add , remove } ) => (
754+ { fields => (
753755 < >
754756 { fields . map ( ( { key, name, ...restField } ) => (
755757 < Field
@@ -774,13 +776,13 @@ describe('Form.Basic', () => {
774776 } ;
775777
776778 const wrapper = mount ( < Demo /> ) ;
777- expect ( wrapper . find ( 'input' ) . first ( ) . getDOMNode ( ) . value ) . toBe ( '11' ) ;
779+ expect ( wrapper . find ( 'input' ) . first ( ) . getDOMNode < HTMLInputElement > ( ) . value ) . toBe ( '11' ) ;
778780 wrapper . find ( '.reset-btn' ) . first ( ) . simulate ( 'click' ) ;
779781 expect ( wrapper . find ( 'input' ) . length ) . toBe ( 0 ) ;
780782 } ) ;
781783
782784 it ( 'setFieldsValue should work for multiple Select' , ( ) => {
783- const Select = ( { value, defaultValue } ) => {
785+ const Select : React . FC < any > = ( { value, defaultValue } ) => {
784786 return < div className = "select-div" > { ( value || defaultValue || [ ] ) . toString ( ) } </ div > ;
785787 } ;
786788
@@ -808,7 +810,7 @@ describe('Form.Basic', () => {
808810 it ( 'remount should not clear current value' , ( ) => {
809811 let refForm ;
810812
811- const Demo = ( { remount } ) => {
813+ const Demo : React . FC < any > = ( { remount } ) => {
812814 const [ form ] = Form . useForm ( ) ;
813815 refForm = form ;
814816
@@ -840,9 +842,9 @@ describe('Form.Basic', () => {
840842 } ) ;
841843
842844 it ( 'setFieldValue' , ( ) => {
843- const formRef = React . createRef ( ) ;
845+ const formRef = React . createRef < FormInstance > ( ) ;
844846
845- const Demo = ( ) => (
847+ const Demo : React . FC = ( ) => (
846848 < Form ref = { formRef } initialValues = { { list : [ 'bamboo' , 'little' , 'light' ] } } >
847849 < Form . List name = "list" >
848850 { fields =>
0 commit comments