fix(ivy): semantic module check incorrectly handles nested arrays (#30993)

In View Engine, developers can pass bootstrap and entry components
as nested arrays. e.g.

```ts
export const MyOtherEntryComponents = [A, B, C]

@NgModule({
  entryComponents: [MyComp, MyOtherEntryComponents]
})
```

Currently using nested arrays for these properties causes
unexpected errors to be reported in Ivy since the semantic
NgModule checks aren't properly recursing into the nested
entry/bootstrap components. This issue has been unveiled by
enabling the strict function parameter checks.

PR Close #30993
This commit is contained in:
Paul Gschwendtner
2019-06-11 22:53:03 +02:00
committed by Miško Hevery
parent dda781ecce
commit e061e638cb
4 changed files with 89 additions and 10 deletions

View File

@ -11,6 +11,7 @@ import '../util/ng_dev_mode';
import {OnDestroy} from '../interface/lifecycle_hooks';
import {Type} from '../interface/type';
import {throwCyclicDependencyError, throwInvalidProviderError, throwMixedMultiProviderError} from '../render3/errors';
import {deepForEach} from '../util/array_utils';
import {stringify} from '../util/stringify';
import {resolveForwardRef} from './forward_ref';
@ -497,10 +498,6 @@ function makeRecord<T>(
};
}
function deepForEach<T>(input: (T | any[])[], fn: (value: T) => void): void {
input.forEach(value => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
}
function isValueProvider(value: SingleProvider): value is ValueProvider {
return value !== null && typeof value == 'object' && USE_VALUE in value;
}