Error AtlasError Documentation and Resolution

Spread types may only be created from object types

Spread types may only be created from object types.

TypeScript rejected an object spread because one of the spread operands is not known to be an object type.

TS2698build
Spread types may only be created from object types.
  • A spread expression includes null, undefined, or a primitive value.
  • A union type includes non-object members that have not been narrowed out.
  • A helper returns a value whose type is too broad for safe object spreading.
  1. Only spread values that are known object types.
  2. Narrow union values before spreading them into a new object.
  3. Provide a safe fallback object when the source may be missing.
TypeScript Handbook: Object Types
TS2698 Spread types may only be created from object types: causes and fixes | Error Atlas