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 ruleP2stack specificStack: TypeScript / NestJS
configtypesnull-handling
Type guaranteed config values as non-optional to avoid undefined leaks
When an env/config value is enforced at startup, type the config accessor so it returns a definite string, instead of letting `get<string>()` return string|undefined and propagating undefined through the code.
PR: hegnar-user-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const prodSlug = this.configService.get<string>('zephrSiteSlug') || 'fallback'; // still string|undefined upstream |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // typed config so required keys are non-optional |
| 2 | const prodSlug: string = this.config.zephrSiteSlug; // guaranteed present |
Explanation (EN)
Objašnjenje (HR)