Type Helpers 9 exercises
Problem

Constraining Type Helpers to Non-Empty Arrays

This exercise starts with a NonEmptyArray that is currently unknown:


type `NonEmptyArray`= unknown;

Challenge

Your challenge is to update ``NonEmptyArray` so that it accepts an argument and turns it into an array with a length of at least one.

As seen in the tests, there shoul

Loading exercise

Transcript

0:00 In this exercise, we're going to be creating a type helper called NonEmptyArray. This NonEmptyArray is going to accept an argument here, a T probably. It's going to turn it into an array of at least one length.

0:14 We can see here that we're expecting an error if we pass in an empty array into this function, makeEnum. It's fine if you accept one or three or a hundred different numbers of that rank. That's your challenge. You'll need a little bit of knowledge about tuples as well. Good luck.