Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add "AbstractType<T>" interface #29295

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@Goodwine
Copy link
Contributor

Goodwine commented Mar 14, 2019

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

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?

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 and TestBed.get to make the former more convenient and the latter more strict

Does this PR introduce a breaking change?

  • Yes
  • No

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? 馃)

@Goodwine Goodwine requested review from angular/fw-core as code owners Mar 14, 2019

@googlebot googlebot added the cla: yes label Mar 14, 2019

@Goodwine

This comment has been minimized.

Copy link
Contributor Author

Goodwine commented Mar 14, 2019

@JoostK

This comment has been minimized.

Copy link
Contributor

JoostK commented Mar 18, 2019

Looks like this duplicates #25222, which contains a lot of background info in its thread.

@Goodwine

This comment has been minimized.

Copy link
Contributor Author

Goodwine commented Mar 18, 2019

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.

@alxhub

alxhub approved these changes Mar 18, 2019

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

This comment has been minimized.

@alxhub

alxhub Mar 18, 2019

Contributor

We can remove this for now - commented-out code is unnecessary and distracting.

This comment has been minimized.

@Goodwine

Goodwine Mar 18, 2019

Author Contributor

Done

feat(core): Add "AbstractType<T>" interface
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

@Goodwine Goodwine force-pushed the Goodwine:new-types-for-injector branch from fc9dec2 to 79bb2b5 Mar 18, 2019

@ngbot ngbot bot added this to the needsTriage milestone Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.