-
Notifications
You must be signed in to change notification settings - Fork 26.2k
feat(core): Add "AbstractType<T>" interface #29295
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
Conversation
Looks like this duplicates #25222, which contains a lot of background info in its thread. |
This is interesting, IMO this can be submitted before the other PR as a "prework" since it's only adding the type without actually using it, as mentioned on the PR description. |
packages/core/src/di/injector.ts
Outdated
@@ -69,6 +69,12 @@ export abstract class Injector { | |||
static THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND; | |||
static NULL: Injector = new NullInjector(); | |||
|
|||
// TODO(@Goodwine): Redefine get() as: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this for now - commented-out code is unnecessary and distracting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Ping :) |
This new interface will match classes whether they are abstract or concrete. Casting as `AbstractType<MyConcrete>` will return a type that isn't newable. This type will be used to match abstract classes in the `get()` functions of `Injector` and `TestBed`. Type isn't used yet so this isn't a breaking change. Issue #26491
Public API approval from @mhevery & merged without presubmit due to type addition only without being used. |
This new interface will match classes whether they are abstract or concrete. Casting as `AbstractType<MyConcrete>` will return a type that isn't newable. This type will be used to match abstract classes in the `get()` functions of `Injector` and `TestBed`. Type isn't used yet so this isn't a breaking change. Issue angular#26491 PR Close angular#29295
This new interface will match classes whether they are abstract or concrete. Casting as `AbstractType<MyConcrete>` will return a type that isn't newable. This type will be used to match abstract classes in the `get()` functions of `Injector` and `TestBed`. Type isn't used yet so this isn't a breaking change. Issue angular#26491 PR Close angular#29295
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 new interface will match classes whether they are abstract or
concrete. Casting as
AbstractType<MyConcrete>
will return a type thatisn't newable. This type will be used to match abstract classes in the
get()
functions ofInjector
andTestBed
.Type isn't used yet so this isn't a breaking change.
Issue #26491
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?
There is no abstract type sugar syntax
Issue Number: #26491
What is the new behavior?
There is now an interface that matches abstract classes just like
Type<T>
matches concrete classes.This will be used in the future for
Injector.get
andTestBed.get
to make the former more convenient and the latter more strictDoes this PR introduce a breaking change?
Other information
Added a bunch of TODOs on places I plan to update the
get
calls with a plan of how will they look like in the future (maybe Angular 9? 🤞)