hexh250786313 / pretty-ts-errors-markdown

A fork of pretty-ts-errors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pretty-ts-errors-markdown

A fork of https://github.com/yoavbls/pretty-ts-errors. It transforms TypeScript errors into markdown.

simplescreenrecorder-2024-02-03_19.11.18.mp4

Install

※ Global

npm i -g pretty-ts-errors-markdown

※ Local

npm i pretty-ts-errors-markdown

Usage (CLI)

※ Use inline parameters

pretty-ts-errors-markdown -i "{\"range\":{\"start\":{\"line\":6,\"character\":6},\"end\":{\"line\":6,\"character\":7}},\"message\":\"Variable 'a' implicitly has an 'any' type.\",\"code\":7005,\"severity\":1,\"source\":\"tsserver\"}"

※ Use standard input

git clone https://github.com/hexh250786313/pretty-ts-errors-markdown && cd pretty-ts-errors-markdown
cat ./examples/input.txt | pretty-ts-errors-markdown > ./examples/output.md

Usage (Programmatically)

import { formatDiagnostic } from "pretty-ts-errors-markdown";
import { Diagnostic } from "vscode-languageserver-types";

const diagnostic: Diagnostic = {
  range: {
    start: { line: 6, character: 6 },
    end: { line: 6, character: 7 },
  },
  message: "Variable 'a' implicitly has an 'any' type.",
  code: 7005,
  severity: 1,
  source: "tsserver",
};

const marked = formatDiagnostic(diagnostic);
console.log(marked);

Credits

Awesome thanks to yoavbls and other contributors for the original pretty-ts-errors

About

A fork of pretty-ts-errors

License:MIT License


Languages

Language:TypeScript 88.2%Language:JavaScript 11.8%