Skip to content

Emitting combined output declarations tries to resolve monorepo imports #39547

Closed
@mischnic

Description

@mischnic

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

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions