我正在做一个VueJS项目。我们刚刚实现了Typescript (版本4.8.4)。
在更新ts类型文件中的接口后,我得到了这个错误error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'
。
在我的tsconfig
文件中,我们只声明了"emitDeclarationOnly": true,
,但似乎noEmit
是在node_modules下与其他包一起声明的。
下面是tsconfig文件的完整内容
{
"compilerOptions": {
"target": "es6",
"module": "es6",
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"sourceMap": true,
"noImplicitAny": false,
"baseUrl": ".",
"allowJs": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true,
"isolatedModules": true,
"emitDeclarationOnly": true,
"outDir": "tsdist",
"types": [
"webpack-env",
"jest"
],
"typeRoots": [
"./node_modules/@types",
],
"paths": {
"@/*": [
"src/*"
],
"AppCheckout/*": ["src/assets/scripts/AppComponent/Checkout/src/*"],
"AppCommon/*": ["src/assets/scripts/AppComponent/Common/src/*"],
"AppPublication/*": ["src/assets/scripts/AppComponent/Publication/src/*"],
"AppStore/*": ["src/assets/scripts/AppComponent/Store/src/*"]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
, "src/assets/scripts/globals/Container/Core/initContainer.js" ],
"exclude": [
"node_modules",
"./tasks"
],
"vueCompilerOptions": {
"target": 2.7
}
}
1条答案
按热度按时间lrpiutwd1#
我找到了这个问题的根源。顺便说一下,我们在项目上使用
lint-staged
包来验证提交前的修改。在这个包的配置文件中,我们通过强制使用noEmit
选项来检查typescript文件,而在tsconfig配置文件中,我们定义了emitDeclarationOnly
。因此,有必要协调这两种配置,以避免这种错误。