Skip to content

RFC: Syntax for "declaration references" (hyperlinks) #9

Open
@octogonz

Description

@octogonz

Certain tags such as {@inheritdoc} contain references to other API items. AEDoc supports two notations for API item references:

  • For internal references, we use: exportName.memberName

    Example: {@inheritdoc BaseWidget.draw}

    The ".memberName" is optional and included e.g. if the API item is a member of a class or interface.

  • For external references, we use: @scopeName/packageName:exportName.memberName

    Example: {@inheritdoc @microsoft/widget-lib:BaseWidget.draw}

    The "@scopeName/" and ".memberName" are optional. The "@scopeName/" is used for scoped NPM packages.

This might be a reasonable starting point. However, it doesn't consider nesting members such as namespaces (which has turned out to be surprisingly common for legacy SDKs, despite all the downsides and attempts to deprecate them).

Also, AEDoc today overlooks an interesting edge case:

export class A {
    public b: string = 'hello';
}

export namespace A {
    export let b: number = 123;
}

let a = new A();

// a.b is a string
// A.b is a number

In this example, an expression such as {@link A.b} would be ambiguous. Which declaration is it referring to? How to handle this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    request for commentsA proposed addition to the TSDoc spectool scenarioIncludes a writeup about a tool that might use TSDoc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions