Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Export every type referenced by an exported type
Export nested types when consumers or declaration tooling need them; referencing a local type does not always break declaration emit.
Bad example
| 1 | export interface ApiResponse { |
| 2 | user: User; |
| 3 | orders: Order[]; |
| 4 | } |
| 5 |
|
| 6 | type User = { id: string; name: string }; |
| 7 | type Order = { id: string; total: number }; |
Explanation (EN)
A useful nested domain type cannot be imported by name when it is not exported.
Objašnjenje (HR)
Koristan ugniježđeni domenski tip ne može se izravno importati po nazivu ako nije exportan.
Good example
| 1 | export interface ApiResponse { |
| 2 | user: User; |
| 3 | orders: Order[]; |
| 4 | } |
| 5 |
|
| 6 | export type User = { id: string; name: string }; |
| 7 | export type Order = { id: string; total: number }; |
Explanation (EN)
Every type reachable from the exported ApiResponse is itself exported, so declaration emit succeeds and consumers can import each nested type.
Objašnjenje (HR)
Svaki tip dostupan iz izvezenog ApiResponse je i sam izvezen, pa emisija deklaracija uspijeva, a potrosaci mogu uvesti svaki ugnijezdeni tip.
Notes (EN)
Export nested types that consumers should name directly or that the declaration toolchain requires, then verify generated declarations.
Exceptions / Tradeoffs (EN)
A non-exported local type referenced by an exported interface can be emitted correctly and remain structurally usable. Do not expand the public API solely from an assumed private-name error.
Iznimke / Tradeoffi (HR)
Lokalni neexportani tip na koji se poziva javno sučelje može se ispravno emitirati i ostati strukturno upotrebljiv. Ne širi javni API samo zbog pretpostavljene private-name pogreške.