Loading topic
jsdoc command-line tool turns it into HTML p6 min read@param and @returns are the JSDoc tags that describe that contract. They are also the tags you will write most often. Tools read them in three ways: the jsdoc generator turns them into HTML tables, editors show them in hover tool6 min read{number} and {string} inside @param and @returns. Real code also passes arrays, objects, values that may be null, callbacks, and parameters that accept more than one kind of value. This chapter covers the type expression syntax that goes betwe5 min read@typedef for object shapes, @property for their fields, and @callback for fu6 min read@example, @throws, @see, inline {@link}, and `@deprecat6 min read@param and @returns, type expressions, and @typedef. Real code is usually organized into classes and modules, so this chapter applies those tools to both. It assumes you are comfortable with ES classes, import/export, and the basic6 min readUser objects. If you type its parameter as any[] and its return as any, you lose the link between input and out6 min readjsdoc documentation tool. The TypeScript compiler can read those same comments and check your plain .js files against them. You don't rename files, add a build step, or learn new syntax. The types you already wrote are enoug7 min readUser shape defined in user.js is needed in describe.js, api.js, and a dozen other places. Copying the @typedef into each file works for a week. Then someone adds a field to one copy and forgets the others. This chapter shows how to defi6 min readjsdoc command-line tool turns those same comments into a browsable HTML website, with one page per class and module, a navigation sidebar, and links between related symbol7 min read@param line. Someone types @parm instead of @param. A new exported function ships with no comment at all. None of these break the program, so tests won't catch them. A linter will. This chapter shows how to u7 min read