Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aivenio/tsc-output-parser

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aivenio/tsc-output-parser

Parses errors from tsc output to a structured JSON format.

  • 2.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
25K
decreased by-0.63%
Maintainers
6
Weekly downloads
 
Created
Source

tsc-output-parser

Parses errors from tsc output to a structured JSON format.

Converts tsc output:

src/actions.ts(691,20): error TS7006: Parameter 'error' implicitly has an 'any' type.

to JSON:

[
  {
    "type": "Item",
    "value": {
      "path": {
        "type": "Path",
        "value": "src/actions.ts"
      },
      "cursor": {
        "type": "Cursor",
        "value": {
          "line": 691,
          "col": 20
        }
      },
      "tsError": {
        "type": "TsError",
        "value": {
          "type": "error",
          "errorString": "TS7006"
        }
      },
      "message": {
        "type": "Message",
        "value": " Parameter 'error' implicitly has an 'any' type.\n"
      }
    }
  }
]

Install

Install with npm i -g @aivenio/tsc-output-parser.

Usage

CLI

Via temporary file:

tsc --strict --noEmit > ts.out
tsc-output-parser ts.out > errors.json

By piping:

tsc --strict --noEmit | tsc-output-parser

API

import { parse } from '@aivenio/tsc-output-parser';

const input = `
src/actions.ts(691,20): error TS7006: Parameter 'error' implicitly has an 'any' type.
`;

const errors = parse(input);

Test examples

To convert the real.txt test example, clone the repo and run:

npm install
npm run peg
./node_modules/.bin/ts-node src/cli.ts test/inputs/real.txt

Motivation

To migrate our code base to TypeScript using strict types, we built tooling to track our progress. The parsing could've been done in many (probably easier) ways, but it serves as a good example of using PEG.js to parse text.

FAQs

Package last updated on 18 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc