developer-plus / weekly

记录每周值得分享的内容,周一发布。
MIT License
11 stars 0 forks source link

【日常踩坑】模块的默认导出具有或正在使用专用名称 “Props” #31

Open Hongbusi opened 2 years ago

Hongbusi commented 2 years ago

问题背景

<script setup lang="ts">
interface Props {
  title: string
}

defineProps<Props>() // Error:模块的默认导出具有或正在使用专用名称 “Props”。
</script>

解决方案

移除 composite:true 在 tsconfig.json 中,警告消失。详见:https://github.com/johnsoncodehk/volar/issues/1232

问题原因

使用 pnpm create vite 初始化项目之后,嫌两个配置文件看起来过于多余,于是手动合并了 tsconfig.jsontsconfig.node.json

Vite 中关于修改 tsconfig.json 的讨论:

相关文档

https://www.typescriptlang.org/docs/handbook/project-references.html