Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: typescript
datestypesserialization
Pass Date objects internally and serialize to string only at the boundary
Keep dates as Date objects through the codebase and only convert to strings when serializing for output.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | function schedule(startsAt: string) { |
| 2 | // start is parsed and re-stringified all over the place |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | function schedule(startsAt: Date) { |
| 2 | // work with Date; serialize only when sending out |
| 3 | return { startsAt: startsAt.toISOString() }; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)