{"id":20378,"library":"prettier-plugin-jsdoc-type","title":"Prettier Plugin for JSDoc Type Annotations","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/ota-meshi/prettier-plugin-jsdoc-type","tags":["javascript","jsdoc","prettier-plugin"],"install":[{"cmd":"npm install prettier-plugin-jsdoc-type","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-jsdoc-type","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-jsdoc-type","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: plugin requires Prettier >=3.5.3","package":"prettier","optional":false},{"reason":"Peer dependency: used for parsing type annotations","package":"typescript","optional":true}],"imports":[{"note":"This is a separate plugin from prettier-plugin-jsdoc; both can be used together.","wrong":"// In .prettierrc: { \"plugins\": [\"prettier-plugin-jsdoc\"] }","symbol":"plugin","correct":"// In .prettierrc: { \"plugins\": [\"prettier-plugin-jsdoc-type\"] }"},{"note":"Plugin is not imported in code; it is loaded by Prettier via the plugins array in configuration.","wrong":"import prettierPluginJsdocType from 'prettier-plugin-jsdoc-type'","symbol":"default","correct":"// No direct import; configure via Prettier config"},{"note":"CommonJS require is not the intended use; the plugin is only for Prettier configuration.","wrong":"const plugin = require('prettier-plugin-jsdoc-type')","symbol":"require","correct":"// Not applicable; use Prettier config file"}],"quickstart":{"code":"// Install\nnpm install --save-dev prettier prettier-plugin-jsdoc-type typescript\n\n// .prettierrc\n{\n  \"plugins\": [\"prettier-plugin-jsdoc-type\"],\n  \"parser\": \"typescript\"\n}\n\n// Input file: example.js\n/** @type {{a?:number,b?:string}} */\nconst obj = {};\n\n/**\n * @param {{\n * type?:string,\n *  a?:number\n *   b?:string}} n\n * @returns {n   is Foo}\n */\nfunction fn(n) {\n  // do something\n}\n\n/** @import {Foo}from'bar' */\n\n// After formatting with Prettier:\n// /** @type {{ a?: number; b?: string }} */\n// const obj = {};\n//\n// /**\n//  * @param {{\n//  *   type?: string;\n//  *   a?: number;\n//  *   b?: string;\n//  * }} n\n//  * @returns {n is Foo}\n//  */\n// function fn(n) {\n//   // do something\n// }\n//\n// /** @import { Foo } from \"bar\" */","lang":"typescript","description":"Installation, configuration, and example formatting of JSDoc type annotations including object types, unions, @import, and @returns with type predicates."},"warnings":[{"fix":"Upgrade to Prettier >=3.5.3 and plugin >=0.2.0.","message":"Plugin may produce formatting incompatible with older Prettier versions (requires Prettier >=3.5.3).","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Consider using prettier-plugin-jsdoc alongside if you need full comment formatting.","message":"The plugin does not handle JSDoc comments (description, tags); use prettier-plugin-jsdoc for that.","severity":"deprecated","affected_versions":"*"},{"fix":"Test thoroughly; report issues on GitHub.","message":"Plugin is experimental; may not support all JSDoc type syntax edge cases.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure you are not expecting TypeScript code formatting from this plugin.","message":"Plugin only formats JSDoc type annotations inside comments, not TypeScript types in code.","severity":"gotcha","affected_versions":"*"},{"fix":"Run Prettier with this plugin alone to isolate issues, or check plugin ordering.","message":"Plugin might conflict with other Prettier plugins if they also transform JSDoc or comments.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev prettier-plugin-jsdoc-type prettier@>=3.5.3 typescript`","cause":"Plugin not installed or peer dependencies missing.","error":"Cannot find module 'prettier-plugin-jsdoc-type'"},{"fix":"Install TypeScript: `npm install --save-dev typescript`","cause":"TypeScript is a peer dependency but not installed.","error":"Error: Cannot find module 'typescript'"},{"fix":"Ensure .prettierrc contains: { \"plugins\": [\"prettier-plugin-jsdoc-type\"] }","cause":"Prettier configuration file (e.g., .prettierrc) references plugin incorrectly.","error":"Configuration error: Could not resolve plugin \"prettier-plugin-jsdoc-type\""},{"fix":"Set parser to 'typescript' in Prettier config or use proper file extension (.ts/.tsx).","cause":"Prettier might be using a parser that doesn't handle JSDoc (e.g., babel instead of typescript).","error":"JSDoc type formatting not applied"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}