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:
parent
19a2b783cf
commit
2fc5f002e0
|
@ -188,11 +188,12 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a `FunctionDeclaration` or `MethodDeclaration`, check if it is typed as a
|
* Given a `FunctionDeclaration`, `MethodDeclaration` or `FunctionExpression`, check if it is
|
||||||
* `ModuleWithProviders` and return an expression referencing the module if available.
|
* typed as a `ModuleWithProviders` and return an expression referencing the module if available.
|
||||||
*/
|
*/
|
||||||
private _extractModuleFromModuleWithProvidersFn(node: ts.FunctionDeclaration|
|
private _extractModuleFromModuleWithProvidersFn(node: ts.FunctionDeclaration|
|
||||||
ts.MethodDeclaration): ts.Expression|null {
|
ts.MethodDeclaration|
|
||||||
|
ts.FunctionExpression): ts.Expression|null {
|
||||||
const type = node.type || null;
|
const type = node.type || null;
|
||||||
return type &&
|
return type &&
|
||||||
(this._reflectModuleFromTypeParam(type) || this._reflectModuleFromLiteralType(type));
|
(this._reflectModuleFromTypeParam(type) || this._reflectModuleFromLiteralType(type));
|
||||||
|
|
|
@ -15,8 +15,8 @@ import {StaticInterpreter} from './interpreter';
|
||||||
import {ResolvedValue} from './result';
|
import {ResolvedValue} from './result';
|
||||||
|
|
||||||
export type ForeignFunctionResolver =
|
export type ForeignFunctionResolver =
|
||||||
(node: Reference<ts.FunctionDeclaration|ts.MethodDeclaration>, args: ts.Expression[]) =>
|
(node: Reference<ts.FunctionDeclaration|ts.MethodDeclaration|ts.FunctionExpression>,
|
||||||
ts.Expression | null;
|
args: ReadonlyArray<ts.Expression>) => ts.Expression | null;
|
||||||
|
|
||||||
export class PartialEvaluator {
|
export class PartialEvaluator {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {Declaration, ReflectionHost} from '../../reflection';
|
||||||
|
|
||||||
import {ArraySliceBuiltinFn} from './builtin';
|
import {ArraySliceBuiltinFn} from './builtin';
|
||||||
import {DynamicValue} from './dynamic';
|
import {DynamicValue} from './dynamic';
|
||||||
|
import {ForeignFunctionResolver} from './interface';
|
||||||
import {BuiltinFn, EnumValue, ResolvedValue, ResolvedValueArray, ResolvedValueMap} from './result';
|
import {BuiltinFn, EnumValue, ResolvedValue, ResolvedValueArray, ResolvedValueMap} from './result';
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,9 +74,7 @@ interface Context {
|
||||||
*/
|
*/
|
||||||
resolutionContext: string;
|
resolutionContext: string;
|
||||||
scope: Scope;
|
scope: Scope;
|
||||||
foreignFunctionResolver?
|
foreignFunctionResolver?: ForeignFunctionResolver;
|
||||||
(ref: Reference<ts.FunctionDeclaration|ts.MethodDeclaration|ts.FunctionExpression>,
|
|
||||||
args: ReadonlyArray<ts.Expression>): ts.Expression|null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StaticInterpreter {
|
export class StaticInterpreter {
|
||||||
|
@ -542,4 +541,4 @@ function joinModuleContext(existing: Context, node: ts.Node, decl: Declaration):
|
||||||
} else {
|
} else {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue