Lets Be Real: Its Time to Ditch `any` for `unknown` in TypeScript
dev.to·16h·
Discuss: DEV

We’ve all seen it in a pull request. A developer hits a snag with a tricky data type, and to get things working, they reach for the easiest tool available: any. It gets the job done and silences the compiler, but it comes at a hidden cost.

Our team has a Husky pre-commit hook set up to flag any, which is a great first step. But we all know that in a pinch, the --no-verify flag is an easy out. This makes the code review our most important line of defense. When you spot an any that has slipped through, it’s the perfect opportunity to advocate for its safer, smarter alternative: unknown.


The Danger of any: A “Trust Me” Promise to the Compiler 🙈

Let’s be blunt: using any is like telling the TypeScript compiler to just look the other way. When you type a variabl…

Similar Posts

Loading similar posts...