22import React , {
33 forwardRef ,
44 PureComponent ,
5- ReactNode ,
6- Ref ,
75 useContext ,
86 useImperativeHandle ,
97 useRef ,
108 useState ,
119} from 'react' ;
12- import { cls , Validator , ValidatorType , ValidatorError } from '@arco-design/mobile-utils' ;
13- import { Promise } from 'es6-promise' ;
10+ import type { ReactNode , Ref } from 'react' ;
11+ import { cls , Validator , ValidatorType } from '@arco-design/mobile-utils' ;
12+ import type { ValidatorError } from '@arco-design/mobile-utils' ;
13+ import { Promise as ES6Promise } from 'es6-promise' ;
1414import { FormItemContext } from './form-item-context' ;
1515import { GlobalContext } from '../context-provider' ;
16- import {
16+ import type {
1717 IFieldError ,
1818 FieldValue ,
1919 IFormItemInnerProps ,
2020 FormItemProps ,
2121 ValidateStatus ,
2222 FormItemRef ,
23- FormInternalComponentType ,
24- ValueChangeType ,
2523 IFormItemContext ,
2624} from './type' ;
25+ import { ValueChangeType , FormInternalComponentType } from './type' ;
2726import { getDefaultValueForInterComponent , getErrorAndWarnings , isFieldRequired } from './utils' ;
2827import { DefaultDatePickerLinkedContainer , DefaultPickerLinkedContainer } from './linked-container' ;
29- import { BasicInputProps } from '../input/props' ;
30- import { DatePickerProps } from '../date-picker/type' ;
31- import { PickerProps } from '../picker/type' ;
32- import { SwitchProps } from '../switch' ;
33- import { ImagePickerProps } from '../image-picker/type' ;
28+ import type { BasicInputProps } from '../input/props' ;
29+ import type { DatePickerProps } from '../date-picker/type' ;
30+ import type { PickerProps } from '../picker/type' ;
31+ import type { SwitchProps } from '../switch' ;
32+ import type { ImagePickerProps } from '../image-picker/type' ;
3433
3534interface IFormItemInnerState {
3635 validateStatus : ValidateStatus ;
@@ -133,7 +132,7 @@ class FormItemInner extends PureComponent<IFormItemInnerProps, IFormItemInnerSta
133132 if ( curRules ?. length && field ) {
134133 const fieldDom = this . props . getFormItemRef ( ) ;
135134 const fieldValidator = new Validator ( { [ field ] : curRules } , { validateMessages } ) ;
136- return new Promise ( resolve => {
135+ return new ES6Promise < IFieldError > ( resolve => {
137136 fieldValidator . validate (
138137 { [ field ] : value } ,
139138 ( errorsMap : Record < string , ValidatorError [ ] > ) => {
@@ -146,7 +145,7 @@ class FormItemInner extends PureComponent<IFormItemInnerProps, IFormItemInnerSta
146145 warnings,
147146 errorTypes,
148147 } ) ;
149- return resolve ( {
148+ resolve ( {
150149 errors : this . _errors ,
151150 warnings,
152151 value,
@@ -155,9 +154,15 @@ class FormItemInner extends PureComponent<IFormItemInnerProps, IFormItemInnerSta
155154 } ) ;
156155 } ,
157156 ) ;
158- } ) ;
157+ } ) as Promise < IFieldError > ;
159158 }
160- return Promise . resolve ( { errors : [ ] , warnings : [ ] , value, field, dom : null } ) ;
159+ return ES6Promise . resolve < IFieldError > ( {
160+ errors : [ ] ,
161+ warnings : [ ] ,
162+ value,
163+ field,
164+ dom : null ,
165+ } ) as Promise < IFieldError > ;
161166 } ;
162167
163168 setFieldData = ( value : FieldValue ) => {
0 commit comments