79585128

Date: 2025-04-21 18:41:03
Score: 0.5
Natty:
Report link

You don't show where updateSource is being called, but I'm going to take a guess and assume that this T extends "object" | "array" means you're passing in the string from typeof(myObject)? If that's the case, an array will just return object, not array. If you're only trying to distinguish between an actual object and an array, just pass in the boolean returned from Array.isArray. If you really want to stick with the strings, and just make sure that T fits the case that you have now, you can do Array.isArray(myObject) ? "array" : "object".

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Single line (0.5):
  • Low reputation (0.5):
Posted by: Andrew