fix(core): export inject() from @angular/core (#22389)
inject() supports the ngInjectableDef-based configuration of the injector (otherwise known as tree-shakeable services). It was missing from the exported API of @angular/core, this PR adds it. The test added here is correct in theory, but may pass accidentally due to the decorator side-effect replacing the inject() call at runtime. An upcoming compiler PR will strip reified decorators from the output entirely. Fixes #22388 PR Close #22389
This commit is contained in:

committed by
Alex Eagle

parent
7d65356ae3
commit
f8749bfb70
@ -9,6 +9,7 @@
|
||||
import {enableProdMode} from '@angular/core';
|
||||
import {renderModuleFactory} from '@angular/platform-server';
|
||||
import {BasicAppModuleNgFactory} from 'app_built/src/basic.ngfactory';
|
||||
import {DepAppModuleNgFactory} from 'app_built/src/dep.ngfactory';
|
||||
import {HierarchyAppModuleNgFactory} from 'app_built/src/hierarchy.ngfactory';
|
||||
import {RootAppModuleNgFactory} from 'app_built/src/root.ngfactory';
|
||||
import {SelfAppModuleNgFactory} from 'app_built/src/self.ngfactory';
|
||||
@ -66,4 +67,14 @@ describe('ngInjectableDef Bazel Integration', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can inject dependencies', done => {
|
||||
renderModuleFactory(DepAppModuleNgFactory, {
|
||||
document: '<dep-app></dep-app>',
|
||||
url: '/',
|
||||
}).then(html => {
|
||||
expect(html).toMatch(/>true<\//);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user