Registry /
serialization / prettier-plugin-jsdoc-type
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
muslnode 18–226 runs
build_error
glibcnode 18–226 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" */
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-jsdoc-type'
Plugin not installed or peer dependencies missing.
fixRun `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.
fixInstall 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.
fixEnsure .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).
fixSet parser to 'typescript' in Prettier config or use proper file extension (.ts/.tsx).
Audit
Dependencies
prettierrequiredPeer dependency: plugin requires Prettier >=3.5.3
typescriptoptionalPeer dependency: used for parsing type annotations