fix(ivy): ngtsc should pay attention to declaration order (#25392)

When generating the 'directives:' property of ngComponentDef, ngtsc
needs to be conscious of declaration order. If a directive being
written into the array is declarated after the component currently
being compiled, then the entire directives array needs to be wrapped
in a closure.

This commit fixes ngtsc to pay attention to such ordering issues
within directives arrays.

PR Close #25392
This commit is contained in:
Alex Rickabaugh
2018-08-06 14:49:35 +02:00
committed by Ben Lesh
parent 6f085f8610
commit 2befc65777
7 changed files with 94 additions and 13 deletions

View File

@ -73,6 +73,7 @@ export function compileComponent(type: Type<any>, metadata: Component): void {
directives: new Map(),
pipes: new Map(),
viewQueries: [],
wrapDirectivesInClosure: false,
},
constantPool, makeBindingParser());
const preStatements = [...constantPool.statements, ...res.statements];