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
JSX element type does not have any construct or call signatures.ts(2604) #1405
Comments
Hi @NikhilVerma, since this is a departure from the original TS type behavior, I'll explore support vue-class-component in plugin API. |
I'm getting this error on non class components as well. Something as simple as this will trigger it:
I also get the error if I have
Not to mention I'm getting it on |
@johnsoncodehk I suspect this commit broke it - cc57bff which was a fix for #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 My personal opinion on the original issue #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. |
I'm getting this with vue-router, in particular. 0.36 is fine. 0.37 does |
Is there a workaround for this in vscode for now? I have Vue 2 projects with globally registered Vuetify that have a distracting number of errors which don't represent runtime issues |
same here. added to src/components.d.ts:
and error with vue-router went away, but created new error with importing anything from vue, e.g. |
Suddenly everything is broken after upgrading to 0.37. :( |
@NikhilVerma 2, 3, 5, 6 is supported type in template. 1 is supported with config |
@szulcus Make sure you have |
+1 |
@zlotnika You can define global component type by Or in v0.37.1, you can config // tsconfig.json
{
"vueCompilerOptions": {
"experimentalSuppressInvalidJsxElementTypeErrors": true
}
} |
@Yoduh Please make sure component.d.ts has |
+1 |
|
@NikhilVerma can you reopen this issue as |
|
Converting the tag of the component in error from the kebab case to the pascal case seems to eliminate the error. Apologies if this report is already well known to you all. |
+1 |
I am also using
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. |
感谢,找了半天的原因终于找到解决方案了 |
It's Runtime Status shows a message: Error: the pattern with the identifier $tsc doesn't exist. |
I didn't have it installed (I don't think nuxt needs it), but I added it to the types just to be sure. I still have the same error. Installing version |
头发都快掉完了,终于发现怎么解决了 |
这个bug 在 0.37.2 中 并没有解决啊?!还是报错! |
@kingyue737 I guess you are using Vuetify, am I correct? I have the same problem in that you lose all type inference of Vuetify components with the configuration above, but are you sure you had type inference of these components before? I reverted back to 0.36.1 and with that version each vuetify component for me is also typed as |
@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. |
For the record: updating Volar to the latest version 0.37.3 fixes this issue. |
@kingyue737 I copied and ran your script and it works great in generating the type files! Thanks for it. |
@dschreij this bug has already been fixed one month ago. You can try the latest volar v0.38.5 published one hour ago. I'm using v0.38.3 which seems stable. |
@dschreij Or you can use the new @volar-plugins/vetur to profit vetur component data with volar in a non-Typescript project. |
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 Source code for that component is straightforward. <script setup lang="ts">
import { Button as KButton } from "@progress/kendo-vue-buttons";
</script>
<template>
<KButton v-bind="$attrs">
<slot></slot>
</KButton>
</template> |
@JessicaSachs I'm not sure the reason yet, but you can remove this error by add
{
"extends": "./tsconfig.app.json",
"include": ["**/*.cy.*"],
"exclude": [],
"files": ["./cypress.d.ts"],
"compilerOptions": {
"isolatedModules": false,
"composite": true,
"lib": ["DOM"],
"jsx": "preserve",
- "types": ["cypress"],
+ "types": ["node", "cypress"],
}
} |
@kingyue737 it was working after all! I just had to set the |
Hi! I know this is already closed but someone might find this relevant and/or helpful. I'm using Volar 0.40.9 on a vue2.7 + typescript setup and this is still present. I suspect that between 0.36.1 and later versions something changed in how Volar detects the component registration, but I haven't digged inside the code so it's pure speculation. What I found is that when importing and locally registering components, doing the mapping explicitly with the kebab-case works, e.g. import FirstChild from './whatever'
import SecondChild from './whatever'
export default defineComponent({
name: 'ParentComponent',
components: {
//<first-child> will be recognized correctly in template!
'first-child': FirstChild,
//<second-child> will throw 'JSX element type 'SecondChild' does not have any construct or call signatures'
SecondChild,
},
...
}) I adopted the manual kebab-case mapping approach for now, I can get more insights on this and/or give more feedback if it's needed. |
Volar v0.40.9 still cope with this issue, Using package |
Still actual with Ts config
Error: d.ts of component library
|
@grindpride |
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)
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.
The text was updated successfully, but these errors were encountered: