Skip to content

Commit e6dfab6

Browse files
Blog: Mini TypeScript Hero (#48)
* blog: add Mini TypeScript Hero article * blog: fine-tune Mini TypeScript Hero article
1 parent 392cf6b commit e6dfab6

5 files changed

Lines changed: 193 additions & 0 deletions

File tree

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
title: 'TypeScript Hero is dead (is yet another VS Code extension gone forever?)'
3+
author: Johannes Hoppe
4+
mail: johannes.hoppe@haushoppe-its.de
5+
bio: '<a href="https://angular-buch.com"><img src="https://angular-buch.com/assets/img/book-cover-v1m.png" alt="Angular-Buch Cover" style="float: right; margin-top: -60px; margin-right: 30px; max-width: 250px;"></a>Johannes Hoppe is a trainer, consultant and developer specializing in Angular. He is a co-author of the <b>Angular book</b> (in German language), together with Ferdinand Malcher and Danny Koppenhagen. After four successful editions, they have rewritten the book from scratch – with modern syntax, compact and covering many new topics. The new book will be released in May 2026. More info at <a href="https://angular-buch.com" style="text-decoration: underline;"><b>angular-buch.com</b></a>'
6+
bioHeading: About Johannes Hoppe
7+
author2: Angular.Schule Team
8+
mail2: team@angular.schule
9+
bio2: '<a href="https://angular.schule"><img src="/img/logo-angular-schule-gradient-550.png" alt="Angular.Schule Logo" style="float: right; margin-left: 30px; margin-top: -10px; margin-right: 30px; max-width: 250px;"></a>Want to write clean, well-structured code with best practices in mind? Join Ferdinand Malcher and Johannes Hoppe in our workshops, where you learn Angular the practical way – including modern tools for more efficient development. More at <a href="https://angular.schule" style="text-decoration: underline;"><b>angular.schule</b></a>'
10+
bio2Heading: About our Angular workshops
11+
published: 2026-03-14
12+
keywords:
13+
- TypeScript
14+
- JavaScript
15+
- VS Code
16+
- VSCode Extension
17+
- Imports
18+
- Organize Imports
19+
- TypeScript Hero
20+
- Mini TypeScript Hero
21+
header: mini-typescript-hero.png
22+
language: en
23+
hidden: true
24+
---
25+
26+
I use TypeScript Hero every single day. Multiple times per hour, actually. One keyboard shortcut (`Ctrl+Alt+O`) and my messy imports transform into a well organized, alphabetically sorted list. Unused imports? Gone. Proper grouping? Done. Consistent formatting? Check. Then one day, VSCode hit me with a warning I couldn't ignore: **"This extension is deprecated as it is no longer being maintained."** My heart sank. Not another one!
27+
28+
<p align="center" style="margin-top: 30px">
29+
So, is TypeScript Hero dead? <b>Yes!</b><br>
30+
But there's a new hero in town! πŸ¦Έβ€β™‚οΈ
31+
</p>
32+
33+
<div align="center">
34+
<img src="logo.png" alt="Mini TypeScript Hero" width="40%">
35+
</div>
36+
37+
<h1 align="center">Mini TypeScript Hero – Small hero. Big cleanup!</h1>
38+
39+
## Contents
40+
41+
[[toc]]
42+
43+
## The Problem
44+
45+
Here's what TypeScript Hero does for me (and hopefully for you too):
46+
47+
**Before** (the chaos):
48+
49+
```typescript
50+
import { UserDetail } from './components/user-detail';
51+
import { Component } from '@angular/core';
52+
import { UnusedService } from './services/unused';
53+
import {Router} from "@angular/router"
54+
import { map, switchMap } from 'rxjs/operators';
55+
import {OnInit, inject} from "@angular/core"
56+
import { BookList } from './components/book-list';
57+
```
58+
59+
**After** pressing `Ctrl+Alt+O` (or `Cmd+Alt+O` on macOS):
60+
61+
```typescript
62+
import { Component, inject, OnInit } from '@angular/core';
63+
import { Router } from '@angular/router';
64+
import { map, switchMap } from 'rxjs/operators';
65+
66+
import { BookList } from './components/book-list';
67+
import { UserDetail } from './components/user-detail';
68+
```
69+
70+
As you can see, the Angular libraries are grouped together and automatically merged into one import. Then the local imports follow, separated by a blank line. Unused imports are removed. Everything is sorted with consistent quotes and semicolons. And if you want, you could even go further and separate the RxJS operators into their own group. Beautiful.
71+
72+
**This really helps keep the code clean.**
73+
74+
![Demo](demo.gif)
75+
76+
## The Mission
77+
78+
[Christoph BΓΌhler](https://me.cbue.ch/), the original author of TypeScript Hero, no longer had time to maintain the extension. He's moved on from TypeScript work, which is totally fair. We all have our seasons with different technologies.
79+
80+
But I needed this feature. Every. Single. Day.
81+
So I reached out to Christoph with a simple question: Could I pick up TypeScript Hero and release it as a new extension?
82+
His response was incredibly kind and supportive. He gave me his blessing, shared what code he still had, and even said he'd be excited to see the work continue.
83+
84+
**My mission was simple**: Preserve this feature for myself. And hopefully, other people will like it too.
85+
86+
## Cool New Features
87+
88+
While modernizing, I added some features that the original never had:
89+
90+
**πŸ—‚οΈ Organize entire folders or your whole workspace at once!**
91+
92+
Right-click any folder in the Explorer β†’ "Organize imports in folder". Or run "Organize imports in workspace" from the Command Palette. Perfect for:
93+
- Cleaning up after major refactorings
94+
- Onboarding legacy projects to your team's import style
95+
- Enforcing consistent imports across hundreds of files
96+
97+
The extension intelligently skips `node_modules`, `dist`, `build`, and other artifacts. You can also configure custom exclude patterns for auto-generated files your team shouldn't touch.
98+
99+
![Folder organization demo](demo2.gif)
100+
101+
**⚠️ Conflict detection**
102+
103+
Using Prettier or ESLint plugins that also sort imports? Run "Check for configuration conflicts" to detect if multiple tools are fighting over your imports. This would have saved me a lot of fiddling in the past.
104+
105+
## Wait, Doesn't VS Code Already Have This?
106+
107+
**Yes, but no.** VS Code has a built-in "Organize Imports" feature that removes unused imports, sorts alphabetically, and merges duplicate imports. Since TypeScript 4.7+, it preserves blank lines you manually add between import groups. The fundamental difference is **how groups are created**: you manually type blank lines (VS Code preserves them), versus automatic grouping (Mini TypeScript Hero creates them).
108+
109+
**VS Code's approach:** You type blank lines between imports to create groups. VS Code sees these blank lines and treats them as group separators, sorting within each group while preserving the blank lines. If you want external (node_modules) imports separated from internal (local files) imports, you manually add a blank line between them and maintain it yourself every time you add new imports.
110+
111+
**Mini TypeScript Hero's approach:** The extension automatically separates external (node_modules) from internal (local files) imports with blank lines between them. This will cover most use cases without any configuration. Want more? Optionally add specific patterns like `["/^@angular/", "/rxjs/", "Workspace"]` to group framework or library imports separately. No manual maintenance required.
112+
113+
**What VS Code cannot do:**
114+
115+
❌ **Automatically create groups based on patterns** β€” Without manual blank lines, VS Code sorts everything alphabetically as one flat list
116+
❌ **Remove `/index` from paths** β€” Keeps `./lib/index` as-is instead of cleaning to `./lib`
117+
❌ **Sort by first specifier** β€” Only sorts by module path, not by the first imported name
118+
119+
**In practice:** When you add a new import, VS Code requires you to manually maintain blank line separators between import groups. With Mini TypeScript Hero, you press `Ctrl+Alt+O` and it automatically places imports in the correct groups with proper spacing. Configure once, organize forever.
120+
121+
## What Changed Under the Hood
122+
123+
The original TypeScript Hero used Christoph's own `typescript-parser` library ([node-typescript-parser](https://github.com/buehler/node-typescript-parser) on GitHub), a great piece of software that did its job well. But like the extension itself, it hasn't been maintained in years. Updating it to work with modern TypeScript versions would become increasingly challenging.
124+
125+
For a tool I rely on daily, that was a ticking time bomb.
126+
127+
**The old engine:**
128+
- Custom-built `typescript-parser` (Christoph's library, great but unmaintained)
129+
- InversifyJS for dependency injection
130+
- A lot of hand-written infrastructure code from 2018
131+
132+
**The new engine:**
133+
- [`ts-morph`](https://github.com/dsherret/ts-morph) for parsing (actively maintained, battle-tested)
134+
- TypeScript with strict mode
135+
- Leaner codebase β€” delegate the heavy lifting to a proven library instead of rolling our own parser
136+
- No deprecated dependencies
137+
138+
**Other improvements:**
139+
- **Smart blank line handling**: Choose how many blank lines you want after imports (1, 2, or preserve existing). The old behavior where blank lines would sometimes "move" unpredictably is now configurable.
140+
- **Configurable import merging**: Combine multiple imports from the same module into one clean statement. Migrated users keep their original behavior; new users get modern best practices.
141+
- **Modern TypeScript support**: Full support for `import type` syntax and import attributes<br>(`with { type: 'json' }`).
142+
143+
The goal was simple: **Future-proof**. Make sure this tool keeps working for years to come, without depending on abandoned libraries.
144+
145+
## Migration
146+
147+
If you're already using TypeScript Hero, switching is straightforward:
148+
149+
1. Install Mini TypeScript Hero from the marketplace
150+
2. Open VSCode
151+
3. Your settings automatically migrate (one-time, on first startup)
152+
4. Done.
153+
154+
All your custom configurations transfer automatically β€” quote style, semicolons, import grouping rules, blank line handling, everything. The extension preserves your output format by automatically enabling `legacyMode: true` for migrated users, which matches the old TypeScript Hero behavior as closely as possible, including replicating certain quirks to ensure consistent output. You can switch to the new defaults anytime you want cleaner, more consistent behavior. You can even keep both extensions installed if you want, but I highly recommend deactivating the old hero because both will fight for the same shortcut. Speaking of which: the keyboard shortcut works exactly the same, `Ctrl+Alt+O` (or `Cmd+Alt+O` on macOS).
155+
156+
## A Quick Thank You
157+
158+
Thanks to Christoph BΓΌhler for creating TypeScript Hero in the first place. The original code, the design decisions, the thoughtful features: all of that came from Christoph.
159+
160+
I'm committed to keeping this tool maintained and working for the community. This extension is **MIT licensed and free for everyone**.
161+
162+
## Install Mini TypeScript Hero Now
163+
164+
Ready to organize your imports with a single keystroke?
165+
166+
* **Install from VSCode Marketplace:**
167+
Search for "Mini TypeScript Hero" or visit:
168+
πŸ‘‰ [marketplace.visualstudio.com/items?itemName=angular-schule.mini-typescript-hero](https://marketplace.visualstudio.com/items?itemName=angular-schule.mini-typescript-hero)
169+
170+
* **Keyboard shortcut:**
171+
`Ctrl+Alt+O` (Windows/Linux) | `Cmd+Alt+O` (macOS)
172+
173+
* **Works with:**
174+
TypeScript, JavaScript, TSX, JSX
175+
176+
* **Found a bug or have a feature request?**
177+
πŸ‘‰ [github.com/angular-schule/mini-typescript-hero](https://github.com/angular-schule/mini-typescript-hero)
178+
179+
## What's Next? (Your call to action!)
180+
181+
Here's a genuine question: **Does nicely formatted code still matter in the age of AI?**
182+
183+
With AI generating more and more code, the temptation is to just let it write whatever and move on. But I still believe that clean, well-organized imports make a real difference. For readability, for code reviews, for the next person who opens your file.
184+
185+
So if you still care about this stuff, tell me. I'm considering a standalone CLI tool for CI pipelines, or an MCP server that formats all that AI-generated slop before it lands in your codebase. But only if someone actually wants it.
186+
187+
Please reach out! πŸ™ [Give it a star on GitHub](https://github.com/angular-schule/mini-typescript-hero), [give me feedback via an issue](https://github.com/angular-schule/mini-typescript-hero/issues) or just drop me a nice message.
188+
189+
---
190+
191+
**TL;DR:** TypeScript Hero isn't really dead. I picked it up and modernized it as Mini TypeScript Hero. VS Code has basic organize imports, but Mini TypeScript Hero gives you custom grouping patterns, formatting control, and import organization that can match your team's style guide.
192+
193+
Happy coding! ✨
629 KB
Loading
3.32 MB
Loading
54.6 KB
Loading
51.5 KB
Loading

0 commit comments

Comments
Β (0)