Fix type narrowing for non empty array assert

This commit is contained in:
Eugene 2023-07-14 15:39:33 +01:00
parent 6d4f32287f
commit 16d8e52e2b
2 changed files with 32 additions and 2 deletions

View file

@ -1477,6 +1477,36 @@ test('is.nonEmptyArray', t => {
function_(value);
}
}
{
const strings = ['🦄', 'unicorn'];
const function_ = (value: string) => value;
assert.nonEmptyArray(strings);
const value = strings[0];
function_(value);
}
{
const mixed = ['🦄', 'unicorn', 1, 2];
const function_ = (value: string | number) => value;
assert.nonEmptyArray(mixed);
const value = mixed[0];
function_(value);
}
{
const arrays = [['🦄'], ['unicorn']];
const function_ = (value: string[]) => value;
assert.nonEmptyArray(arrays);
const value = arrays[0];
function_(value);
}
});
test('is.emptyString', t => {