File tree 2 files changed +21
-6
lines changed
2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,19 @@ This function takes an initial value and a yup schema.
3
3
This function returns ` Field ` object.
4
4
5
5
## Parameters
6
- The ` field() ` takes 3 parameters and 2 generic type parameters:
6
+ The ` field() ` takes 3 parameters and some generic type parameters:
7
7
8
8
``` typescript
9
- function field<T , U extends T = T >(
9
+ declare function field<T >(
10
10
value : T | Ref <T >,
11
11
schema ? : FieldSchema ,
12
12
validateOptions ? : ValidateOptions
13
- ): Field <T , T extends U ? T : U >;
13
+ ): Field <T , T >;
14
+ declare function field<T , U extends T >(
15
+ value : T | Ref <T >,
16
+ schema ? : FieldSchema ,
17
+ validateOptions ? : ValidateOptions
18
+ ): Field <T , U >;
14
19
```
15
20
16
21
### 1. ` value ` <Badge type =" danger " text =" Required " />
@@ -74,7 +79,7 @@ Since `validateSync()` is used internally, Async tests are not available.
74
79
### ` T ` <Badge type =" info " text =" Optional " />
75
80
- Pass the type of ` $value ` explicitly like ` ref<T>() ` .
76
81
77
- ### ` U ` <Badge type =" info " text =" Optional / Default: T " />
82
+ ### ` U ` <Badge type =" info " text =" Optional " />
78
83
- Pass the preferred type as the result of [ ` toObject() ` ] ( /api/toObject ) .
79
84
80
85
## Details of ` Field ` object
Original file line number Diff line number Diff line change @@ -210,11 +210,21 @@ export function defineForm<T extends Form>(form: T): T {
210
210
return form ;
211
211
}
212
212
213
- export function field < T , U extends T = T > (
213
+ export function field < T > (
214
214
value : T | Ref < T > ,
215
215
schema ?: FieldSchema ,
216
216
validateOptions ?: ValidateOptions
217
- ) : Field < T , T extends U ? T : U > {
217
+ ) : Field < T , T > ;
218
+ export function field < T , U extends T > (
219
+ value : T | Ref < T > ,
220
+ schema ?: FieldSchema ,
221
+ validateOptions ?: ValidateOptions
222
+ ) : Field < T , U > ;
223
+ export function field < T > (
224
+ value : T | Ref < T > ,
225
+ schema ?: FieldSchema ,
226
+ validateOptions ?: ValidateOptions
227
+ ) {
218
228
return new Field ( value , schema , validateOptions ) ;
219
229
}
220
230
You can’t perform that action at this time.
0 commit comments