This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
Releases: gcanti/tcomb
Releases · gcanti/tcomb
v3.0.0
v2.7.0
- New Feature
lib/fromJSON
module: generic deserialize, fix #169lib/fromJSON
TypeScript definition file
- Bug Fix
- t.update module: $apply doesn't play well with dates and regexps, fix #172
- t.update: cannot $merge and $remove at once, fix #170 (thanks @grahamlyus)
- TypeScript: fix Exported external package typings file '...' is not a module
- misleading error message in
Struct.extend
functions, fix #177 (thanks @Firfi)
v2.6.0
- New Feature
declare
API: recursive and mutually recursive types (thanks @utaal)- typescript definition file, fix #160 (thanks @DanielRosenwasser)
t.struct.extend
, fix #164 (thanks @dzdrazil)
- Internal
- split main file to separate modules, fix #158
- add "typings" field to package.json (TypeScript)
- add
predicate
field to irreducibles meta objects
- Documentation
v2.5.2
v2.5.1
v2.5.0
- New Feature
- check if the type returned by a union dispatch function is correct, fix #136 (thanks @fcracker79)
- added
refinement
alias tosubtype
(which is deprecated), fix #140
- Internal
- optimisations: for identity types return early in production, fix #135 (thanks @fcracker79)
- exposed
getDefaultName
on combinator constructors
v2.4.1
v2.4.0
v2.3.0
- New Feature
-
Add support for lazy messages in asserts, fix #124
-
Better error messages for assert failures, fix #120
The messages now have the following general form:
Invalid value <value> supplied to <context>
where context is a slash-separated string with the following properties:
- the first element is the name of the "root"
- the following elements have the form:
<field name>: <field type>
Note: for more readable messages remember to give types a name
Example:
var Person = t.struct({ name: t.String }, 'Person'); // <- remember to give types a name var User = t.struct({ email: t.String, profile: Person }, 'User'); var mynumber = t.Number('a'); // => Invalid value "a" supplied to Number var myuser = User({ email: 1 }); // => Invalid value 1 supplied to User/email: String myuser = User({ email: 'email', profile: { name: 2 } }); // => Invalid value 2 supplied to User/profile: Person/name: String
-
v2.2.1
-
Experimental
- pattern matching #121
// this example uses ES6 syntax const A = t.struct({...}); const result = t.match(1, t.String, (s) => 'a string', t.Number, (n) => n > 2, (n) => 'a number gt 2', // case with a guard (optional) t.Number, (n) => 'a number lte 2', A, (a) => 'an instance of A', t.Any, (x) => 'other...' // catch all ); console.log(result); // => 'a number lte 2'