我们的项目中有一个enum或一组consts,PR评论引发了关于构建它的最惯用方式的讨论:
export class ThingTypes {
public static readonly THING = "thing";
public static readonly OTHERTHING = "otherthing";
}
或
export namespace ThingTypes {
public static readonly THING = "thing";
public static readonly OTHERTHING = "otherthing";
}
或
export const ThingTypes {
THING: "thing",
OTHERTHING: "otherthing"
}
我们不在> = 2.4因此我们不能使用enum
(因为2.4之前,它们只能是字符串),但为了论证:enum
是最惯用的办法?拉:
export enum ThingTypes {
public static readonly THING = "thing";
public static readonly OTHERTHING = "otherthing";
}
互联网没有产生任何明确的答案。哪种是最常用的方式和传统方式在打字稿中制作一组条形码?