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

@ -299,7 +299,7 @@ describe('ViewContainerRef', () => {
const changeDetector = ref.injector.get(ChangeDetectorRef);
changeDetector.detectChanges();
expect(dynamicComp.doCheckCount).toEqual(1);
expect(changeDetector.context).toEqual(dynamicComp);
expect((changeDetector as any).context).toEqual(dynamicComp);
});
it('should not throw when destroying a reattached component', () => {