From 961c9d48ae1a1fea24b5f064883f1fc88aaab63b Mon Sep 17 00:00:00 2001 From: Chuck Jazdzewski Date: Wed, 13 Jul 2016 10:55:23 -0700 Subject: [PATCH] fix(compiler): Query expression lambdas should have dynamic type Fixes: #9875 --- .../integrationtest/src/queries.ts | 20 ++++++++++++++++++- .../src/view_compiler/compile_query.ts | 7 ++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/modules/@angular/compiler-cli/integrationtest/src/queries.ts b/modules/@angular/compiler-cli/integrationtest/src/queries.ts index cb3677e8e7..76a92d93cd 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/queries.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/queries.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core'; +import {NgFor} from '@angular/common'; +import {Component, Directive, QueryList, ViewChild, ViewChildren} from '@angular/core'; @Component({selector: 'comp-for-child-query', template: 'child'}) export class CompForChildQuery { @@ -21,3 +22,20 @@ export class CompWithChildQuery { @ViewChild(CompForChildQuery) child: CompForChildQuery; @ViewChildren(CompForChildQuery) children: QueryList; } + +@Directive({selector: '[directive-for-query]'}) +export class DirectiveForQuery { +} + +@Component({ + selector: 'comp-with-directive-child', + directives: [DirectiveForQuery, NgFor], + template: `
+
{{data}}
+
` +}) +export class CompWithDirectiveChild { + @ViewChildren(DirectiveForQuery) children: QueryList; + + divData: string[]; +} diff --git a/modules/@angular/compiler/src/view_compiler/compile_query.ts b/modules/@angular/compiler/src/view_compiler/compile_query.ts index 8b6ae7b5c5..29343485d3 100644 --- a/modules/@angular/compiler/src/view_compiler/compile_query.ts +++ b/modules/@angular/compiler/src/view_compiler/compile_query.ts @@ -105,9 +105,10 @@ function mapNestedViews( return o.replaceVarInExpression(o.THIS_EXPR.name, o.variable('nestedView'), expr); }); return declarationAppElement.callMethod('mapNestedViews', [ - o.variable(view.className), o.fn( - [new o.FnParam('nestedView', view.classType)], - [new o.ReturnStatement(o.literalArr(adjustedExpressions))]) + o.variable(view.className), + o.fn( + [new o.FnParam('nestedView', view.classType)], + [new o.ReturnStatement(o.literalArr(adjustedExpressions))], o.DYNAMIC_TYPE) ]); }