Giter VIP home page Giter VIP logo

jsdoc-plugin-typescript's Introduction

jsdoc-plugin-typescript

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

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"
],
"typescript": {
  "moduleRoot": "src"
}

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

In the above snippet, "src" is the directory that contains the source files. Inside that directory, each .js file needs a @module annotation with a path relative to that "moduleRoot", e.g.

/** @module ol/proj **/

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:

TypeScript

Named export:

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

Default export:

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

typeof type:

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

JSDoc

Named export:

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

Default export 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.

Anonymous default export:

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

typeof type:

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

jsdoc-plugin-typescript's People

Contributors

ahocevar avatar stephanebury avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.