|
@@ -240,12 +240,15 @@ export function defineSlots<
|
|
|
return null as any
|
|
return null as any
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export type ModelRef<T, M extends PropertyKey = string> = Ref<T> &
|
|
|
|
|
- [ModelRef<T, M>, Record<M, true | undefined>]
|
|
|
|
|
|
|
+export type ModelRef<T, M extends PropertyKey = string, G = T, S = T> = Ref<
|
|
|
|
|
+ G,
|
|
|
|
|
+ S
|
|
|
|
|
+> &
|
|
|
|
|
+ [ModelRef<T, M, G, S>, Record<M, true | undefined>]
|
|
|
|
|
|
|
|
-export type DefineModelOptions<T = any> = {
|
|
|
|
|
- get?: (v: T) => any
|
|
|
|
|
- set?: (v: T) => any
|
|
|
|
|
|
|
+export type DefineModelOptions<T = any, G = T, S = T> = {
|
|
|
|
|
+ get?: (v: T) => G
|
|
|
|
|
+ set?: (v: S) => any
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -281,27 +284,28 @@ export type DefineModelOptions<T = any> = {
|
|
|
* const count = defineModel<number>('count', { default: 0 })
|
|
* const count = defineModel<number>('count', { default: 0 })
|
|
|
* ```
|
|
* ```
|
|
|
*/
|
|
*/
|
|
|
-export function defineModel<T, M extends PropertyKey = string>(
|
|
|
|
|
- options: { required: true } & PropOptions<T> & DefineModelOptions<T>,
|
|
|
|
|
-): ModelRef<T, M>
|
|
|
|
|
-export function defineModel<T, M extends PropertyKey = string>(
|
|
|
|
|
- options: { default: any } & PropOptions<T> & DefineModelOptions<T>,
|
|
|
|
|
-): ModelRef<T, M>
|
|
|
|
|
-export function defineModel<T, M extends PropertyKey = string>(
|
|
|
|
|
- options?: PropOptions<T> & DefineModelOptions<T>,
|
|
|
|
|
-): ModelRef<T | undefined, M>
|
|
|
|
|
-export function defineModel<T, M extends PropertyKey = string>(
|
|
|
|
|
- name: string,
|
|
|
|
|
- options: { required: true } & PropOptions<T> & DefineModelOptions<T>,
|
|
|
|
|
-): ModelRef<T, M>
|
|
|
|
|
-export function defineModel<T, M extends PropertyKey = string>(
|
|
|
|
|
|
|
+export function defineModel<T, M extends PropertyKey = string, G = T, S = T>(
|
|
|
|
|
+ options: ({ default: any } | { required: true }) &
|
|
|
|
|
+ PropOptions<T> &
|
|
|
|
|
+ DefineModelOptions<T, G, S>,
|
|
|
|
|
+): ModelRef<T, M, G, S>
|
|
|
|
|
+
|
|
|
|
|
+export function defineModel<T, M extends PropertyKey = string, G = T, S = T>(
|
|
|
|
|
+ options?: PropOptions<T> & DefineModelOptions<T, G, S>,
|
|
|
|
|
+): ModelRef<T | undefined, M, G | undefined, S | undefined>
|
|
|
|
|
+
|
|
|
|
|
+export function defineModel<T, M extends PropertyKey = string, G = T, S = T>(
|
|
|
name: string,
|
|
name: string,
|
|
|
- options: { default: any } & PropOptions<T> & DefineModelOptions<T>,
|
|
|
|
|
-): ModelRef<T, M>
|
|
|
|
|
-export function defineModel<T, M extends PropertyKey = string>(
|
|
|
|
|
|
|
+ options: ({ default: any } | { required: true }) &
|
|
|
|
|
+ PropOptions<T> &
|
|
|
|
|
+ DefineModelOptions<T, G, S>,
|
|
|
|
|
+): ModelRef<T, M, G, S>
|
|
|
|
|
+
|
|
|
|
|
+export function defineModel<T, M extends PropertyKey = string, G = T, S = T>(
|
|
|
name: string,
|
|
name: string,
|
|
|
- options?: PropOptions<T> & DefineModelOptions<T>,
|
|
|
|
|
-): ModelRef<T | undefined, M>
|
|
|
|
|
|
|
+ options?: PropOptions<T> & DefineModelOptions<T, G, S>,
|
|
|
|
|
+): ModelRef<T | undefined, M, G | undefined, S | undefined>
|
|
|
|
|
+
|
|
|
export function defineModel(): any {
|
|
export function defineModel(): any {
|
|
|
if (__DEV__) {
|
|
if (__DEV__) {
|
|
|
warnRuntimeUsage('defineModel')
|
|
warnRuntimeUsage('defineModel')
|