const a = {age:18, name:"alex"}
type T = {
[K in keyof typeof a]: typeof a[K];
} & {
test: number;
};
// больше свободы
type TT<OB> = {
[K in keyof OB]: OB[K];
} & {
test: number;
};
const t1: T = {test: 1, age: 1, name: 1} // ошибка
const t2: T = {some: 1, name: "Fewfwefw" }; // ошибка
const t3: T = {age:19, name: "ivan", test: 1 }; // корректно
const tt1: TT<typeof a> = {test: 1, age: 1, name: 1} // ошибка
const tt2: TT<typeof a> = {some: 1, name: "Fewfwefw" }; // ошибка
const tt3: TT<typeof a> = {age:19, name: "ivan", test: 1 }; // корректно