There is something to be said about pushing such things to runtime checks.
I'm not arguing for giving up type systems in general, but I'd rather read something like `class VersionString` that asserts the requirements in the constructor. If it really matters, you can check this at run time but before releasing using a test.
Like what exactly are you trying to get from autocomplete in a version string literal?
There are libraries that let you define refinement types[0] but it does require a bit of runtime overhead, and the added complexity depends on the library.
[0] https://zod.dev/?id=refine as an example
I wish, however, I could cleanly type “this must be an integer between 0 and 58” but typescript isn’t that expressive unless you do some pretty ridonkulous things. Especially with template strings it would be so cool to have something like:
type foo = `v${0:1}.{0:99}.{0:}`
(or whatever pre-existing format exists elsewhere. I just made that up)
This would be generalized as a “number range literal”, maybe. So not particular to template strings.
But not regex. Solving this with a regex literal type would be the poster child of “hyper typing”.