In the decorator's usage notes, Angular claims it does track all deps. Also, inject() is the prefered way to inject deps to e.g. a service instead of injecting deps from its constructor.
However, if I inspect the produced code, I only see empty deps when using inject():
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AlertPopupService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AlertPopupService, providedIn: 'root' }); }
but the deps array has some content if I use the constructor approach:
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AlertPopupService, deps: [{ token: LOGGER }], target: i0.ɵɵFactoryTarget.Injectable }); }
Passing deps: [...] as part of the @Injectable decorators options is completely ignored btw.
Is it still safe to use inject() or could this cause problems with not-yet provided or initialized services ?