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
This commit is contained in:
Pete Bacon Darwin 2018-07-16 08:45:32 +01:00 committed by Igor Minar
parent 67588ec606
commit 6f1685ab98
1 changed files with 3 additions and 3 deletions

View File

@ -279,7 +279,7 @@ interface Context {
absoluteModuleName: string|null; absoluteModuleName: string|null;
scope: Scope; scope: Scope;
foreignFunctionResolver? foreignFunctionResolver?
(ref: Reference<ts.FunctionDeclaration|ts.MethodDeclaration>, (ref: Reference<ts.FunctionDeclaration|ts.MethodDeclaration|ts.FunctionExpression>,
args: ReadonlyArray<ts.Expression>): ts.Expression|null; args: ReadonlyArray<ts.Expression>): ts.Expression|null;
} }
@ -528,7 +528,7 @@ class StaticInterpreter {
value = this.visitExpression(member.value, context); value = this.visitExpression(member.value, context);
} else if (member.implementation !== null) { } else if (member.implementation !== null) {
value = new NodeReference(member.implementation, absoluteModuleName); value = new NodeReference(member.implementation, absoluteModuleName);
} else { } else if (member.node) {
value = new NodeReference(member.node, absoluteModuleName); value = new NodeReference(member.node, absoluteModuleName);
} }
} }
@ -670,7 +670,7 @@ class StaticInterpreter {
} }
function isFunctionOrMethodReference(ref: Reference<ts.Node>): function isFunctionOrMethodReference(ref: Reference<ts.Node>):
ref is Reference<ts.FunctionDeclaration|ts.MethodDeclaration> { ref is Reference<ts.FunctionDeclaration|ts.MethodDeclaration|ts.FunctionExpression> {
return ts.isFunctionDeclaration(ref.node) || ts.isMethodDeclaration(ref.node); return ts.isFunctionDeclaration(ref.node) || ts.isMethodDeclaration(ref.node);
} }