Consider the following code...
I would expect the spread operator to be valid code, but it ends up not being so. I'm hoping somebody with expertise in Typescript can advise on why this is...
export default function convertToGlobalFragment<
T extends basicFragmentRecipe_T
>(
fragmentFactory: (recipe: T) => configFragment_I,
recipe: T & { matchingRules: globalMatchingRules_T }
): globalConfigFragment_I {
let {
matchingRules,
...restOfRecipe
}: { matchingRules: globalMatchingRules_T, restOfRecipe: T } = recipe;
}
The error code
Property 'restOfRecipe' is missing in type 'basicFragmentRecipe_T & { matchingRules: globalMatchingRules_T; }' but required in type '{ matchingRules: globalMatchingRules_T; restOfRecipe: T; }'.ts(2741)
