1.0.3 • Published 6 years ago

@fmtk/model v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Model

It is often useful to have a list of keys for an interface in Typescript. It would be awesome if you could do this:

interface Thing {
  id: number;
  name: string;
}

const thingKeys = keyof Thing;

But you can't do that. Until then, you can do this:

import { keyof, model, UnwrapDefinition } from '@fmtk/model';

const thingDef = model({
  id: type<number>(),
  name: type<string>(),
});

type Thing = UnwrapDefinition<typeof thingDef>;

const thingKeys = keyof(thingDef);

It's a bit clanky but it cuts down on typing a little, which improves development speed and maintainability.

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago