Skip to content

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

Closed
mitchellwills wants to merge 1 commit into
angular:masterfrom
mitchellwills:master
Closed

mitchellwills wants to merge 1 commit into
angular:masterfrom
mitchellwills:master

Conversation

@mitchellwills

@mitchellwills mitchellwills commented Jul 7, 2020 •

Copy link
Copy Markdown
Contributor

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.

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

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

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@AndrewKushnir AndrewKushnir left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@googlebot ping.

@atscott atscott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@alxhub alxhub left a comment

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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 ;)

@atscott atscott left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@mitchellwills

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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.

8 participants