Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5a44265
reimplement #133 in the monorepo setup
kevinramharak Oct 19, 2025
02af660
port the changes of web-preview-poc; integrate vscode-shiki-bridge
kevinramharak Oct 22, 2025
d8b76f6
stich everything together
kevinramharak Oct 23, 2025
88685a6
Get the feature working
kevinramharak Oct 23, 2025
d234df9
implement webview as seperate files, implement csp with a lot of head…
kevinramharak Oct 23, 2025
17b4105
finalize implementation
kevinramharak Oct 23, 2025
de28d44
implement the webviewviewprovider
kevinramharak Oct 23, 2025
20215ab
Merge branch 'main' into feature/107-button-to-open-error-in-new-tab
kevinramharak Nov 5, 2025
26473c4
Merge branch 'main' into feature/107-button-to-open-error-in-new-tab
kevinramharak Dec 19, 2025
4147c36
finalize webview parts
kevinramharak Dec 19, 2025
5bf4f08
remove obsolete files
kevinramharak Dec 19, 2025
3fafd38
remove obsolete file
kevinramharak Dec 19, 2025
b6a80b9
implement proper markdown rendering
kevinramharak Dec 19, 2025
918aa87
bump vscode-shiki-bridge to v0.3.0
yoavbls Dec 19, 2025
f462b2b
implement vscode-shiki-bridge
kevinramharak Dec 19, 2025
31caba3
Few minor fixes
yoavbls Dec 19, 2025
446eb30
fix copy type button
kevinramharak Dec 20, 2025
56fad21
only hide new tab button in the new tab markdown preview
kevinramharak Dec 21, 2025
6700a52
use whitelisted badge urls
kevinramharak Dec 21, 2025
5a58f7b
avoid triggering complete rerenders of the webview
kevinramharak Dec 22, 2025
1a08df3
decrease vertical padding
kevinramharak Dec 22, 2025
f0b4eaa
keep track of shown diagnostic per webview, to ensure the panel is re…
kevinramharak Dec 22, 2025
70c7002
add missing .delete on the weakmap
kevinramharak Dec 22, 2025
313b39e
add another .delete to onDidDispose to prevent leaking memory
kevinramharak Dec 22, 2025
29b25c1
fix background color of the panel preview variant
kevinramharak Dec 23, 2025
a0b6363
bump version in lock
yoavbls Dec 24, 2025
f87072f
Remove icons not in use to reduce size
yoavbls Dec 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<b>Make TypeScript errors prettier and human-readable in VSCode.</b>

[![GitHub stars](https://img.shields.io/github/stars/yoavbls/pretty-ts-errors.svg?style=social&label=Star)](https://GitHub.com/yoavbls/pretty-ts-errors/stargazers/)
[![Visual Studio Code](https://custom-icon-badges.demolab.com/badge/Visual%20Studio%20Code-0078d7.svg?logo=vsc&logoColor=white)](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors)&nbsp;[![GitHub license](https://badgen.net/github/license/yoavbls/pretty-ts-errors)](https://github.com/yoavbls/pretty-ts-errors/blob/main/LICENSE)&nbsp;[![Visual Studio Code](https://img.shields.io/visual-studio-marketplace/i/yoavbls.pretty-ts-errors)](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors)
[![Visual Studio Code][vsc]](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors)&nbsp;[![GitHub license](https://badgen.net/github/license/yoavbls/pretty-ts-errors)](https://github.com/yoavbls/pretty-ts-errors/blob/main/LICENSE)&nbsp;[![Visual Studio Code](https://img.shields.io/visual-studio-marketplace/i/yoavbls.pretty-ts-errors)](https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors)
<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>
[![Cursor](https://custom-icon-badges.demolab.com/badge/Cursor-000000?logo=cursor-ai-white)](https://open-vsx.org/extension/yoavbls/pretty-ts-errors)
[![Cursor](https://img.shields.io/badge/Cursor-000000?logo=cursor)](https://open-vsx.org/extension/yoavbls/pretty-ts-errors)

TypeScript errors become messier as the complexity of types increases. At some point, TypeScript will throw on you a shitty heap of parentheses and `"..."`.
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:

<img src="./assets/this.png" width="340.438px" />&nbsp; &nbsp; <img src="./assets/instead-of-that.png" width="350px" />
Expand Down Expand Up @@ -61,10 +61,10 @@ Follow the instructions [there](./docs/hide-original-errors.md). unfortunately,

## Why isn't it trivial

1. TypeScript errors contain types that are not valid in TypeScript.
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.
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.
<img src="./assets/errors-hover.png" width="600" />

## Hype section
Expand All @@ -82,7 +82,7 @@ Follow the instructions [there](./docs/hide-original-errors.md). unfortunately,
</picture>
</a>
<a href="https://twitter.com/t3dotgg/status/1647759462709747713">
<picture>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/yoavbls/pretty-ts-errors/main/assets/mentions/theo-dark.png#gh-dark-mode-only">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/yoavbls/pretty-ts-errors/main/assets/mentions/theo-light.png#gh-light-mode-only">
<img width="400" src="https://raw.githubusercontent.com/yoavbls/pretty-ts-errors/main/assets/mentions/theo-dark.png#gh-dark-mode-only" alt="Theo's tweet">
Expand All @@ -104,13 +104,13 @@ Follow the instructions [there](./docs/hide-original-errors.md). unfortunately,
<td align="center">
<a href="https://github.com/kentcdodds">
<img src="https://images.weserv.nl/?url=github.com/kentcdodds.png&fit=cover&mask=circle" width="80"><br>
Kent C. Dodds
Kent C. Dodds
<a/>
</td>
<td align="center">
<a href="https://github.com/mattpocock">
<img src="https://images.weserv.nl/?url=github.com/mattpocock.png&fit=cover&mask=circle" width="80"><br>
Matt Pocock
Matt Pocock
<a/>
</td>
<td align="center">
Expand All @@ -122,7 +122,7 @@ Follow the instructions [there](./docs/hide-original-errors.md). unfortunately,
<td align="center">
<a href="https://github.com/tannerlinsley">
<img src="https://images.weserv.nl/?url=github.com/tannerlinsley.png&fit=cover&mask=circle" width="80"><br>
Tanner Linsley
Tanner Linsley
<a/>
</td>
<td align="center">
Expand All @@ -137,10 +137,12 @@ Follow the instructions [there](./docs/hide-original-errors.md). unfortunately,

## Sponsorship

Every penny will be invested in other contributors to the project, especially ones that work
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you want your contribution.md file to have developer setup instructions for getting debugging environment up and running. The dev setup has changed a bit since the mono repo update. But also this change might be out of scope of this pr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there was an issue for this, but I cant find it. This is indeed on the todo list after the monorepo setup. I will do this next, as it is intended to easily setup and contribute to this repo


Help by upvoting or commenting on issues we need to be resolved [here](https://github.com/yoavbls/pretty-ts-errors/discussions/43)
Help by upvoting or commenting on issues we need to be resolved [here](https://github.com/yoavbls/pretty-ts-errors/discussions/43)
Any other contribution is welcome. Feel free to open any issue / PR you think.

[vsc]: https://img.shields.io/badge/Visual%20Studio%20Code-0078d7?logoColor=white&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAQAAgMAAAACc8MQAAAAAXNSR0IArs4c6QAAAAxQTFRFR3BM////////////Bp/QCgAAAAN0Uk5TABla6sjVLAAAFQlJREFUeNrtnUFu7Dp2hg9l4GmggRdwB1yClmBuJpNk8JYgLsHbyChLkJegJTCBBxkWAgWh0yWeRnfjgbN2qZ7I/5DH3/heoPD5nA+UjDLphx9++OGHH35olH8h3az8RZqZmDmQYhZmTo7UMvDf2HVvADO/k1Zm/jsHaWXlf/CpNgF/4LQm4A++FCdAcwfXLCA5nQnIfCpNQMbrTEDmS2kCMkFnAtAdxCcgE5UmIPOuMwGZpDQBmU+lCch4nQnIfClNQCboTEAmOZ0JyESlCci860xAJilNQOZTaQIyXmcCMl9KE5AJOhOQSU5nAjK70gRk3nUmIHMoTUDmU0ECNHdw5m/5UpAAvR0c+AGSggSo7eDMD+EVJEBnBwd+kKAzAZnkdCYgE5UmIPOuMwGZpDQBmU+lCch4nQnIfClNQCboTEAmOZ0JyESlCci860xAJilNQOZTaQIyXmcCMl9KE5AJOhOQSU5nAjK70gRk3nUmIHMoTUDmU2kCMk5nAjJRaQIy7zoTkElKE5D5VJqAjNeZgMyX0gRkgs4EZJLTmYBMVJqAzLvOBGSS0gRkPpUmION1JiDzpTQBmaAzAZnkdCYgE5UmIPOuMwGZpDQBmU+lCch4nQnIfClNQCboTEAmOZ0JyOxKE5B515mAzKE0AZnQXAIUd3DgEsTGEqC5gzMXISlNQOZTZwIySWkCMpvOBGR2nQnIHEoTkFGagIzXmYDMpjMBmaA8AXxTngDelSeAo/IE8L2FBCgXMGkXMGsXsCoXMLByAZN2AbN2AatyAQMrFzBpFzBrF7AqFzCwcgGTdgGzdgGrcgEDKxcwaRcwaxewKhcwsHIBk3YBs3YBq3IBAysXMGkXMGsXsCoXMLByAZN2AbN2AatyAQMrFzBpFzBrF7AqFzCwcgGTdgGzdgGrc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BdCiXYDVLmDULsBoF0CLdgFWu4BRuwCjXQAt2gVY7QJG7QKMdgG0aBdgtQsYtQsw2gXQol2A1S5g1C7AaBdAi3YBVruAUbsAo10ALdoFWO0CRu0CjHYBtGgXYLULGLULMNoF0KJdgNUuYNQuwGgXQIt2AVa7gFG7AKNdAC3aBVjtAkbtAox2AbRoF2C1Cxi1CzDaBdCiXYDVLmDULsBoF0CLdgFWu4BRuwCjXQAt2gVY7QJG7QKMdgG0aBdgAQL0RCCS8gjspDwCN1IegUDKI/BByiPgSHcEEpHuCEQi3RHYqAkMYAN0ROCTGsECBkBDBN4pozECkTIaI5ActYMFPAb0HoEvyqiMgKemWABHgK4jkCijMgIbNYYBHAF6joCj5rCAI0C3ETioQQzgIajXCOzUJBbwENRnBDZqEwN4COoyAp5axQIegvqLQKJ2MYAjQHcRiNQyFnAE6CwCgZrGAI4AfUXAU+NYwBGgowgkah4DOAL0E4FIHWABR4BeIhCoBwzgCNBJBDz1gQUcAXqIQKJeMIAjQAcRiJRRGQFH/TACjgCtR+CgrlgABWw7Ajv1xQh4CGo6Ahv1xgJ4CGo4Ap66YwQ8BDUbgUQ9smCPAHhesQ9BeEbAEaDNCATqlAVwBGgxAp56ZQQfAfCAjwB4FvgRQH4EIvXMCD4C4AEfAfAs2COA/Ah46pwX7BEAjwEfAfC8YY8AeCzsCCA/AsmRAgzqCCA/AgfpwGKOAPIjsJMWIAWUH4GN1GABD0HyI+BIEYCHIOkRSKSKV8BDkOwIRFIG4AggOgKBtPEKOAIIjoAnfQCOAGIjkEgjr4AjgNAIRNIJ4AggMwKBlPIKOAJIjIAnteQjgFLmfATQyW/5CKCUf+P/ph9++OGHH3744Ycn+StuK4YiyBVN0wAAAABJRU5ErkJggg==
41 changes: 37 additions & 4 deletions apps/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Pretty TypeScript Errors",
"publisher": "YoavBls",
"description": "Make TypeScript errors prettier and more human-readable in VSCode",
"version": "0.6.3",
"version": "0.7.0",
"icon": "assets/icon.png",
"repository": {
"type": "git",
Expand Down Expand Up @@ -45,9 +45,35 @@
"dist/**/*",
"assets/**/*",
"syntaxes/**/*",
"webview/**/*",
"LICENSE"
],
"contributes": {
"views": {
"explorer": [
{
"id": "prettyTsErrors.markdownPreview",
"icon": "$(open-preview)",
"name": "Pretty TypeScript Error",
"type": "webview",
"visibility": "collapsed"
}
]
},
"commands": [
{
"command": "prettyTsErrors.openMarkdownPreview",
"title": "Open the diagnostic in a new tab",
"category": "Pretty TS Errors",
"enablement": "!isCommandPanel"
},
{
"command": "prettyTsErrors.revealSelection",
"title": "Reveal the given selection",
"category": "Pretty TS Errors",
"enablement": "!isCommandPanel"
}
],
"languages": [
{
"id": "type",
Expand Down Expand Up @@ -78,12 +104,16 @@
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"lint": "tsc -p . --noEmit",
"test": "node ./out/test/runTest.js"
"test": "node ./out/test/runTest.js",
"webview": "npx http-server ./webview -o -a localhost -p 8080"
},
"devDependencies": {
"@shikijs/types": "^3.13.0",
"@types/mocha": "^10.0.10",
"@types/node": "^16.11.68",
"@types/vscode": "^1.77.0",
"@types/vscode-webview": "^1.57.5",
"@vscode/codicons": "^0.0.41",
"@vscode/test-electron": "^2.5.2",
"esbuild": "^0.25.11",
"glob": "^11.0.3",
Expand All @@ -93,6 +123,9 @@
"dependencies": {
"@pretty-ts-errors/formatter": "*",
"@pretty-ts-errors/vscode-formatter": "*",
"vscode-languageclient": "^9.0.1"
"markdown-exit": "^1.0.0-beta.6",
"shiki": "^3.13.0",
"vscode-languageclient": "^9.0.1",
"vscode-shiki-bridge": "^0.3.0"
}
}
}
13 changes: 13 additions & 0 deletions apps/vscode-extension/src/commands/copyError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { commands, env, window, type ExtensionContext } from "vscode";

export function registerCopyError(context: ExtensionContext) {
context.subscriptions.push(
commands.registerCommand(
"prettyTsErrors.copyError",
async (errorMessage: string) => {
await env.clipboard.writeText(errorMessage);
window.showInformationMessage("Copied error message to clipboard!");
}
)
);
}
72 changes: 72 additions & 0 deletions apps/vscode-extension/src/commands/revealSelection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {
type ExtensionContext,
commands,
Range,
TabInputText,
TabInputWebview,
Uri,
ViewColumn,
window,
} from "vscode";
import { MarkdownWebviewProvider } from "../provider/markdownWebviewProvider";

export function registerRevealSelection(context: ExtensionContext) {
context.subscriptions.push(
commands.registerCommand(
"prettyTsErrors.revealSelection",
async (uri: Uri, range: Range) => {
// ensure these are real instances
uri = Uri.from({ ...uri });
range = new Range(
range.start.line,
range.start.character,
range.end.line,
range.end.character
);

// default behaviour is to use the active view column
let viewColumn = ViewColumn.Active;

// detect if the active tab is our preview webview
let isFromMarkdownPreviewWebview = false;
const activeTab = window.tabGroups.activeTabGroup.activeTab;
if (activeTab && activeTab.input instanceof TabInputWebview) {
// For an unknown reason this string is prefixed with something like `mainthread-${viewType}`
// endsWith should handle a full match and the prefixed versions
if (
activeTab.input.viewType.endsWith(MarkdownWebviewProvider.viewType)
) {
isFromMarkdownPreviewWebview = true;
}
}

if (isFromMarkdownPreviewWebview) {
// find a tab group where the file is open, then use that view column for the `vscode.open` command
const tabs = window.tabGroups.all.flatMap(
(tabGroup) => tabGroup.tabs
);
const tabWithFileOpen = tabs.find((tab) => {
if (tab.input instanceof TabInputText) {
return tab.input.uri.toString() === uri.toString();
}
return false;
});
if (tabWithFileOpen) {
viewColumn = tabWithFileOpen.group.viewColumn;
} else {
// If markdown preview is not open on 1, open the link in 1, else open the link in 2
viewColumn =
activeTab!.group.viewColumn !== 1
? ViewColumn.One
: ViewColumn.Two;
}
}

return commands.executeCommand("vscode.open", uri, {
selection: range,
viewColumn,
});
}
)
);
}
Loading