I'm struggling with a riddle related to Typescript:
const randomFn = (arg: Record<string, unknown>): string => 'kappa'
export type Values = {
key: string;
};
const values: Values = {
key: 'kappa'
}
const { ...spread } = values;
randomFn(values)
randomFn(spread) // produce Index signature for type 'string' is missing in type '{ transaction: string; }'.(2345)
Why does Typescript generate errors for the spread object when they should have the same typing in my opinion? When examining the object in the playground, it appears to be identical for the TS compiler. Both the original and the spreaded object.
Typescript version 4.5.4. Reproduction in Type Script Playground
EDIT: also doing double spread to make it work again .
randomFn({...spread}) // NO error