'How to write a typescript type to build an object from an array of classes

The result I want should be clear from the following code This is the closest code I can write

type GetField<T extends Component> = Lowercase<T['name']>;
type ConstructorType<T> = new (...args: any[]) => T;
type QueryType<T extends Component[]> = {
    [P in GetField<T[number]>]: T[number]
}
interface Component {
    new(...args: any[]): Component;
    name: string;
}

class Foo {
   age:number
}
class Bar {
   address
}

type MyObj = QueryType<[Foo,Bar]>

let obj:MyObj; //Expect obj.foo.age obj.bar.address



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source