Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Type assertion in JSDoc VScode

/** * @typedef Animal * @property {string} noise */ /** * @typedef Duck * @property {string} noise * @property {number} wings */ /** * @param {Animal} a */ function TestAnimal(a) { console....
Shuri2060's user avatar
  • 797
0 votes
1 answer
12 views

How to automatically display ts type definitions in storybook

const mate = { title: 'MemoOrMessage', component: MemoOrMessage, tags: ['autodocs'], } satisfies Meta<typeof MemoOrMessage>; I'm currently using autodocs to generate documentation, which ...
Gauch's user avatar
  • 29
0 votes
0 answers
17 views

express-session & jsdoc: correct types for req.session

I'm just starting to learn jsdoc, so this is all new to me. In exrpress-session we have a session object, which stores session data req.session. I'd like to store a userId in the session object. But ...
FrontendC's user avatar
  • 401
0 votes
1 answer
35 views

How to disable eslint `require-jsdoc` for TS type declarations, or at least for individual props

We love the eslint rule require-jsdoc... most of the time. But whenever we export a TS type (or interface), we're warned if we don't have a jsdoc block on not only the type itself, but also on each ...
XML's user avatar
  • 19.4k
0 votes
0 answers
13 views

How to add JSDoc documentation to a re-exported namespace in TypeScript?

I have a module that re-exports another module as a namespace: export * as Foo from "bar"; I want to add documentation to the exported namespace so when it is imported, some description of ...
Adam Simon's user avatar
  • 2,930
0 votes
0 answers
9 views

How to recycle both function and it's JSDoc in a class definition?

I'm cracking my head over this... I know I can recycle/reuse both function and it's documentation by defining them on a class then extending another class... But this way will block inheriting from ...
user2804429's user avatar
0 votes
0 answers
30 views

JSDoc duplicate documentation of classes

I'm using JSDoc and better-docs to document my TypeScript code. I encounter two not that fatal but very annoying problems. One of them is I get this weird double documentation that I will try my best ...
Tereza Hristova's user avatar
0 votes
0 answers
20 views

JSDoc source links are incorrect

I'm using jsdoc and better-docs to document my typescript code. I encounter two not that fatal but very annoying problems. One of them is connected to the source links. On everything I have documented ...
Tereza Hristova's user avatar
0 votes
0 answers
27 views

JSDOC: Private name is not defined

I am trying to document some classes using JSdoc comments and the JSdoc plugin. /** * @category SomeCategory * @class * @extends someClass * @description Lorem ipsum */ class ExampleClass extends ...
Tereza Hristova's user avatar
1 vote
1 answer
45 views

How do I keep the literal type information alive? [duplicate]

I have the following code snippet, my question is how do I keep the literal type information of knowLiteral without having to spell out the type like I am doing right now? I want this in JSdoc since ...
tovernaar123's user avatar
1 vote
0 answers
26 views

Can I annotate a strategy-pattern class-factory using JSDoc?

Essentially I have the following inheritance chain: Chainable -> Strategy -> Actions Actions are used at the call-site returning a chainable API: await actionMaker() .action1() .action2() ...
shuckster's user avatar
  • 5,399
2 votes
0 answers
54 views

Javascript variable as the type of itself

I have an object with jsdoc annotations for the properties: const foo = { /** @type {string[]} */ bar: [], baz: { /** * @param {string} x * @returns {number} ...
dragoncoder047's user avatar
1 vote
2 answers
95 views

Forwarding JSDoc for object members whose source is a variable

I have a function documented with JSDoc which then becomes part of an object literal. How can I forward the documentation for the function to the object literal, and thus make it available to an ...
Zev Spitz's user avatar
  • 14.9k
0 votes
1 answer
41 views

How do I get JSDoc @typedef and @type to appear in Intellisense of an ASP.NET Core MVC project in either Visual Studio 2022 or Visual Studio Code?

So I've started to document my code a lot more lately as I've not been soloing on a number of projects. In my standard nodejs projects inside VSCode I can create inline @typedef and @type like this: **...
clubside's user avatar
0 votes
1 answer
29 views

How do you document this.field in the Mocha TestContext with JSDoc types in a before() hook so that other it() tests and IntelliJ know what it is?

I want IntelliJ (or any similar IDE, like WebStorm or VSCode) to give me auto-complete for my fields that I define in my test context in a Mocha.js before() hook. I then want to be able to see the ...
Luke Machowski's user avatar
1 vote
1 answer
27 views

How to use generic types in JSDoc to represent an instance of a (class) type

I am fairly sure this is not possible, but figured someone out there may know more. I have a simple object factory in JavaScript that I'm using to minimize heap allocs of the same service objects. ...
Jason Polites's user avatar
0 votes
1 answer
27 views

Reference a typescript class in jsdoc

I've been documenting my JS using jsdoc and am now converting to d.ts files in order to have these exported as types from my package. I want to keep things as DRY as possible. declare class ...
wheresrhys's user avatar
  • 23.2k
0 votes
1 answer
40 views

Set the key type in the object based on the contents of the array

const keys = ['x', 'y', 'z']; /** @typedef ??????? KeyType`*/ //is important that the type is based on the values from the keys /** @type {{[key: KeyType]?: number}} */ const obj = {}; for(const k of ...
vadimmos's user avatar
1 vote
0 answers
25 views

getting prisma types into jsdoc and shown in docdash

im trying to build some api docs with jsdoc and docdash. im importing types from prisma into my jsdox types and thats working fine. what i cant get to work: getting the prisma types to show up, ...
Jared Myhrberg's user avatar
0 votes
1 answer
29 views

How to annotate plain javascript "overloads" to avoid errors in calls and have correct type in the function?

I have JavaScript type checking enabled in my project with the following jsconfig.json settings: { "compilerOptions": { "target": "ES2020", "...
Tomáš Zato's user avatar
  • 52.4k
0 votes
0 answers
43 views

JSDoc auto-generation in PhpStorm - no empty lines before parameters

Whenever auto-generating a JSDoc in PhpStorm, it adds an extra empty line before the parameters, presumably for description, however description is not needed all the time. I would like to set it so ...
bulanmaster's user avatar
2 votes
1 answer
29 views

How to use JSDoc to express what events a class can listen to

How to use JSDoc to express what events a class can listen to This is a simplified example //event: 'open', 'log', 'data', 'error', 'close' class MyWrap extends EventEmitter { #port /** ...
yujen's user avatar
  • 43
0 votes
0 answers
39 views

Disable eslint `require-jsdoc` for nested functions

I'm trying to disable jsdoc warnings for nested functions. For example, in this file it spits a warning on the commented line. // Notifications.ts import * as Device from "expo-device"; ...
reactive's user avatar
0 votes
1 answer
29 views

How to get the inner type from the Iterator (or other template) in JSDoc in VSCode?

I am writing a helper for iterating, similar to the upcoming experimental Iterator APIs, like map. This is written in vanilla JS and I want all type hints to work for chain of calls. To try and ...
Tomáš Zato's user avatar
  • 52.4k
1 vote
1 answer
43 views

Letting Typescript recognize new methods added through Object.prototype

I would like for typescript to recognize changes I make to the Object.prototype. Ideally, I would like to be able to do something like: Object.prototype.l = function (title: string) => { ...
cayge sinnett's user avatar
2 votes
1 answer
64 views

JSdoc vscode intellisense on monkey patched / added function?

Here's an example of what I'm trying to do. Just wondering if there's any way to accomplish having the moo method referenced in other places on VS code populate intellisense using jsdoc. Right now it ...
FDEV's user avatar
  • 23
1 vote
1 answer
26 views

Combined type gets lost when used in the code

I have this function call: myapp.auth(formData).then((/**@type {(import('$lib/types').APIEndpoint & {data?: import('$lib/types').LoginToken}) | null}*/ response) => { if (!response) { ...
thisjt's user avatar
  • 324
1 vote
1 answer
96 views

Dynamic return type based on param value JSDoc

I've been trying to document my JS code with types, but am having trouble with this one function. I'm trying to filter an array using its type property, however when trying to map the provided string ...
Zachary's user avatar
  • 65
0 votes
1 answer
30 views

In JsDoc, how do I make the @return type of my function the type of a local variable set in child class?

Using this question as a reference: jsDoc : How do I make the @return type of my method the type of a local variable from it? How do I accomplish this using an extended class? class Parent { static ...
Nihilum's user avatar
  • 33
0 votes
2 answers
89 views

Use styled-components props in v6 with JSDoc

How can JSDoc be used to type props of styled-components in combination with tsconfig.json and tsc. In TypeScript this is very easy with a simple generic, unfortunately I cannot achieve the same using ...
controlol's user avatar
0 votes
1 answer
37 views

How to write a @typedef with arguments? (Like CustomEvent's detail type argument)

Suppose I have a type that describes an API response: /** * @typedef {{ * status: string, * code: number, * type: string, * data: T[], * }} ApiResponse */ where T could be any of a number ...
AnrDaemon's user avatar
  • 342
0 votes
0 answers
61 views

Can I define a jsdoc typedef (an object) by "spreading" existing typedefs?

Can I use the spread operator to create typedefs by combining existing typedefs? For example- given typedefs One and Two where both are objects, how do I then create typedef Three? JSDoc seems to let ...
Fergie's user avatar
  • 6,190
0 votes
1 answer
112 views

Route params not populating properly from Swagger UI in ExpressJs api

I am implementing Swagger into an ExpressJs API application. In the controller files, we are using nested folders and "const router = require('express').Router({ mergeParams: true });" to ...
Paul Pickins's user avatar
0 votes
1 answer
78 views

How do I successfully use an interface from a TypeScript file that has its own import inside it?

I'm working on a React JavaScript project with WebStorm and trying to implement type hinting for our IDEs (VS Code as well) using TypeScript interfaces and JSDoc annotations (which hopefully we'll ...
Chris Simpson's user avatar
1 vote
2 answers
121 views

JSDoc intellisense when using script tags

Problem I am finding that JSDoc works well with intellisense and type checking when the JSDoc-typed code is "inside" the project; however, including a JSDoc-typed library via a script tag (&...
Jacob Runge's user avatar
-1 votes
2 answers
310 views

await has no effect on this kind of expression - but clearly does

I recently added jsdocs to my project and since then I have eslint telling me that 'await has no effect on this kind of expression' const result = await someAsyncFunction(); // await has no effect ...
user3086509's user avatar
0 votes
0 answers
191 views

JSDoc not generating the documentation correctly in Vue 3

I made a simple app in Vue 3 and i'm trying to use JSdoc to make the documentation of my code, but when im trying to generate it, the index.html file is empty. I've tried to debug the command but i ...
Fargex12's user avatar
0 votes
0 answers
57 views

Can I make JSDoc trust me that 1 egg + 1 egg = 2 eggs?

I want to write nC = nA + nB (see below) but JSDoc thinks that is an error. Can I make JSDoc change its mind? /** @typedef {number&{_tag: 'numberOfEggs'}} numberOfEggs */ /** @param {number} ...
Leo's user avatar
  • 4,388
-2 votes
2 answers
185 views

How can I make JSDoc/TypeScript understand JavaScript imports?

I have added // @ts-check to a JavaScript file to use JSDoc. Suddenly I get errors in VS Code for functions included with a script tag: <script src="imported-file.js"></script> ...
Leo's user avatar
  • 4,388
0 votes
1 answer
81 views

How to add description to returned object props with JSDoc or TypeScript?

I have a TypeScript project and have a custom hook which returns a bunch of variables isMobile | isDesktop | ... and I'd like to add a description to each of these variables so that somewhere in ...
qweezz's user avatar
  • 764
0 votes
1 answer
23 views

JSDOC Reference key of other type

How does one reference the key of another object within a @type or @typedef? /** * @typedef {{name: {name: string}}} moo * @typedef {{name: moo.name}} moo2 */ I would expect vscode to resolve moo2 ...
Grithin's user avatar
-1 votes
1 answer
38 views

Cannot find name 'myFun' (defined in included file "my-funs.js")

The function myFun is defined in the included file: <include src="my-funs.js"><script> The include file has // @ts-check and a JSDoc comment for the function: /** * * @param {...
Leo's user avatar
  • 4,388
1 vote
1 answer
60 views

milliSeconds vs seconds, can JsDoc tell me when I mix things up?

I want to learn a bit TypeScript and JsDoc. A common situation for me is that I happen to mix numeric values that are not quite the same. As a simple example (not very realistic, perhaps) let us say I ...
Leo's user avatar
  • 4,388
4 votes
0 answers
96 views

How can I reuse JSDoc function definition in react hooks?

I'm working on documenting custom hook code in React using JSDoc. I'm trying to find the best way to include documentation for the functions that the hook returns. For example, consider the following ...
Ori Swid's user avatar
1 vote
0 answers
45 views

jsdoc @example from another file

I want to use another file to document my function so I could enjoy full syntax highlighting, error report, and type safety in example. currently I just manually coping it over when i change the ...
Eliav Louski's user avatar
  • 4,835
0 votes
0 answers
84 views

What is the JSDoc's equivelant of 'extends' in Typescript

I am trying to extend type definitions @typedef in JSDoc. Coming from Typescript I am looking for something along the lines of extending interfaces like the code below. interface Animal { name: ...
Marinos Chrysanthou's user avatar
0 votes
1 answer
21 views

How do I use jsdoc to document a set of functions that destructured from the return value of another function?

Firstly, I have read this question/answer, and it doesn't quite apply to my situation. I'm calling a library function, which dynamically creates and returns an array of functions. My module then ...
Cam Jackson's user avatar
  • 12.2k
0 votes
0 answers
47 views

Document an inherited property dinamically created from parent class in JSDoc?

I'm extending a Controller class which (dynamically) adds a property named clearResultValue: import { Controller } from '@hotwired/stimulus'; export default class extends Controller {} I want to ...
gremo's user avatar
  • 48.5k
1 vote
0 answers
47 views

How to document function parameters' order in JSDoc?

I've got a function that uses the arguments object to accept parameters, like this: function DoLog() { let level='info', content, logger='log'; switch (arguments.length) { case 1: ...
PY-DNG's user avatar
  • 11
0 votes
0 answers
23 views

How do I preview collapsed JSDoc comments in Visual Studio?

I am using Visual Studio 2022 v17.9.5 and I have JavaScript files with JSDoc comments that look like this when expanded: When I collapse the JSDoc comments, they just become a box with three dots and ...
Eric Mutta's user avatar
  • 1,407

1
2 3 4 5
36