core-js/src/util/ReflectionUtil.ts
crusader e81ce83303 ing
2018-09-05 23:47:01 +09:00

33 lines
788 B
TypeScript

import { Method } from '../reflect';
export abstract class ReflectionUtil {
public static getParamTypes(method: Method): any[] {
if (0 === method.getParameterCount()) {
return [];
}
const parameters = method.getParameters();
if (undefined === parameters) {
return [];
}
const results: any[] = [];
for (let indexI = 0; indexI < parameters.length; indexI++) {
const paramType = parameters[indexI].getType();
results.push(paramType);
}
return results;
}
public static getParamTypeStrings(method: Method): string[] {
const paramTypes = ReflectionUtil.getParamTypes(method);
const results: string[] = [];
paramTypes.forEach(paramType => {
results.push(paramType.name);
});
return results;
}
}