打字稿中的复杂类型
我需要在我的接口中描述一个带有索引的字符串,在字符串的末尾也可以是工作或崩溃:
export interface Test {
date: string,
'stat.conv[index: number].key[index: number].(work || crash)': Test2[]
}
在Typescript中,这是否可以吗?
I need to describe in my interface a string with indexes also in the end of string can be work or crash:
export interface Test {
date: string,
'stat.conv[index: number].key[index: number].(work || crash)': Test2[]
}
Is this possible in typescript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 模板文字类型 来定义键:
You can use a template literal type to define the keys: