{"id":11105,"library":"is-what","title":"JavaScript Type Checking Utilities","description":"`is-what` is a lightweight, fully TypeScript-supported utility library providing a comprehensive set of functions for JavaScript type checking, such as `isPlainObject()`, `isArray()`, `isString()`, and many more specific checks. Currently at version `5.5.0`, the library maintains a steady release cadence, frequently adding new type-checking utilities and dependency updates. Its core differentiators include a focus on simplicity, a small footprint, robust TypeScript type inference (automatically narrowing types after checks), and a more intuitive handling of edge cases like `NaN` compared to native JavaScript functions. It explicitly distinguishes between plain objects (`{}`) and class instances, addressing a common pain point in JavaScript development. The library aims to be a straightforward and reliable alternative to more complex or less type-safe existing solutions. Its `v5.x` releases moved to ESM-only and refined its TypeScript integration.","status":"active","version":"5.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/mesqueeb/is-what","tags":["javascript","typescript","typechecker","check-type","javascript-type","primitive-types","plain-object","plain-objects"],"install":[{"cmd":"npm install is-what","lang":"bash","label":"npm"},{"cmd":"yarn add is-what","lang":"bash","label":"yarn"},{"cmd":"pnpm add is-what","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library is ESM-only since v5.0.0. Use `import` statements.","wrong":"const { isPlainObject } = require('is-what')","symbol":"isPlainObject","correct":"import { isPlainObject } from 'is-what'"},{"note":"All functions are named exports; there is no default export.","wrong":"import isString from 'is-what'","symbol":"isString","correct":"import { isString } from 'is-what'"},{"note":"Use `isNaNValue` for explicit NaN checks, as `isNumber(NaN)` returns `false` in this library.","symbol":"isNaNValue","correct":"import { isNaNValue } from 'is-what'"}],"quickstart":{"code":"import { isString, isNumber, isPlainObject, isArray, isDate, isNaNValue, isHexDecimal } from 'is-what';\n\nconsole.log('Is \"hello\" a string?', isString('hello')); // true\nconsole.log('Is 123 a number?', isNumber(123)); // true\nconsole.log('Is NaN a number (is-what)?', isNumber(NaN)); // false, by design\nconsole.log('Is NaN truly NaN?', isNaNValue(NaN)); // true\nconsole.log('Is {} a plain object?', isPlainObject({})); // true\nconsole.log('Is new Date() a plain object?', isPlainObject(new Date())); // false\nconsole.log('Is [] an array?', isArray([])); // true\nconsole.log('Is new Date() a Date object?', isDate(new Date())); // true\nconsole.log('Is an invalid date a Date object?', isDate(new Date('invalid date'))); // false\nconsole.log('Is \"60adf084f0fbdcab42de841e\" a hex decimal of length 24?', isHexDecimal('60adf084f0fbdcab42de841e', 24)); // true","lang":"typescript","description":"Demonstrates basic type checking with `is-what`, including special handling for `NaN` and `isPlainObject`."},"warnings":[{"fix":"Migrate your project to use ES modules (`import`) or use a tool like `esm` if you cannot fully migrate.","message":"`is-what` became an ESM-only package in version 5.0.0. CommonJS `require()` statements will no longer work.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Adjust your TypeScript code to explicitly narrow types or handle `unknown` correctly after `is-what` checks.","message":"In `v5.0.0`, type definitions were updated to use `unknown` instead of `any` for better type safety. This might cause TypeScript errors if your code relied on `any` for inferred types.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"When checking for numbers, be aware that `isNumber(NaN)` will be `false`. If you specifically need to check if a value is `NaN`, use the dedicated `isNaNValue()` function.","message":"The `isNumber()` function in `is-what` explicitly returns `false` for `NaN`, differing from JavaScript's native `typeof NaN === 'number'` or `Number.isNaN()` behavior. Use `isNaNValue()` for specific `NaN` checks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to `is-what@5.1.0` or newer to incorporate the security patch: `npm install is-what@latest`.","message":"Version `5.1.0` included a fix for a security issue identified via `npm audit`. Users on older `v5.x` versions should upgrade.","severity":"security","affected_versions":"<5.1.0"},{"fix":"To check for a specific length, pass the desired length as the second argument: `isHexDecimal('idstring', 24)`.","message":"The `isHexDecimal` function, introduced in `v5.2.0`, accepts an optional second argument for checking a specific string length, useful for IDs like MongoDB ObjectIds. Omitting it will only check for valid hexadecimal characters.","severity":"gotcha","affected_versions":">=5.2.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `const { someFn } = require('is-what')` to `import { someFn } from 'is-what'`.","cause":"Attempting to use `require()` with `is-what` v5 and later, which is an ESM-only package.","error":"TypeError [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/is-what/dist/index.js from ... not supported."},{"fix":"Explicitly narrow the type using a type assertion `(myVar as MyType).xyz` or perform further checks that TypeScript can use for inference.","cause":"After checking a variable with `is-what`, TypeScript still infers it as `unknown` due to the v5 update, preventing direct property access.","error":"Property 'xyz' does not exist on type 'unknown'."},{"fix":"If you need to check specifically if a value is `NaN`, use `isNaNValue(value)` instead.","cause":"`isNumber(NaN)` intentionally returns `false` in `is-what`.","error":"console.log(isNumber(NaN)); // Expected true, got false"}],"ecosystem":"npm"}