Answer the question
In order to leave comments, you need to log in
How to pass through an object if it can have a different interface?
One of 4 objects can be passed to the method, so key can be one of the four interfaces. Tried to do so to pass through the object
createBlock(obj: contentBl | asideBl | EngineBl | PetsBl) {
let key: keyof contentBl | asideBl | EngineBl | PetsBl;
for (key in obj) {
console.log(obj[key].name);
}
}
Answer the question
In order to leave comments, you need to log in
let key: keyof contentBl | keyof asideBl | keyof EngineBl | keyof PetsBl;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question