feat(ivy): Forward refs now supported (#27439)

Adds deferred execution of scope setting for modules such that forward refs can be supported in ivy. Design docs can be found at https://docs.google.com/document/d/11KTbybis9rt0cZgMKd1wo_IKb6y1PMU-RoTDVLTXK4Y/edit#

PR Close #27439
This commit is contained in:
Ben Lesh
2018-12-03 13:58:07 -08:00
committed by Igor Minar
parent 2bc39860bb
commit cd858323f2
5 changed files with 83 additions and 23 deletions

View File

@ -24,7 +24,6 @@ jasmine_node_test(
name = "test",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
tags = [
"fixme-ivy-aot",
"ivy-only",
],
deps = [

View File

@ -7,7 +7,6 @@
*/
import {Injectable, InjectionToken, Injector, NgModule, createInjector, forwardRef} from '@angular/core';
import {fixmeIvy} from '@angular/private/testing';
import {AOT_TOKEN, AotModule, AotService} from 'app_built/src/module';
describe('Ivy NgModule', () => {
@ -41,24 +40,23 @@ describe('Ivy NgModule', () => {
it('works', () => { createInjector(JitAppModule); });
fixmeIvy('FW-645: jit doesn\'t support forwardRefs')
.it('throws an error on circular module dependencies', () => {
@NgModule({
imports: [forwardRef(() => BModule)],
})
class AModule {
}
it('throws an error on circular module dependencies', () => {
@NgModule({
imports: [forwardRef(() => BModule)],
})
class AModule {
}
@NgModule({
imports: [AModule],
})
class BModule {
}
@NgModule({
imports: [AModule],
})
class BModule {
}
expect(() => createInjector(AModule))
.toThrowError(
'Circular dependency in DI detected for type AModule. Dependency path: AModule > BModule > AModule.');
});
expect(() => createInjector(AModule))
.toThrowError(
'Circular dependency in DI detected for type AModule. Dependency path: AModule > BModule > AModule.');
});
it('merges imports and exports', () => {
const TOKEN = new InjectionToken<string>('TOKEN');
@ -84,4 +82,4 @@ describe('Ivy NgModule', () => {
expect(injector.get(TOKEN)).toEqual('provided from B');
});
});
});
});