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 ruleP2universalStack: typescript
typescripttypesservice-layersimplicity
Drop redundant intermediate response types
Don't define a wrapper interface that is only used to unwrap a response; type the parsed JSON inline and return the inner data directly.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codets
| 1 | interface ITickerListData { data: Ticker[]; } |
| 2 | interface ITickerListResponse { data: Ticker[]; } |
| 3 | // two near-identical wrappers |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | interface ITickerListResponse { data: Ticker[]; } |
| 2 |
|
| 3 | const getTickers = async (): Promise<Ticker[]> => { |
| 4 | const json: ITickerListResponse = await (await fetch(url)).json(); |
| 5 | return json.data; |
| 6 | }; |
Explanation (EN)
Objašnjenje (HR)