Skip to content

Commit 3c43cad

Browse files
committed
Add examples
1 parent b27fc08 commit 3c43cad

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<b>Make TypeScript errors prettier and human-readable in VSCode.</b>
1212

1313
[![Visual Studio Code](https://img.shields.io/badge/--007ACC?logo=visual%20studio%20code&logoColor=ffffff)](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;![visitor badge](https://visitor-badge.glitch.me/badge?page_id=pretty-ts-errors)
14+
[![GitHub stars](https://img.shields.io/github/stars/yoavbls/pretty-ts-errors.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/yoavbls/pretty-ts-errors/stargazers/)
15+
1416

1517

1618
TypeScript errors become messier as the complexity of types increases. At some point, TypeScript will throw on you a shitty heap of parentheses and `"..."`.

examples/errors.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
interface Person {
2+
name: string;
3+
age: number;
4+
address: {
5+
street: string;
6+
city: string;
7+
country: string;
8+
};
9+
}
10+
11+
const john: Person = {
12+
name: "John Doe",
13+
age: 30,
14+
address: {
15+
street: "123 Main St",
16+
city: "New York",
17+
},
18+
};
19+
20+
type GetUserFunction = () => {
21+
user: {
22+
name: string;
23+
email: `${string}@${string}.${string}`;
24+
age: number;
25+
};
26+
};
27+
28+
const getPerson: GetUserFunction = () => ({
29+
person: {
30+
username: "usr",
31+
32+
},
33+
});
34+
35+
interface Animal {
36+
name: string;
37+
age: number;
38+
}
39+
40+
function run<T extends Animal>(animal: T) {
41+
return animal;
42+
}
43+
44+
run({ firstName: "John", weight: 20 });

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Pretty TypeScript Errors",
44
"publisher": "yoavbls",
55
"description": "Make TypeScript errors prettier and more human-readable in VSCode",
6-
"version": "0.2.8",
6+
"version": "0.3.0",
77
"icon": "assets/icon.png",
88
"repository": {
99
"type": "git",
@@ -60,7 +60,7 @@
6060
"compile-tests": "tsc -p . --outDir out",
6161
"watch-tests": "tsc -p . -w --outDir out",
6262
"pretest": "npm run compile-tests && npm run compile && npm run lint",
63-
"lint": "eslint src --ext ts",
63+
"lint": "eslint src --ext ts & tsc --noEmit",
6464
"test": "node ./out/test/runTest.js"
6565
},
6666
"devDependencies": {

syntaxes/type.tmGrammar.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"version": "https://github.com/microsoft/TypeScript-TmLanguage/commit/0dfae8cc4807fecfbf8f1add095d9817df824c95",
32
"name": "TypeScript Type",
43
"scopeName": "source.type",
54
"patterns": [
@@ -16,4 +15,4 @@
1615
"include": "source.ts#shebang"
1716
}
1817
]
19-
}
18+
}

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
1212
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
1313
// "noUnusedParameters": true, /* Report errors on unused parameters. */
14-
}
14+
},
15+
"include": ["src/**/*.ts"]
1516
}

0 commit comments

Comments
 (0)