当更新我的项目以使用最新的@vue/tsconfig
版本( compose 本文时的版本0.5.1
)时,命令vue-tsc
失败并返回错误
Referenced project 'd:/repos/project/Tsconfig.node.json' may not disable emit
该项目是用Vite和Vue3构建的,在此更新之前工作没有任何问题.将"noEmit": false
添加到指定的tsconfig可以解决此问题.
此错误来自对我的tsconfig扩展的默认tsconfig @vue/tsconfig/Tsconfig.json
中vue-tsc
设置"noEmit": true
的 destruct 性更改.
我的问题是:在Tsconfig.node.json
(VITE使用的)上增加"noEmit": false
有什么缺点吗?我已经读过了,noEmit
告诉TypeScrip在编译我的代码时不发出任何输出(如JavaScript文件或类型声明).
下面是我的项目中使用的vue和vite的一些最小版本(位于项目根文件夹中):
Tsconfig.json
{
"extends": "@vue/tsconfig/Tsconfig.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"noImplicitAny": false,
"allowJs": true,
"ignoreDeprecations": "5.0"
},
"references": [
{
"path": "./Tsconfig.node.json"
}
]
}
Tsconfig.node.json
{
"extends": "@vue/tsconfig/Tsconfig.json",
"include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "playwright.config.*"],
"compilerOptions": {
"composite": true,
"types": ["node"],
"noEmit": false // this was added
}
}