Encountering issues when experimenting with this TypeScript code in VSCode:
enum Title {
Manager,
Developer
};
interface Staff {
Name: string;
Position: Title;
}
let staffNames: string[] = ['Alice', 'Bob'];
//Error message for missing Name property
function* getStaff(): Staff {
for (let name in staffNames) {
if (name === 0) //Issue raised here for name being a string
yield { Name: staffNames[name], Position: Title.Manager }
else
yield { Name: staffNames[name], Position: Title.Developer }
}
}
for (let employee of getStaff()) {
console.log(`${employee.Name} holds the title of ${employee.Position}`);
}
Seeking clarification on this matter...