@@ -240,12 +240,15 @@ export function defineSlots<
240
240
return null as any
241
241
}
242
242
243
- export type ModelRef < T , M extends PropertyKey = string > = Ref < T > &
244
- [ ModelRef < T , M > , Record < M , true | undefined > ]
243
+ export type ModelRef < T , M extends PropertyKey = string , G = T , S = T > = Ref <
244
+ G ,
245
+ S
246
+ > &
247
+ [ ModelRef < T , M , G , S > , Record < M , true | undefined > ]
245
248
246
- export type DefineModelOptions < T = any > = {
247
- get ?: ( v : T ) => any
248
- set ?: ( v : T ) => any
249
+ export type DefineModelOptions < T = any , G = T , S = T > = {
250
+ get ?: ( v : T ) => G
251
+ set ?: ( v : S ) => any
249
252
}
250
253
251
254
/**
@@ -281,27 +284,28 @@ export type DefineModelOptions<T = any> = {
281
284
* const count = defineModel<number>('count', { default: 0 })
282
285
* ```
283
286
*/
284
- export function defineModel < T , M extends PropertyKey = string > (
285
- options : { required : true } & PropOptions < T > & DefineModelOptions < T > ,
286
- ) : ModelRef < T , M >
287
- export function defineModel < T , M extends PropertyKey = string > (
288
- options : { default : any } & PropOptions < T > & DefineModelOptions < T > ,
289
- ) : ModelRef < T , M >
290
- export function defineModel < T , M extends PropertyKey = string > (
291
- options ?: PropOptions < T > & DefineModelOptions < T > ,
292
- ) : ModelRef < T | undefined , M >
293
- export function defineModel < T , M extends PropertyKey = string > (
294
- name : string ,
295
- options : { required : true } & PropOptions < T > & DefineModelOptions < T > ,
296
- ) : ModelRef < T , M >
297
- export function defineModel < T , M extends PropertyKey = string > (
287
+ export function defineModel < T , M extends PropertyKey = string , G = T , S = T > (
288
+ options : ( { default : any } | { required : true } ) &
289
+ PropOptions < T > &
290
+ DefineModelOptions < T , G , S > ,
291
+ ) : ModelRef < T , M , G , S >
292
+
293
+ export function defineModel < T , M extends PropertyKey = string , G = T , S = T > (
294
+ options ?: PropOptions < T > & DefineModelOptions < T , G , S > ,
295
+ ) : ModelRef < T | undefined , M , G | undefined , S | undefined >
296
+
297
+ export function defineModel < T , M extends PropertyKey = string , G = T , S = T > (
298
298
name : string ,
299
- options : { default : any } & PropOptions < T > & DefineModelOptions < T > ,
300
- ) : ModelRef < T , M >
301
- export function defineModel < T , M extends PropertyKey = string > (
299
+ options : ( { default : any } | { required : true } ) &
300
+ PropOptions < T > &
301
+ DefineModelOptions < T , G , S > ,
302
+ ) : ModelRef < T , M , G , S >
303
+
304
+ export function defineModel < T , M extends PropertyKey = string , G = T , S = T > (
302
305
name : string ,
303
- options ?: PropOptions < T > & DefineModelOptions < T > ,
304
- ) : ModelRef < T | undefined , M >
306
+ options ?: PropOptions < T > & DefineModelOptions < T , G , S > ,
307
+ ) : ModelRef < T | undefined , M , G | undefined , S | undefined >
308
+
305
309
export function defineModel ( ) : any {
306
310
if ( __DEV__ ) {
307
311
warnRuntimeUsage ( 'defineModel' )
0 commit comments