Reputation: 51
I'm working on a project using typescript & vue3 & vite. It's a common component library, so when I build this project, I have to generate .d.ts declaration files. I have tried in two ways:
emitDeclarationOnly: true
in tsconfig.json, but I got error Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'
. However, in my project, I didn't config noEmit
option. So I think the noEmit
option is from node_modules
.
This is my tsconfig.json
file:{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noImplicitThis": true,
"baseUrl": ".",
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
],
"paths":{
"@": ["src"],
"@/*": ["src/*"],
},
"types": ["node"],
},
"include": [ // 编译哪些文件
// "src/**/.d.ts",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx",
".eslintrc.cjs",
],
"exclude": [
"node_modules",
"vite.config.ts",
],
"references": [{ "path": "./tsconfig.node.json" }]
}
--emitDeclarationOnly
in package.json like below works fine for me:"build": "vite build && vue-tsc --emitDeclarationOnly",
So I'm wondering what exactly the difference between configuration in tsconfig.json
or in package.json
?
Thanks in advance.
Upvotes: 1
Views: 386