When updating my project to use the latest @vue/tsconfig version (version 0.5.1 as of this writing) the command vue-tsc fails with error
Referenced project 'd:/repos/project/tsconfig.node.json' may not disable emit
The project is build with Vite and Vue3 and was working without a problem prior to this update. Adding a "noEmit": false to the specified tsconfig fixes this.
This error comes from a breaking change of vue-tsc setting "noEmit": true in their default tsconfig @vue/tsconfig/tsconfig.json which my tsconfig extends.
My question is: are there any drawbacks from adding "noEmit": false to the tsconfig.node.json (which is used by vite). I have read, that noEmit tells typescript to not emit any output (like JavaScript files or type declarations) when it compiles my code.
Below are some minimal tsconfigs both for vue and vite used in my project (located in the project root folder):
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
}
}
I'm assuming you meant
@vue/[email protected]instead ofvue-tsc.The upstream
tsconfig.jsonaddition of"noEmit": trueis likely breaking your project because you're also runningvue-tsc --noEmitsomewhere in yourpackage.jsonscripts.If you look at a recent GitHub commit in the
create-vuestarter kit, you'll notice they repeated the same"noEmit": trueaddition in localtsconfig.jsonfiles, but removed the--noEmitflag to match, making a zero-sum change:On your end, you should be able to solve your problem by updating your
package.jsonscripts to match theirs.I'm far from a TypeScript expert, but my understanding is you don't ever want to emit files from TS when using Vite, since Vite is handling the compilation for you. (I would imagine
vite buildpasses the necessary flags behind the scenes.)That said, if you keep this flag disabled and don't see any superfluous files being generated throughout your project, then it's probably fine? (Regardless — I would still follow
create-vue's approach.)Also see this SO answer on usage of this flag.
As an aside, it's worth mentioning that
create-vuenow generates atsconfig.jsonthat looks like:You may have an easier time following along with future changes by updating your codebase to match this structure. You can browse those files here: https://github.com/vuejs/create-vue/tree/v3.9.1/template/tsconfig/base.