Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -318,13 +319,19 @@ export interface DirectiveBinding extends Readonly<VNodeDirective> {
readonly modifiers: { [key: string]: boolean }
}

/**
* @deprecated use {@link FunctionDirective} instead
*/
export type DirectiveFunction = (
el: HTMLElement,
binding: DirectiveBinding,
vnode: VNode,
oldVnode: VNode
) => void

/**
* @deprecated use {@link ObjectDirective} instead
*/
export interface DirectiveOptions {
bind?: DirectiveFunction
inserted?: DirectiveFunction
Expand Down
5 changes: 5 additions & 0 deletions types/vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ExtractComputedReturns,
ComponentOptionsMixin
} from './v3-component-options'
import { Directive, ObjectDirective } from './v3-directive'

export interface CreateElement {
(
Expand Down Expand Up @@ -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
Expand Down