Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
54 views

How to get IDE intellisense autocompletion through JSDoc type hints with TypeScript packages?

I just noticed that we can get IDE intellisense autocompletion through JSDoc type hints like this (from Vite config documentation): /** @type {import('vite').UserConfig} */ export default { / ... } ...
Ole's user avatar
  • 47.4k
1 vote
0 answers
71 views

How does one declare a variable with the type of global object (of other JavaScript Context)?

How can one declare a variable to have the type of global object (of other JavaScript context); that is, it contains all JavaScript built-in objects, but it is not typeof globalThis (which is ...
user2771324's user avatar
0 votes
0 answers
35 views

Why is the generic type of this class getting overwritten in JSDOC, but not Typescript?

We're working on converting a project from Typescript (.ts) to Typescript-via-JSDOC (.js). We have a class StateHolder, instances of which contain data described by the generic State. The data can be ...
RobertAKARobin's user avatar
0 votes
0 answers
21 views

Import JSDOC type annotations from a JavaScript npm package

I have an npm package for NodeJS that is implemented in (plain and not compiled) JavaScript and uses JSDOC type annotations to type check the code using TypeScript and this works like a charm. When ...
doberkofler's user avatar
  • 10.4k
0 votes
0 answers
37 views

How to Import Types or Variables from a Module in JSDoc in a JS File Imported into an HTML File

I'm trying to import a type or variable from a module using JSDoc. The program works, but VSCode gives the following errors, and I want to fix them: Cannot find name 'TomSelect'. Did you mean '...
ProfBrickz's user avatar
0 votes
0 answers
28 views

How can I use the @class tag value instead of the constructor function name as a class's longname?

The framework I am using creates classes using arrow functions that stick 'create' at the start so when you want to create an instance of Example you would use createExample(). In the documentation, I ...
Jamesyboy1994's user avatar
0 votes
1 answer
28 views

How to define @template types for parent class in child class?

I am using JSDoc to try and emulate some type hinting and I am running into an issue while trying to get generic types working with @template. Here is a snippet of the parent class (BaseFixture): /** ...
Sammaye's user avatar
  • 43.9k
0 votes
1 answer
39 views

How to write comments on a @typedef for Closure compiler?

Here is how you define a custom type, from the Closure compiler documentation: /** * @typedef {{ * foo:string, * bar:number, * foobar: (number|string) * ...
Björn Morén's user avatar
2 votes
1 answer
78 views

jsDoc to define constructor function properties that are assigned implicitly (not set with `this`)

Using jsDoc in VS Code, How could we define the properties of a constructor function that its properties are not set directly through this.property = value syntax, but implicitly via Object.assign() ...
S.Serpooshan's user avatar
  • 7,470
0 votes
0 answers
25 views

Error not found p5.js in Vercel but Vite works fine

Not showing p5,js sketches as Vercel gives an not defined error, in Vite works fine. Also would like to go to myproject/docs and show the jsdoc documentation. Load my project, and sketches are not ...
Eduardo Gutiérrez's user avatar
1 vote
0 answers
32 views

How to pass generic type while calling a function? [duplicate]

How to pass generic type while calling a function using JSDoc. This generic type is not part of any actual parameters. /** * @template T * @template {string} C * @param {string} param1 * @param {...
Vinod Gubbala's user avatar
0 votes
0 answers
12 views

Formatting hovertext in vscode in repo with both ts & proptypes

I have a repo using both typescript and proptypes (it started with proptypes and we only recently added ts so I don't want to remove proptypes as the runtime checking is useful), and the hover text on ...
user17928719's user avatar
1 vote
2 answers
478 views

How to correctly generate .d.ts files for library package

I'm working on an JavaScript NPM library package and trying to get typescript to generate a .d.ts file from the jsdocs embedded in the file. Let's say I have the following three files: index.js, the ...
Brad Robinson's user avatar
-1 votes
1 answer
46 views

How to comment the variables declared by destructuring so that the description is displayed when the mouse hovers over them [duplicate]

I tried adding a description but it didn't work, No matter how I annotate it it will only show the type. Neither of the following methods work. / not working /** not working */ const [state, setState]...
Tukun33's user avatar
  • 37
2 votes
1 answer
71 views

How to write JSDoc if name of property is string, like 'aria-label'

I want to write JSDoc for some React component: /** * Some Component * @param {Object} props - props of the component * @param {boolean} [props.active=false] - active * @param {string} props.text -...
Lazy_Cat's user avatar
0 votes
1 answer
25 views

How to propertly define what this references to in JSDOC?

I come this time with a very simple question. Is there a way, on JSDOC, to describe what this represents in a class? /** * This is a very simplified version of what is going on * * I want to ...
Sol's user avatar
  • 891
0 votes
0 answers
26 views

JSdoc preserving comment formatting

How can I preserve the formatting of this comment in JSDoc without wrapping it in a code block? I have a comment in the code that explains the format of a string that represents the an event. I would ...
Don Dugger's user avatar
0 votes
1 answer
114 views

How to type an object with dynamic keys?

How can I achieve typehinting an object having dynamic keys with JavaScript / JSDocs only? (TypeScript knows index signature, yet this is not for TypeScript.) I want to use JSDoc to document an ...
k0pernikus's user avatar
  • 66.8k
0 votes
0 answers
83 views

How can I correctly specify the TypeScript type of a function taking an optional parameter with optional properties in a JSDoc comment?

When I have a function like /** @type {(envVar: string) => boolean} */ const envToBoolean = (envVar) => !!process.env[envVar]; IDEs show its TypeScript type as specified. However, in this more ...
Alexey Romanov's user avatar
0 votes
0 answers
53 views

Re-exporting class in a namespace object loses its "type" in JSDoc

I have issue with VS Code, TypeScript (not used directly) and JSDoc where I re-export a class from a library through a namespace object to users code and type is not properly recognized in all uses: ...
HankMoody's user avatar
  • 3,174
0 votes
2 answers
94 views

How can I have a JSDoc interface with static properties & methods?

The following is an interface. /** * @interface */ class ISomething { /** * @return {number} */ static aMethod() { throw new Error('not implemented'); } /** * @type {Object} ...
AvirukBasak's user avatar
0 votes
0 answers
48 views

Easier way to define JSDoc type hints?

I'd like to use JSDoc type hints as much as possible. But in some cases, defining hints is tricky. In this case, it is Svelte's Store. After much effort, I succeeded with the following code: import { ...
enoeht's user avatar
  • 483
1 vote
0 answers
46 views

Displaying Documentation of a lit web component

I have a simple lit web component defined and documented in typescript but the component's documentation is not showing when i hover over it in its call site. ... /** * @description * MyMessage ...
Jobie J's user avatar
  • 257
0 votes
2 answers
68 views

JSDoc: Documenting a function with interdependent parameters

I have a function which takes in two parameters, something like: function example(type, val) { / handle "val" based on "type" } The acceptable types for val depend on type. The ...
simplexshotz's user avatar
1 vote
0 answers
118 views

Modify VSCode Intellisense for JS/TS Doc?

Does anyone know if it is possible to modify VSCode Intellisense for JSDoc and TSDoc tags? I have always been bothered by the way VSCode handles certain JS/TS doc tags and I just cannot handle it ...
DaveyJake's user avatar
  • 2,439
2 votes
2 answers
134 views

How to specify a parameter as a function from a specific class in JSDoc?

I'm working on a JavaScript class and using JSDoc for documentation. In the constructor, I have a parameter mutationAlgorithm that should accept a function from the Mutation class (e.g., Mutation....
iso53's user avatar
  • 72
0 votes
0 answers
75 views

Preserving type parameters of a constructor when replacing the instance type

I'm coding a type-safe class system using ES5 and JSDoc. At the most basic level, the problem boils down to adding a property to the constructor's returned instance type, while preserving the type ...
Shmookoff's user avatar
2 votes
0 answers
23 views

JSDoc not appearing on the returned object of a function

In my TypeScript project, I've got a React Hook and would like to include some handy JSDoc for the next dev. My function returns an object with methods, and I've noticed that the function and the ...
Josh Silveous's user avatar
0 votes
1 answer
59 views

How to properly infer the Constructor of an object through JSDoc?

I want to make this function that receives a parameter and return its class if object, the parameter itself if function or the legacy object constructor if anything else. In JavaScript the example ...
KLASANGUI's user avatar
  • 1,132
0 votes
0 answers
43 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
  • 806
0 votes
0 answers
40 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
31 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 ...
pqzpkaot's user avatar
  • 411
0 votes
1 answer
233 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.5k
0 votes
0 answers
44 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,970
0 votes
0 answers
16 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 ...
KLASANGUI's user avatar
  • 1,132
0 votes
0 answers
61 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
28 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
34 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
55 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
31 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,437
2 votes
0 answers
75 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
97 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
  • 15.4k
0 votes
1 answer
124 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
41 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
31 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
56 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.6k
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
0 votes
0 answers
57 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
34 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
  • 53.5k
0 votes
0 answers
56 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

1
2 3 4 5
36

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant