I can create a TypeScript interface like so which will help with static typing:
interface IFoo {
bar: string,
baz: boolean
}
but I am wondering if there is a way to convert this information to JS and use it to do runtime validation as well? Otherwise I'd likely have to keep track of this info in two different places which is no fun.
Anyone know if this is possible somehow?
What it might look like is
const ifoo = {
bar: 'String',
baz: 'Boolean'
}
and then I could use an object like that to do runtime validation.
via Alexander Mills
No comments:
Post a Comment