npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsdoc-plugin-typescript

v3.2.0

Published

Plugin to make TypeScript's JSDoc type annotations work with JSDoc

Downloads

39,724

Readme

jsdoc-plugin-typescript

Plugin to make TypeScript's JSDoc type annotations work with JSDoc. Requires JSDoc v3.6.0 or higher.

Installation and use

JSDoc accepts plugins by simply installing their npm package:

npm install --save-dev jsdoc-plugin-typescript

To configure JSDoc to use the plugin, add the following to the JSDoc configuration file, e.g. conf.json:

"plugins": [
  "jsdoc-plugin-typescript"
],

See http://usejsdoc.org/about-configuring-jsdoc.html for more details on how to configure JSDoc.

What this plugin does

When using the class keyword for defining classes (required by TypeScript), JSDoc requires @classdesc and @extends annotations. With this plugin, no @classdesc and @extends annotations are needed.

Types defined in a project are converted to JSDoc module paths, so they can be documented and linked properly.

In addition to types that are used in the same file that they are defined in, imported types are also supported.

TypeScript and JSDoc use a different syntax for imported types. This plugin converts the TypeScript types so JSDoc can handle them:

Named export

/**
 * @type {import("./path/to/module").exportName}
 */

To:

/**
 * @type {module:path/to/module.exportName}
 */

Default export

/**
 * @type {import("./path/to/module").default}
 */

To:

/**
 * @type {module:path/to/module}
 */

When assigned to a variable in the exporting module:

/**
 * @type {module:path/to/module~variableOfDefaultExport}
 */

This syntax is also used when referring to types of @typedefs and @enums.

@link tags

/**
 * {@link Identifier}
 */

/**
 * {@link Identifier Link text}
 */

/**
 * {@link Identifier.member}
 */

To:

/**
 * {@link module:path/to/module.Identifier Identifier}
 */

/**
 * {@link module:path/to/module.Identifier Link text}
 */

/**
 * Member accessors are not currently linked to, just the root identifier:
 * {@link module:path/to/module.Identifier Identifier.member}
 */

typeof type

/**
 * @type {typeof import("./path/to/module").exportName}
 */

To:

/**
 * @type {Class<module:path/to/module.exportName>}
 */

Template literal type

/**
 * @type {`static:${dynamic}`}
 */

To:

/**
 * @type {'static:${dynamic}'}
 */

@override annotations

are removed because they make JSDoc stop inheritance

Interface style semi-colon separators

/**
 * @type {{a: number; b: string;}}
 */

To:

/**
 * @type {{a: number, b: string}}
 */

Also removes trailing commas from object types.

TS inline function syntax

/**
 * @type {(a: number, b: string) => void}
 */

To:

/**
 * @type {function(): void}
 */

Bracket notation

/**
 * @type {obj['key']}
 */

To:

/**
 * @type {obj.key}
 */

Tuples

/**
 * @type {[string, number]}
 */

To:

/**
 * @type {Array}
 */

Module id resolution

For resolving module ids, this plugin mirrors the method used by JSDoc:

  1. Parse the referenced module for an @module tag.
  2. If a tag is found and it has an explicit id, use that.
  3. If a tag is found, but it doesn't have an explicit id, use the module's file path relative to the nearest shared parent directory, and remove the file extension.

Contributing

If you are interested in making a contribution to the project, please see the contributing page for details on getting your development environment set up.