New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(core): various fixes for missing-injectable migration #33286
refactor(core): various fixes for missing-injectable migration #33286
Conversation
02c4c04
to
ad5a3c6
Compare
246f661
to
a80d60b
Compare
e6e6d58
to
483c4d4
Compare
@@ -6,6 +6,7 @@ | |||
* found in the LICENSE file at https://angular.io/license | |||
*/ | |||
|
|||
import {forwardRefResolver} from '@angular/compiler-cli/src/ngtsc/annotations/src/util'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need to put this in a better place...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. It currently is somewhat odd to import from the annotations build package.
Currently the migration is unable to migrate instances where the provider definition uses `forwardRef`. Since this is a common pattern, we should support that from within the migration. The solution to the problem is adding a foreign function resolver to the `PartialEvaluator`. This basically matches the usage of the static evaluation that is used by the ngtsc annotations.
…with "useExisting" 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.
…tions Currently the `missing-injectable` migration seems to add `@Injectable()` to third-party classes in type definitions. This not an issue in general since we do not generate broken code by inserting a decorator into a type definition file. Though, we can avoid adding the decorator since it won't have any effect and in general we should not write to non source files of the compilation unit.
483c4d4
to
4656cae
Compare
FYI, g3 presubmit looks good. |
…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
…tions (#33286) Currently the `missing-injectable` migration seems to add `@Injectable()` to third-party classes in type definitions. This not an issue in general since we do not generate broken code by inserting a decorator into a type definition file. Though, we can avoid adding the decorator since it won't have any effect and in general we should not write to non source files of the compilation unit. PR Close #33286
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
See individual commits.