Browse Source

chore: fix typing for withDirectives

Evan You 6 năm trước cách đây
mục cha
commit
43f4bd3aaa
1 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 5 2
      packages/runtime-core/src/directives.ts

+ 5 - 2
packages/runtime-core/src/directives.ts

@@ -104,11 +104,14 @@ export type DirectiveArguments = Array<
   | [Directive, any, string, DirectiveModifiers]
 >
 
-export function withDirectives(vnode: VNode, directives: DirectiveArguments) {
+export function withDirectives<T extends VNode>(
+  vnode: T,
+  directives: DirectiveArguments
+): T {
   const internalInstance = currentRenderingInstance
   if (internalInstance === null) {
     __DEV__ && warn(`withDirectives can only be used inside render functions.`)
-    return
+    return vnode
   }
   const instance = internalInstance.renderProxy
   const props = vnode.props || (vnode.props = {})