core: An type error occurs when building Teleport using the
Version
3.0.4
Reproduction link
https://github.com/Wizard67/rollup-vue
Steps to reproduce
- install dependencies.
- run build script.
What is expected?
Building Success.
What is actually happening?
typescript throws the following error.
semantic error TS2345: Argument of type '{ new (): { $props: VNodeProps & TeleportProps; }; __isTeleport: true; }' is not assignable to parameter of type 'string | ComponentOptions<any, any, any, Record<string, ComputedGetter<any> | WritableComputedOptions<any>>, MethodOptions, any, any, any> | ... 9 more ... | ClassComponent'.
Type '{ new (): { $props: VNodeProps & TeleportProps; }; __isTeleport: true; }' is not assignable to type 'ComponentPublicInstanceConstructor<any, any, any, any, Record<string, ComputedGetter<any> | WritableComputedOptions<any>>, MethodOptions>'.
Types of property '__isTeleport' are incompatible.
Type 'true' is not assignable to type 'never'.
It looks like the incompatibility between the createBlock and Teleport types is the cause of the.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 15 (3 by maintainers)
Commits related to this issue
- fix(types): ensure createBlock() helper accepts Teleport and Supsense types not their internal counterparts (TeleportImpl and SupenseImpl) fix: #2855 — committed to vuejs/core by LinusBorg 2 years ago
- [TASK] Add teleport workaround https://github.com/vuejs/core/issues/2855 — committed to MALSync/MALSync by lolamtisch 2 years ago
- fix(types): ensure createBlock() helper accepts Teleport and Supsense types (fix: #2855) (#5458) Co-authored-by: Carlos Rodrigues <carlos@hypermob.co.uk> — committed to vuejs/core by LinusBorg 2 years ago
- fix(types): ensure createBlock() helper accepts Teleport and Supsense types (fix: #2855) (#5458) Co-authored-by: Carlos Rodrigues <carlos@hypermob.co.uk> — committed to chrislone/core by LinusBorg 2 years ago
- fix(types): ensure createBlock() helper accepts Teleport and Supsense types (fix: #2855) (#5458) Co-authored-by: Carlos Rodrigues <carlos@hypermob.co.uk> — committed to zhangzhonghe/core by LinusBorg 2 years ago
Workaround:
We also had to do the same for Suspense.
Also indicated by the fact that the issue is still open, yes.
Same problem with Vue 3.2.22 SFC +
<script lang="ts">
+defineComponent
in a webpack project:Workaround works, thanks.
createBlock()
accepts the following types as its first argument:Those
*Impl
types ares used internally only though. Externally, these implementations are cast to soemthing different -typeof Teleport != TeleportImpl
.First instinct is that we should use
Teleport
andSuspense
here as well, instead of their internal*Impl
counterparts.This isn’t a problem when not using
script setup
as the created render function never runs through the typescript compiler in these cases. In other words: a normal component creates the same render function, and at runtime it works - but only withscript setup
this is actually catched by the TS compiler.