TypeScript Version: 3.1.0-dev.20180721
Search Terms: tsc build project reference rootDir outDir
Code
Brief summary: When rootDir and outDir are involved as well as a project reference, source files within an individual project that has a dependency project would be compiled in alphabetical order. The consequence is that an A.ts that imports from B.ts will fail with Output file '.../B.d.ts' has not been built from source file '.../B.ts' but if I rename A.ts to C.ts everything works, as does removing the project reference or not using root/outDir.
The setup is hard to fully convey through text so here's a zip: repro.zip. npm install then npm run build to trigger the issue.
Expected behavior: Compiles both main and other projects successfully regardless of the names of the source files.
Actual behavior:
error TS6305: Output file '.../B.d.ts' has not been built from source file '.../B.ts'.
I was just hit by this as well - exact same issue, and the reproduction is bang on what I'm seeing. Let me know if there's anything I can do to help expedite this (PR, tests, another repro, test a beta, etc.). Thanks!
This is broken in 3.8.0-beta
This is broken. Again.
Version 3.7.5 and 3.7.4.
This is broken in 3.7.5
the same in 3.7.2
I had the same problem but it stopped when I took care of the following. (I'm on v3.8.3 btw).
.tsbuildinfo file too..tsbuildinfo files were created where I would not expect, not in the same folder where the tsconfig.json lives. I didn't catch it because it was gitignored. Regardless, manually setting the "tsBuildInfoFile" compiler option on all my tsconfig files solved that issue.paths compilerOption to the emitted files of any dependencies.My tsconfigs look like this:
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist/lib",
"composite": true,
"baseUrl": "../",
"paths": {
"my-dependency": [
"./my-dependency/dist/lib/index"
],
"my-dependency/*": [
"./my-dependency/dist/lib/index/*"
]
},
"tsBuildInfoFile": "tsconfig.tsbuildinfo"
},
"include": ["src"],
"exclude": [
"**/*.test.ts",
"**/*.test.tsx"
],
"references": [
{
"path": "../my-dependency/tsconfig.json"
}
]
}
I am on 3.9.3 and the bug is still there... @sheetalkamat
This breaks the project references feature and makes it entirely unusable.
@desmap you would need to open new issue with exact repro steps to be able to investigate this. The repro in this issue seems to be working correctly.
@sheetalkamat Unfortunately I'm not in a position to set up a repro project, but in my case, this is happening when the build script is running within a docker image build. I assume it has to do with the way the output file is compared with an existing tsbuildinfo file that has been copied or volume mounted. That's speculative, so I'll try to get an exact answer once I work around the issue.
Most helpful comment
I had the same problem but it stopped when I took care of the following. (I'm on v3.8.3 btw).
.tsbuildinfofile too..tsbuildinfofiles were created where I would not expect, not in the same folder where the tsconfig.json lives. I didn't catch it because it was gitignored. Regardless, manually setting the "tsBuildInfoFile" compiler option on all my tsconfig files solved that issue.pathscompilerOption to the emitted files of any dependencies.My tsconfigs look like this: