Dev.to
7/18/2026

Stronger application-layer types remove impossible states
Short summary
A TypeScript vertical-slice implementation demonstrates that application services should translate repository-level uncertainty (e.g., Company | undefined) into explicit result types (success, validation failure, not-found, repository failure). By doing so, the service contract prevents callers from needing to handle states the service has already made impossible. The takeaway: good types make invalid application states unrepresentable, not just syntactically correct.
- •Application services should translate repository uncertainty into explicit result types
- •Returning Company | undefined after the service already handles not-found forces callers to handle an impossible state
- •Good TypeScript types make invalid application states unrepresentable
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



