Skip to content

v2.1.0

Compare
Choose a tag to compare
@joanllenas joanllenas released this 23 Oct 21:43
· 8 commits to master since this release

Feature

  • Added FromDecoder<D> to infer types from decoder declarations. (docs)

Without FromDecoder

type User = {
  firstname: string;
  lastname: string;
};

const userDecoder = JsonDecoder.object<User>(
  {
    firstname: JsonDecoder.string,
    lastname: JsonDecoder.string
  },
  'User'
);

With FromDecoder

const userDecoder = JsonDecoder.object(
  {
    firstname: JsonDecoder.string,
    lastname: JsonDecoder.string
  },
  'User'
);
type User = FromDecoder<typeof userDecoder>;