Problem
The debugConfigProvider is exported as a global nullable variable, leading to:
- Null check dispersal: Every consumer must check for null before usage
- Lifecycle risk: Race conditions at extension activation/deactivation boundaries
- Type safety: Non-null assertions required despite nullable type union
- Maintenance burden: Hard to track all null checks across codebase
Related code:
Solution
Replace export global variable with controlled getter pattern:
- Private state:
debugConfigProvider
- Public API:
getDebugConfigProvider() - throws if not initialized
- Internal setter:
setDebugConfigProvider() - used only during lifecycle
Benefits
✅ Centralized null validation (single point of check)
✅ Clear initialization contract (throws with descriptive error)
✅ Type-safe for consumers (non-null guarantee)
✅ Improved code maintainability (fewer defensive checks)
✅ Better lifecycle management
Changes
- src/extension/rn-extension.ts: Added getter/setter pattern
- src/extension/commands/selectAndInsertDebugConfiguration.ts: Use getter, remove null check
Testing
✅ Build passes: 0 errors, 161 warnings (pre-existing)
✅ TypeScript: No compilation errors
✅ Formatter: All Prettier checks passed
Problem
The
debugConfigProvideris exported as a global nullable variable, leading to:Related code:
Solution
Replace export global variable with controlled getter pattern:
debugConfigProvidergetDebugConfigProvider()- throws if not initializedsetDebugConfigProvider()- used only during lifecycleBenefits
✅ Centralized null validation (single point of check)
✅ Clear initialization contract (throws with descriptive error)
✅ Type-safe for consumers (non-null guarantee)
✅ Improved code maintainability (fewer defensive checks)
✅ Better lifecycle management
Changes
Testing
✅ Build passes: 0 errors, 161 warnings (pre-existing)
✅ TypeScript: No compilation errors
✅ Formatter: All Prettier checks passed