Which alternative for type "object" could be in TypeScript?

Rather than isNonNullObject, it should be sufficient to simply check:

// the `ban-types` rule should allow `Object` here because it's
// the value `Object`, not the type `Object`. Note the capital "O".
if (!(responseData instanceof Object)) {
  throw new Error(...);
}

// `responseData`'s type is now narrowed to `Object`, so you can now call `hasOwnProperty`
if (!responseData.hasOwnProperty("products")) {
 throw new Error(...);
}

...

This article also might serve as a nice refresher: https://mariusschulz.com/blog/the-object-type-in-typescript

Tags:

Typescript