microsoft / tsdoc

A doc comment standard for TypeScript
https://tsdoc.org/
MIT License
4.74k stars 131 forks source link

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

Open LvChengbin opened 3 years ago

LvChengbin commented 3 years ago

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.

HolgerJeromin commented 3 years ago

Visual Studio / TypeScript supports @template for that:

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

iansan5653 commented 3 years ago

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.