I want to use my enum to make an interface.
Just because one should change and the other one also needs to be changed. I want to change the code more closely.
The enum's key is the same Interface's Key.
export enum SmsReplaceKeyEnum {
STAY_DATE = "%STAYDATE%",
STAY_DATE_YMD = "$STAYDATEYMD%",
ROOMTYPE_N_COUNT = "%ROOMTYPENCOUNT%",
BOOKERNAME = "%BOOKER%",
TOTAL_PRICE = "%TOTALPRICE%"
}
interface IPareser {
STAY_DATE: string;
STAY_DATE_YMD: string;
ROOMTYPE_N_COUNT: string;
BOOKERNAME: string;
TOTAL_PRICE: string;
}
I also have this one
export const SmsReplaceKeyEnumKeys = [
"STAY_DATE",
"STAY_DATE_YMD",
"ROOMTYPE_N_COUNT",
"BOOKERNAME",
"TOTAL_PRICE"
];
I tried
interface IPareser {
[key in SmsReplaceKeyEnumKeys]: string;
}
interface IPareser {
[key keyof SmsReplaceKeyEnumKeys]: string;
}
The final goal is to create an object's type with all the keys in the list.