У меня проблема со следующим кодом.Я думаю, что это проблема приведения, но я не могу понять, как ее решить.
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;
}
};
Вы можете скопировать код здесь, чтобы увидеть проблему. TypeScript Playground