TS: Vue Component not imported as class but only as type #11422
Unanswered
func0der
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am having a bit of an issue here.
I am on the newest create-app skeleton.
I am trying to do this basically: https://play.vuejs.org/#eNp9Uk2P0zAQ/SsjX9JWJTnAqWQrwaoSywEQ9IY5ZJNJ4sWxLX+Urkr+O2OnLVmEeonseS9v3ozfib0zJj8EZBtWutoK48GhDwZkpbo7zrzjbMuVGIy2Hk5gsYURWqsHyOi37Ar5Z4NAYve9kM2ZkBeXQmyRveWKq1or56FOrLsoVz5QoVI17kmhjDK6vQpt4TeoIOV2Eb/LKFAWk09yRRePg5GVR7oBlJUxryZpEib36UwD7Hu0CK7XgaBHhAqyx8pmoPBIzjX4XrgNtFqXxVWCFMtiJs/WtAxy34ouf3Ja0cZOsSl10YMREu1n4wVNx9kGEhKxSkr962OqeRtwfanXPdY//1N/csdY4+yLRYf2gJxdMV/ZDv0E7759Iu8zcNBNkMS+AX5Fp2WIHifa+6Aasj3jJbcP6UGF6vZud/So3GWoaDQyx8TnTKhahib1/M4ZqkPe5DEv6/NOtELl3azobF2sVsXq5S1mg7MfZ1G63N/Y598dvM7fJDNcjfQ086D9m+WUlCl3rnr+gDQkRa8Nqo76sFhO8pGhJeZSd4usj6yMAkf6XDXYCoW7o9EOF6eLyLi8lcVGHNKBjk5qD8WWIpeQYoJepmv8AyMXMRM=
As you see I want to use a typed reference of the
AppChild
component in my code.For Typescript to be satisfied, I should use
import type AppChild
, which leads to the component not being rendered.I understand that this happens, because typescript thinks I can drop the file completely during compilation, since there are only types in there.
BUT I also need the import for the
<AppChild>
component in the template. Which would need aimport AppChild
directive.That would also work with the
typeof
line of the code.BUT now comes the IDE(s):
VSCode only wants to import
AppChildVue
. I dunno what that is, but the import basically the same as forAppChild
only that is suffixed withVue
:import AppChildVue from './AppChild.vue'
PHPStorm on the other hand creates an
import type AppChild...
line all the time. This is probably a context issue, since it does not realize that I am still using the component in the template.So....wth is going on and how would I go about fixing it xD
I am unsure if I am in the right place here or if I would better open a discussion in vuejs/language-tools.
I have been struggeling with this for some days now (been updating and adapting an existing project to the
create
project structure.Any help is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions