tsdoc icon indicating copy to clipboard operation
tsdoc copied to clipboard

How to denote that a @typeparam should extends another type?

Open LvChengbin opened this issue 5 years ago • 2 comments

I want to tell others that a type param should follow some rules for example:

/**
 * @typeparam T - some desc
 */

interface A<T extends string> {
    name: T;
}

How can I add description like "should extend from string" for @typeparam T?

The playground https://microsoft.github.io/tsdoc seems not supports display @typeparam information in the output.

LvChengbin avatar Dec 20 '20 02:12 LvChengbin

Visual Studio / TypeScript supports @template for that:

https://github.com/microsoft/TypeScript/issues/1178.

HolgerJeromin avatar Dec 20 '20 06:12 HolgerJeromin

I don't think you can or should do this. The documentation is not for declaring types, just for describing. In the same way, you wouldn't put the type of a param in the TSDoc comment.

iansan5653 avatar Dec 22 '20 19:12 iansan5653