gpt4 book ai didi

带有项目引用的 typescript 构建失败, `Output file has not been built from source file` 即使它已构建

转载 作者:行者123 更新时间:2023-12-03 20:55:45 76 4
gpt4 key购买 nike

我正在尝试构建一个引用共享项目的项目。
我的配置看起来像:
projectA/tsconfig.json :

{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"lib": [
"esnext.asynciterable"
],
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": [
"src"
],
"references": [
{
"path": "../shared",
"prepend": true
}
]
}
shared/tsconfig.json :
{
"compilerOptions": {
"outFile": "build/out.js",
"composite": true,
"target": "es5",
"module": "amd",
"declaration": true,
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src"
]
}

ts -b 内部运行 projectA 产生:
src/index.ts:6:24 - error TS6305: Output file '.../shared/build/out.d.ts' has not been built from source file '.../shared/src/index.ts'.

6 import DummyClass from '../../shared/src';

即使确实创建了此文件。

我究竟做错了什么?

最佳答案

只包含 ts 文件,不包含转译的 js 文件。

"include": [
"./**/*.ts*"
]

关于带有项目引用的 typescript 构建失败, `Output file has not been built from source file` 即使它已构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61014711/

76 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com