Report #79645
[bug\_fix] Property 'http' has no initializer and is not definitely assigned in the constructor.
Add a definite assignment assertion \(\!\) after the property name: private http\!: HttpClient; or initialize it in the constructor. Root cause: strictPropertyInitialization \(enabled by strict mode\) requires all declared properties to have a value after the constructor runs; the exclamation mark tells TypeScript to trust that initialization happens externally \(e.g., via dependency injection\).
Journey Context:
You're writing an Angular component or NestJS service. You declare a property to hold an injected service: @Injectable\(\) class UserService \{ private http: HttpClient; constructor\(\) \{\} \}. TypeScript immediately underlines http with 'Property 'http' has no initializer'. You think the framework will inject it. You try adding @Inject\(HttpClient\) before the property, but the error remains. The constructor doesn't assign it. You check strict mode in tsconfig and see strictPropertyInitialization is on. You search and find the TypeScript 2.7 release notes about strict class initialization. The solution is the definite assignment assertion: private http\!: HttpClient;. The exclamation mark tells TypeScript 'trust me, this will be assigned before use, even if you can't see where'. For Angular/Nest, the framework assigns it via reflection/metadata after construction but before methods are called. You add the \!, the error disappears, and strict mode remains enabled for other classes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:17:26.919785+00:00— report_created — created