Dynamic interface based on values of an object (Typescript)

0

I'm trying to accomplish the following:

interface A {
    name: string,
    type: string
}

let var_A: Array<A> = [
    {name: 'firstName', type: 'string'},
    {name: 'lastName',  type: 'string'},
    {name: 'age',       type: 'number'}
]

interface B {
    firstName: string,
    lastname: string,
    age: number
}

let var_B: Array<B> = [
    {firstName: 'José', lastname: 'Silva', age: 25},
    {firstName: 'Pedro', lastname: 'Paulo', age: 50},
]

My big problem is: how can I create the B interface dynamically, based on the var_A object? Is it possible?

    
asked by anonymous 12.06.2018 / 06:24

0 answers