{"id":12221,"library":"typedash","title":"Typedash Utility Functions","description":"Typedash is a modern, type-safe collection of utility functions designed for TypeScript environments, offering a robust alternative to libraries like Lodash with a strong focus on simplicity, tree-shaking, and precise type inference. It currently stands at version 3.3.3 and maintains a fairly active release cadence with frequent minor and patch updates, as evidenced by recent changelog entries. Key differentiators include its complete type-safety, ensuring type-level transformations for string casing functions and precise key/value types for object utilities. The library boasts zero runtime dependencies, making it highly tree-shakeable and performant. It operates on the principle of \"trust the compiler\" by leveraging TypeScript's robust type system for correctness rather than relying on extensive runtime checks. Typedash provides over 60 utility functions categorized for Array, Object, String, Type Guards, Function, and Math operations.","status":"active","version":"3.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/bengry/typedash","tags":["javascript","typescript","lodash","utility","utilities","type-safe","util","stdlib"],"install":[{"cmd":"npm install typedash","lang":"bash","label":"npm"},{"cmd":"yarn add typedash","lang":"bash","label":"yarn"},{"cmd":"pnpm add typedash","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Typedash is primarily designed for ESM consumption, especially with its tree-shaking capabilities. While CommonJS 'require' might work in some setups, direct named imports are the intended and most reliable approach.","wrong":"const { pick } = require('typedash')","symbol":"pick","correct":"import { pick } from 'typedash'"},{"note":"The `camelCase` function returns a type-level transformed string literal type (e.g., 'fooBarBaz'), not just `string`, for enhanced type safety and auto-completion.","symbol":"camelCase","correct":"import { camelCase } from 'typedash'"},{"note":"Individual function imports, such as this explicit path, are recommended for optimal tree-shaking, allowing bundlers to include only the code you use.","wrong":"import objectKeys from 'typedash/objectKeys'","symbol":"objectKeys","correct":"import { objectKeys } from 'typedash/objectKeys'"}],"quickstart":{"code":"import { pick, objectKeys, camelCase, compact } from 'typedash';\n\ninterface User {\n  id: string;\n  firstName: string;\n  lastName: string;\n  email: string;\n  isAdmin?: boolean;\n  'user-role': string;\n}\n\nconst userData: User = {\n  id: '123',\n  firstName: 'John',\n  lastName: 'Doe',\n  email: 'john.doe@example.com',\n  isAdmin: false,\n  'user-role': 'admin'\n};\n\n// Demonstrate pick for selecting properties with preserved types\nconst publicInfo = pick(userData, ['id', 'firstName', 'lastName']);\nconsole.log('Public Info:', publicInfo);\n// Expected type: { id: string; firstName: string; lastName: string; }\n\n// Demonstrate objectKeys with precise type inference for array of keys\nconst keys = objectKeys(publicInfo);\nconsole.log('Keys:', keys);\n// Expected type: (\"id\" | \"firstName\" | \"lastName\")[]\n\n// Demonstrate camelCase for string literal transformation\nconst userRoleKey = camelCase(userData['user-role']);\nconsole.log('CamelCased Role Key:', userRoleKey);\n// Expected type: \"userRole\"\n\n// Demonstrate compact for array filtering, inferring non-falsy types\nconst values = [0, 1, false, '', 'hello', null, undefined];\nconst compacted = compact(values);\nconsole.log('Compacted Array:', compacted);\n// Expected type: (1 | \"hello\")[]","lang":"typescript","description":"This quickstart demonstrates `typedash`'s core features including `pick` for object property selection, `objectKeys` for precise key inference, `camelCase` for type-level string transformations, and `compact` for array filtering, all with robust TypeScript support."},"warnings":[{"fix":"Ensure your codebase is strictly typed and compiler errors are addressed. Runtime type checking should be implemented separately if required for untrusted input at boundaries.","message":"Typedash relies heavily on TypeScript's type system for correctness and performs minimal runtime validation. Unlike libraries such as Lodash, it generally does not include extensive runtime checks for input types or values, operating on the principle of 'trust the compiler'.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Upgrade your Node.js environment to version 20.0.0 or newer using `nvm` or your preferred Node.js version manager.","message":"Typedash requires Node.js version 20.0.0 or higher. Older Node.js versions are not supported and may lead to runtime errors or unexpected behavior due to modern language features and module resolution.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade to Typedash version 3.2.3 or newer to resolve CommonJS build and import issues. For older Node.js projects, consider using individual function imports (e.g., `require('typedash/pick')`) if the main entry point causes problems.","message":"Versions of Typedash prior to 3.2.3 may have experienced issues with CommonJS consumers, specifically regarding module resolution and incorrect builds, which could lead to `TypeError: ... is not a function` errors when using `require()`.","severity":"breaking","affected_versions":"<3.2.3"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you are using `import { functionName } from 'typedash'` for named ESM imports in a compatible environment. If using CommonJS, individual function imports like `const pick = require('typedash/pick')` are often more reliable, as full CJS support for the main entry point may vary by version and build setup.","cause":"This error typically indicates incorrect CommonJS `require` syntax, bundler misconfiguration, or an attempt to import a module primarily designed for ESM using CJS patterns.","error":"TypeError: (0, typedash_1.pick) is not a function"},{"fix":"Review your object's type definition and ensure it accurately reflects all possible properties. Use type assertions (`as Type`) sparingly and only when you are absolutely certain of the type. For dynamic property access, consider using type guards or utility functions like `objectKeys` to safely narrow types.","cause":"Attempting to access a property that TypeScript's inferred type for the object does not include, often due to an incorrect type assertion or unexpected input. Typedash's strict typing will surface these issues.","error":"Property 'xyz' does not exist on type 'ABC'."},{"fix":"Ensure the array of keys passed to functions like `pick` or `omit` is correctly typed as a `const` assertion (`['a', 'b'] as const`) or explicitly as a union of literal types (e.g., `const keys: Array<'a' | 'b'> = ['a', 'b'];`) so TypeScript can infer the precise subset of keys.","cause":"Providing an array of generic `string` literals where Typedash expects an array of specific literal keys derived from the object's type, typically when using functions like `pick` or `omit`.","error":"Argument of type 'string[]' is not assignable to parameter of type 'keyof T | readonly (keyof T)[]'."}],"ecosystem":"npm"}