Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Releases: gcanti/tcomb

v3.0.0

07 Mar 10:44
Compare
Choose a tag to compare

Warning. If you don't rely in your codebase on the property maybe(MyType)(undefined) === null this is not a breaking change for you.

  • Breaking Change
    • prevent Maybe constructor from altering the value when Nil, fix #183 (thanks @gabro)

v2.7.0

08 Feb 08:49
Compare
Choose a tag to compare
  • New Feature
    • lib/fromJSON module: generic deserialize, fix #169
    • lib/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

17 Jan 10:27
Compare
Choose a tag to compare

v2.5.2

02 Nov 13:10
Compare
Choose a tag to compare
  • Bug Fix
    • remove the assert checking if the type returned by a union dispatch function is correct (was causing issues with unions of unions or unions of intersections)

v2.5.1

06 Oct 07:19
Compare
Choose a tag to compare
  • Internal
    • t.update should not change the reference when no changes occur, fix #153

v2.5.0

22 Sep 08:04
Compare
Choose a tag to compare
  • New Feature
    • check if the type returned by a union dispatch function is correct, fix #136 (thanks @fcracker79)
    • added refinement alias to subtype (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

15 Sep 15:19
Compare
Choose a tag to compare
  • New Feature
    • added struct multiple inheritance, fix #143

v2.4.0

04 Sep 07:50
Compare
Choose a tag to compare
  • New Feature
    • unions
      • added update function, #127
      • the default dispatch implementation now handles unions of unions, #126
      • show the offended union type in error messages

v2.3.0

25 Aug 14:05
Compare
Choose a tag to compare
  • 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

23 Aug 07:39
Compare
Choose a tag to compare
  • 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'