Rules Hub
Code Ruleset
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: TypeScript
typescripttypesconsistency
Match an object's shape to the existing canonical type
When building an object that should conform to an established type (e.g. Ticker), include the type's required fields and reuse the type rather than a partial ad-hoc shape.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | ticker: { id: number; name: string; fullname: string; logo: string | null } | null |
Explanation (EN)
Ad-hoc copies drift from the shared contract and conceal missing fields.
Objašnjenje (HR)
Good example
New codets
| 1 | ticker: Ticker | null // includes insref, isin, instrumentType, marketplace, ... |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
When an object represents the existing domain entity, reuse its canonical type and supply required fields from actual data.
Exceptions / Tradeoffs (EN)
Use an explicit Pick/projection or DTO when the boundary intentionally returns a subset; never invent fields to satisfy the full entity type.