Skip to content

Implement type predicate #27

@PumpedSardines

Description

@PumpedSardines

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 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions