Skip to content

v1.1.2

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 21 Jul 22:59
· 1 commit to main since this release
af408c6

Patch Changes

  • aec6f75 Thanks @lukemorales! - Improve inference of return types with new generic value

    The return type of exhaustive and exhaustive.tag will now be inferred based on the return type of the callback function.

    type Union = "IDLE" | "LOADING" | "SUCCESS" | "ERROR";
    
    type HumanReadableUnion = "idle" | "loading" | "success" | "error";
    
    function unionToHumanReadableString(union: Union): HumanReadableUnion {
      return exhaustive(union, {
        IDLE: () => "idle",
        LOADING: () => "loading",
        SUCCESS: () => "success",
        ERROR: (value) => value.toLowerCase(), // type `string` is not assignable to type `HumanReadableUnion`
      });
    }