-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An type error occurs when building Teleport using the <script setup lang="ts"> #2855
Comments
export type VNodeTypes =
| string
| VNode
| Component
| typeof Text
| typeof Static
| typeof Comment
| typeof Fragment
| typeof TeleportImpl
| typeof SuspenseImpl Those First instinct is that we should use This isn't a problem when not using |
Workaround: <script lang="ts" setup>
import {
Teleport as teleport_,
TeleportProps,
VNodeProps
} from 'vue'
const Teleport = teleport_ as {
new (): {
$props: VNodeProps & TeleportProps
}
}
</script>
<template>
<component :is="Teleport">
</component>
</template>
|
Hitting this or a very similar issue in my vue-loader/webpack-based project even without Thanks for sharing the workaround, it seems to work in my case as well. |
Same problem with Vue 3.2.22 SFC +
Workaround works, thanks. |
This bug still occurs when using the latest version of vue. |
Also indicated by the fact that the issue is still open, yes. |
… types not their internal counterparts (TeleportImpl and SupenseImpl) fix: #2855
We also had to do the same for Suspense.
|
Suspense has also been added to the VNodeTypes type in LinusBorg's PR. |
I was adding the workaround for people that have the issue with Suspense as the workaround was not in the thread and there doesn't seem to be a separate issue for that. |
I just came across this when doing watch with webpack. Maybe it helps somebody or is related to this. I get the error when I have my
When I remove the leading
But it's not consistent... It seems the error only appears the first time, then after a change it seems to disappear. If I add or remove the leading div while watch is running, the type error always disappears. Additionaly, if I remove the leading div, I get a Vue Warning: "Extraneous non-props attributes (name) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. " (which probably makes sense, but still, maybe it helps) Feel free to delete this comment if it is off topic. |
I am having the same issue - but sadly your solution doesn't fix it for me - I am running in a Laravel Mix stack (which I converted to Typescript) and I am only seeing this error when running a production build - dev builds don't throw the error |
for me it's the opposite 🤷♂️ runs fine on prod build, only watch and dev complain... |
I also get it only in the production build 🤷♂️ weird |
I've also met with this issue building project for production. Workaround helped. |
I can't speak to the dev/prod build issue, but with regard to the attribute inheritance, you can solve that issue by explicitly binding the Teleport props to the dynamic component. I'm currently using the following as a generalized Teleport replacement (thanks @LinusBorg for the head start!): <!-- VueTeleport.vue -->
<template>
<component :is="Teleport" v-bind="props">
<slot></slot>
</component>
</template>
<script setup lang="ts">
import { Teleport as teleport_, type TeleportProps, type VNodeProps } from 'vue';
const Teleport = teleport_ as {
new (): {
$props: VNodeProps & TeleportProps
}
};
const props = defineProps<{
to: TeleportProps['to'],
disabled?: TeleportProps['disabled'],
}>();
</script> Note that if the Teleport API changes then any changes would also need to be propagated to the |
… types (fix: vuejs#2855) (vuejs#5458) Co-authored-by: Carlos Rodrigues <carlos@hypermob.co.uk>
… types (fix: vuejs#2855) (vuejs#5458) Co-authored-by: Carlos Rodrigues <carlos@hypermob.co.uk>
Version
3.0.4
Reproduction link
https://github.com/Wizard67/rollup-vue
Steps to reproduce
What is expected?
Building Success.
What is actually happening?
typescript throws the following error.
It looks like the incompatibility between the createBlock and Teleport types is the cause of the.
The text was updated successfully, but these errors were encountered: