Improvements to Dynamic Components, aka <component :is /> #609
BlackYuzia
started this conversation in
General
Replies: 1 comment
-
Related thread in Volar discord https://discord.com/channels/793943652350427136/1099776004286844938/1100032028927340705 I'll test with dynamic import cause I don't remember what should I expect from Vue Language Tool when using If you can confirm issue maybe it's better to report the issue in Vue Language Tools repository |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there.
Description
How you could know vue has dynamic-components
That will allow to use change component fast and simple (without a lot of
if-else
,v-else-if
andv-else
). Hellov-switch
&v-switch-case
? But that a bit off-topic now.Problem
So, we could make something like this:
That code will return to us
VHelloWorld1
orVHelloWorld2
component.But, we have bad news. We don't get any warns about props that not exist in our component:
VSCode do not say to us "hello, you forget
title
,description
andactive
props,".That's a huge trouble when you add / change any props and then found what you forgot to add it to the
<component :is="...">
Solutions
I see only one way to fix that properly, maybe you know any other ways.
<component>
(merge all possible types from:is="getComponent()"
) and return merged props (and/or any else too)This will grant what we don't miss any prop(s) on changing components or components list
Potential difficulties
If we look our component with vscode we saw what
component
do not has type as well.and if we click on it with
CTRL + LMB
nothing happen. That because<component>
is DYNAMIC COMPONENT!, WOW.That mean what he does not exist in our components.
But, this will work with other components.
Conclusions
We have dynamic components.
We can't set or get the type of these components in any case, right?
We want types when it is possible.
We need to make it possible if no types there.
Thanks for attention.
Beta Was this translation helpful? Give feedback.
All reactions