Skip to content

Links point to wrong scope when linking from interface to external scope #1949

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

Closed
ritave opened this issue Jun 5, 2022 · 1 comment
Closed
Milestone

Comments

@ritave
Copy link

ritave commented Jun 5, 2022

Search terms

link

Steps to reproduce the bug

export interface MyInterface {
}
export interface Nested {
  // This will link to Nested.MyInterface in generated documentation
  // The behaviour is different from the Typescript Language Server, which links to interface MyInterface
  /** {@link MyInterface} */
  readonly MyInterface: new() => MyInterface;
}

Notice that this will work correctly

export interface MyInterface {
}
export type Nested = {
  // Both Typedoc and TS Language Server will point to interface MyInterface
  /** {@link MyInterface} */
  readonly MyInterface: new() => MyInterface;
};

Environment

  • Typedoc version: TypeDoc 0.22.17
  • TypeScript version: Version 4.7.2
  • Node.js version: v16.15.0
  • OS: macOS Monterey Version 12.4
@ritave ritave added the bug label Jun 5, 2022
@ritave ritave changed the title Links point to wrong scope when overloaded Links point to wrong scope when linking from interface to external scope Jun 5, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 5, 2022

Oh TypeScript, why did you have to add support for @link... This is working as documented today, though it would be nice to try to be consistent with TypeScript's behavior. If I remember right, the "correctly" working one is doing that because TypeDoc doesn't traverse into type literals for links (TypeScript sometimes does)

TypeScript how I despise you some days...

// TypeScript / TypeDoc

/** {@link abc} 1/1 */
type abc = 1

/** {@link abc} 2/2 */
namespace Foo {
    /** {@link abc} 2/2 */
    export type abc = 2

    /** {@link abc} 3/2 */
    export function asdf(){
        /** {@link abc} 3/not processed */
        type abc = 3
    }
}

/** {@link abc} 1/4 */
interface Bar {
    /** {@link abc} 1/4 */
    abc: 4
}

/** {@link abc} 1/5? maybe 1 */
type Baz = {
    /** {@link abc} 1/5 */
    abc: 5
}

/** {@link abc} 1/6 */
class Zip {
    /** {@link abc} 1/6 */
    abc?: 6
}

{
    /** {@link abc} */
    type abc = 7
}

... Namespaces create a new scope, so do other nodes with a body, but nothing else, well... okay...

One advantage to TypeDoc's resolution strategy is that links that TS resolves to 1 don't change what they are pointing to if you comment out type abc = 1... though I guess the opposite could be said if Foo.abc went away...

@Gerrit0 Gerrit0 added this to the v0.23 milestone Jun 12, 2022
@Gerrit0 Gerrit0 removed the bug label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants