[英]typescript shot form notation of used Enum in interface
Is there any way to shorten this piece of code?有没有办法缩短这段代码? Basically I do not want to write Aa, Ab, etc. Some how I just want to write A and type script will understand it needs to be one of the enum values.
基本上我不想写 Aa、Ab 等。一些我只想写 A 和类型脚本的方式会明白它需要是枚举值之一。
Thanks谢谢
enum A {
a: 'one',
b: 'two',
c: 'three'
}
interface check {
type: A.a|A.b|A.c
}
enums should be used in below way枚举应按以下方式使用
enum A{
a:'one',
b:'two',
c:'three'
}
interface check{
type:A
}
in this way, check.type can have values 'one', 'two', 'three'这样, check.type 可以有值 'one', 'two', 'three'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.