Catharsis is a JavaScript library designed for parsing and manipulating type expressions used by Google Closure Compiler and JSDoc. It provides robust capabilities to convert these expressions into a structured Abstract Syntax Tree (AST), and then back into a string or a human-readable description. The current stable version is 0.11.0, last published about a year ago, indicating an irregular or maintenance-focused release cadence. Key differentiators include its high accuracy, backed by a Peggy grammar and a comprehensive test suite, and its flexibility in handling both standard Closure Compiler syntax and JSDoc-specific extensions like `string[]` for `Array<string>`. This library is primarily used by tools and systems that need to interpret or generate type annotations, offering programmatic access to the structure and meaning of complex type expressions.
npm install catharsisVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing both Closure Compiler and JSDoc-style type expressions, then stringifying and describing the results, including HTML-safe output.
Pass `{ jsdoc: true }` as the second argument to `catharsis.parse()` for JSDoc-specific expressions.Ensure your code relies on the generated string from `stringify()` and remove any usage of `options.cssClass`. If caching was previously performed, implement external caching as Catharsis no longer caches return values internally.
Manually escape or sanitize name expressions if they are derived from untrusted input and are intended for HTML output, even when `htmlSafe` is enabled.
Consider the long-term support implications for projects requiring ongoing feature enhancements or rapid adaptation to new language features in JSDoc/Closure Compiler. Ensure the existing functionality meets all project requirements.
Ensure you are importing the default export object and accessing its methods: `import catharsis from 'catharsis'; catharsis.parse(...);` or for CommonJS: `const catharsis = require('catharsis'); catharsis.parse(...);`Review the type expression for syntax errors. If parsing JSDoc-specific syntax (e.g., `string[]`, `function`), ensure `catharsis.parse(expression, { jsdoc: true })` is used.No dependency data recorded yet.