diff --git a/packages/utils/src/typechecks.ts b/packages/utils/src/typechecks.ts index 664fcc53..40faa05d 100644 --- a/packages/utils/src/typechecks.ts +++ b/packages/utils/src/typechecks.ts @@ -1,5 +1,10 @@ /** - * Checks if data is a non-null object (i.e. matches the TypeScript object type) + * Checks if data is a non-null object (i.e. matches the TypeScript object type). + * + * Note: this returns true for arrays, which are objects in JavaScript + * even though array and object are different types in JSON. + * + * @see https://www.typescriptlang.org/docs/handbook/basic-types.html#object */ export function isNonNullObject(data: unknown): data is object { return typeof data === "object" && data !== null; diff --git a/packages/utils/types/typechecks.d.ts b/packages/utils/types/typechecks.d.ts index 3e911797..68c29628 100644 --- a/packages/utils/types/typechecks.d.ts +++ b/packages/utils/types/typechecks.d.ts @@ -1,5 +1,10 @@ /** - * Checks if data is a non-null object (i.e. matches the TypeScript object type) + * Checks if data is a non-null object (i.e. matches the TypeScript object type). + * + * Note: this returns true for arrays, which are objects in JavaScript + * even though array and object are different types in JSON. + * + * @see https://www.typescriptlang.org/docs/handbook/basic-types.html#object */ export declare function isNonNullObject(data: unknown): data is object; /**