Skip to content

v3.1.0

Compare
Choose a tag to compare
@lukeed lukeed released this 14 Aug 07:41
· 9 commits to main since this release

Features

  • Add unknown export: b9ac7b8

    // NOTE: Allows any value!
    // ---
    let x = t.unknown();
    //-> { }
    type X = t.Infer<typeof x>;
    //-> unknown
  • Add partial modifier: 56041e6
    Accepts a t.object and marks all its fields as optional (not required).

    let person1 = t.object({
      name: t.string(),
      age: t.number(),
    });
    type Person1 = t.Infer<typeof person1>;
    //-> {
    //->   name: string;
    //->   age: number;
    //-> }
    
    // NOTE: The input (`person1`) is not modified
    let person2 = t.partial(person1);
    type Person2 = t.Infer<typeof person2>;
    //-> {
    //->   name?: string;
    //->   age?: number;
    //-> }
    
    // NOTE: equivalent to person2
    let person3 = t.object(
      name: t.optional(t.string()),
      age: t.optional(t.number()),
    });
    type Person3 = t.Infer<typeof person3>;
    //-> {
    //->   name?: string;
    //->   age?: number;
    //-> }

Patches

  • (types): Add default object type arg: ac25ad7
    This means that you can now import/extend the t.object type directly.

Chores

  • Update module size: 22ee312
    NOTE: Everything is still tree-shakable!
    In other words, if you don't use the new methods, you don't import those bytes.

Full Changelog: v3.0.0...v3.1.0