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).
backend ruleP2stack specificStack: typescript
typescripttypesreadabilitynitpick
Do not add a redundant empty-array member to a return type
Typing a result as `T[] | []` is redundant because `[]` is already assignable to `T[]`; declare it simply as `T[]`.
PR: hegnar-investor-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | async getItems(): Promise<ItemDto[] | []> { ... } |
Explanation (EN)
An empty array already satisfies the ordinary array return type.
Objašnjenje (HR)
Good example
New codetypescript
| 1 | async getItems(): Promise<ItemDto[]> { ... } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
For a TypeScript union containing both T[] and the empty tuple [], confirm that the API only promises an array and does not use tuple-specific conditional-type behavior.
Exceptions / Tradeoffs (EN)
Preserve tuple distinctions when a generic or conditional type intentionally observes them.