I am seeking to convert the data type of each member in an object based on the specific member variable.
Here is an example:
class A {
fct = (): string => 'blabla';
}
class B {
fct = (): number => 1;
}
class C {
fct = (): { obj: string } => ({
obj: 'la'
});
}
export const Contracts = {
a: A,
b: B,
c: C
};
type myContracts = typeof Contracts;
type MySuperType<T> = {
[P in keyof T]: string;
};
type a = MySuperType<myContracts>;
The snippet provided yields:
type a = {
a: string;
b: string;
c: string;
}
Desired output:
type a = {
a: string;
b: number;
c: { obj: string };
}