fix(core): missing-injectable migration should not migrate providers with "useExisting" (#33286)
We should not migrate the reference from `useExisting`. This is because developers can only use the `useExisting` value as a token. e.g. ```ts @NgModule({ providers: [ {provide: AppRippleConfig, useValue: rippleOptions}, {provide: MAT_RIPPLE_OPTIONS, useExisting: AppRippleConfig}, ] }) export class AppModule {} ``` In the case above, nothing should be decorated with `@Injectable`. The `AppRippleConfig` class is just used as a token for injection. PR Close #33286
This commit is contained in:

committed by
Andrew Kushnir

parent
eeecbf28e4
commit
4d23b60d09
@ -8,7 +8,7 @@ export class ComponentProvider2 {}
|
||||
@Component({
|
||||
template: '',
|
||||
viewProviders: [ComponentTypeProvider, [
|
||||
{provide: ComponentDontNeedCase, useExisting: ComponentProvider}]
|
||||
{provide: ComponentDontNeedCase, useClass: ComponentProvider}]
|
||||
],
|
||||
providers: [ComponentProvider2]
|
||||
})
|
||||
@ -21,7 +21,7 @@ export class DirectiveProvider {}
|
||||
@Directive({
|
||||
selector: 'test-dir',
|
||||
providers: [DirectiveTypeProvider, [
|
||||
{provide: DirectiveDontNeedCase, useExisting: DirectiveProvider}]
|
||||
{provide: DirectiveDontNeedCase, useClass: DirectiveProvider}]
|
||||
],
|
||||
})
|
||||
export class ProvidersTestDirective {}
|
||||
|
@ -11,7 +11,7 @@ export class ComponentProvider2 {}
|
||||
@Component({
|
||||
template: '',
|
||||
viewProviders: [ComponentTypeProvider, [
|
||||
{provide: ComponentDontNeedCase, useExisting: ComponentProvider}]
|
||||
{provide: ComponentDontNeedCase, useClass: ComponentProvider}]
|
||||
],
|
||||
providers: [ComponentProvider2]
|
||||
})
|
||||
@ -26,7 +26,7 @@ export class DirectiveProvider {}
|
||||
@Directive({
|
||||
selector: 'test-dir',
|
||||
providers: [DirectiveTypeProvider, [
|
||||
{provide: DirectiveDontNeedCase, useExisting: DirectiveProvider}]
|
||||
{provide: DirectiveDontNeedCase, useClass: DirectiveProvider}]
|
||||
],
|
||||
})
|
||||
export class ProvidersTestDirective {}
|
||||
|
Reference in New Issue
Block a user