6 min read
|
Saved February 14, 2026
|
Copied!
Do you care about this?
The author reflects on their initial misconceptions about TypeScript, highlighting its shortcomings, especially its error handling and reliance on the `any` type. They argue that TypeScript's type system lacks the strictness and runtime enforcement found in languages like Rust, leading to potential runtime errors.
If you do, here's more
The author reflects on their evolving perspective of TypeScript, initially skeptical but ultimately recognizing its strengths, particularly in type safety. They outline their programming background, which includes experience with languages like Java, Python, and Rust, noting how Rust's strict type system shaped their expectations. The author appreciates TypeScript's potential but highlights significant flaws, starting with the lack of concrete error return types. This means functions can throw errors without the compiler warning the developer, leading to potential runtime failures that are hard to trace back to their source.
Another major concern is the ubiquitous use of the `any` type, which undermines TypeScript’s purpose. The author illustrates this with examples that show how easy it is to bypass type checks, allowing erroneous casts that can lead to crashes. They argue that TypeScript's default laxness compromises the benefits of a type-safe environment, with developers often resorting to workarounds like the `!!` syntax to force the compiler to accept potentially unsafe code.
The author also criticizes TypeScript’s function typing, explaining that it doesn’t enforce return types as strictly as one would expect. For instance, a function meant to return a `SafeUser` can still return an object with additional properties from the `User` type without triggering a compiler error. This structural typing approach, they argue, is fundamentally weaker than Rust’s guarantees, where the compiler actively verifies that a function meets its declared contract. Ultimately, the author portrays TypeScript as a tool that provides useful type documentation during development but lacks runtime enforcement, making it less reliable than other strictly typed languages.
Questions about this article
No questions yet.