Giter Site home page Giter Site logo

Comments (8)

rbuckton avatar rbuckton commented on July 22, 2024 13

Also, the Closure Annotated JavaScript syntax is @template T (1, 2), which is already supported by TypeScript for hover/quick-info comments in both JavaScript and TypeScript files:

image

But @typeParam (or even @typeparam) is not currently supported:

image

from tsdoc.

MartynasZilinskas avatar MartynasZilinskas commented on July 22, 2024 5

I used @template in previous codebases. I think the word came from c++.

@typeparam make more sense in TypeScript context.

from tsdoc.

dschnare avatar dschnare commented on July 22, 2024 2

I like this idea, but usually I solve this by giving the template parameters a better name.

class MyClass<TValue> {
  public value: TValue
  constructor (value: TValue) {
    this.value = value
  }
}

But I imagine there will be scenarios where having documentation for template parameters would be useful.

I also found this in the TypeScript wiki: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript#template

Looks like the compiler went with @template for this one.

from tsdoc.

octogonz avatar octogonz commented on July 22, 2024

I like @typeparam since @template seems unclear, like it's maybe telling us that the entire declaration is a template class. Following TSDoc capitalization it would be @typeParam.

Official JSDoc doesn't support either, so maybe have some freedom to choose which tag to use.

The grammar should be pretty much identical to @param, so if there's a consensus, I can create a PR to add it to the library pretty easily.

from tsdoc.

helmbold avatar helmbold commented on July 22, 2024

@dschnare I agree with you that type parameters should have meaningful names, especially if there is more than on of it. However, sometimes it makes sense to explain a type parameter.

For example I have a class with a render function, that can take differently shaped objects and that may not be obvious to the user of this class. Let me show an example:

class Example<Parameters> {
  ...
  render(paramters: Parameters) {
    ...
  }
}

Usage is like this:

const e = new Example<{a: number, b: string}>();
e.render({a: 123, b: 'test'})

If I could explain this parameter, it would improve my API.

/**
 * @typeparam Parameters Shape of the object containing variables for rendering the template,
 * e.g. `Example<{a: number, b: string}>`.
 */
class Example<Parameters> {
```

from tsdoc.

octogonz avatar octogonz commented on July 22, 2024

FYI @rbuckton recently implemented support for @typeParam in API Extractor with PR microsoft/rushstack#1317.

from tsdoc.

rbuckton avatar rbuckton commented on July 22, 2024

Does TSDoc require camelCase capitalization for tags? The JSDoc syntax uses all lowercase:

from tsdoc.

rbuckton avatar rbuckton commented on July 22, 2024

I threw together a PR that adds support for synonyms so that @template could be used as well.

from tsdoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.