microsoft / microsoft/tsdoc

RFC: Syntax for "declaration references" (hyperlinks)

Open
#9 61 comments 24 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

request for comments tool scenario
Dominant language
TypeScript
Stars
5k
Forks
162
Avg merge
17h 24m
Merged PRs (30d)
8

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the AEDoc API item reference notation and the TypeScript example in this issue. Define how references represent nested members and how the ambiguous A.b case is resolved; done means the syntax and resolution rules are specified for these cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.