I'm facing an issue with the code snippet provided. I suspect it might be related to casting, but I'm unable to pinpoint the exact solution.
interface Code {
code: string;
expiration: number;
}
interface IActivationCode {
[userId: string]: Code;
}
const activationCode: IActivationCode = {
set userId(id: string) {
this[id] = {
code: Math.random()
.toString(36)
.substring(7),
expiration: new Date().setMinutes(new Date().getMinutes() + 30)
};
},
get userId() {
return this.id;
}
};
To analyze the problem further, you can try running the code in the TypeScript Playground.