{"id":12265,"library":"typpy","title":"Typpy: Enhanced Type Checking","description":"Typpy is a lightweight JavaScript utility that provides a more robust and accurate approach to determining variable types compared to the native `typeof` operator. It addresses common ambiguities of `typeof`, such as `null` evaluating to \"object\" and distinguishing between different object types like arrays and plain objects. The library allows for type comparison against both string representations (e.g., \"array\") and constructor functions (e.g., `Array`). Currently at version 2.4.0, its release cadence is moderate, primarily consisting of minor updates for documentation, sponsor links, and small bug fixes like handling null/undefined constructors. It differentiates itself by offering a consolidated API for precise type checks, simplifying conditional logic and reducing potential type-related bugs in applications.","status":"active","version":"2.4.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/IonicaBizau/typpy","tags":["javascript","typeof","typpy"],"install":[{"cmd":"npm install typpy","lang":"bash","label":"npm"},{"cmd":"yarn add typpy","lang":"bash","label":"yarn"},{"cmd":"pnpm add typpy","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For ESM, use default import. The package's primary export is a callable function that also carries `is` and `get` methods as properties. CommonJS `require` is still widely used in older Node.js projects, but `import` is preferred for modern JavaScript.","wrong":"const Typpy = require('typpy');","symbol":"Typpy","correct":"import Typpy from 'typpy';"},{"note":"The `is` method is a property of the default `Typpy` export, not a standalone named export. It's accessed directly via the imported `Typpy` object/function.","wrong":"import { is } from 'typpy';","symbol":"Typpy.is","correct":"import Typpy from 'typpy'; Typpy.is(value, type);"},{"note":"Similar to `Typpy.is`, the `get` method is a property of the default `Typpy` export, not a named export. Access it via `Typpy.get` after importing the default.","wrong":"import { get } from 'typpy';","symbol":"Typpy.get","correct":"import Typpy from 'typpy'; Typpy.get(value);"}],"quickstart":{"code":"import Typpy from 'typpy';\n\nconsole.log(Typpy(0));\n// => \"number\"\n\nconsole.log(Typpy('', String));\n// => true\n\nconsole.log(Typpy.is(null, 'null'));\n// => true\n\nconsole.log(Typpy.get([]));\n// => Array\n\nconsole.log(Typpy({}, true));\n// => false\n\nconsole.log(Typpy({}, Object));\n// => true\n\nconsole.log(Typpy.get({}));\n// => Object\n\nconsole.log(Typpy.get(42, true));\n// => \"number\"","lang":"javascript","description":"This example demonstrates how to use the main `Typpy` function to get a type string or compare against a target, and how to use the `Typpy.is` and `Typpy.get` helper methods for specific type checks."},"warnings":[{"fix":"Use `import Typpy from 'typpy';` and then `Typpy.is(...)` or `Typpy.get(...)` for ESM. For CommonJS, `const Typpy = require('typpy');` remains valid.","message":"The documentation primarily showcases CommonJS `require` syntax. While modern Node.js and bundlers support `import Typpy from 'typpy';` for ESM, direct named exports like `import { is } from 'typpy';` are not provided. Always import the default `Typpy` object and access `is` and `get` as properties.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"When using `Typpy(input, target)`, check for a boolean result. When using `Typpy(input)` to get the type, expect a string. If consistent boolean results are desired, prefer `Typpy.is(input, target)`.","message":"Typpy's primary function `Typpy(input, target)` returns a boolean if `target` is provided, but a string if `target` is omitted. Ensure you handle both return types correctly in your logic.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Leverage `Typpy`'s accurate `null` checking. If you specifically need the native `typeof` behavior, use the built-in operator directly. For consistent and precise type checking across all primitive and object types, stick with `Typpy`.","message":"Unlike the native `typeof` operator which returns 'object' for `null`, `Typpy.is(null, 'null')` correctly evaluates to `true`. Be aware of this difference when migrating code or expecting native `typeof` behavior.","severity":"gotcha","affected_versions":">=2.4.0"}],"env_vars":null,"search_vec":"'2.4.0':72 'accur':17 'address':30 'allow':54 'ambigu':32 'api':102 'applic':118 'approach':18 'array':48,63,68 'bug':89,116 'cadenc':75 'check':4,106 'common':31 'compar':23 'comparison':57 'condit':108 'consist':79 'consolid':101 'constructor':65,94 'current':69 'determin':20 'differ':44 'differenti':96 'distinguish':42 'document':84 'e.g':62,67 'enhanc':2 'evalu':38 'fix':90 'function':66 'handl':92 'javascript':9,119 'librari':53 'lightweight':8 'like':47,91 'link':86 'logic':109 'minor':81 'moder':77 'nativ':26 'null':37 'null/undefined':93 'object':40,45,51 'offer':99 'oper':28 'plain':50 'potenti':112 'precis':104 'primarili':78 'provid':12 'reduc':111 'relat':115 'releas':74 'represent':61 'robust':15 'simplifi':107 'small':88 'sponsor':85 'string':60 'type':3,22,46,56,105,114 'type-rel':113 'typeof':27,34,120 'typpi':1,5,121 'updat':82 'util':10 'variabl':21 'version':71","created_at":"2026-04-19T13:42:16.952464+00:00","updated_at":"2026-04-19T13:42:16.952464+00:00","problems":[{"fix":"Change your import statement to `import Typpy from 'typpy';` and then call `Typpy.is(value, type);`.","cause":"Attempting to import `is` as a named export (`import { is } from 'typpy';`) instead of accessing it as a property of the default export.","error":"TypeError: Typpy.is is not a function"},{"fix":"Update your import statement to use ESM syntax: `import Typpy from 'typpy';`.","cause":"Using `const Typpy = require('typpy');` in an environment configured for ECMAScript Modules (ESM) without a CommonJS shim.","error":"ReferenceError: require is not defined"},{"fix":"First, ensure the package is installed: `npm install typpy`. Then, verify the import statement `import Typpy from 'typpy';` (for ESM) or `const Typpy = require('typpy');` (for CommonJS) is correct and at the top of your file.","cause":"The Typpy package was not correctly installed or imported. This could be due to a typo in the import path or a missing `npm install typpy` step.","error":"Typpy is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/IonicaBizau/typpy","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/typpy","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}