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 ruleP2stack specificStack: typescript
dtodrytypestypescript
Derive related DTOs from a base with Pick/Omit/extends instead of redefining fields
When one DTO is a subset or variant of another, construct it from the base type (PickType, OmitType, extends) rather than re-declaring the shared properties.
PR: hegnar-investor-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | class UpdateVoteDto { |
| 2 | public postId: number; |
| 3 | public vote: boolean; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | class UpdateVoteDto extends PickType(CreateVoteDto, ['postId', 'vote']) {} |
Explanation (EN)
Objašnjenje (HR)