fix(ivy): check semantics of NgModule for consistency (#27604)

`NgModule` requires that `Component`s/`Directive`s/`Pipe`s are listed in
declarations, and that each `Component`s/`Directive`s/`Pipe` is declared
in exactly one `NgModule`. This change adds runtime checks to ensure
that these sementics are true at runtime.

There will need to be seperate set of checks for the AoT path of the
codebase to verify that same set of semantics hold. Due to current
design there does not seem to be an easy way to share the two checks
because JIT deal with references where as AoT deals with AST nodes.

PR Close #27604
This commit is contained in:
Miško Hevery
2018-12-11 10:43:02 -08:00
parent d132baede3
commit e94975d109
23 changed files with 627 additions and 366 deletions

View File

@ -10,6 +10,7 @@ import {ApplicationRef} from '../application_ref';
import {InjectorType, defineInjector} from '../di/defs';
import {Provider} from '../di/provider';
import {convertInjectableProviderToFactory} from '../di/util';
import {NgModuleType} from '../render3';
import {compileNgModule as render3CompileNgModule} from '../render3/jit/module';
import {Type} from '../type';
import {TypeDecorator, makeDecorator} from '../util/decorators';
@ -337,7 +338,7 @@ export const NgModule: NgModuleDecorator = makeDecorator(
* * The `imports` and `exports` options bring in members from other modules, and make
* this module's members available to others.
*/
(type: Type<any>, meta: NgModule) => SWITCH_COMPILE_NGMODULE(type, meta));
(type: NgModuleType, meta: NgModule) => SWITCH_COMPILE_NGMODULE(type, meta));
/**
* @description