From e5fc7dcc02f2dd3fa8172958259049031626375f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20L=C3=BCnborg?= Date: Thu, 20 Oct 2022 21:45:51 +0200 Subject: [PATCH] fix(types): ensure createBlock() helper accepts Teleport and Supsense types (fix: #2855) (#5458) Co-authored-by: Carlos Rodrigues --- packages/runtime-core/src/vnode.ts | 5 ++++- test-dts/compiler.test-d.ts | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test-dts/compiler.test-d.ts diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index b731dc0b51f..2122f9f855a 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -24,6 +24,7 @@ import { RawSlots } from './componentSlots' import { isProxy, Ref, toRaw, ReactiveFlags, isRef } from '@vue/reactivity' import { AppContext } from './apiCreateApp' import { + Suspense, SuspenseImpl, isSuspense, SuspenseBoundary @@ -31,7 +32,7 @@ import { import { DirectiveBinding } from './directives' import { TransitionHooks } from './components/BaseTransition' import { warn } from './warning' -import { TeleportImpl, isTeleport } from './components/Teleport' +import { Teleport, TeleportImpl, isTeleport } from './components/Teleport' import { currentRenderingInstance, currentScopeId @@ -63,7 +64,9 @@ export type VNodeTypes = | typeof Static | typeof Comment | typeof Fragment + | typeof Teleport | typeof TeleportImpl + | typeof Suspense | typeof SuspenseImpl export type VNodeRef = diff --git a/test-dts/compiler.test-d.ts b/test-dts/compiler.test-d.ts new file mode 100644 index 00000000000..974b49492a4 --- /dev/null +++ b/test-dts/compiler.test-d.ts @@ -0,0 +1,20 @@ +import { + expectType, + createBlock, + VNode, + Teleport, + Text, + Static, + Comment, + Fragment, + Suspense, + defineComponent +} from './index' + +expectType(createBlock(Teleport)) +expectType(createBlock(Text)) +expectType(createBlock(Static)) +expectType(createBlock(Comment)) +expectType(createBlock(Fragment)) +expectType(createBlock(Suspense)) +expectType(createBlock(defineComponent({})))