language-tools: JSX element type does not have any construct or call signatures.ts(2604)
This happens when using vue-class-component. Here is an example snippet. (Taken from https://class-component.vuejs.org/guide/class-component.html#other-options and converted to TS)
<template>
<OtherComponent />
</template>
<script lang="ts">
import Vue from 'vue'
import Component from 'vue-class-component'
import OtherComponent from './OtherComponent.vue'
@Component({
components: {
OtherComponent
}
})
export default class HelloWorld extends Vue {}
</script>
This happens because https://github.com/johnsoncodehk/volar/tree/master/packages/vue-language-service does not support vue-class-component syntax, so volar can’t understand where the component definition is coming from.
I believe vue-class-component is still officially supported by Vue team, so we should have support for it in Volar as well.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 23
- Comments: 46 (13 by maintainers)
@zlotnika You can define global component type by
GlobalComponents
interface for vue-router and project components, see https://github.com/johnsoncodehk/volar/tree/master/extensions/vscode-vue-language-features#usage.Or in v0.37.1, you can config
experimentalSuppressUnknownJsxPropertyErrorsexperimentalSuppressInvalidJsxElementTypeErrors = true
to ignore unknown component type errors.Reverting to version
0.36.1
looks safe.I’m getting this with vue-router, in particular. 0.36 is fine. 0.37 does
JSX element type 'RouterView' does not have any construct or call signatures.
andJSX element type 'RouterLink' does not have any construct or call signatures.
.For the record: updating Volar to the latest version 0.37.3 fixes this issue.
I am also using
vite
+vue3
.Volar v0.36.1 (kebab case)
Volar v0.37.1 (kebab case)
Volar v0.37.1 (pascal case)
Sorry, I only reported the phenomena I observed and do not understand the details. I reported it in the hope that it would be of some help in the investigation.
+1
vue3
+vite
+1
@NikhilVerma can you reopen this issue as
experimentalSuppressInvalidJsxElementTypeErrors
will make all global components becomeany
in vue2 projectvue2 project. I’ve upgraded to v0.37.1 and added
"experimentalSuppressUnknownJsxPropertyErrors": true
explicitly. After reloading volar and restarting vscode several times, this bug still existsstatus bar:
tsconfig:
@johnsoncodehk I suspect this commit broke it - https://github.com/johnsoncodehk/volar/commit/cc57bff0a7c028b81f9be5a5aea7f1028172f8f3 which was a fix for https://github.com/johnsoncodehk/volar/issues/1203
In many cases it’s not possible to know all the potential component types (in my case vue-class-component syntax is not supported by Volar, so component types can’t be extracted) same goes for global component types like
transition-group
.My personal opinion on the original issue https://github.com/johnsoncodehk/volar/issues/1203 is that because the Vue ecosystem has a variety of syntaxes:
It will be a big pain to support all of them in the same project. We have a few potential solutions:
I think Option 2 is the most realistic given the variety we are dealing with.
Suddenly everything is broken after upgrading to 0.37. 😦
@grindpride
Component
type invalid in JSX, you can try useDefineComponent
orFunctionComponent
instead of.@kingyue737 it was working after all! I just had to set the
strictTemplates
setting to false in tsconfig.json, and now typing of vuetify components is working beatifully. If I understand you correctly, the plugin you describe is only useful for non-TS projects? We are using TS so I guess it is recommendable to follow the approach you suggested before (e.g. generating the type descriptions of Vuetify components).感谢,找了半天的原因终于找到解决方案了
FWIW, I’m still running into this issue on the latest version of Volar @johnsoncodehk (0.38.5). Here’s a reproduction https://github.com/JessicaSachs/vuejs-forge-the-project/tree/jess/reproduction-of-volar-issue
The
src/components/AppButton.cy.tsx
file is having issues.Source code for that component is straightforward.
@dschreij Vuetify 2 doesn’t support volar officialy. I generate vuetify component types myself. See the guide in this comment. @me in that issue if you meet any problem.
It’s Runtime Status shows a message: Error: the pattern with the identifier $tsc doesn’t exist. Dose it matter?