buildo / metarpheus-io-ts

Generate domain models and client interpreting metarpheus output
MIT License
7 stars 1 forks source link

Add support for union types #79

Closed ecamellini closed 5 years ago

ecamellini commented 5 years ago

After https://github.com/buildo/metarpheus/issues/73 is merged, we should add support for union types also in the TS generation.

The example shown in https://github.com/buildo/metarpheus/issues/73 should result in the following:

export interface First {
  arg: string;
}

export const First = t.interface(
  {
    arg: t.string
  },
  'First'
);

export interface Second {
  arg: string;
  anotherArg: string;
}

export const Second = t.interface(
  {
    arg: t.string
    anotherArg: t.string
  },
  'Second'
);

export type UnionExample =
  | First
  | Second