Vue3 + TS:所有全局组件都会抛出“JSX 元素类型 '___' 没有任何构造或调用签名.ts(2604)”

Scu*_*ket 1 typescript vue.js vue-component

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

  • 它发生在所有组件、定制组件第三方库上。

  • 如果我将它们直接导入到 vue 文件中,它不会抛出错误。

注册组件的无聊示例

//main.ts
import MyComponent from "./components/MyComponent.vue";
_app.component(MyComponent,  "my-component");
Run Code Online (Sandbox Code Playgroud)

无聊的使用

//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>

Run Code Online (Sandbox Code Playgroud)

到底他妈发生了什么?我是否不小心更新了 typescript 或 Volar 或 linter 之类的东西?这是一个假错误,对吗?当然是丑了

hhu*_*i64 6

此错误来自 Vue 语言功能 (Volar)。

问题页面

将volar插件回滚到0.36.1版本可以解决这个问题。