Skip to content

v1.1.0

Compare
Choose a tag to compare
@github-actions github-actions released this 12 Feb 05:47
· 14 commits to main since this release
f9e9331

Minor Changes

  • #6 abc000e Thanks @lukemorales! - Add support for booleans

    Both exhaustive and exhaustive.tag can now be exhaustive checked against booleans:

    function handleStatus(isSelected: boolean) {
      return exhaustive(isSelected, {
        true: () => {
          // ...run handler for true case
        },
        false: () => {
          // ...run handler for false case
        },
      });
    }
    type ProfileStatus =
      | { checked: true; data: string }
      | { checked: false; error: string };
    
    function handleProfileStatus(status: ProfileStatus) {
      return exhaustive.tag(status, "checked", {
        true: (value) => saveProfile(value.data),
        //       ^? value is { checked: true; data: string }
        false: (value) => throwException(value.error),
        //        ^? value is { checked: false; error: string }
      });
    }