tsc-output-format
raw JSON → 1.1.1 verified Fri May 01 auth: no javascript
tsc-output-format v1.1.1 is a TypeScript library and CLI tool that formats tsc diagnostic output into JSON, GitHub Actions annotations, grouped text, and more. Released in March 2025 with monthly updates, it supports pretty mode, watch mode, and custom formatters/parsers. Unlike other tsc output processors, it provides a pluggable architecture and first-class TypeScript types. Minimal bundle size (<5KB) and zero runtime dependencies make it suitable for CI pipelines.
Common errors
error TypeError: Cannot read properties of undefined (reading 'length') ↓
cause Passing empty or malformed input to parse().
fix
Ensure tsc output is not empty and is a string. Use parse(String(tscOutput)).
error SyntaxError: Named export 'formatGHA' not found. The requested module 'tsc-output-format' is a commonjs module... ↓
cause Importing formatGHA from the main entry (tsc-output-format) instead of subpath.
fix
import { formatGHA } from 'tsc-output-format/formatters';
Warnings
gotcha Package is ESM-only. Using require() or CommonJS will throw a runtime error. ↓
fix Use import syntax or set { "type": "module" } in package.json.
gotcha formatGHA is exported from a subpath, not the main entry. ↓
fix Import from 'tsc-output-format/formatters'.
breaking In v1.0.0, parse() did not return a 'line' property as number; it was a string. v1.1.0+ may have fixed this, but verify types. ↓
fix Upgrade to v1.1.1 or cast line to number.
Install
npm install tsc-output-format yarn add tsc-output-format pnpm add tsc-output-format Imports
- parse wrong
import parse from 'tsc-output-format'correctimport { parse } from 'tsc-output-format' - format wrong
const { format } = require('tsc-output-format')correctimport { format } from 'tsc-output-format' - formatGHA wrong
import { formatGHA } from 'tsc-output-format'correctimport { formatGHA } from 'tsc-output-format/formatters'
Quickstart
import { parse, format } from 'tsc-output-format';
import { execSync } from 'child_process';
const tscOutput = execSync('npx tsc --noEmit 2>&1', { encoding: 'utf-8' });
const diagnostics = parse(tscOutput);
const formatted = format(diagnostics, {
formatter: 'json', // or 'gha', 'grouped'
});
console.log(formatted);
// Output JSON array of diagnostics with file, line, column, errorCode, message.