isobject
isobject copied to clipboard
Type predicate for easier type checking
PR to address my complaint in issue #27. Instead of the return type being true or false, the function should return if the value is a object or not.
The point of this function is to return true or false if the value passed in is an object, and it does. I don't understand your issue.
@windusayles Take this following example if "isObject" returns a bool
const myVariable: unknown = ({ foo: "bar" }) as any;
if(isObject(myVariable)) {
// TypeScript still sees myVariable as unknown in this scope
}
And this is an example if isObject returns val is { [key: string]: unknown }
const myVariable: unknown = ({ foo: "bar" }) as any;
if(isObject(myVariable)) {
// TypeScript now sees myVariable as { [key: string]: unknown }
}