Repository navigation
v0.4.0
Additions
-
A
createMatchutility 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"; } };
-
Equtility marker which compares a value to an expression, skipping validation of the value type.
Changes
Min,Max,Float, andIntutility markers now combine with thenumbertype by default, so doingnumber & Min<3>for example is excessive.Matchesutility marker now combines with thestringtype by default.
Bug fixes
- Unions that include the
booleantype no longer generate excessive code. - Random comments no longer get added to output (#26)