Stop using any. Use unknown instead

📰 Dev.to · Rocky Chowdhury

Learn why using 'unknown' is better than 'any' in TypeScript and how it improves code safety

intermediate Published 11 May 2026
Action Steps
  1. Replace 'any' with 'unknown' in your TypeScript code to enable better type checking
  2. Use the 'unknown' type to represent unknown or untrusted data
  3. Configure your TypeScript compiler to warn against the use of 'any'
  4. Test your code with 'unknown' to ensure it handles type errors correctly
  5. Apply this best practice to your existing codebase to improve overall code safety
Who Needs to Know This

Developers and engineers working with TypeScript can benefit from this best practice to improve code quality and reduce errors

Key Insight

💡 Using 'unknown' instead of 'any' in TypeScript helps catch type errors at compile time and improves code reliability

Share This
💡 Ditch 'any' and use 'unknown' in TypeScript for better type safety!

Key Takeaways

Learn why using 'unknown' is better than 'any' in TypeScript and how it improves code safety

Full Article

TypeScript's main job is to catch type bugs at compile time, before your code ever runs. But there...
Read full article → ← Back to Reads