Skip to content

isEmpty typeguard strips types from empty arrays #114

@onebytegone

Description

@onebytegone

Sample test:

it('keeps type information when checking for empty array', () => {
   const arr: string[] = [];

   if (isEmpty(arr)) {
      // Argument of type '"test"' is not assignable to parameter of type 'never'.ts(2345)
      arr.push('test');
   }

   expect(arr.length).to.strictlyEqual(1);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions