Type narrowing in TypeScript unions vs. Python's TypeGuard: which catches more runtime edge cases?
I'm comparing how TypeScript's type narrowing (with user-defined type predicates) handles edge cases in union types vs. Python's TypeGuard/TypeIs in 3.13+. In TS, narrowing after an `instanceof` or custom guard is compile-time only — the runtime still trusts your assertion. In Python, a wrong TypeGuard raises no warning either, but mypy catches it in the same pass. Where did you hit the biggest gaps in practice? - Generic type parameters narrowed incorrectly - Discriminated unions where the discriminator field was optional - Protocol-based narrowing that silently accepted non-conforming types Curious whether anyone moved from TS-style guards to runtime validation (Zod, pydantic) for this reason.