Skip to content

Commit ffb9c96

Browse files
Merge pull request #102 from WebDevSimplified/add-video-link-ts-article
Add Video Link TS Article
2 parents 648ddd5 + a3a8dfb commit ffb9c96

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

  • src/pages/2026-04/advanced-tsconfig-settings

src/pages/2026-04/advanced-tsconfig-settings/index.mdx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ freebie: "ts-util-cheat-sheet"
99

1010
TypeScript's `strict` mode is a great starting point, but it leaves a surprising number of dangerous patterns unchecked. There is a whole category of compiler options that are disabled by default, and enabling them can catch subtle bugs that would otherwise slip through to production. In this article I will walk through the TSConfig settings that I think should be enabled in nearly every project, organized from settings I consider non-negotiable all the way to JS-only migration helpers.
1111

12+
_If you prefer to learn visually, check out the video version of this article._
13+
`youtube: 35cESnxXH6o`
14+
1215
## Must Have
1316

1417
These settings have essentially no downside and catch real bugs. Enable all of them.
@@ -49,7 +52,7 @@ import path from "path"
4952

5053
export default defineConfig({
5154
resolve: {
52-
tsconfigPaths: true
55+
tsconfigPaths: true,
5356
},
5457
})
5558
```
@@ -92,6 +95,7 @@ array.forEach((_item, index) => {
9295
### `allowUnusedLabels: false`
9396

9497
JavaScript has a labeled statement syntax that almost nobody uses intentionally. An unused label is almost always a typo. The classic case is someone who meant to write an object key but accidentally put the key outside the object, creating a label instead:
98+
9599
```json
96100
{
97101
"compilerOptions": {
@@ -300,7 +304,7 @@ This option is especially valuable if you are using Node.js's native TypeScript
300304

301305
Some TypeScript features emit JavaScript code when compiled; they are not just type annotations. These features cannot be used with type-stripping tools because there is no JavaScript to strip them to:
302306

303-
```ts
307+
````ts
304308
// Error: Enums are not erasable syntax.
305309
// Enums compile to a JavaScript object, so the stripper has no JS to output.
306310
enum Direction {
@@ -337,7 +341,7 @@ class User {
337341
this.age = age
338342
}
339343
}
340-
```
344+
````
341345
342346
The whole purpose of this option to ensure your code will work when your types are stripped out without needing them to be compiled with a tool like `tsc`. If you are using `tsc` to compile your code, this option is not necessary since `tsc` can handle all TypeScript features, but I still enable it since features like enums are generally considered bad practice anyway.
343347
@@ -391,7 +395,8 @@ class Animal {
391395

392396
// Error: There is no method 'speak' to override
393397
class Dog extends Animal {
394-
override speak(): string { // TypeScript catches the stale override
398+
override speak(): string {
399+
// TypeScript catches the stale override
395400
return "Woof!"
396401
}
397402
}
@@ -422,7 +427,7 @@ type User = {
422427
// Error: Type 'undefined' is not assignable to type 'string'.
423428
const user: User = {
424429
name: "Alice",
425-
nickname: undefined
430+
nickname: undefined,
426431
}
427432
428433
// Correct: omit the key entirely

0 commit comments

Comments
 (0)