Typescript Typsescript项目引用、复合和allowJS

Typescript Typsescript项目引用、复合和allowJS,typescript,config,transpiler,project-reference,Typescript,Config,Transpiler,Project Reference,我希望能够在几个Typescript项目之间共享代码 ts-project ├── project1 │   ├── package.json │   ├── somecode.ts │   └── tsconfig.json ├── project2 │   ├── somecode.ts │   └── tsconfig.json └── shared ├── dist ├── index.ts ├── package.json ├── someotherco

我希望能够在几个Typescript项目之间共享代码

ts-project
├── project1
│   ├── package.json
│   ├── somecode.ts
│   └── tsconfig.json
├── project2
│   ├── somecode.ts
│   └── tsconfig.json
└── shared
    ├── dist
    ├── index.ts
    ├── package.json
    ├── someothercode.js
    ├── somesharedcode.ts
    └── tsconfig.json

要在
shared
中传输代码,我以前有
allowJS:true
,因此
someothercode.js
被包括在tsc传输步骤中,所有代码最终都在
dist/
package.json
main
中指向
dist/index.js

project1
中的
package.json
依赖项中,我有
“共享”:“文件:../shared”
,我可以
像导入普通包一样导入共享代码

这样,typescript编译器就知道
共享的
code
project1
tsconfig.json
需要什么了

   "references": [{
        "path": "../shared"
    }]
现在我的问题来了,我需要你的帮助

要使项目参考正常工作,
shared
中的
tsconfig
需要一个属性

    "compilerOptions": {
        "composite": true,
   }
但是,设置了
composite:true
后,我不能再使用
allowJS:true
,这意味着
someothercode.js
文件不再包含在dist文件夹中


目前无法将所有
.js
代码更改为
ts
(我们正在努力!),因此我需要能够同时处理
ts
js
文件,但仍然需要IDE类型脚本支持,并且能够使用
tsc-b

您找到解决方案了吗?我们的团队正在开始将现有的NodeJS项目从JS增量迁移到TS,我想使用
composite:true
too@AmitBeckenstein,我没有得到答案。我们最终将所有内容都转换为打字脚本!(伟大的一天)。很抱歉没有帮助:)自从TS3.7以来,这似乎不再是一个问题