@vue/runtime-core 3.3.0-alpha.8 → 3.3.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,7 +95,7 @@ type EmitFn<Options = ObjectEmitsOptions, Event extends keyof Options = keyof Op
95
95
  export interface ComponentCustomProperties {
96
96
  }
97
97
  type IsDefaultMixinComponent<T> = T extends ComponentOptionsMixin ? ComponentOptionsMixin extends T ? true : false : false;
98
- type MixinToOptionTypes<T> = T extends ComponentOptionsBase<infer P, infer B, infer D, infer C, infer M, infer Mixin, infer Extends, any, any, any, infer Defaults> ? OptionTypesType<P & {}, B & {}, D & {}, C & {}, M & {}, Defaults & {}> & IntersectionMixin<Mixin> & IntersectionMixin<Extends> : never;
98
+ type MixinToOptionTypes<T> = T extends ComponentOptionsBase<infer P, infer B, infer D, infer C, infer M, infer Mixin, infer Extends, any, any, infer Defaults, any, any, any> ? OptionTypesType<P & {}, B & {}, D & {}, C & {}, M & {}, Defaults & {}> & IntersectionMixin<Mixin> & IntersectionMixin<Extends> : never;
99
99
  type ExtractMixin<T> = {
100
100
  Mixin: MixinToOptionTypes<T>;
101
101
  }[T extends ComponentOptionsMixin ? 'Mixin' : never];
@@ -108,11 +108,11 @@ type ComponentPublicInstanceConstructor<T extends ComponentPublicInstance<Props,
108
108
  __isSuspense?: never;
109
109
  new (...args: any[]): T;
110
110
  };
111
- export type CreateComponentPublicInstance<P = {}, B = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, S extends SlotsType = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, I extends ComponentInjectOptions = {}, PublicMixin = IntersectionMixin<Mixin> & IntersectionMixin<Extends>, PublicP = UnwrapMixinsType<PublicMixin, 'P'> & EnsureNonVoid<P>, PublicB = UnwrapMixinsType<PublicMixin, 'B'> & EnsureNonVoid<B>, PublicD = UnwrapMixinsType<PublicMixin, 'D'> & EnsureNonVoid<D>, PublicC extends ComputedOptions = UnwrapMixinsType<PublicMixin, 'C'> & EnsureNonVoid<C>, PublicM extends MethodOptions = UnwrapMixinsType<PublicMixin, 'M'> & EnsureNonVoid<M>, PublicDefaults = UnwrapMixinsType<PublicMixin, 'Defaults'> & EnsureNonVoid<Defaults>> = ComponentPublicInstance<PublicP, PublicB, PublicD, PublicC, PublicM, E, S, PublicProps, PublicDefaults, MakeDefaultsOptional, ComponentOptionsBase<P, B, D, C, M, Mixin, Extends, E, string, S, Defaults>, I>;
111
+ export type CreateComponentPublicInstance<P = {}, B = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, I extends ComponentInjectOptions = {}, S extends SlotsType = {}, PublicMixin = IntersectionMixin<Mixin> & IntersectionMixin<Extends>, PublicP = UnwrapMixinsType<PublicMixin, 'P'> & EnsureNonVoid<P>, PublicB = UnwrapMixinsType<PublicMixin, 'B'> & EnsureNonVoid<B>, PublicD = UnwrapMixinsType<PublicMixin, 'D'> & EnsureNonVoid<D>, PublicC extends ComputedOptions = UnwrapMixinsType<PublicMixin, 'C'> & EnsureNonVoid<C>, PublicM extends MethodOptions = UnwrapMixinsType<PublicMixin, 'M'> & EnsureNonVoid<M>, PublicDefaults = UnwrapMixinsType<PublicMixin, 'Defaults'> & EnsureNonVoid<Defaults>> = ComponentPublicInstance<PublicP, PublicB, PublicD, PublicC, PublicM, E, PublicProps, PublicDefaults, MakeDefaultsOptional, ComponentOptionsBase<P, B, D, C, M, Mixin, Extends, E, string, Defaults, {}, string, S>, I, S>;
112
112
  export type ComponentPublicInstance<P = {}, // props type extracted from props option
113
113
  B = {}, // raw bindings returned from setup()
114
114
  D = {}, // return from data()
115
- C extends ComputedOptions = {}, M extends MethodOptions = {}, E extends EmitsOptions = {}, S extends SlotsType = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>, I extends ComponentInjectOptions = {}> = {
115
+ C extends ComputedOptions = {}, M extends MethodOptions = {}, E extends EmitsOptions = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>, I extends ComponentInjectOptions = {}, S extends SlotsType = {}> = {
116
116
  $: ComponentInternalInstance;
117
117
  $data: D;
118
118
  $props: Prettify<MakeDefaultsOptional extends true ? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults> : P & PublicProps>;
@@ -507,7 +507,7 @@ declare function checkCompatEnabled(key: DeprecationTypes, instance: ComponentIn
507
507
  export interface ComponentCustomOptions {
508
508
  }
509
509
  export type RenderFunction = () => VNodeChild;
510
- export interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string, S extends SlotsType = {}, Defaults = {}, I extends ComponentInjectOptions = {}, II extends string = string> extends LegacyOptions<Props, D, C, M, Mixin, Extends, I, II>, ComponentInternalOptions, ComponentCustomOptions {
510
+ export interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string, Defaults = {}, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}> extends LegacyOptions<Props, D, C, M, Mixin, Extends, I, II>, ComponentInternalOptions, ComponentCustomOptions {
511
511
  setup?: (this: void, props: LooseRequired<Props & Prettify<UnwrapMixinsType<IntersectionMixin<Mixin> & IntersectionMixin<Extends>, 'P'>>>, ctx: SetupContext<E, S>) => Promise<RawBindings> | RawBindings | RenderFunction | void;
512
512
  name?: string;
513
513
  template?: string | object;
@@ -539,17 +539,17 @@ export interface RuntimeCompilerOptions {
539
539
  comments?: boolean;
540
540
  delimiters?: [string, string];
541
541
  }
542
- export type ComponentOptionsWithoutProps<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string, PE = Props & EmitsToProps<E>> = ComponentOptionsBase<PE, RawBindings, D, C, M, Mixin, Extends, E, EE, S, {}, I, II> & {
542
+ export type ComponentOptionsWithoutProps<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, PE = Props & EmitsToProps<E>> = ComponentOptionsBase<PE, RawBindings, D, C, M, Mixin, Extends, E, EE, {}, I, II, S> & {
543
543
  props?: undefined;
544
- } & ThisType<CreateComponentPublicInstance<PE, RawBindings, D, C, M, Mixin, Extends, E, S, PE, {}, false, I>>;
545
- export type ComponentOptionsWithArrayProps<PropNames extends string = string, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string, Props = Prettify<Readonly<{
544
+ } & ThisType<CreateComponentPublicInstance<PE, RawBindings, D, C, M, Mixin, Extends, E, PE, {}, false, I, S>>;
545
+ export type ComponentOptionsWithArrayProps<PropNames extends string = string, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, Props = Prettify<Readonly<{
546
546
  [key in PropNames]?: any;
547
- } & EmitsToProps<E>>>> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, S, {}, I, II> & {
547
+ } & EmitsToProps<E>>>> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, {}, I, II, S> & {
548
548
  props: PropNames[];
549
- } & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, S, Props, {}, false, I>>;
550
- export type ComponentOptionsWithObjectProps<PropsOptions = ComponentObjectPropsOptions, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string, Props = Prettify<Readonly<ExtractPropTypes<PropsOptions> & EmitsToProps<E>>>, Defaults = ExtractDefaultPropTypes<PropsOptions>> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, S, Defaults, I, II> & {
549
+ } & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, Props, {}, false, I, S>>;
550
+ export type ComponentOptionsWithObjectProps<PropsOptions = ComponentObjectPropsOptions, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, Props = Prettify<Readonly<ExtractPropTypes<PropsOptions> & EmitsToProps<E>>>, Defaults = ExtractDefaultPropTypes<PropsOptions>> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, Defaults, I, II, S> & {
551
551
  props: PropsOptions & ThisType<void>;
552
- } & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, S, Props, Defaults, false, I>>;
552
+ } & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, Props, Defaults, false, I, S>>;
553
553
  export type ComponentOptions<Props = {}, RawBindings = any, D = any, C extends ComputedOptions = any, M extends MethodOptions = any, Mixin extends ComponentOptionsMixin = any, Extends extends ComponentOptionsMixin = any, E extends EmitsOptions = any, S extends SlotsType = any> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, string, S> & ThisType<CreateComponentPublicInstance<{}, RawBindings, D, C, M, Mixin, Extends, E, Readonly<Props>>>;
554
554
  export type ComponentOptionsMixin = ComponentOptionsBase<any, any, any, any, any, any, any, any, any, any, any>;
555
555
  export type ComputedOptions = Record<string, ComputedGetter<any> | WritableComputedOptions<any>>;
@@ -674,6 +674,13 @@ export interface App<HostElement = any> {
674
674
  mount(rootContainer: HostElement | string, isHydrate?: boolean, isSVG?: boolean): ComponentPublicInstance;
675
675
  unmount(): void;
676
676
  provide<T>(key: InjectionKey<T> | string, value: T): this;
677
+ /**
678
+ * Runs a function with the app as active instance. This allows using of `inject()` within the function to get access
679
+ * to variables provided via `app.provide()`.
680
+ *
681
+ * @param fn - function to run with the app as active instance
682
+ */
683
+ runWithContext<T>(fn: () => T): T;
677
684
  _uid: number;
678
685
  _component: ConcreteComponent;
679
686
  _props: Data | null;
@@ -1166,7 +1173,8 @@ export declare function watch<T, Immediate extends Readonly<boolean> = false>(so
1166
1173
  export declare function watch<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle;
1167
1174
 
1168
1175
  type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps;
1169
- export type DefineComponent<PropsOrPropOptions = {}, RawBindings = {}, D = {}, C extends ComputedOptions = ComputedOptions, M extends MethodOptions = MethodOptions, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, PP = PublicProps, Props = Readonly<PropsOrPropOptions extends ComponentPropsOptions ? ExtractPropTypes<PropsOrPropOptions> : PropsOrPropOptions> & ({} extends E ? {} : EmitsToProps<E>), Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>> = ComponentPublicInstanceConstructor<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, S, PP & Props, Defaults, true> & Props> & ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, S, Defaults> & PP;
1176
+ type ResolveProps<PropsOrPropOptions, E extends EmitsOptions> = Readonly<PropsOrPropOptions extends ComponentPropsOptions ? ExtractPropTypes<PropsOrPropOptions> : PropsOrPropOptions> & ({} extends E ? {} : EmitsToProps<E>);
1177
+ export type DefineComponent<PropsOrPropOptions = {}, RawBindings = {}, D = {}, C extends ComputedOptions = ComputedOptions, M extends MethodOptions = MethodOptions, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, PP = PublicProps, Props = ResolveProps<PropsOrPropOptions, E>, Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>, S extends SlotsType = {}> = ComponentPublicInstanceConstructor<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, PP & Props, Defaults, true, {}, S> & Props> & ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, Defaults, {}, string, S> & PP;
1170
1178
  export declare function defineComponent<Props extends Record<string, any>, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}>(setup: (props: Props, ctx: SetupContext<E, S>) => RenderFunction | Promise<RenderFunction>, options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
1171
1179
  props?: (keyof Props)[];
1172
1180
  emits?: E | EE[];
@@ -1177,11 +1185,11 @@ export declare function defineComponent<Props extends Record<string, any>, E ext
1177
1185
  emits?: E | EE[];
1178
1186
  slots?: S;
1179
1187
  }): (props: Props & EmitsToProps<E>) => any;
1180
- export declare function defineComponent<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, S, I, II>): DefineComponent<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, S>;
1181
- export declare function defineComponent<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M, Mixin, Extends, E, EE, S, I, II>): DefineComponent<Readonly<{
1188
+ export declare function defineComponent<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II, S>): DefineComponent<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, PublicProps, ResolveProps<Props, E>, ExtractDefaultPropTypes<Props>, S>;
1189
+ export declare function defineComponent<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string, Props = Readonly<{
1182
1190
  [key in PropNames]?: any;
1183
- }>, RawBindings, D, C, M, Mixin, Extends, E, EE, S>;
1184
- export declare function defineComponent<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, S, I, II>): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, S>;
1191
+ }>>(options: ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II, S>): DefineComponent<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, PublicProps, ResolveProps<Props, E>, ExtractDefaultPropTypes<Props>, S>;
1192
+ export declare function defineComponent<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II, S>): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, PublicProps, ResolveProps<PropsOptions, E>, ExtractDefaultPropTypes<PropsOptions>, S>;
1185
1193
 
1186
1194
  type AsyncComponentResolveResult<T = Component> = T | {
1187
1195
  default: T;
@@ -1236,10 +1244,10 @@ export declare function defineProps<PropNames extends string = string>(props: Pr
1236
1244
  [key in PropNames]?: any;
1237
1245
  }>>;
1238
1246
  export declare function defineProps<PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions>(props: PP): Prettify<Readonly<ExtractPropTypes<PP>>>;
1239
- export declare function defineProps<TypeProps>(): ResolveProps<TypeProps>;
1240
- type ResolveProps<T, BooleanKeys extends keyof T = BooleanKey<T>> = Prettify<Readonly<T & {
1241
- [K in BooleanKeys]-?: boolean;
1242
- }>>;
1247
+ export declare function defineProps<TypeProps>(): DefineProps<TypeProps>;
1248
+ type DefineProps<T> = Readonly<T> & {
1249
+ readonly [K in BooleanKey<T>]-?: boolean;
1250
+ };
1243
1251
  type BooleanKey<T, K extends keyof T = keyof T> = K extends any ? [T[K]] extends [boolean | undefined] ? K : never : never;
1244
1252
  /**
1245
1253
  * Vue `<script setup>` compiler macro for declaring a component's emitted
@@ -1301,6 +1309,58 @@ export declare function defineOptions<RawBindings = {}, D = {}, C extends Comput
1301
1309
  slots?: undefined;
1302
1310
  }): void;
1303
1311
  export declare function defineSlots<S extends Record<string, any> = Record<string, any>>(): TypedSlots<SlotsType<S>>;
1312
+ /**
1313
+ * (**Experimental**) Vue `<script setup>` compiler macro for declaring a
1314
+ * two-way binding prop that can be consumed via `v-model` from the parent
1315
+ * component. This will declare a prop with the same name and a corresponding
1316
+ * `update:propName` event.
1317
+ *
1318
+ * If the first argument is a string, it will be used as the prop name;
1319
+ * Otherwise the prop name will default to "modelValue". In both cases, you
1320
+ * can also pass an additional object which will be used as the prop's options.
1321
+ *
1322
+ * The options object can also specify an additional option, `local`. When set
1323
+ * to `true`, the ref can be locally mutated even if the parent did not pass
1324
+ * the matching `v-model`.
1325
+ *
1326
+ * @example
1327
+ * ```ts
1328
+ * // default model (consumed via `v-model`)
1329
+ * const modelValue = defineModel<string>()
1330
+ * modelValue.value = "hello"
1331
+ *
1332
+ * // default model with options
1333
+ * const modelValue = defineModel<stirng>({ required: true })
1334
+ *
1335
+ * // with specified name (consumed via `v-model:count`)
1336
+ * const count = defineModel<number>('count')
1337
+ * count.value++
1338
+ *
1339
+ * // with specified name and default value
1340
+ * const count = defineModel<number>('count', { default: 0 })
1341
+ *
1342
+ * // local mutable model, can be mutated locally
1343
+ * // even if the parent did not pass the matching `v-model`.
1344
+ * const count = defineModel<number>('count', { local: true, default: 0 })
1345
+ * ```
1346
+ */
1347
+ export declare function defineModel<T>(options: {
1348
+ required: true;
1349
+ } & PropOptions<T> & DefineModelOptions): Ref<T>;
1350
+ export declare function defineModel<T>(options: {
1351
+ default: any;
1352
+ } & PropOptions<T> & DefineModelOptions): Ref<T>;
1353
+ export declare function defineModel<T>(options?: PropOptions<T> & DefineModelOptions): Ref<T | undefined>;
1354
+ export declare function defineModel<T>(name: string, options: {
1355
+ required: true;
1356
+ } & PropOptions<T> & DefineModelOptions): Ref<T>;
1357
+ export declare function defineModel<T>(name: string, options: {
1358
+ default: any;
1359
+ } & PropOptions<T> & DefineModelOptions): Ref<T>;
1360
+ export declare function defineModel<T>(name: string, options?: PropOptions<T> & DefineModelOptions): Ref<T | undefined>;
1361
+ interface DefineModelOptions {
1362
+ local?: boolean;
1363
+ }
1304
1364
  type NotUndefined<T> = T extends undefined ? never : T;
1305
1365
  type InferDefaults<T> = {
1306
1366
  [K in keyof T]?: InferDefault<T, NotUndefined<T[K]>>;
@@ -1332,7 +1392,11 @@ type PropsWithDefaults<Base, Defaults> = Base & {
1332
1392
  export declare function withDefaults<Props, Defaults extends InferDefaults<Props>>(props: Props, defaults: Defaults): PropsWithDefaults<Props, Defaults>;
1333
1393
  export declare function useSlots(): SetupContext['slots'];
1334
1394
  export declare function useAttrs(): SetupContext['attrs'];
1395
+ export declare function useModel<T extends Record<string, any>, K extends keyof T>(props: T, name: K, options?: {
1396
+ local?: boolean;
1397
+ }): Ref<T[K]>;
1335
1398
  /* removed internal: mergeDefaults */
1399
+ /* removed internal: mergeModels */
1336
1400
  /* removed internal: createPropsRestProxy */
1337
1401
  /* removed internal: withAsyncContext */
1338
1402
 
@@ -1626,6 +1690,7 @@ type _defineEmits = typeof defineEmits
1626
1690
  type _defineExpose = typeof defineExpose
1627
1691
  type _defineOptions = typeof defineOptions
1628
1692
  type _defineSlots = typeof defineSlots
1693
+ type _defineModel = typeof defineModel
1629
1694
  type _withDefaults = typeof withDefaults
1630
1695
 
1631
1696
  declare global {
@@ -1634,5 +1699,6 @@ declare global {
1634
1699
  const defineExpose: _defineExpose
1635
1700
  const defineOptions: _defineOptions
1636
1701
  const defineSlots: _defineSlots
1702
+ const defineModel: _defineModel
1637
1703
  const withDefaults: _withDefaults
1638
1704
  }