|
8 | 8 |
|
9 | 9 | # Pretty `TypeScript` Errors
|
10 | 10 |
|
11 |
| -<b>Make TypeScript errors prettier and human-readable in VSCode.</b> |
12 |
| - |
| 11 | +<b>Make TypeScript errors prettier and human-readable in VSCode.</b> |
| 12 | + |
13 | 13 | [](https://GitHub.com/yoavbls/pretty-ts-errors/stargazers/)
|
14 | 14 | [](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors) [](https://github.com/yoavbls/pretty-ts-errors/blob/main/LICENSE) [](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors)
|
15 | 15 | <a href="https://github.com/yoavbls/pretty-ts-errors/discussions/43#user-content-jetbrains-support"><img src="https://cdn.icon-icons.com/icons2/2530/PNG/512/jetbrains_webstorm_button_icon_151873.png" height="20" alt="Webstorm logo"></a>
|
16 | 16 |
|
17 | 17 | TypeScript errors become messier as the complexity of types increases. At some point, TypeScript will throw on you a shitty heap of parentheses and `"..."`.
|
18 | 18 | This extension will help you understand what's going on. For example, in this relatively simple error:
|
19 | 19 |
|
20 |
| -<img src="./assets/this.png" width="340.438px" /> <img src="./assets/instead-of-that.png" width="350px" /> |
21 |
| - |
22 |
| - |
| 20 | +<img src="./assets/this.png" width="340.438px" /> <img src="./assets/instead-of-that.png" width="350px" /> |
| 21 | + |
23 | 22 | ## Watch this
|
| 23 | + |
24 | 24 | <a href="https://www.youtube.com/watch?v=9RM2aErJs-s" target="_blank">
|
25 | 25 | <img src="https://raw.githubusercontent.com/yoavbls/pretty-ts-errors/assets/assets/mentions/theo-video.png" alt="Watch theo's video" width="600" />
|
26 | 26 | </a>
|
27 | 27 |
|
28 |
| -and others from: |
| 28 | +and others from: |
29 | 29 | [Web Dev Simplified](https://www.youtube.com/watch?v=ccg-erZYO4k&list=PL0rc4JAdEsVpOriHzlAG7KUnhKIK9c7OR&index=1),
|
30 | 30 | [Josh tried coding](https://www.youtube.com/watch?v=_9y29Cyo9uU&list=PL0rc4JAdEsVpOriHzlAG7KUnhKIK9c7OR&index=3),
|
31 | 31 | [trash dev](https://www.youtube.com/watch?v=WJeD3DKlWT4&list=PL0rc4JAdEsVpOriHzlAG7KUnhKIK9c7OR&index=4&t=208),
|
32 | 32 | and [more](https://www.youtube.com/playlist?list=PL0rc4JAdEsVpOriHzlAG7KUnhKIK9c7OR)
|
33 | 33 |
|
34 |
| - |
35 | 34 | ## Features
|
| 35 | + |
36 | 36 | - Syntax highlighting with your theme colors for types in error messages, supporting both light and dark themes
|
37 | 37 | - A button that leads you to the relevant type declaration next to the type in the error message
|
38 | 38 | - A button that navigates you to the error at [typescript.tv](http://typescript.tv), where you can find a detailed explanation, sometimes with a video
|
39 | 39 | - A button that navigates you to [ts-error-translator](https://ts-error-translator.vercel.app/), where you can read the error in plain English
|
40 | 40 |
|
41 | 41 | ## Supports
|
| 42 | + |
42 | 43 | - Node and Deno TypeScript error reporters (in `.ts` files)
|
43 | 44 | - JSDoc type errors (in `.js` and `.jsx` files)
|
44 | 45 | - React, Solid and Qwik errors (in `.tsx` and `.mdx` files)
|
45 | 46 | - Astro, Svelte and Vue files when TypeScript is enabled (in `.astro`, `.svelte` and `.vue` files)
|
46 | 47 | - Ember and Glimmer TypeScript errors and template issues reported by Glint (in `.hbs`, `.gjs`, and `.gts` files)
|
47 |
| - |
48 |
| - |
| 48 | + |
49 | 49 | ## Installation
|
| 50 | + |
50 | 51 | ```
|
51 | 52 | code --install-extension yoavbls.pretty-ts-errors
|
52 | 53 | ```
|
53 |
| -Or simply by searching for `pretty-ts-errors` in the [VSCode marketplace](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors) |
54 |
| - |
55 |
| - |
| 54 | + |
| 55 | +Or simply by searching for `pretty-ts-errors` in the [VSCode marketplace](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors) |
| 56 | + |
| 57 | +#### How to hide the original errors and make the types copyable |
| 58 | + |
| 59 | +Follow the instructions [there](./docs/hide-original-errors.md). unfortunately, this hack is required because of VSCode limitations. |
| 60 | + |
56 | 61 | ## Why isn't it trivial
|
| 62 | + |
57 | 63 | 1. TypeScript errors contain types that are not valid in TypeScript.
|
58 |
| -Yes, these types include things like `... more ...`, `{ ... }`, etc in an inconsistent manner. Some are also cutting in the middle because they're too long. |
| 64 | + Yes, these types include things like `... more ...`, `{ ... }`, etc in an inconsistent manner. Some are also cutting in the middle because they're too long. |
59 | 65 | 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`.
|
60 | 66 | 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.
|
61 |
| -<img src="./assets/errors-hover.png" width="600" /> |
| 67 | + <img src="./assets/errors-hover.png" width="600" /> |
62 | 68 |
|
63 | 69 | ## Hype section
|
| 70 | + |
64 | 71 | <a href="https://www.youtube.com/live/Zze1y2iZ3bQ?si=Yj1Qw2S8FbGbTA5c&t=11589">
|
65 | 72 | <picture>
|
66 | 73 | <img width="400" src="https://github.com/yoavbls/pretty-ts-errors/blob/assets/assets/mentions/js-nation.png?raw=true" alt="Winning the Productivity Booster category at JSNation 2023">
|
@@ -88,8 +95,8 @@ Yes, these types include things like `... more ...`, `{ ... }`, etc in an incons
|
88 | 95 | </picture>
|
89 | 96 | </a>
|
90 | 97 |
|
91 |
| - |
92 |
| -### Stars from stars |
| 98 | +### Stars from stars |
| 99 | + |
93 | 100 | <table>
|
94 | 101 | <tbody>
|
95 | 102 | <tr>
|
@@ -127,14 +134,12 @@ Yes, these types include things like `... more ...`, `{ ... }`, etc in an incons
|
127 | 134 | </tbody>
|
128 | 135 | </table>
|
129 | 136 |
|
130 |
| - |
131 | 137 | ## Sponsorship
|
| 138 | + |
132 | 139 | Every penny will be invested in other contributors to the project, especially ones that work
|
133 | 140 | on things that I can't be doing myself like adding support to the extension for other IDEs 🫂
|
134 |
| - |
| 141 | + |
135 | 142 | ## Contribution
|
| 143 | + |
136 | 144 | Help by upvoting or commenting on issues we need to be resolved [here](https://github.com/yoavbls/pretty-ts-errors/discussions/43)
|
137 | 145 | Any other contribution is welcome. Feel free to open any issue / PR you think.
|
138 |
| - |
139 |
| - |
140 |
| - |
|
0 commit comments