Comment by Waterluvian

1 day ago

I’ve been absolutely loving template types and dot notation pathing. I have an entire compile time (and therefore autocompletable) argument for major.minor.patch.theme.schemaname for all schemas in the program manage. I don’t consider these “hyper typing” because they’re very, very easy to reason about when used in the right context like dot notation paths.

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”.

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?