Skip to content
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

Conversation

devversion
Copy link
Member

@devversion devversion commented Oct 21, 2019

See individual commits.

@devversion devversion added action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: major This PR is targeted for the next major release comp: ivy labels Oct 21, 2019
@devversion devversion requested a review from a team as a code owner October 21, 2019 09:50
@ngbot ngbot bot modified the milestone: needsTriage Oct 21, 2019
@devversion devversion force-pushed the refactor/core-missing-injectable-forward-ref branch from 02c4c04 to ad5a3c6 Compare October 21, 2019 13:45
@devversion devversion force-pushed the refactor/core-missing-injectable-forward-ref branch 2 times, most recently from 246f661 to a80d60b Compare October 22, 2019 08:14
@devversion devversion changed the title refactor(core): missing-injectable migration should handle forwardRef refactor(core): various fixes for missing-injectable migration Oct 22, 2019
@devversion devversion force-pushed the refactor/core-missing-injectable-forward-ref branch 2 times, most recently from e6e6d58 to 483c4d4 Compare October 22, 2019 09:32
@devversion devversion requested a review from a team as a code owner October 22, 2019 09:32
@@ -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';
Copy link
Member

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...

Copy link
Member Author

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.

@alxhub
Copy link
Member

alxhub commented Oct 24, 2019

Presubmit

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.
@devversion devversion force-pushed the refactor/core-missing-injectable-forward-ref branch from 483c4d4 to 4656cae Compare October 24, 2019 16:38
@devversion devversion added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 24, 2019
@AndrewKushnir AndrewKushnir added the action: presubmit The PR is in need of a google3 presubmit label Oct 24, 2019
@AndrewKushnir
Copy link
Contributor

FYI, g3 presubmit looks good.

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Oct 25, 2019
AndrewKushnir pushed a commit that referenced this pull request Oct 25, 2019
…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
AndrewKushnir pushed a commit that referenced this pull request Oct 25, 2019
…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
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants