Skip to content

refactor(core): add single type for injector token - #41580

Closed
crisbeto wants to merge 3 commits into
angular:masterfrom
crisbeto:39792/di-token
Closed

crisbeto wants to merge 3 commits into
angular:masterfrom
crisbeto:39792/di-token

Conversation

@crisbeto

@crisbeto crisbeto commented Apr 12, 2021 •

Copy link
Copy Markdown
Member

Currently we have a lot of places where we repeat the type Type<T>|AbstractType<T>|InjectionToken<T> which makes it cumbersome to add another type or to type something else with the same signature.

These changes add a new type that can be used instead.

Fixes #39792.

@google-cla google-cla Bot added the cla: yes label Apr 12, 2021
Comment thread packages/core/src/di/token.ts Resolved
@petebacondarwin petebacondarwin added aio: preview target: minor This PR is targeted for the next minor release labels Apr 12, 2021
@mary-poppins

Copy link
Copy Markdown

You can preview 2daf941 at https://pr41580-2daf941.ngbuilds.io/.

@crisbeto
crisbeto marked this pull request as ready for review April 12, 2021 15:55
@pullapprove
pullapprove Bot requested review from AndrewKushnir and alxhub April 12, 2021 15:56
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime labels Apr 12, 2021
@ngbot ngbot Bot modified the milestone: Backlog Apr 12, 2021
@petebacondarwin

Copy link
Copy Markdown
Contributor

To be honest, I am not convinced this is a valuable change.

@crisbeto

crisbeto commented Apr 12, 2021 •

Copy link
Copy Markdown
Member Author

IMO it's worth having, because it's a safe change that will allow us to avoid having to adjust 20+ places if we have to make a change similar to #37958.

@crisbeto

Copy link
Copy Markdown
Member Author

Renamed to ProviderToken as discussed.

@mary-poppins

Copy link
Copy Markdown

You can preview 7fcc8b9 at https://pr41580-7fcc8b9.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 56d8661 at https://pr41580-56d8661.ngbuilds.io/.

Comment thread packages/core/src/di/index.ts Resolved
Comment thread packages/core/src/di/injector.ts Resolved
Comment thread packages/core/src/di/provider_token.ts Resolved
Comment thread packages/core/src/render3/di.ts Resolved
Comment thread packages/core/src/metadata/di.ts Resolved
Comment thread packages/core/src/render3/query.ts Resolved
Currently we have a lot of places where we repeat the type `Type<T>|AbstractType<T>|InjectionToken<T>` which makes it cumbersome to add another type or to type something else with the same signature.

These changes add a new type that can be used instead.

Fixes angular#39792.
@mary-poppins

Copy link
Copy Markdown

You can preview 38d7c4d at https://pr41580-38d7c4d.ngbuilds.io/.

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

NIce! LGTM

@crisbeto crisbeto removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Apr 20, 2021
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit and removed aio: preview labels Apr 20, 2021
@mary-poppins

Copy link
Copy Markdown

You can preview 2daf941 at https://pr41580-2daf941.ngbuilds.io/.
You can preview 7fcc8b9 at https://pr41580-7fcc8b9.ngbuilds.io/.
You can preview 56d8661 at https://pr41580-56d8661.ngbuilds.io/.
You can preview 38d7c4d at https://pr41580-38d7c4d.ngbuilds.io/.

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

LGTM 👍

I feel like we may need to expand docs on the ProviderToken symbol (for ex. to describe its practical use for developers), but we can do that as a followup (may be create a ticket on that?).

@AndrewKushnir

Copy link
Copy Markdown
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir removed the action: merge The PR is ready for merge by the caretaker label Apr 20, 2021

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

Reviewed-for: public-api

(note: I've removed the "merge" label as more people from "public-api" group should review the changes first)

@pullapprove
pullapprove Bot requested a review from atscott April 20, 2021 22:56

@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

@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

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Apr 21, 2021
@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Apr 21, 2021
@AndrewKushnir

Copy link
Copy Markdown
Contributor

@crisbeto FYI the current target label is "target: minor", so the change will land only in master (which targets first minor after v12, i.e. v12.1.0). I guess we may want to include that into v12 too? (note to caretaker: this comment is not a merge-blocker, we can merge it with the current set of labels and create a followup PR if needed)

@crisbeto crisbeto added target: rc This PR is targeted for the next release-candidate and removed target: minor This PR is targeted for the next minor release labels Apr 21, 2021
@crisbeto

Copy link
Copy Markdown
Member Author

Not sure why it was targeting minor. Switching it to rc.

jessicajaniuk pushed a commit that referenced this pull request Apr 22, 2021
Currently we have a lot of places where we repeat the type `Type<T>|AbstractType<T>|InjectionToken<T>` which makes it cumbersome to add another type or to type something else with the same signature.

These changes add a new type that can be used instead.

Fixes #39792.

PR Close #41580
@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 May 23, 2021
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: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There should be a type alias for types that can be used as an injection token

6 participants