v0.4.0
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
, andInt
utility markers now combine with thenumber
type by default, so doingnumber & Min<3>
for example is excessive.Matches
utility marker now combines with thestring
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)