vue3+ TS:所有全局组件投掷“ JSX元素类型”; __________________没有任何构造或呼叫签名。TS(2604);

发布于 2025-02-05 14:53:18 字数 858 浏览 2 评论 0原文

每个全球注册的组件都在标记中都有一个红色的打字稿!该应用程序仍然运行,就像没有错误一样!

  • 它发生在所有组件上,定制第三方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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

错爱 2025-02-12 14:53:18

此错误来自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.

静赏你的温柔 2025-02-12 14:53:18

只需将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

静水深流 2025-02-12 14:53:18

根据问题页

// tsconfig.json
{
  "vueCompilerOptions": {
    "experimentalSuppressInvalidJsxElementTypeErrors": true
  }
}

将此配置添加到您的tsconfig.json文件中:
Volar已更新到V0.37.3版本以解决此问题。因此,只需重新安装Volar即可。
这对我来说很好。

According to the issue page, add this config to your tsconfig.json file:

// tsconfig.json
{
  "vueCompilerOptions": {
    "experimentalSuppressInvalidJsxElementTypeErrors": true
  }
}

update:
the volar have updated to version v0.37.3 to resolve this issue.so,just reinstall the volar.
that works fine for me.

挽你眉间 2025-02-12 14:53:18

修复在0.37.3上,因此您不必更改配置或其他任何内容 - https://github.com/johnsoncodehk/volar/issues/1405#issuecomment-1149618450

Fixed on 0.37.3, so you don't have to alter your config or anything - https://github.com/johnsoncodehk/volar/issues/1405#issuecomment-1149618450

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文