Repository navigation
Relative reference in generated .d.ts file in a monorepo #26863
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Activity
- addedBugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts files
on Sep 17, 2018 RyanCavanaugh commented
on Mar 13, 2019 MemberMore actionsProbably a duplicate of the linked related issue
Ryan Cavanaugh (@RyanCavanaugh) Yes - but this one has a reproduction repository so it should be easier for somebody to get to the root cause on.
In my case the generated .d.ts file contains syntax errors – is that related to this issue?
/// <reference path="../../../../../../../../node_modules/@types/moduleE/dist/index.d.ts" /> declare const myFunc: () => O<'moduleE'.E<any>>;
The above is invalid, hence definitely a bug.
The file causing this error is as follows:
declare module 'moduleE' { export interface E<T> { …
If I remove the
declare module, it's at least generating an@import()around the module name.And if I replace the arrow function by a regular function, everything works:
export function myFunc(): MyResult<any> {Andy Pillip (@andypillip) if you could open up a new issue with a repro, that's be great, it's definitely not (directly) related to the issue in the OP here.
- addedFix AvailableA PR has been opened for this issueA PR has been opened for this issue
on Aug 13, 2019 - locked as resolved and limited conversation to collaborators
on Oct 21, 2025
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesFix AvailableA PR has been opened for this issueA PR has been opened for this issue
When generating a .d.ts file, typescript is including a relative reference for an import, which is imported as a module.
generated a definition file:
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