Skip to content

v0.4.0

Compare
Choose a tag to compare
@GoogleFeud GoogleFeud released this 14 Aug 15:16
· 77 commits to dev since this release

Additions

  • A createMatch utility function that creates pattern-matching functions.

    // We want the match function to return a string and to accept a number
    const resolver = createMatch<string, number>([
        // Match arm which catches the values 0 or 1
        (_: 0 | 1) => "not many",
        // Match arm which catches any number less than 9
        (_: Max<9>) => "a few",
        // Match arm which catches any number that hasn't already been caught
        (_: number) => "lots"
    ]);
    
    // Transpiles to:
    const resolver = value_1 => {
        if (typeof value_1 === "number") {
            if (value_1 === 1 || value_1 === 0) return "not many";
            else if (value_1 < 9) return "a few";
            else return "lots";
        }
    };
  • Eq utility marker which compares a value to an expression, skipping validation of the value type.

Changes

  • Min, Max, Float, and Int utility markers now combine with the number type by default, so doing number & Min<3> for example is excessive.
  • Matches utility marker now combines with the string type by default.

Bug fixes

  • Unions that include the boolean type no longer generate excessive code.
  • Random comments no longer get added to output (#26)