Pattern matching in TypeScript today
JavaScript does not have pattern matching yet, but TypeScript developers can model states clearly and use ts-pattern for exhaustive pattern matching today.
TypeScript patterns that make intent, failures, and domain rules explicit.
JavaScript does not have pattern matching yet, but TypeScript developers can model states clearly and use ts-pattern for exhaustive pattern matching today.
Enums add runtime behavior, work against modern TypeScript workflows, and have simpler alternatives like string literal unions and const objects.
Truthy and falsy checks in TypeScript hide intent and can introduce bugs. Prefer explicit checks for the values you actually care about.
Promises hide failure in an untyped rejection path. Task from true-myth makes asynchronous success and failure explicit in TypeScript.
Use Result in TypeScript for expected failures, Maybe for absence, and reserve exceptions for truly exceptional situations.
Why null still causes bugs in TypeScript - and how Maybe types make absence explicit.