const numbers = [1, 2] as const;
const words = ['three', 'four'] as const;
const combined = Arr.concat(numbers, words);
// Because at least one input is non-empty, the result is assignable to
// NonEmptyArray.
const nonEmpty: NonEmptyArray<number | string> = combined;
const expectedCombined = [1, 2, 'three', 'four'] as const;
assert.deepStrictEqual<readonly (number | string)[]>(
combined,
expectedCombined,
);
assert.isTrue(nonEmpty.length >= 1);
Concatenates two arrays.
The exact tuple shape is preserved. Additionally, when either input is known to be non-empty (a non-empty tuple or a branded
NonEmptyArray), the result is branded as non-empty so it is assignable toNonEmptyArray.