4 ms·
To me it feels like less of a hack if I can make the type declaration not a lie. e.g. type FooID = string & { typeName? : "FooID" } Read as 'of course thi
by TOGoS 2y ago
To me it feels like less of a hack if I can make the type declaration not a lie. e.g.
type FooID = string & { typeName? : "FooID" }
Read as 'of course this thing doesn't have a typeName[1] property, since it's a string, but if it did have the property, the value would be "FooID"'. You can then cast between FooID and string, but not between FooID and some other type that declares a typeName property.
[1] I actually tend to use 'classRef' with an RDFish long name for the type, but that makes examples longer and isn't the point.
- Waterluvian 2y agoThat’s a really helpful way of framing it. I’m tempted to try this with our uuid type and see how well it works. I think I’ll also try to base it on a template string too if that’s possible. Given we use a standard dash segmented uuid string.