|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -import {compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, ConstantPool, Expression, ExternalExpr, FactoryTarget, getSafePropertyAccessString, makeBindingParser, ParsedHostBindings, ParseError, parseHostBindings, R3ClassMetadata, R3DirectiveMetadata, R3FactoryMetadata, R3QueryMetadata, Statement, verifyHostBindings, WrappedNodeExpr} from '@angular/compiler'; |
| 9 | +import {compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, ConstantPool, createMayBeForwardRefExpression, Expression, ExternalExpr, FactoryTarget, ForwardRefHandling, getSafePropertyAccessString, makeBindingParser, MaybeForwardRefExpression, ParsedHostBindings, ParseError, parseHostBindings, R3ClassMetadata, R3DirectiveMetadata, R3FactoryMetadata, R3QueryMetadata, Statement, verifyHostBindings, WrappedNodeExpr} from '@angular/compiler'; |
10 | 10 | import {emitDistinctChangesOnlyDefaultValue} from '@angular/compiler/src/core';
|
11 | 11 | import * as ts from 'typescript';
|
12 | 12 |
|
@@ -532,17 +532,21 @@ export function extractQueryMetadata(
|
532 | 532 | ErrorCode.DECORATOR_ARITY_WRONG, exprNode, `@${name} must have arguments`);
|
533 | 533 | }
|
534 | 534 | const first = name === 'ViewChild' || name === 'ContentChild';
|
535 |
| - const node = tryUnwrapForwardRef(args[0], reflector) ?? args[0]; |
| 535 | + const forwardReferenceTarget = tryUnwrapForwardRef(args[0], reflector); |
| 536 | + const node = forwardReferenceTarget ?? args[0]; |
| 537 | + |
536 | 538 | const arg = evaluator.evaluate(node);
|
537 | 539 |
|
538 | 540 | /** Whether or not this query should collect only static results (see view/api.ts) */
|
539 | 541 | let isStatic: boolean = false;
|
540 | 542 |
|
541 | 543 | // Extract the predicate
|
542 |
| - let predicate: Expression|string[]|null = null; |
| 544 | + let predicate: MaybeForwardRefExpression|string[]|null = null; |
543 | 545 | if (arg instanceof Reference || arg instanceof DynamicValue) {
|
544 | 546 | // References and predicates that could not be evaluated statically are emitted as is.
|
545 |
| - predicate = new WrappedNodeExpr(node); |
| 547 | + predicate = createMayBeForwardRefExpression( |
| 548 | + new WrappedNodeExpr(node), |
| 549 | + forwardReferenceTarget !== null ? ForwardRefHandling.Unwrapped : ForwardRefHandling.None); |
546 | 550 | } else if (typeof arg === 'string') {
|
547 | 551 | predicate = [arg];
|
548 | 552 | } else if (isStringArrayOrDie(arg, `@${name} predicate`, node)) {
|
|
0 commit comments