Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
feat(core): Introduce TestBed.inject to replace TestBed.get #32200
TestBed.get is not type safe, fixing it would be a massive breaking
BREAKING CHANGE: Injector.get now accepts abstract classes to return
Please check if your PR fulfills the following requirements:
What kind of change does this PR introduce?
What is the current behavior?
TestBed.get(ChangeDetectorRef) // returns any
What is the new behavior?
// Now deprecated TestBed.get(ChangeDetectorRef) // returns any TestBed.inject(ChangeDetectorRef) // returns ChangeDetectorRef
Does this PR introduce a breaking change?
The breaking change affects a feature that has been deprecated since Angular 4.x
The updated Typed signature now also accepts abstract classes (
Internal doc - go/testbed.inject
Note: I did not update all uses of
2 times, most recently
Aug 19, 2019
It can be caused by:
The former can be fixed by using proper typings, the latter can be solved by not marking
IgorMinar left a comment
Can't we change this so that #get behavior is unmodified while #inject projects a type-safe implementation?
I don't think that we can change the behavior of the #get api without causing lots of breakages.
This is what this commit is doing, I discussed with Vikram (see doc linked at the bottom of the PR) and he had the concern that