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).
frontend ruleP2stack specificStack: typescript
typescriptclassesencapsulation
Prefer JavaScript #private fields over the TypeScript private keyword
Use #field for true runtime privacy; the `private` keyword is compile-time only and can be bypassed at runtime.
PR: hegnar-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | class Ad { |
| 2 | private listener?: () => void; // gone after compilation |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | class Ad { |
| 2 | #listener?: () => void; // genuinely private at runtime |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)