For example, given an object:
const TypeDef1 = {
foo: {optional: true, type: 'string'},
bar: {type: 'number'}
}
which conforms to type, say
type TypeDef = {
[key: string]: {
optional?: boolean,
type: 'number' | 'string' | 'boolean'
}
}
I want to have some reusable typing Transform<T extends TypeDef> such that
Transform<typeof TypeDef1>
gives:
{
foo?: string
bar: number
}
Is this at all possible in Typescript?