fix(ivy): let ngtsc unwrap expressions when resolving forwardRef (#29886)

Previously, ngtsc would fail to resolve `forwardRef` calls if they
contained additional parenthesis or casts. This commit changes the
behavior to first unwrap the AST nodes to see past such insignificant
nodes, resolving the issue.

Fixes #29639

PR Close #29886
This commit is contained in:
JoostK
2019-04-13 18:28:27 +02:00
committed by Ben Lesh
parent 725148a44d
commit 83291f01b0
2 changed files with 7 additions and 0 deletions

View File

@ -197,6 +197,7 @@ export function unwrapExpression(node: ts.Expression): ts.Expression {
}
function expandForwardRef(arg: ts.Expression): ts.Expression|null {
arg = unwrapExpression(arg);
if (!ts.isArrowFunction(arg) && !ts.isFunctionExpression(arg)) {
return null;
}
@ -228,6 +229,7 @@ function expandForwardRef(arg: ts.Expression): ts.Expression|null {
* expression otherwise
*/
export function unwrapForwardRef(node: ts.Expression, reflector: ReflectionHost): ts.Expression {
node = unwrapExpression(node);
if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression) ||
node.arguments.length !== 1) {
return node;