Skip to content

Relative reference in generated .d.ts file in a monorepo #26863

Closed
@wgcrouch

Description

@wgcrouch

When generating a .d.ts file, typescript is including a relative reference for an import, which is imported as a module.

import { a } from "@ts-bug/a";

export function b(text: string) {
  return a(text);
}

generated a definition file:

/// <reference path="../../a/index.d.ts" />
export declare function b(text: string): import("@ts-bug/a").AText;

In this case it is in a mono-repo which may be confusing things, but the reference should be the same as the import.

TypeScript Version:
3.0.3, but also happens with 3.1.0-dev.20180901

Search Terms:
relative reference paths
generated reference relative

Code
I have created a repo with a simple reproduction here https://github.com/wgcrouch/ts-bug

Expected behavior:
The reference /// <reference types="@ts-bug/a" />

Actual behavior:
The reference generated is /// <reference path="../../a/index.d.ts" />

Related Issues:
#26439

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions