Repository navigation
Conversation
45bbce3 to
86c6692
Compare
|
Instead of relaxing the constraints of |
|
@JoostK With @Injectable({
providedIn: 'root'
})
abstract class Foo { }The newable or not of class Then it will always be casting as |
There was a problem hiding this comment.
What is the reasoning to change null to undefined?
There was a problem hiding this comment.
angular/packages/core/src/linker/component_factory.ts
Lines 85 to 87 in 732026c
ComponentFactory#create() accepts NgModuleRef | undefined, not NgModuleRef | null, it's a compilation error in TypeScript.
Previously ngModule is of any type so bypassed the type-checking.
There was a problem hiding this comment.
I think this is a breaking change since we are changing the meaning of Type. I would much rather create AbstractType which is than extended by Type
interface AbstractType<T> extends Function { prototype: T; }
interface Type<T> extends AbstractType<T> { new (...args: any[]): T;}
I think that would work better and be less breaking. Many of the changes you had to do would not need to be made. What do you think?
There was a problem hiding this comment.
Sounds reasonable, I'll have a try.
There was a problem hiding this comment.
This is indeed less breaking, but would let Type being completely meaningless, every API would only use AbstractType rather than Type.
AbstractType | Type is just AbstractType.
86c6692 to
f0bba3a
Compare
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
mhevery
left a comment
There was a problem hiding this comment.
Created fixup for outstanding issues.
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
|
There are a lot of breaking targets in Googl3 from this PR so this seems to be a breaking change. Needs more investigation. |
|
@mhevery The code |
b3fc729 to
3cdfda7
Compare
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
IgorMinar
left a comment
There was a problem hiding this comment.
I like this version of the PR, but I don't see any test that proves that abstract classes can actually be used as injection tokens. Can you please add one?
|
The PR also needs a rebase, which might uncover other compilation issues (many tests didn't run on CI). And I see that google3 has quite a few compilation failures as well. The combination of all of these makes me more and more uncomfortable about landing this change now. If we can't make this a no/low developer pain change, we should wait with this until v8 and make a plan to roll it out. |
575ee45 to
9045583
Compare
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
|
Rebased and added a test. |
Issues:
|
|
Hi, I'm closing this PR in favor of recently active #37958 that targets Ivy code. Thank you. |
|
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. |
closes #23611
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?
Issue Number: #23611
There're many services used an abstract class as tokens, like:
After #13785 merged,
injector.get(ChangeDetectorRef)would produce a deprecation warning since anabstract classis not aType:angular/packages/core/src/di/injector.ts
Lines 71 to 75 in 3f20a2f
Also in the new
inject()API, it throws an error as no deprecatedanyfallback:angular/packages/core/src/di/injector.ts
Lines 459 to 461 in 3f20a2f
What is the new behavior?
Abstract classes should be allowed as injection tokens, this PR has relaxed typing of
Typeso that abstract class can be now used.Technically any non-class function can also pass the type now as they have an
anyprototype.Does this PR introduce a breaking change?
If one uses
Typetype and trying tonewit directly.Other information