Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
blutorange opened this issue Nov 24, 2024 · 2 comments
Closed
Labels
bug Functionality does not match expectation
Milestone

Comments

@blutorange
Copy link

blutorange commented Nov 24, 2024

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
@blutorange blutorange added the bug Functionality does not match expectation label Nov 24, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 24, 2024

How on earth has nobody noticed this before... I'm pretty sure it's been there for at least 4 years at this point.

Gerrit0 added a commit that referenced this issue Nov 24, 2024
@Gerrit0 Gerrit0 added this to the v0.27.0 milestone Nov 24, 2024
@blutorange
Copy link
Author

I guess because it only happens with declare module, which isn't that common (and was previously converted to namespaces). In our case, after some experimenting, I found creating a merged declaration file with declare module to be the best option.

Anyways, I just tried out your change and it works as expected. With that, I think I now also have a working setup for generating a nice looking documentation for primefaces/primefaces#12717 Thanks again for fixing this so quickly.

image

blutorange pushed a commit to blutorange/primefaces-js-refactor-test that referenced this issue Nov 24, 2024
@Gerrit0 Gerrit0 closed this as completed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants