isobject icon indicating copy to clipboard operation
isobject copied to clipboard

Implement type predicate

Open PumpedSardines opened this issue 4 years ago • 0 comments

Summary

Currently isObject returns the type boolean, but i think it would improve the package if it returned val is { [key: string]: unknown }.

Current behaviour

const test: { example: "hello" } | string[] = ...;

if(isObject(test)) {
  test.example = "world" // Error since test could be a string array
}

Improved behaviour

const test: { example: "hello" } | string[] = ...;

if(isObject(test)) {
  test.example = "world" // No error 
}

PumpedSardines avatar Oct 15 '21 12:10 PumpedSardines