From 27eed829ccf9978a63b8cd989ff4c03897276bc2 Mon Sep 17 00:00:00 2001 From: ZHAO Jinxiang Date: Mon, 10 Oct 2022 20:51:05 -0700 Subject: [PATCH] fix(types): vue 3 directive type compatibility (#12792) --- types/options.d.ts | 7 +++++++ types/vue.d.ts | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/types/options.d.ts b/types/options.d.ts index 9fcdaca62..93379edbe 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -4,6 +4,7 @@ import { SetupContext } from './v3-setup-context' import { DebuggerEvent } from './v3-generated' import { DefineComponent } from './v3-define-component' import { ComponentOptionsMixin } from './v3-component-options' +import { ObjectDirective, FunctionDirective } from './v3-directive' type Constructor = { new (...args: any[]): any @@ -318,6 +319,9 @@ export interface DirectiveBinding extends Readonly { readonly modifiers: { [key: string]: boolean } } +/** + * @deprecated use {@link FunctionDirective} instead + */ export type DirectiveFunction = ( el: HTMLElement, binding: DirectiveBinding, @@ -325,6 +329,9 @@ export type DirectiveFunction = ( oldVnode: VNode ) => void +/** + * @deprecated use {@link ObjectDirective} instead + */ export interface DirectiveOptions { bind?: DirectiveFunction inserted?: DirectiveFunction diff --git a/types/vue.d.ts b/types/vue.d.ts index 5a2027a01..f158cf017 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -22,6 +22,7 @@ import { ExtractComputedReturns, ComponentOptionsMixin } from './v3-component-options' +import { Directive, ObjectDirective } from './v3-directive' export interface CreateElement { ( @@ -338,6 +339,10 @@ export interface VueConstructor { id: string, definition?: DirectiveOptions | DirectiveFunction ): DirectiveOptions + directive( + id: string, + definition?: Directive + ): ObjectDirective filter(id: string, definition?: Function): Function component(id: string): VueConstructor