Fix type guard for isWhitespaceString and isEmptyStringOrWhitespace (#207)
This commit is contained in:
parent
8cbcaee674
commit
25a376875d
3 changed files with 14 additions and 4 deletions
|
|
@ -1793,6 +1793,13 @@ test('is.emptyStringOrWhitespace', t => {
|
|||
t.throws(() => {
|
||||
assert.emptyStringOrWhitespace('unicorn');
|
||||
});
|
||||
|
||||
let value = 'test'; // eslint-disable-line prefer-const -- can't use `const` here because then it will be inferred as `never` in the `if` block
|
||||
if (is.emptyStringOrWhitespace(value)) {
|
||||
value.charAt(0); // Should be inferred as `'' | Whitespace` and not `never`
|
||||
} else {
|
||||
value.charAt(0); // Should be inferred as `string` and not `never`
|
||||
}
|
||||
});
|
||||
|
||||
test('is.nonEmptyString', t => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue