2 ms·
You underestimate TypeScript. Your example will give a compiler error: This comparison appears to be unintentional because the types '"a"' and '"b"' have n
by teaearlgraycold 2y ago
You underestimate TypeScript. Your example will give a compiler error:
This comparison appears to be unintentional because the types '"a"' and '"b"' have no overlap.(2367)
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAZiEAuGAiAhqmBeNmDcAUIQJZwwAUCIO2uqARqgJQwDehMXMokIANgFMAdPxABzChgCeIFkQC+hIA https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAZiEAu...
It's features like these that make Python/Ruby/etc. type-checkers insufficient substitutes for TypeScript.
I think my example wasn't the best. Of course "active" | "inactive" would get reused. But if it's just a little function flag it could easily be a one-off.