Как указать ts брать имя свойства интерфейса из экземпляра класса, который нужно найти по ключу из значения другого свойства?
class A {aaa: number = 1;}
class B {bbb: number = 2;}
class C {ccc: number = 3;}
interface I {
qwerty: A;
abcde: B;
zzz: C;
}
interface Test<T extends keyof I, K = I[T]> {
test1: T;
[M: keyof K]: K[typeof M]; // typeof K[M] ???
}
function load<T extends keyof I>(test: Test<T>): void {}
load({
test1: 'abcde',
bbb: 50, // Argument of type '{ test1: "abcde"; bbb: number; }' is not assignable to parameter of type 'Test<"abcde", B>'. Object literal may only specify known properties, and 'bbb' does not exist in type 'Test<"abcde", B>'
});