3 ms·
TypeScript's type system, with tagged unions, `never` type and type inference being used in an app with good Language Server support (e.g. VSCode) is probably t
by TheCoreh 5y ago
TypeScript's type system, with tagged unions, `never` type and type inference being used in an app with good Language Server support (e.g. VSCode) is probably the closest I've seen to this.
The biggest limitation still in place is that it can't reason very well about value ranges (e.g. numbers between 20 and 30) without you enumerating every single possibility (i.e. 20 | 21 | 22 | 23 | ... | 30) which isn't really feasible or desirable for larger ranges.
We're probably very close to this level of generality, though, with the recent string template types being a major step forward in expressiveness.
- setr 5y agoIf you can manually enumerate it, and typescript reasons about it correctly, then it seems to me it would be trivial for the compiler to generate the enumeration? It sounds like the job is already done, at least for slow but correct, they just didn’t finish up Except of course infinite ranges