Commit a116a64
refactor(migrations): useFactory in provide-initializer migration (angular#58493)
The following provider:
```ts
{
provide: APP_INITIALIZER,
useFactory: (initService: InitService) => {
return () => initService.init()
},
deps: [InitService],
multi: true
}
```
was migrated into:
```ts
provideAppInitializer(() => { return ((initService: InitService) => {
return () => initService.init()
})(inject(InitService)); })
```
This doesn't compile because there is an extra function:
```
✘ [ERROR] TS2345: Argument of type '() => () => void' is not assignable to parameter of type '() => void | Observable<unknown> | Promise<unknown>'.
Type '() => void' is not assignable to type 'void | Observable<unknown> | Promise<unknown>'. [plugin angular-compiler]
src/app/app.config.ts:7:26:
7 │ ...ovideAppInitializer(() => { return ((initService: InitService) => {
```
It now migrates the provider into:
```ts
provideAppInitializer(((initService: InitService) => {
return () => initService.init()
})(inject(InitService)))
```
PR Close angular#584931 parent 536ee2b commit a116a64
File tree
2 files changed
+5
-5
lines changed- packages/core/schematics
- migrations/provide-initializer
- test
2 files changed
+5
-5
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
0 commit comments