I have two projects: app
and lib
. app
depends on lib
.
app
is a strict Typescript project, lib
does not work with strict.
I've wired them together using Typescript Project References:
"compilerOptions": {
"strict": true,
},
"references": [
{ "path": "./apps/app" },
{ "path": "./libs/lib/" }
]
"extends": "../../tsconfig.json",
"references": [
{
"path": "../../libs/lib/tsconfig.json"
}
]
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"strict": false
},
But when I run app
I get a failure because lib
code is being run as if strict is true:
TSError: ⨯ Unable to compile TypeScript:
../../libs/lib/src/index.ts:4:3 - error TS2564: Property 'uninitializedProperty' has no initializer and is not definitely assigned in the constructor.
But lib
specifies strict as false! It works fine if strict is just disabled. How can I configure Typescript so the projects are actually separate, and the code within each uses their own tsconfig options?
I've prepared an example repository here: https://github.com/gaggle/monorepo-tsconfig-experiment . Any thoughts and suggestions welcomed!
Just to put some context to my question: I'd like to move several projects to a single monorepo, but not all the code can use the same compiler options. The "strict" difference is an example of that, and I can't just fix the code so it all works with the same options.
I got your example repo to build pretty easily -- the only trouble I had was that it was incomplete, which tells me you didn't actually try to build it. Project.json was missing dependencies.
But more significantly, I could tell that you didn't spend much time reading how Project References work, didn't read much of the project references page. So I hesitate to just do your work for you and give you the final answer. Instead, I will give you a list of the things you are not understanding, hints to what you got wrong.
These are the tsconfig
settings you got wrong:
composite
rootDir
include
files
There is at least one thing wrong in each of your three tsconfig
s.
Fix those and tsc -b .
, tsc -b apps/app
and tsc -b libs/lib
will all work as expected.
If you make progress and still are confused or stuck, then I'll help. Update the example repo and your question, and show that you tried.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.