我正在查询一个系统API (Linux的DBus
API),它需要3个string
的:
service
path
name
因此,我可以编写调用接口的TypeScript方法的签名,如下所示:
getInterface(service: string, path: string, name: string): DBusInterface;
但我知道,service
、path
和name
都遵循特定的字符串模式:
service
= /^org\.bluez/
path
= /(\/[a-zA-Z]*)+/
name
= /([a-zA-Z]+\.)+/
(Regex不是100%正确,但这里是为了可理解性)
我想知道是否可以键入保护3个参数来匹配这些模式,如
type ServiceName: /^org\.bluez/
发布于 2019-11-05 08:46:05
目前,在11/2019中,这是不可能的,有一段时间对此有一个开放的建议,因为您可以跟踪这里的https://github.com/Microsoft/TypeScript/issues/6579
你可以阅读这些评论,也许能找到一些有用的东西。
https://stackoverflow.com/questions/58707055
复制相似问题