event.ts
export interface Action {
description: string;
location: string;
duration: number;
}
export interface IEvent {
title: string;
actions: Array<Action>;
}
Festival.ts
import {IEvent, Action} from './interfaces/event'
export default class Festival implements IEvent {
title: string = 'Adventure at the festival';
actions: Array<Action> = [
{
description: 'You arrived at the festival',
location: 'https://example.com/festival.jpg',
duration: 3000,
},
{
description: 'You see a stage in front of you',
location: '',
duration: 5000,
},
];
private *listActions(actions: Array<Action>): IterableIterator<Action> {
yield action;
}
start(): void {
for (const action of this.listActions(this.actions)) {
setTimeout(() => {
console.log(action.description);
action.next();
}, action.duration);
}
}
}
I am trying to move to the next action after a certain time but encountering an error:
The property 'next' is not present on the type 'Action'.
There is also an issue with the absence of `action` for some reason, and I'm unsure why.