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).
fullstack ruleP1universalStack: typescript
typesconsistencydata-flow
Don't convert a value's type back and forth across layers
Pick one representation for a value and keep it consistent; avoid serializing number-to-string on the backend then parsing it back on the frontend.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | // backend |
| 2 | const page = String(Number(req.query.page)); |
| 3 | // frontend |
| 4 | const page = Number(data.page); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // pick one type and keep it end-to-end |
| 2 | const page: number = Number(req.query.page); |
Explanation (EN)
Objašnjenje (HR)