From 6f1685ab98024f9995e916ab85ab71c941a3d5cb Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Mon, 16 Jul 2018 08:45:32 +0100 Subject: [PATCH] fix(ivy): allow `FunctionExpression` to indicate a method declaration (#24897) In some code formats (e.g. ES5) methods can actually be function expressions. For example: ```js function MyClass() {} // this static method is declared as a function expression MyClass.staticMethod = function() { ... }; ``` PR Close #24897 --- packages/compiler-cli/src/ngtsc/metadata/src/resolver.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/metadata/src/resolver.ts b/packages/compiler-cli/src/ngtsc/metadata/src/resolver.ts index 17b831087f..acc8ff3f17 100644 --- a/packages/compiler-cli/src/ngtsc/metadata/src/resolver.ts +++ b/packages/compiler-cli/src/ngtsc/metadata/src/resolver.ts @@ -279,7 +279,7 @@ interface Context { absoluteModuleName: string|null; scope: Scope; foreignFunctionResolver? - (ref: Reference, + (ref: Reference, args: ReadonlyArray): ts.Expression|null; } @@ -528,7 +528,7 @@ class StaticInterpreter { value = this.visitExpression(member.value, context); } else if (member.implementation !== null) { value = new NodeReference(member.implementation, absoluteModuleName); - } else { + } else if (member.node) { value = new NodeReference(member.node, absoluteModuleName); } } @@ -670,7 +670,7 @@ class StaticInterpreter { } function isFunctionOrMethodReference(ref: Reference): - ref is Reference { + ref is Reference { return ts.isFunctionDeclaration(ref.node) || ts.isMethodDeclaration(ref.node); }