February 2019
Beginner
694 pages
18h 4m
English
Now that we know what each of our constructor parameter names are, we need to match these with a parameter type. In order to do this, we will need to make use of the reflect-metadata package in our ConstructorInject decorator, as follows:
let parameterTypeArray =
Reflect.getMetadata("design:paramtypes", classDefinition);
console.log(`parameterTypeArray:`);
console.log(`===================`);
console.log(`${parameterTypeArray}`);
console.log(`===================`);
for (let type of parameterTypeArray) {
console.log(`found type : ${type.name}`);
}
Here, we are calling the Reflect.getMetadata function, and using the "design:paramtypes" argument to extract an array from the class definition. We then print this array to ...
Read now
Unlock full access