mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
The manual replacement logic had a flaw and was inserting the imports several times.
For example:
```ts
import { APP_INITIALIZER, ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { InitService } from './init.service';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }),
{
provide: APP_INITIALIZER,
useFactory: (initService: InitService) => initService.init(),
deps: [InitService],
multi: true
},
{
provide: APP_INITIALIZER,
useFactory: (initService: InitService) => initService.init(),
deps: [InitService],
multi: true
}
]
};
```
produced:
```ts
import { ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer }{ ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer } from '@angular/core';
import { InitService } from './init.service';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }),
provideAppInitializer(() => { return ((initService: InitService) => initService.init())(inject(InitService)); }),
provideAppInitializer(() => { return ((initService: InitService) => initService.init())(inject(InitService)); })
]
};
```
It now produces proper imports:
```ts
import { ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer } from '@angular/core';
```
PR Close #58456
|
||
|---|---|---|
| .. | ||
| google3 | ||
| all-migrations.spec.ts | ||
| BUILD.bazel | ||
| control_flow_migration_spec.ts | ||
| explicit_standalone_flag_spec.ts | ||
| helpers.ts | ||
| inject_migration_spec.ts | ||
| output_migration_spec.ts | ||
| pending_tasks_spec.ts | ||
| project_tsconfig_paths_spec.ts | ||
| provide_initializer_spec.ts | ||
| queries_migration_spec.ts | ||
| signals_migration_spec.ts | ||
| standalone_migration_spec.ts | ||
| standalone_routes_spec.ts | ||