Repository navigation
fix(core): Allow passing AbstractType to the inject function - #37958
mitchellwills wants to merge 1 commit into
Conversation
jelbourn
left a comment
There was a problem hiding this comment.
LGTM
Reviewed-for: public-api
petebacondarwin
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
AndrewKushnir
left a comment
There was a problem hiding this comment.
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):
- https://github.com/angular/angular/blob/master/packages/core/src/di/injector.ts#L157
- https://github.com/angular/angular/blob/master/packages/core/src/di/r3_injector.ts#L183
- https://github.com/angular/angular/blob/master/packages/core/src/di/r3_injector.ts#L406
- https://github.com/angular/angular/blob/master/packages/core/src/render3/component_ref.ts#L85
- https://github.com/angular/angular/blob/master/packages/core/src/render3/interfaces/injector.ts#L137
- https://github.com/angular/angular/blob/master/packages/core/src/render3/interfaces/injector.ts#L241
- https://github.com/angular/angular/blob/master/packages/examples/core/di/ts/injector_spec.ts#L15
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.
|
@googlebot ping. |
atscott
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
alxhub
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
LGTM with one suggestion
There was a problem hiding this comment.
It's just a nitpick, but I would suggest reordering AbstractType and InjectionToken:
| 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
left a comment
There was a problem hiding this comment.
Adding approval for fw-core
|
@mitchellwills - are you still interested in working on this PR? If so, could you rebase and deal with the comments? Thanks! |
|
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 |
|
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.
74a1fc5 to
c80fe19
Compare
|
I think i've addressed the comments from above: rebase, additional replacements, reorder to I also filed #39792 |
|
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). |
|
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. |
This is a type only change that replaces
Type<T>|InjectionToken<T>withType<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?
What is the current behavior?
injectinstruction does not acceptAbstractTypeas a token.Issue Number: N/A
What is the new behavior?
injectinstruction acceptsAbstractTypeas a token. This is a type only change (should have no runtime impact)Does this PR introduce a breaking change?
Other information
Potentially
Type<T>|AbstractType<T>|InjectionToken<T>should become a type alias, but i'm not sure what it should be called.