Question presented to candidate: "Our app still has HttpClientModule in an NgModule and four class interceptors registered with HTTP_INTERCEPTORS. We are going standalone. What replaces that setup, how do you migrate without breaking anything, and what happens while both styles exist?"
What a strong answer should cover:
- The legacy setup:
HttpClientModuleplus{ provide: HTTP_INTERCEPTORS, useClass: X, multi: true }for each class implementingHttpInterceptor. - The replacement:
provideHttpClient(withInterceptors([fnA, fnB]))withHttpInterceptorFnfunctions; ordering is one explicit array. - The bridge:
withInterceptorsFromDi()keeps class interceptors working underprovideHttpClient(); without it they are silently ignored. - When mixed, the position of the features in the
provideHttpClient(...)call decides whether classes or functions run first. - Status in 22.2.3:
HttpClientModuleandHttpClientTestingModuleare deprecated; DI-based interceptors "may be phased out in a later release". - A safe migration order: switch the module to
provideHttpClient(withInterceptorsFromDi()), then convert classes one at a time, then drop the bridge.
Clarifying questions expected:
- "Do any interceptors depend on registration order today?"
- "Are there interceptors provided by third-party NgModules we cannot rewrite?"
Code / implementation expected: Yes β a class interceptor and its functional equivalent registered side by side, showing the resulting order.