Questions tagged [tsdoc]
32 questions
18
votes
2 answers
Convert Typescript with JsDoc
Can I convert TypeScript file to JavaScript file with JSDoc?
For example, if I have this main.ts file:
let x: string = "hello";
// This could be number or array of numbers
let y: number | number[];
It will be converted to something like this…

עתודה אקדמאית
- 385
- 3
- 10
8
votes
2 answers
Writing more descriptive intellisense docs for Typescript Union Types
Given the following code, when we call the baz function, the typeahead will show 'a' and 'b' as possible values.
However, if I want to provide additional documentation for each of those values, how would I do it? For example, if something like this…

davidx1
- 3,525
- 9
- 38
- 65
4
votes
2 answers
How do you add nested params to tsdoc documentation
The code below shows functionality that can potentially be used to register a user. The request body takes in multiple nested parameters such as firstName, lastName, and more. How can I adequately document these nested parameters with tsdoc?
…

myrdstom
- 156
- 3
- 15
4
votes
0 answers
How can I document overloading arrow functions in Typescript / TSDoc?
Per this answer I know how to type an overloaded error function:
type IOverload = {
(param:number):number[];
(param:object):object[];
}
const overloadedArrowFunc:IOverload = (param:any) => {
return [param,param];
}
let val =…

Erwin Wessels
- 2,972
- 1
- 24
- 17
3
votes
1 answer
What is the proper format for typing React props in TSDoc?
I'm trying to apply the TSDoc standard for comments to a React project written in Typescript (with an eye towards generating documentation with Typedoc), but can't find any definitive answers for the preferred way to annotate a React props object.…

Andrew
- 3,825
- 4
- 30
- 44
2
votes
1 answer
How to describe object properties parameters for a function in typescript TSDoc?
How do I add descriptions for a and b in TSDoc? I want the description be shown when I hover on a property argument in a function call like fn({ a }).
// This does not work
/**
* @param props
* @param props.a docs for a
* @param props.b docs for…

golopot
- 10,726
- 6
- 37
- 51
2
votes
0 answers
How to document rest parameters in TSDoc
is there a way to document with TSDoc rest parameters or parameters that going to be destructured inside a function?, a pattern that is used for example in react, where params it be destructured inside the function(Component). Something similar to…

Cristian Flórez
- 2,277
- 5
- 29
- 51
2
votes
1 answer
Missing JSDoc @param "props.children" type. and Missing JSDoc @param "props.children" type. with React Native FunctionalComponents
I'm using JSDoc & TSDoc on a react native project.
Here is the file:
import React, { createContext, useContext, FC } from 'react'
import useUserData, { UseUserDataType } from './useUserData'
import { AuthContext } from…

Xiiryo
- 3,021
- 5
- 31
- 48
1
vote
0 answers
How to document a callback function parameter in typescript
I am using TypeDoc to generate documentation from my typescript files. Let say I have this source code
/**
* Some function
* @param bar some callback function
*/
export function foo(bar:(x:number)=>void)
{
}
Which gives me this output
I could…

Ricky Mo
- 6,285
- 1
- 14
- 30
1
vote
0 answers
Is there a TSDoc tag other than @returns for type guards functions?
I was adding TSDoc to a type guard function and found out that using @returns might not be the most appropriate way to document a type guard.
/**
* Type guard to tell if a pet is a fish or a bird.
*
* @param pet - A pet that is either a fish or…

Nicolas Bouvrette
- 4,295
- 1
- 39
- 53
1
vote
2 answers
How to mark a property deprecated in a @typedef?
I would like to mark a property (for example, qux below) as deprecated:
/**
@typedef {object} Foo
@property {string} bar
@property {symbol} qux - How to deprecate it?
@deprecated @property {symbol} qux2 - Doesn't work
@property {symbol} qux3…

P Varga
- 19,174
- 12
- 70
- 108
1
vote
0 answers
is there a way to add TSDoc to Mapped Types?
here's a simple repo : https://codesandbox.io/s/elastic-ellis-bzo8h8?file=/src/App.tsx
I want to see my props description like above picture.
type AnimalAttributes = "head" | "tail";
type Animal = {
/** more than one head or tail is gross */
[k…

Mocha
- 129
- 1
- 7
1
vote
1 answer
How to forward a TSDoc description within an object property
For example, I have a function:
/**
* Function returns null
*/
const myFunction = () => {
return null
}
And an object like this:
const internals = {
myFunction: myFunction,
}
So I want to see this description: "Function returns null" at…

Mikhail Shemenyov
- 525
- 6
- 8
1
vote
2 answers
prevent asking "Missing JSDoc comment" for standard react methods in typescript project
we have React project with Typescript.
We use TSDoc to standardize the doc comments used in TypeScript code
Our eslint.trc file as follow:
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
…

loviji
- 12,620
- 17
- 63
- 94
1
vote
2 answers
Monaco Editor (TypeScript): Decorate JSDoc or TSDoc with further buttons/links/actions
I'm using Microsoft Monaco Editor for TypeScript language. The TypeScript classes and functions have JSDoc. I'd like to add buttons/links/etc. to the existing JSDoc in order to invoke a JavaScript function when the user clicks on them in the code…

PAX
- 1,056
- 15
- 33