kitimat icon indicating copy to clipboard operation
kitimat copied to clipboard

Code generation from TS type aliases

Open garbles opened this issue 7 years ago • 0 comments

TS exposes custom transformers through the public API, so it should be possible to create generates purely from a type alias. I've done something like before with babel as Flow.

import { fromType } from 'kitimat-type-to-gen';

const person = fromType<Person>();

// would expand to something like...

const kitimat = require('kitimat-jest');
const person = kitimat.object<Person>({
  name: kitimat.string(),
  age: kitimat.posInt(),
  // ... etc
});

garbles avatar Mar 20 '18 04:03 garbles