{"id":11030,"library":"helpertypes","title":"TypeScript Helper Types Collection","description":"helpertypes is a lightweight collection of general-purpose TypeScript helper types designed to simplify complex type manipulations across various projects. As of version `0.0.19`, the library offers utilities like deep partial/required types, object key pickers, and string lookup types. The project maintains an active development status, with frequent releases (often multiple per month) focused on introducing new helper types and refining the behavior and robustness of existing ones, particularly for deep type transformations. Its key differentiators include its small footprint, focused scope on just type utilities without runtime code, and a commitment to providing common, reusable type patterns that might otherwise be cumbersome to implement from scratch. While still in a pre-1.0 state, it's regularly updated with fixes and new features.","status":"active","version":"0.0.19","language":"javascript","source_language":"en","source_url":"https://github.com/wessberg/helpertypes","tags":["javascript","typescript","lib","type","helpers"],"install":[{"cmd":"npm install helpertypes","lang":"bash","label":"npm"},{"cmd":"yarn add helpertypes","lang":"bash","label":"yarn"},{"cmd":"pnpm add helpertypes","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Always use `import type` as this library exports only TypeScript types, not runtime values.","wrong":"import { PartialDeep } from 'helpertypes';","symbol":"PartialDeep","correct":"import type { PartialDeep } from 'helpertypes';"},{"note":"Like all types from this package, it should be imported using `import type` and is not available via CommonJS `require`.","wrong":"const { RequiredDeep } = require('helpertypes');","symbol":"RequiredDeep","correct":"import type { RequiredDeep } from 'helpertypes';"},{"note":"This type, like others in helpertypes, is purely for design-time type checking and has no runtime representation. Use `import type`.","symbol":"ObjectLookupString","correct":"import type { ObjectLookupString } from 'helpertypes';"}],"quickstart":{"code":"import type { PartialDeep, RequiredDeep, ObjectLookupString } from 'helpertypes';\n\ninterface UserProfile {\n  id: string;\n  name: string;\n  settings: {\n    theme: 'dark' | 'light';\n    notifications: boolean;\n  };\n  tags?: string[];\n}\n\n// Create a deeply partial version of UserProfile\ntype PartialUserProfile = PartialDeep<UserProfile>;\n\nconst partialUser: PartialUserProfile = {\n  id: 'abc-123',\n  settings: { theme: 'dark' } // Only define some nested properties\n};\n\nconsole.log(partialUser);\n\n// Create a deeply required version, making all optional properties required (if possible)\ntype FullyRequiredUserProfile = RequiredDeep<UserProfile>;\n\nconst fullUser: FullyRequiredUserProfile = {\n  id: 'def-456',\n  name: 'Jane Doe',\n  settings: { theme: 'light', notifications: true },\n  tags: [] // 'tags' is now required\n};\n\nconsole.log(fullUser);\n\ninterface NestedObject {\n  a: { b: { c: string } };\n  d: number;\n}\n\n// Look up a string path in a nested object type\ntype PathA_B_C = ObjectLookupString<NestedObject, 'a.b.c'>; // Expected: string\ntype PathD = ObjectLookupString<NestedObject, 'd'>;         // Expected: number\n\n// Type checking for example usage (won't run in JS)\nconst val1: PathA_B_C = 'hello';\n// @ts-expect-error - Type 'number' is not assignable to type 'string'.\nconst val2: PathA_B_C = 123;\n\nconsole.log('Demonstrating type utilities. Check TypeScript compiler for full effect.');\n","lang":"typescript","description":"This quickstart demonstrates how to install `helpertypes` and use `PartialDeep`, `RequiredDeep`, and `ObjectLookupString` to create new derived types from existing interfaces, showcasing deep optionality, deep requiredness, and string-based path lookups."},"warnings":[{"fix":"Upgrade to the latest version of `helpertypes` (v0.0.19 or newer) to benefit from the most stable implementations of `RequiredDeep` and `PartialDeep`. Review any complex type definitions that use these helpers after upgrading to ensure desired behavior.","message":"The `RequiredDeep` and `PartialDeep` types have undergone several bug fixes across minor versions (e.g., v0.0.16, v0.0.17). Users relying on their behavior in older versions might encounter subtle changes in type inference or edge case handling, especially with deeply nested or complex types. Ensure thorough type checking when upgrading.","severity":"gotcha","affected_versions":"<0.0.18"},{"fix":"Upgrade to `helpertypes@0.0.18` or newer. If you were encountering recursion limit errors with `ObjectLookupTuple`, this fix should resolve them. Otherwise, verify that the type inference for paths you use with this helper remains correct.","message":"The implementation of `ObjectLookupTuple` was replaced in v0.0.18 to address issues where it could exceed TypeScript's allowed recursive call limits, leading to compilation errors or incorrect type inference. While a fix, code that might have (erroneously) compiled with the previous, less robust implementation due to recursion limits might now behave differently or resolve types correctly.","severity":"breaking","affected_versions":"<0.0.18"},{"fix":"Always use `import type { SomeType } from 'helpertypes';` to explicitly import only the type definitions. This helps prevent accidental runtime imports and ensures correct usage.","message":"As a type-only library, `helpertypes` exports no runtime values. Attempting to `import { SomeType } from 'helpertypes';` without `type` or using `require()` will result in runtime errors (e.g., `TypeError: (0 , helpertypes_1.PartialDeep) is not a function` in ESM contexts or `undefined` in CJS) or TypeScript compiler warnings.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Upgrade `helpertypes` to the latest version (v0.0.19+), as many recursion issues have been fixed. If the problem persists with extremely deep types, consider manually increasing TypeScript's `--declarationDir` or `--maxNodeModuleJsDepth` compiler options, though this is often a sign of overly complex types.","cause":"Using complex recursive helper types (like `PartialDeep`, `RequiredDeep`, or `ObjectLookupTuple`) from `helpertypes` on very deeply nested object structures or with older versions of the library, hitting TypeScript's default recursion depth limit.","error":"Type instantiation is excessively deep and possibly infinite."},{"fix":"Change the import statement from `import { PartialDeep } from 'helpertypes';` to `import type { PartialDeep } from 'helpertypes';`. This explicitly tells TypeScript to only import the type definition, which is correctly stripped at compile time.","cause":"Attempting to import a type from `helpertypes` as if it were a runtime value in an ESM context, leading to a failed runtime import and execution.","error":"TypeError: (0 , helpertypes_1.PartialDeep) is not a function"}],"ecosystem":"npm"}