Answers for "spread types may only be created from"

0

spread types may only be created from

function foo<T extends object>(t: T): T {
  return { ...(t as object) } as T;
}
Posted by: Guest on July-12-2020
0

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.
  }
}
Posted by: Guest on July-12-2020

Code answers related to "spread types may only be created from"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language