Comments (8)
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:
But @typeParam
(or even @typeparam
) is not currently supported:
from tsdoc.
I used @template in previous codebases. I think the word came from c++.
@typeparam make more sense in TypeScript context.
from tsdoc.
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.
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.
@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.
FYI @rbuckton recently implemented support for @typeParam
in API Extractor with PR microsoft/rushstack#1317.
from tsdoc.
Does TSDoc require camelCase
capitalization for tags? The JSDoc syntax uses all lowercase:
@classdesc
@defaultvalue
(synonym for@default
)@fileoverview
(synonym for@file
)@inheritdoc
- etc.
from tsdoc.
I threw together a PR that adds support for synonyms so that @template
could be used as well.
from tsdoc.
Related Issues (20)
- Upgrade Node.js and `node-sass` dependencies HOT 1
- Validate invalid params through tsdoc eslint plugin HOT 1
- This repo is missing important files
- Documentation coverage? HOT 1
- JSDoc/TSDoc `@inherit[dD]oc` mismatch HOT 1
- Is it dead? HOT 4
- VS Code unable to load Schema
- tsdoc-unnecessary-backslash false positive
- Weird warnings about multiple declarations HOT 1
- Grouping classes under the same index name
- Support for defining custom tag syntax HOT 1
- tsdoc-html-tag-missing-equals erroneously flagging boolean attributes
- tsdoc-malformed-html-name erroneously flagging use of less than symbol HOT 1
- Unable to load schema from 'https://json.schemastore.org/tsconfig HOT 1
- `tsdoc-reference-unquoted-identifier` is incorrectly reported for certain identifiers
- [ Question ][ Playground ] Intended Behaviour? HOT 2
- eslint-plugin-tsdoc: Missing rule to check for absence of a TSDoc comment HOT 1
- ESLint flat configurations? HOT 1
- "extends": "@rushstack/heft-node-rig/profiles/default/config/jest.config.json"
- Can inherit doc also copy the TSDoc when I hover?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsdoc.