pretty-ts-errors README

The project's README from github.com/yoavbls/pretty-ts-errors. As one markdown file: README.md.

Logo

Pretty TypeScript Errors

Make TypeScript errors prettier and human-readable in VSCode.

GitHub stars Visual Studio Code GitHub license Visual Studio Code Webstorm logo Cursor

TypeScript errors become messier as the complexity of types increases. At some point, TypeScript will throw on you a shitty heap of parentheses and "...". This extension will help you understand what's going on. For example, in this relatively simple error:

   

Watch this

Watch theo's video

and others from: Web Dev Simplified, Josh tried coding, trash dev, and more

Features

Supports

Installation

code --install-extension yoavbls.pretty-ts-errors

Or simply by searching for pretty-ts-errors in the VSCode marketplace

How to hide the original errors and make the types copyable

Follow the instructions there. unfortunately, this hack is required because of VSCode limitations.

Why isn't it trivial

  1. TypeScript errors contain types that are not valid in TypeScript. Yes, these types include things like ... more ..., { ... }, etc in an inconsistent manner. Some are also cutting in the middle because they're too long.
  2. Types can't be syntax highlighted in code blocks because the part of type X = ... is missing, so I needed to create a new TextMate grammar, a superset of TypeScript grammar called type.
  3. VSCode markdown blocks all styling options, so I had to find hacks to style the error messages. e.g., there isn't an inlined code block on VSCode markdown, so I used a code block inside a codicon icon, which is the only thing that can be inlined. That's why it can't be copied. but it isn't a problem because you can still hover on the error and copy things from the original error pane.

Hype section

Winning the Productivity Booster category at JSNation 2023 Tanner's tweet Theo's tweet Johnson's tweet

Stars from stars


Kent C. Dodds

Matt Pocock

Alex / KATT

Tanner Linsley

Theo Browne

Sponsorship

Every penny will be invested in other contributors to the project, especially ones that work on things that I can't be doing myself like adding support to the extension for other IDEs 🫂

Contribution

Help by upvoting or commenting on issues we need to be resolved here Any other contribution is welcome. Feel free to open any issue / PR you think.

pretty-ts-errors (yoavbls/pretty-ts-errors)

Searching Database…

What is this?A VSCode extension that turns TypeScript's often unreadable, deeply nested error messages into syntax-highlighted, human-readable text right in the editor.
Does it change how TypeScript checks types, or just how errors look?It only changes the display: it reformats and syntax-highlights the same error TypeScript already produces, it doesn't alter type checking itself.
Which file types and frameworks does it understand?It covers Node and Deno .ts errors, JSDoc errors in .js/.jsx, React/Solid/Qwik errors in .tsx/.mdx, Astro/Svelte/Vue files when TypeScript is enabled, and Ember/Glimmer templates via Glint.
Can I just copy the prettified error text?Not directly — VSCode's markdown rendering blocks normal inline code, so the author had to fake it with a codicon-wrapped code block that can't be copied; you still copy from the original hover pane instead.
Can I jump straight to a type's declaration from an error?Yes, each error gets a button that navigates to the relevant type declaration, plus buttons linking to typescript.tv and ts-error-translator for a plain-English explanation of the error.
Why wasn't this a trivial extension to build?TypeScript's error output isn't valid TypeScript syntax, so the author built a custom TextMate grammar for highlighting, and had to hack around VSCode's markdown styling limits using a codicon-based code block.
Can I hide the original raw error alongside the prettified one?The README points to separate instructions for hiding the original error and making types copyable, though it notes this requires an extra workaround due to VSCode limitations.
Creator
yoavbls
Size
7.3 MB
Stars
14.1K
Age
4y
Commits · 90 Days