Improve docs of isNonNullObject

This commit is contained in:
Simon Warta 2020-08-04 11:38:48 +02:00
parent f7745b47b2
commit 8bb2b1bb76
2 changed files with 12 additions and 2 deletions

View File

@ -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;

View File

@ -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;
/**