fix(types): vue 3 directive type compatibility (#12792)

This commit is contained in:
ZHAO Jinxiang 2022-10-10 20:51:05 -07:00 committed by GitHub
parent 2f335b2f9d
commit 27eed829cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

7
types/options.d.ts vendored
View File

@ -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<VNodeDirective> {
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

5
types/vue.d.ts vendored
View File

@ -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<V extends Vue = Vue> {
id: string,
definition?: DirectiveOptions | DirectiveFunction
): DirectiveOptions
directive(
id: string,
definition?: Directive
): ObjectDirective
filter(id: string, definition?: Function): Function
component(id: string): VueConstructor