ForbesLindesay / funtypes

Runtime validation for static types
MIT License
29 stars 4 forks source link

Tuple / Array concat #15

Open ForbesLindesay opened 4 years ago

ForbesLindesay commented 4 years ago

https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#variadic-tuple-types means it should now be possible to build a type safe concat method that supports mixing Tuple types and Array types. This primitive would also allow proper typed support for things like "non-empty Array" via:

Tuple(Value).concat(Array(Value))
// => Runtype<[Value, ...Value[]]>

Requested in: https://github.com/pelotom/runtypes/issues/147