Registry / serialization / prettier-plugin-jsdoc-type

prettier-plugin-jsdoc-type

JSON →
library0.2.0jsnpmunverified

A Prettier plugin that formats JSDoc type annotations to match a consistent TypeScript style. Current stable version is 0.2.0, released in early 2025. It focuses solely on JSDoc type syntax (e.g., @type, @param, @returns, @import) unlike broader JSDoc formatting tools. Supports object types, arrays, unions, function types, and complex constructs like @import with aliases and @returns {foo is Foo}. Requires Prettier >=3.5.3 and TypeScript as peer dependencies. Actively maintained with frequent patches fixing edge cases in type parsing.

npm install prettier-plugin-jsdoc-type
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-JS
P
prettier-plugin-jsdoc-type
serializationjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
// In .prettierrc: { "plugins": ["prettier-plugin-jsdoc-type"] }
// In .prettierrc: { "plugins": ["prettier-plugin-jsdoc"] }
This is a separate plugin from prettier-plugin-jsdoc; both can be used together.
default
// No direct import; configure via Prettier config
import prettierPluginJsdocType from 'prettier-plugin-jsdoc-type'
Plugin is not imported in code; it is loaded by Prettier via the plugins array in configuration.
require
// Not applicable; use Prettier config file
const plugin = require('prettier-plugin-jsdoc-type')
CommonJS require is not the intended use; the plugin is only for Prettier configuration.

Installation, configuration, and example formatting of JSDoc type annotations including object types, unions, @import, and @returns with type predicates.

// Install npm install --save-dev prettier prettier-plugin-jsdoc-type typescript // .prettierrc { "plugins": ["prettier-plugin-jsdoc-type"], "parser": "typescript" } // Input file: example.js /** @type {{a?:number,b?:string}} */ const obj = {}; /** * @param {{ * type?:string, * a?:number * b?:string}} n * @returns {n is Foo} */ function fn(n) { // do something } /** @import {Foo}from'bar' */ // After formatting with Prettier: // /** @type {{ a?: number; b?: string }} */ // const obj = {}; // // /** // * @param {{ // * type?: string; // * a?: number; // * b?: string; // * }} n // * @returns {n is Foo} // */ // function fn(n) { // // do something // } // // /** @import { Foo } from "bar" */
Debug
Known issues
breakingPlugin may produce formatting incompatible with older Prettier versions (requires Prettier >=3.5.3).
fix
Upgrade to Prettier >=3.5.3 and plugin >=0.2.0.
affects: <0.2.0
deprecatedThe plugin does not handle JSDoc comments (description, tags); use prettier-plugin-jsdoc for that.
fix
Consider using prettier-plugin-jsdoc alongside if you need full comment formatting.
affects: *
gotchaPlugin is experimental; may not support all JSDoc type syntax edge cases.
fix
Test thoroughly; report issues on GitHub.
affects: *
gotchaPlugin only formats JSDoc type annotations inside comments, not TypeScript types in code.
fix
Ensure you are not expecting TypeScript code formatting from this plugin.
affects: *
gotchaPlugin might conflict with other Prettier plugins if they also transform JSDoc or comments.
fix
Run Prettier with this plugin alone to isolate issues, or check plugin ordering.
affects: *
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-jsdoc-type'
Plugin not installed or peer dependencies missing.
fix
Run `npm install --save-dev prettier-plugin-jsdoc-type prettier@>=3.5.3 typescript`
Error: Cannot find module 'typescript'
TypeScript is a peer dependency but not installed.
fix
Install TypeScript: `npm install --save-dev typescript`
Configuration error: Could not resolve plugin "prettier-plugin-jsdoc-type"
Prettier configuration file (e.g., .prettierrc) references plugin incorrectly.
fix
Ensure .prettierrc contains: { "plugins": ["prettier-plugin-jsdoc-type"] }
JSDoc type formatting not applied
Prettier might be using a parser that doesn't handle JSDoc (e.g., babel instead of typescript).
fix
Set parser to 'typescript' in Prettier config or use proper file extension (.ts/.tsx).
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency: plugin requires Prettier >=3.5.3
typescriptoptionalPeer dependency: used for parsing type annotations
Agent activity
6 hits · last 30 days
node
6
Resources
prettier-plugin-jsdoc-type — npm install prettier-plugin-jsdoc-type · libregistry