refactor(ivy): re-use the `ForeignFunctionResolver` interface when appropriate (#27697)

This makes the types (and intentions) more explicit and clear.

PR Close #27697
This commit is contained in:
George Kalpakas 2018-12-22 13:40:13 +02:00 committed by Alex Rickabaugh
parent 19a2b783cf
commit 2fc5f002e0
3 changed files with 9 additions and 9 deletions

View File

@ -188,11 +188,12 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
}
/**
* Given a `FunctionDeclaration` or `MethodDeclaration`, check if it is typed as a
* `ModuleWithProviders` and return an expression referencing the module if available.
* Given a `FunctionDeclaration`, `MethodDeclaration` or `FunctionExpression`, check if it is
* typed as a `ModuleWithProviders` and return an expression referencing the module if available.
*/
private _extractModuleFromModuleWithProvidersFn(node: ts.FunctionDeclaration|
ts.MethodDeclaration): ts.Expression|null {
ts.MethodDeclaration|
ts.FunctionExpression): ts.Expression|null {
const type = node.type || null;
return type &&
(this._reflectModuleFromTypeParam(type) || this._reflectModuleFromLiteralType(type));

View File

@ -15,8 +15,8 @@ import {StaticInterpreter} from './interpreter';
import {ResolvedValue} from './result';
export type ForeignFunctionResolver =
(node: Reference<ts.FunctionDeclaration|ts.MethodDeclaration>, args: ts.Expression[]) =>
ts.Expression | null;
(node: Reference<ts.FunctionDeclaration|ts.MethodDeclaration|ts.FunctionExpression>,
args: ReadonlyArray<ts.Expression>) => ts.Expression | null;
export class PartialEvaluator {
constructor(

View File

@ -13,6 +13,7 @@ import {Declaration, ReflectionHost} from '../../reflection';
import {ArraySliceBuiltinFn} from './builtin';
import {DynamicValue} from './dynamic';
import {ForeignFunctionResolver} from './interface';
import {BuiltinFn, EnumValue, ResolvedValue, ResolvedValueArray, ResolvedValueMap} from './result';
@ -73,9 +74,7 @@ interface Context {
*/
resolutionContext: string;
scope: Scope;
foreignFunctionResolver?
(ref: Reference<ts.FunctionDeclaration|ts.MethodDeclaration|ts.FunctionExpression>,
args: ReadonlyArray<ts.Expression>): ts.Expression|null;
foreignFunctionResolver?: ForeignFunctionResolver;
}
export class StaticInterpreter {
@ -542,4 +541,4 @@ function joinModuleContext(existing: Context, node: ts.Node, decl: Declaration):
} else {
return EMPTY;
}
}
}