vue3+ TS:所有全局组件投掷“ JSX元素类型”; __________________没有任何构造或呼叫签名。TS(2604);
每个全球注册的组件都在标记中都有一个红色的打字稿!该应用程序仍然运行,就像没有错误一样!
它发生在所有组件上,定制和第三方libs。
它确实 不是 如果我将错误直接导入VUE文件。
记录零件
//main.ts
import MyComponent from "./components/MyComponent.vue";
_app.component(MyComponent, "my-component");
用法
//SomeView.vue
< script setup lang="ts>
import OtherComp from "./components"
</script>
<template>
<div>
<my-component>
<!-- Red Squiggles! -->
</my-component>
<OtherComp>
<!-- no error on local import-->
</OtherComp>
</div>
</template>
的无聊示例,到底发生了什么?我是否意外地更新打字稿,Volar或Linter之类的东西?这是一个假错误,对吗?当然是丑陋的。
Every globally registered component has a red typescript squiggle in markup! The app still runs, like there are no errors!
It happens on all components, custom made AND third party libs.
It does NOT throw an error if I import them directly into the vue file.
Boring example of registering a component
//main.ts
import MyComponent from "./components/MyComponent.vue";
_app.component(MyComponent, "my-component");
Boring usage
//SomeView.vue
< script setup lang="ts>
import OtherComp from "./components"
</script>
<template>
<div>
<my-component>
<!-- Red Squiggles! -->
</my-component>
<OtherComp>
<!-- no error on local import-->
</OtherComp>
</div>
</template>
What the heck is going on? Did I accidentally update typescript or Volar or a linter or something? It's a fake error, right? Sure is ugly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
此错误来自VUE语言功能(Volar)。
发行页面
将Volar Plug-In推入版本0.36.1可以解决此问题。
This error comes from Vue Language Features (Volar).
issue page
Rolling back the volar plug-in to version 0.36.1 can solve this problem.
只需将Volar版本 0.37.2更改为0.36.0 即可。
注意:我花了小时的时间,没有找到确切的解决方案,然后只是尝试了一下。然后一切都很好。
该链接有助于使这个问题重新纳入一些想法:
https://github.com/microsoft/TypeScript/issues/28631#issuecomment- 472606019
Just change the volar version 0.37.2 to 0.36.0 and everyting will be fine.
Note: I spent coulple of hours and didn't find the exact solution and then simply tried this; then everything worked fine.
This link helped to get some idea regarading this issue:
https://github.com/microsoft/TypeScript/issues/28631#issuecomment-472606019
根据问题页,
将此配置添加到您的tsconfig.json文件中:
Volar已更新到V0.37.3版本以解决此问题。因此,只需重新安装Volar即可。
这对我来说很好。
According to the issue page, add this config to your tsconfig.json file:
update:
the volar have updated to version v0.37.3 to resolve this issue.so,just reinstall the volar.
that works fine for me.
修复在
0.37.3
上,因此您不必更改配置或其他任何内容 - https://github.com/johnsoncodehk/volar/issues/1405#issuecomment-1149618450Fixed on
0.37.3
, so you don't have to alter your config or anything - https://github.com/johnsoncodehk/volar/issues/1405#issuecomment-1149618450