declare function testDirective<
Value,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
>(): ExtractBinding<Directive<any, Value, Modifiers, Arg>>
describe('vmodel', () => {
value: number
oldValue: number | null
arg?: 'Arg'
- modifiers: Record<'a' | 'b', boolean>
+ modifiers: Partial<Record<'a' | 'b', boolean>>
// @ts-expect-error
}>(testDirective<number, 'a' | 'b', 'Argx'>())
value: number
oldValue: number | null
arg?: 'Arg'
- modifiers: Record<'a' | 'b', boolean>
+ modifiers: Partial<Record<'a' | 'b', boolean>>
// @ts-expect-error
}>(testDirective<string, 'a' | 'b', 'Arg'>())
+
+ expectType<{
+ value: number
+ oldValue: number | null
+ arg?: HTMLElement
+ modifiers: Partial<Record<'a' | 'b', boolean>>
+ }>(testDirective<number, 'a' | 'b', HTMLElement>())
+
+ expectType<{
+ value: number
+ oldValue: number | null
+ arg?: HTMLElement
+ modifiers: Partial<Record<'a' | 'b', boolean>>
+ // @ts-expect-error
+ }>(testDirective<number, 'a' | 'b', string>())
+
+ expectType<{
+ value: number
+ oldValue: number | null
+ arg?: HTMLElement
+ modifiers: Partial<Record<'a' | 'b', boolean>>
+ }>(testDirective<number, 'a' | 'b'>())
})
HostElement = any,
Value = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
>(
name: string,
): Directive<HostElement, Value, Modifiers, Arg> | undefined
HostElement = any,
Value = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
>(
name: string,
directive: Directive<HostElement, Value, Modifiers, Arg>,
export interface DirectiveBinding<
Value = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
> {
instance: ComponentPublicInstance | Record<string, any> | null
value: Value
oldValue: Value | null
arg?: Arg
modifiers: DirectiveModifiers<Modifiers>
- dir: ObjectDirective<any, Value>
+ dir: ObjectDirective<any, Value, Modifiers, Arg>
}
export type DirectiveHook<
Prev = VNode<any, HostElement> | null,
Value = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
> = (
el: HostElement,
binding: DirectiveBinding<Value, Modifiers, Arg>,
export type SSRDirectiveHook<
Value = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
> = (
binding: DirectiveBinding<Value, Modifiers, Arg>,
vnode: VNode,
HostElement = any,
Value = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
> {
/**
* @internal without this, ts-expect-error in directives.test-d.ts somehow
HostElement = any,
V = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
> = DirectiveHook<HostElement, any, V, Modifiers, Arg>
export type Directive<
HostElement = any,
Value = any,
Modifiers extends string = string,
- Arg extends string = string,
+ Arg = any,
> =
| ObjectDirective<HostElement, Value, Modifiers, Arg>
| FunctionDirective<HostElement, Value, Modifiers, Arg>
export type DirectiveArguments = Array<
| [Directive | undefined]
| [Directive | undefined, any]
- | [Directive | undefined, any, string]
- | [Directive | undefined, any, string | undefined, DirectiveModifiers]
+ | [Directive | undefined, any, any]
+ | [Directive | undefined, any, any, DirectiveModifiers]
>
/**