Skip to content
This repository was archived by the owner on Jul 12, 2026. It is now read-only.

futurematik/model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors