Reputation: 10360
I am querying a system API (Linux' DBus
API) that expects 3 string
s:
service
path
name
So I could write the signature of the TypeScript methods that calls the interface like so:
getInterface(service: string, path: string, name: string): DBusInterface;
But I know , service
, path
and name
each follow specific string patterns:
service
= /^org\.bluez/
path
= /(\/[a-zA-Z]*)+/
name
= /([a-zA-Z]+\.)+/
(Regex not 100% correct, but here for comprehensibility)
I am wondering if it is possible to type guard the 3 parameters to match these patterns, like
type ServiceName: /^org\.bluez/
Upvotes: 0
Views: 656
Reputation: 11770
Currently as of 11/2019 this is not possible, there is an open suggestion for this for a while now that you can keep track of here https://github.com/Microsoft/TypeScript/issues/6579
You can read the comments and maybe find something useful
Upvotes: 1