feat(compiler): Support default parameters in static reflector (#10370)

Closes: #10369
This commit is contained in:
Chuck Jazdzewski
2016-07-29 09:10:45 -07:00
committed by GitHub
parent 0eca7abdd8
commit 763ca60f5b
5 changed files with 88 additions and 18 deletions

View File

@ -308,12 +308,17 @@ export class StaticReflector implements ReflectorReader {
}
calling.set(functionSymbol, true);
try {
let value = targetFunction['value'];
const value = targetFunction['value'];
if (value && (depth != 0 || value.__symbolic != 'error')) {
// Determine the arguments
let args = (expression['arguments'] || []).map((arg: any) => simplify(arg));
let parameters: string[] = targetFunction['parameters'];
let functionScope = BindingScope.build();
const args: any[] =
(expression['arguments'] || []).map((arg: any) => simplify(arg));
const parameters: string[] = targetFunction['parameters'];
const defaults: any[] = targetFunction.defaults;
if (defaults && defaults.length > args.length) {
args.push(...defaults.slice(args.length).map((value: any) => simplify(value)));
}
const functionScope = BindingScope.build();
for (let i = 0; i < parameters.length; i++) {
functionScope.define(parameters[i], args[i]);
}