@@ -76,8 +76,8 @@ export type RuleObject = BaseRule | ArrayRule;
76
76
77
77
export type Rule = RuleObject | RuleRender ;
78
78
79
- export interface ValidateErrorEntity {
80
- values : Store ;
79
+ export interface ValidateErrorEntity < Values = any > {
80
+ values : Values ;
81
81
errorFields : { name : InternalNamePath ; errors : string [ ] } [ ] ;
82
82
outOfDate : boolean ;
83
83
}
@@ -159,11 +159,11 @@ export type ValuedNotifyInfo = NotifyInfo & {
159
159
store : Store ;
160
160
} ;
161
161
162
- export interface Callbacks {
163
- onValuesChange ?: ( changedValues : Store , values : Store ) => void ;
162
+ export interface Callbacks < Values = any > {
163
+ onValuesChange ?: ( changedValues : any , values : Values ) => void ;
164
164
onFieldsChange ?: ( changedFields : FieldData [ ] , allFields : FieldData [ ] ) => void ;
165
- onFinish ?: ( values : Store ) => void ;
166
- onFinishFailed ?: ( errorInfo : ValidateErrorEntity ) => void ;
165
+ onFinish ?: ( values : Values ) => void ;
166
+ onFinishFailed ?: ( errorInfo : ValidateErrorEntity < Values > ) => void ;
167
167
}
168
168
169
169
export interface InternalHooks {
@@ -177,10 +177,20 @@ export interface InternalHooks {
177
177
setPreserve : ( preserve ?: boolean ) => void ;
178
178
}
179
179
180
- export interface FormInstance {
180
+ /** Only return partial when type is not any */
181
+ type RecursivePartial < T > = T extends object
182
+ ? {
183
+ [ P in keyof T ] ?: RecursivePartial < T [ P ] > ;
184
+ }
185
+ : any ;
186
+
187
+ export interface FormInstance < Values = any > {
181
188
// Origin Form API
182
189
getFieldValue : ( name : NamePath ) => StoreValue ;
183
- getFieldsValue : ( nameList ?: NamePath [ ] | true , filterFunc ?: ( meta : Meta ) => boolean ) => Store ;
190
+ getFieldsValue : (
191
+ nameList ?: NamePath [ ] | true ,
192
+ filterFunc ?: ( meta : Meta ) => boolean ,
193
+ ) => Values | any ;
184
194
getFieldError : ( name : NamePath ) => string [ ] ;
185
195
getFieldsError : ( nameList ?: NamePath [ ] ) => FieldError [ ] ;
186
196
isFieldsTouched ( nameList ?: NamePath [ ] , allFieldsTouched ?: boolean ) : boolean ;
@@ -190,7 +200,7 @@ export interface FormInstance {
190
200
isFieldsValidating : ( nameList : NamePath [ ] ) => boolean ;
191
201
resetFields : ( fields ?: NamePath [ ] ) => void ;
192
202
setFields : ( fields : FieldData [ ] ) => void ;
193
- setFieldsValue : ( value : Store ) => void ;
203
+ setFieldsValue : ( value : RecursivePartial < Values > ) => void ;
194
204
validateFields : ValidateFields ;
195
205
196
206
// New API
0 commit comments