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

fix(core): Allow passing AbstractType to the inject function #37958

Closed
wants to merge 1 commit into from

Conversation

mitchellwills
Copy link
Contributor

@mitchellwills mitchellwills commented Jul 7, 2020

This is a type only change that replaces Type<T>|InjectionToken<T> with
Type<T>|AbstractType<T>|InjectionToken<T> in the injector.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

inject instruction does not accept AbstractType as a token.

Issue Number: N/A

What is the new behavior?

inject instruction accepts AbstractType as a token. This is a type only change (should have no runtime impact)

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Potentially Type<T>|AbstractType<T>|InjectionToken<T> should become a type alias, but i'm not sure what it should be called.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: public-api

@pullapprove pullapprove bot requested review from petebacondarwin and removed request for IgorMinar July 22, 2020 17:24
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mitchellwills, thanks for creating this PR 👍

I did a quick search in Angular codebase and found a couple more places where the AbstractType is not included (both in the current state of the codebase and in your PR):

Could you please have a quick look to see if these places also require type change?

Potentially Type|InjectionToken|AbstractType should become a type alias, but i'm not sure what it should be called.

I really like this idea, could you please create a new ticket (feature request) to capture this proposal?

Thank you.

@AndrewKushnir AndrewKushnir added cross-cutting: types action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime labels Jul 27, 2020
@ngbot ngbot bot added this to the needsTriage milestone Jul 27, 2020
@AndrewKushnir AndrewKushnir added the target: patch This PR is targeted for the next patch release label Jul 27, 2020
@AndrewKushnir
Copy link
Contributor

@googlebot ping.

Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

Copy link
Member

@alxhub alxhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

LGTM with one suggestion

export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>): T;
export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>, flags?: InjectFlags): T|null;
export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>, flags = InjectFlags.Default): T|null {
export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>|AbstractType<T>): T;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a nitpick, but I would suggest reordering AbstractType and InjectionToken:

Suggested change
export function ɵɵinject<T>(token: Type<T>|InjectionToken<T>|AbstractType<T>): T;
export function ɵɵinject<T>(token: Type<T>|AbstractType<T>|InjectionToken<T>): T;

as they're two sides of the same coin, vs InjectionToken which is more of a foreign currency ;)

Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding approval for fw-core

@petebacondarwin petebacondarwin added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 10, 2020
@petebacondarwin
Copy link
Member

@mitchellwills - are you still interested in working on this PR? If so, could you rebase and deal with the comments? Thanks!

@mitchellwills
Copy link
Contributor Author

yah, sorry for the delay (I worked around it so this dropped in priority for me). I'll rebase and address the comments next week

@AndrewKushnir
Copy link
Contributor

FYI, related ticket: #23611.

This is a type only change that replaces `Type<T>|InjectionToken<T>` with
`Type<T>|AbstractType<T>|InjectionToken<T>` in the injector.
@mitchellwills
Copy link
Contributor Author

I think i've addressed the comments from above: rebase, additional replacements, reorder to AbstractType<T>|InjectionToken<T>.

I also filed #39792

@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Nov 20, 2020
@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Nov 23, 2020
@AndrewKushnir
Copy link
Contributor

Global Presubmit.

@AndrewKushnir AndrewKushnir added target: minor This PR is targeted for the next minor release and removed action: presubmit The PR is in need of a google3 presubmit target: patch This PR is targeted for the next patch release labels Nov 24, 2020
@AndrewKushnir
Copy link
Contributor

FYI, global presubmit indicated no problems related to this change, so I'm adding it to the merge queue. Note: I've changed the target from "patch" to "minor" though since this PR can also be considered as a feature (that more types are now allowed in the inject function).

@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 Dec 25, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Dec 25, 2020
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 cross-cutting: types target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants