mirror of https://github.com/vuejs/core.git
fix(types): the directive's modifiers should be optional (#12605)
* fix(types): the directive's modifiers should be optional * fix: test --------- Co-authored-by: edison <daiwei521@126.com>
This commit is contained in:
parent
4fea167b57
commit
10e54dcc86
|
@ -9,7 +9,7 @@ app.directive<HTMLElement, string, 'prevent' | 'stop', 'arg1' | 'arg2'>(
|
|||
mounted(el, binding) {
|
||||
expectType<HTMLElement>(el)
|
||||
expectType<string>(binding.value)
|
||||
expectType<{ prevent: boolean; stop: boolean }>(binding.modifiers)
|
||||
expectType<{ prevent?: boolean; stop?: boolean }>(binding.modifiers)
|
||||
expectType<'arg1' | 'arg2'>(binding.arg!)
|
||||
|
||||
// @ts-expect-error not any
|
||||
|
|
|
@ -29,7 +29,7 @@ describe('custom', () => {
|
|||
value: number
|
||||
oldValue: number | null
|
||||
arg?: 'Arg'
|
||||
modifiers: Record<'a' | 'b', boolean>
|
||||
modifiers: Partial<Record<'a' | 'b', boolean>>
|
||||
}>(testDirective<number, 'a' | 'b', 'Arg'>())
|
||||
|
||||
expectType<{
|
||||
|
|
|
@ -111,7 +111,9 @@ export type Directive<
|
|||
| ObjectDirective<HostElement, Value, Modifiers, Arg>
|
||||
| FunctionDirective<HostElement, Value, Modifiers, Arg>
|
||||
|
||||
export type DirectiveModifiers<K extends string = string> = Record<K, boolean>
|
||||
export type DirectiveModifiers<K extends string = string> = Partial<
|
||||
Record<K, boolean>
|
||||
>
|
||||
|
||||
export function validateDirectiveName(name: string): void {
|
||||
if (isBuiltInDirective(name)) {
|
||||
|
|
Loading…
Reference in New Issue