Navigation Menu

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

@link causes warning + error when used in namespace with same name as class/interface combo #2033

Closed
frank-weindel opened this issue Aug 11, 2022 · 2 comments
Labels
bug Functionality does not match expectation

Comments

@frank-weindel
Copy link

frank-weindel commented Aug 11, 2022

Search terms

same name interface namespace link

Expected Behavior

No warning or error in the scenario laid out below

Actual Behavior

TypeDoc fails to compile with this warning and error:

warning Failed to resolve {@link AnotherInterface} in SameNameClassNamespace with declaration references. This link will break in v0.24.
error Command failed with exit code 3.

Steps to reproduce the bug

Repro PR:

/**
 * Some code reproducing a bug.
 */
declare namespace SameNameClassNamespace {
  /**
   * This causes an error even though it's relatively correct: {@link AnotherInterface}
   */
  export interface AnInterface {

  }

  /**
   * Some documentation
   */
  export interface AnotherInterface {

  }
}

/*
 * The error goes away in three ways:
 * - Comment out the below class
 * - Comment out the below interface
 * - Even stranger: Make this comment a TSDoc comment (add extra * to beggining of comment),
 *   which will apply to the class.
 *     - This may be a workable workaround
 */


declare class SameNameClassNamespace {

}

/**
 * This interface is used to augment additional keys (from AnInterface) onto SameNameClassNamespace
 */
interface SameNameClassNamespace extends SameNameClassNamespace.AnInterface {

}

export {
  SameNameClassNamespace
};

Environment

  • Typedoc version: 0.23.10
  • TypeScript version: 4.7.3
  • Node.js version: v16.14.0
  • OS: macOS 12.2.1
@frank-weindel frank-weindel added the bug Functionality does not match expectation label Aug 11, 2022
frank-weindel added a commit to frank-weindel/typedoc-repros that referenced this issue Aug 11, 2022
frank-weindel added a commit to frank-weindel/typedoc-repros that referenced this issue Aug 11, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 13, 2022

... at this point, surely you're trying to break me, what a convoluted setup XD

Thanks for the minimal repro!

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 13, 2022

Ah, this makes sense now... confusing bug though.

The link on AnInterface is being resolved as expected. The issue is that the comment is inherited by the class reflection for SameNameClassNamespace. When this happens, the link will then be resolved relative to the class, and TypeDoc today doesn't check for other declaration merged elements when attempting to resolve links

A simpler setup illustrating the same problem is:

namespace Foo {
  export interface Bar {}
}

/** {@link Bar} */
class Foo {}

TypeScript will resolve this link to Foo.Bar... it's not very difficult for TypeDoc to do the same, so I think it's a reasonable change.

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