我正在为第三方js库创建一个TypeScript定义文件。其中一个方法允许使用options对象,而options对象的一个属性接受列表中的字符串:"collapse", "expand", "end-expand"和"none"。
我有一个接口的选项对象:
interface IOptions {
indent_size?: number;
indent_char?: string;
brace_style?: // "collapse" | "expand" | "end-expand" | "none"
}
接口是否可以强制执行这一点,因此如果包含带有brace_style属性的IOptions对象,它将只允许可接受列表中的字符串?