spread types may only be created from code example
Example 1: spread types may only be created from
function foo<T extends object>(t: T): T {
return { ...(t as object) } as T;
}
Example 2: spread types may only be created from
function foo<T extends object>(t: T): T {
return {
...t // Error: [ts] Spread types may only be created from object types.
}
}