I’m trying to use tsc with plain, Vanilla JS and I’m stumped on how to declare the type a function. It seems like it should be this simple: Edit: /** @type PersonGreet */ is correct. The current behavior is a bug in tsc. The selected answer below gives valid workarounds. Reduced Test Case Ignore the fact that someone may want
Tag: jsdoc
How to mark a property deprecated in a @typedef?
I would like to mark a property (for example, qux below) as deprecated: I should mention, I’d like to do this in a JSDoc comment, not using TypeScript. Answer According to Issue#131 over at tsdoc, you can actually use @deprecated on properties, you just have to set it inside the object (works with JS as well). For e.g.: Results in:
JSDoc: How do you include a custom css file template in your generated docs?
The JSDoc docs say Copying a directory of images to the output directory. To copy all of the static files in ./myproject/static to the output directory: If your static files directory contains the file ./myproject/static/img/screen.png, you can display the image in your docs by using the HTML tag <img src=”img/screen.png”>. And so I have this in my jsdoc.config.json My css
How to provide type hints in JavaScript using JSDoc for Apollo Client based code?
I have trouble setting up type hints for my JavaScript code using JSDoc (trying to make this work with VSCode and WebStorm). As first step, I converted GraphQL schema into set of JSDoc @typedef entries using @graphql-codegen/cli. For the sake of this conversation, lets talk about this one: Then, somewhere in my App.js I tried writing: However, it looks like
Vscode available properties intellisense using javascript or typescript in a function which’s parameter is a string
Look here. For the first parameter of the addEventListener function, vscode gives me several inbuilt suggestions How should I make this available in my javascript function? It could be using Jsdoc or typescript etc. Answer You can always see what vscode uses for intellisense by hovering on the addEventListener method or ctrl + click to go to the definition in
IntelliSense/JSDoc @param = @return, a.k.a. how do I document wrapper functions?
I have a function which takes in another function as an argument, does something to that function-argument, and then returns that same function-argument (or at least returns a function with the exact same signature to it) However, as you can see from my comments in the following… … IntelliSense will autocomplete when calling arbitraryFn() but not wrappedArbitraryFn(). Is there any
Type assert an element in a JS file with @ts-check
I have a JS file with a // @ts-check directive, using JSDoc comments to denote types. The problem is that the elements fail type checks when retrieved from the document. So we have in HTML: When I get this element in JS the type checking throws an error: Property ‘value’ does not exist on type ‘HTMLElement’ If I specify the
JSDoc: arrow function params
I’m trying to document my code with JSDoc (EcmaScript 2015, WebStorm 12 Build 144.3357.8). I have an arrow function which I want to document its parameters. This two examples work (I get auto-completion): But when I want to document an arrow function in forEach function, for example, the auto-completion isn’t working (all of the below): Has anyone managed to get
jsdoc: multiline description @property
I am documenting my code using jsdoc, so far so good, I have a comment like below and it comes in html document like I want it to appear something like hope I am making myself clear… Answer You have to use br-Tags to resolve new new lines:
What’s the proper way to document callbacks with jsdoc?
I’ve spent quite a while scouring the internet looking for the best way to properly document callbacks with jsdoc, but unfortunately, I haven’t found a great one yet. Here’s my question: I’m writing a Node.js library for developers. This library provides multiple classes, functions, and methods that developers will be working with. In order to make my code clear and