sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

Add a TypeScript utility for type inference #220

Closed jorisre closed 3 years ago

jorisre commented 3 years ago

The idea is to have the ability to extract typings from a schema. For example:

import ow from 'ow';

const schema = ow.object.exact.shape({
  id: ow.number,
  name: ow.string
});

/**
  Which is an equivalent to:
  interface User {
    id: number;
    name: string;
  }
*/
type User = ow.infer<typeof schema>;

I can open a PR if that request is accepted ✌🏻

jorisre commented 3 years ago

Oops, duplicated. Just saw: https://github.com/sindresorhus/ow/issues/197