我正在为第三方js库创建一个TypeScript定义文件.一项所述的方法允许对选择对象,并且选项对象的属性中的一个接收来自列表的字符串:"collapse","expand","end-expand",和"none".
我有一个options对象的接口:
interface IOptions {
indent_size?: number;
indent_char?: string;
brace_style?: // "collapse" | "expand" | "end-expand" | "none"
}
Run Code Online (Sandbox Code Playgroud)
接口是否可以强制执行此操作,因此如果您包含IOptions具有该brace_style属性的对象,它将只允许可接受列表中的字符串?
typescript ×1