Skip to content

v0.8.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 29 Apr 20:48
9292d80
  • Require @bare-ts/lib v0.3.x

  • Automatically promote root type aliases as main type aliases

    @bare-ts/tool generates encoders and decoders for main type aliases.
    Main type aliases can be selected with the option --main:

    bare-ts compile schema.bare --main Post
    
    # schema.bare
    type Person struct { name: str }
    type Post struct { author: Person }
    

    If the option --main is not set, then @bare-ts/tool promotes now
    root type aliases as main type aliases. Root type aliases are type aliases
    that are not referred by a type in the schema.

    In the previous schema, Post is a root type alias, while Person is not.
    The following command has now the same effect as the previous one:

    bare-ts compile schema.bare
    

    It promotes Post as a main type aliases.

    To avoid the promotion of root types, you must use the option --no-main:

    bare-ts compile schema.bare --no-main
    

    --no-main and --main cannot be both set.

  • BREAKING CHANGES: forbid f32 and f64 as map key type

    According to IEEE-754 2019:
    NaN (Not a Number) is not equal to any value, including itself.

    This inequality leads to different implementations:

    1. Implementations that "follows" the standard

      In this case, an unbounded number of values may be bind to the key NaN
      and cannot be accessed.

      This is the implementation chosen by Golang.

    2. Implementations that normalize NaNs and consider that NaN
      is equal to itself

      This is the implementation chosen by JavaScript

    3. Implementations that rely on the binary comparison of NaNs

    This makes complex the support of f32 and f64 as map key type.

    To avoid this complexity the ongoing BARE draft forbids their usage as
    map key type.

  • Allow leading and trailing pipes in unions

    The following schema is now valid:

    type LeadingPipe union {
        | u8
    }
    
    type TrailingPipe union {
        u8 |
    }
    
  • Do not emit trailing spaces in code generation