Skip to content

Type alias with an import type links to the module, not the referenced type #2779

@blutorange

Description

@blutorange

Search terms

type alias link reference declare module

Steps to reproduce the bug

Just tried your fix for #2778, works perfectly. Unrelated to that, though, I did notice another strange behavior regarding links to type aliases:

declare module "bar" {
    export interface Bar {}
}
declare module "foo" {
    export type Foo = import("bar").Bar;
}

When you generate the docs, the type alias Foo in module foo links to the module bar, instead of directly to the interface Bar.

(Which also results in a missing reference when using typedoc-plugin-merge-modules, since, well, the module does not exist anymore as it was merged).

npx typedoc --entryPoints dist/demo.d.ts --out docs-demo

image

Interestingly, this only happens when using an import type. Importing the symbol first seems to work:

// demo.d.ts
declare module "bar" {
    export interface Bar {}
}

declare module "foo" {
    import { Bar } from "bar";
    export type Foo = Bar;
}

It also seems to happen with declare module "name", but not when using separate files bar.ts and foo.ts.

Expected Behavior

TypeDoc should link directly to the referenced type.

Actual Behavior

TypeDoc links to the the module containing that type.

Environment

  • Typedoc version: 876c690
  • TypeScript version: 5.6.3
  • Node.js version: v20.18.0
  • OS: Linux 6.8.0-35-generic #35-Ubuntu x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions