Description
TypeScript Version: 4.0.0-dev.20200710
Search Terms: emit declaration, combined output, monorepo, outFile
Code
tsc index.ts --declaration --emitDeclarationOnly --outFile dist/index.d.ts
// packages/a/src/index.ts
import { B } from "b"; // this imports another package in the monorepo
export default function () {
return new B();
}
// packages/b/package.json
{
"name": "b",
"version": "0.0.0",
"source": "src/index.ts",
"types": "dist/index.d.ts", // doesn't exist yet
"main": "dist/index.js" // doesn't exist yet
}
The files listed in the package.json of b
don't exist yet because when building all packages in this monorepo setup, a
is built before b
.
Full repro in https://github.com/mischnic/parcel-issue-3891
Strangely enough, when omitting the --outFile
flag, the declaration file for packages/a/src/index.ts
(correctly) contains import ... from "b";
(this suggests that this is indeed a bug and not per design).
Expected behavior:
a/dist/index.d.ts
output:
declare module "index" {
import { B } from "b";
export default function (): B;
}
Actual behavior:
a/dist/index.d.ts
output:
declare module "index" {
import { B } from "../../b/index"; // <---
export default function (): B;
}
Playground Link:
https://github.com/mischnic/parcel-issue-3891
Related Issues: Not really related: #34846