如何在ISupportedTemplateType
中使用typescript枚举值作为templateTypeId
的类型。值是1、2、3,我希望它是templateTypeId
的类型
export enum ETemplateType {
'Cover Letter' = 1,
'Wire Instructions' = 2,
'Amendment' = 3,
}
export interface ISupportedTemplateType {
templateTypeId: number; // HOW CAN I USE ENUM HERE?
templateTypeName: keyof typeof ETemplateType;
}
你只是。。。使用它:
export interface ISupportedTemplateType {
templateTypeId: ETemplateType;
templateTypeName: keyof typeof ETemplateType;
}
然后这很好:
// works
const obj: ISupportedTemplateType = {
templateTypeId: ETemplateType['Cover Letter'],
templateTypeName: 'Cover Letter'
}
游乐场