Skip to content

Add types for objectorarray#74472

Open
gasp wants to merge 1 commit intoDefinitelyTyped:masterfrom
gasp:add-objectorarray-types
Open

Add types for objectorarray#74472
gasp wants to merge 1 commit intoDefinitelyTyped:masterfrom
gasp:add-objectorarray-types

Conversation

@gasp
Copy link
Contributor

@gasp gasp commented Feb 4, 2026

Summary

Adds TypeScript type definitions for objectorarray, which checks if a value is an object or array (but not null or RegExp).

API:

declare function objectorarray(val: unknown): val is object;

Usage:

var isObjectOrArray = require('objectorarray');

isObjectOrArray({}); // true
isObjectOrArray([]); // true
isObjectOrArray(null); // false
isObjectOrArray(/regex/); // false

Package stats:

  • ~4.5M weekly downloads
  • ISC licensed

Test plan

  • pnpm test objectorarray passes

Adds TypeScript type definitions for objectorarray, which checks if
a value is an object or array.
@typescript-bot
Copy link
Contributor

typescript-bot commented Feb 4, 2026

@gasp Thank you for submitting this PR!

This is a live comment that I will keep updated.

1 package in this PR

Code Reviews

This PR adds a new definition, so it needs to be reviewed by a DT maintainer before it can be merged.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • 🕐 Only a DT maintainer can approve changes when there are new packages added

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 74472,
  "author": "gasp",
  "headCommitOid": "adb5a34151303983c44d6c76a977e1ae73c278eb",
  "mergeBaseOid": "982edf5d9655b7eca3825d113f90ebdbed4aaa39",
  "lastPushDate": "2026-02-04T16:46:34.000Z",
  "lastActivityDate": "2026-02-04T23:33:36.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Well-liked by everyone",
  "pkgInfo": [
    {
      "name": "objectorarray",
      "kind": "add",
      "files": [
        {
          "path": "types/objectorarray/.npmignore",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/objectorarray/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/objectorarray/objectorarray-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/objectorarray/package.json",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/objectorarray/tsconfig.json",
          "kind": "package-meta-ok"
        }
      ],
      "owners": [],
      "addedOwners": [
        "gasp"
      ],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    }
  ],
  "reviews": [
    {
      "type": "changereq",
      "reviewer": "sheetalkamat",
      "date": "2026-02-04T23:33:36.000Z"
    }
  ],
  "mainBotCommentID": 3848548193,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added the New Definition This PR creates a new definition package. label Feb 4, 2026
@typescript-bot typescript-bot moved this to Waiting for Code Reviews in Pull Request Status Board Feb 4, 2026
@typescript-bot
Copy link
Contributor

🔔 @gasp — you're the only owner, but it would still be good if you find someone to review this PR in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in Pull Request Status Board Feb 4, 2026
* isObjectOrArray(123); // false
* ```
*/
declare function objectorarray(val: unknown): val is object;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect because it doesnt guarantee that val is object but rather object or array

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Feb 4, 2026
@typescript-bot
Copy link
Contributor

@gasp One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you!

@typescript-bot typescript-bot moved this from Needs Maintainer Action to Needs Author Action in Pull Request Status Board Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Definition This PR creates a new definition package. Revision needed This PR needs code changes before it can be merged.

Projects

Status: Needs Author Action

Development

Successfully merging this pull request may close these issues.

3 participants