Typical is an isomorphic, functional JavaScript library providing comprehensive type-checking utilities. Currently at version 7.3.0, it offers a stable and reliable API for validating values against common types. Key differentiators include its precise handling of numbers (distinguishing `NaN` from valid numbers, and providing checks for finite numbers), its ability to differentiate between plain object literals and other object instances, and its functional approach, making it ideal for use in array methods like `every` or `filter`. The library maintains a steady release cadence focused on stability and compatibility with modern JavaScript environments. It aims to be a foundational utility for robust data validation in both Node.js and browser contexts.
npm install typicalVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the default `t` object and using various type-checking functions like `isNumber`, `isFiniteNumber`, `isPlainObject`, `isObject`, `isDefined`, `isUndefined`, `isString`, and `isArrayLike` on different data types.
Upgrade Node.js to version 12.17.0 or higher. For bundlers, ensure proper configuration for ESM resolution.
Be aware of `isNumber`'s specific behavior regarding `NaN`. Use `t.isFiniteNumber(value)` for strictly finite numbers, or `(t.isNumber(value) || Number.isNaN(value))` if `NaN` should be considered a number for your specific use case.
Distinguish between `t.isPlainObject(value)` for pure object literals and `t.isObject(value)` for any non-null object type. Understand the specific definition of 'plain object' as implemented by the library.
Prefer `import t from 'typical'` for ESM projects. For CJS, try `const t = require('typical')`. If `t` appears empty or its methods are undefined, try `const t = require('typical').default` as a fallback or ensure your environment supports ESM/CJS interop.Correct the import to `import t from 'typical'` and access functions as `t.isNumber` or destructure like `const { isNumber } = t;`.Ensure `import t from 'typical'` (ESM) or `const t = require('typical')` (CJS) is at the top of your file and executed correctly. Check for typos in the import path or variable name.For CommonJS projects, either configure your bundler/environment to transpile ESM to CJS, or explicitly use dynamic `import('typical').then(m => m.default)` if it's ESM-only. The best fix is to migrate to ESM (`"type": "module"` in `package.json`) and use `import t from 'typical'`.No dependency data recorded yet.