feat(core): Introduce TestBed.inject to replace TestBed.get (#32200)

TestBed.get is not type safe, fixing it would be a massive breaking
change. The Angular team has proposed replacing it with TestBed.inject
and deprecate TestBed.get.

Deprecation from TestBed.get will come as a separate commit.

Issue #26491
Fixes #29905

BREAKING CHANGE: Injector.get now accepts abstract classes to return
type-safe values. Previous implementation returned `any` through the
deprecated implementation.

PR Close #32200
This commit is contained in:
Carlos Ortiz García
2019-08-19 15:05:29 -07:00
committed by Misko Hevery
parent 2b28b91fd9
commit 3aba7ebe6a
10 changed files with 132 additions and 79 deletions

View File

@ -677,7 +677,7 @@ describe('AppComponent', () => {
});
it('should not be loaded/registered until necessary', () => {
const loader: TestElementsLoader = fixture.debugElement.injector.get(ElementsLoader);
const loader = fixture.debugElement.injector.get(ElementsLoader) as unknown as TestElementsLoader;
expect(loader.loadCustomElement).not.toHaveBeenCalled();
setHasFloatingToc(true);