0
votes
type SimpleObject = Record<string, any>
<T extends SimpleObject>(param: T = {}) => param
                         ^^^^^^^^^^^^^ 

TS2322: Type '{}' is not assignable to type 'T'.   '{}' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Record<string, any>'.

1

1 Answers

0
votes

TypeScript does not know the shape of T, it may or maynot match {}, so you need to explicitly tell that you know {} is T as mentioned below:

TS Playground link

type SimpleObject = Record<string, any>
<T extends SimpleObject>(param: T = {} as T) => param