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:
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.
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 parameter to type using the typedef-ed object Filter
, the return type is a union type (CardItem | StickyNoteItem)[]
whereas I expected it to be CardItem[]
.
How to write a @typedef with arguments? (Like CustomEvent’s detail type argument)
Suppose I have a type that describes an API response: