I think what might have caused the confusion here is the type object - in TS it's not what you think it is.
The object type refers to anything that is not a number, string, boolean, symbol, null, or undefined (the primitive types). It's actually very similar to any - just a tiny little bit narrower. I rarely find it useful and basically treat it the same way as any (which means - avoid at all costs).
I guess it can be used if you just want an object and don't really care what fields it has (or does it have any fields at all - that's why there are no index signatures on it). In this case since we do care about the parameters having strings as keys, object is not a good fit here.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think what might have caused the confusion here is the type
object
- in TS it's not what you think it is.The
object
type refers to anything that is not anumber
,string
,boolean
,symbol
,null
, orundefined
(the primitive types). It's actually very similar toany
- just a tiny little bit narrower. I rarely find it useful and basically treat it the same way asany
(which means - avoid at all costs).I guess it can be used if you just want an object and don't really care what fields it has (or does it have any fields at all - that's why there are no index signatures on it). In this case since we do care about the parameters having strings as keys,
object
is not a good fit here.