{"id":11835,"library":"react-redux-typescript","title":"TypeScript Mapped Types & Utility Collection","description":"react-redux-typescript provides a robust collection of advanced TypeScript utility types, primarily focusing on 'Mapped Types' for complex object and key manipulation. As of version 3.11.0, it offers types like `DiffKeys`, `Omit`, `Assign`, `Overwrite`, `DeepReadonly`, `Optional`, `Required`, `Mutable`, and `UnionToIntersection`. It also includes a utility function `getReturnOfExpression` for inferring function return types. The library is actively maintained with frequent minor releases, though its name can be misleading as the React/Redux-specific parts (re-exports from `typesafe-actions`) are deprecated and slated for removal in future major versions. A key differentiator is its commitment to thorough type correctness testing, zero third-party runtime dependencies for its core utility types, and providing separate bundles for various module workflows (CommonJS, ES Module).","status":"active","version":"3.0.0-rc.3","language":"javascript","source_language":"en","source_url":"https://github.com/piotrwitek/react-redux-typescript","tags":["javascript","react","redux","typescript","utils"],"install":[{"cmd":"npm install react-redux-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add react-redux-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-redux-typescript","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Mapped types are typically imported as named exports. Avoid default imports.","wrong":"import Omit from 'react-redux-typescript';","symbol":"Omit","correct":"import { Omit } from 'react-redux-typescript';"},{"note":"While CommonJS `require` might work in some configurations, named ESM imports are the recommended and type-safe approach for TypeScript.","wrong":"const { Assign } = require('react-redux-typescript');","symbol":"Assign","correct":"import { Assign } from 'react-redux-typescript';"},{"note":"Destructuring directly from named exports is preferred for tree-shaking and clarity.","wrong":"import * as RRT from 'react-redux-typescript'; const func = RRT.getReturnOfExpression;","symbol":"getReturnOfExpression","correct":"import { getReturnOfExpression } from 'react-redux-typescript';"},{"note":"Use `DeepReadonly` for recursive readonly application; `Readonly` is a standard TypeScript utility type.","wrong":"import { Readonly } from 'react-redux-typescript';","symbol":"DeepReadonly","correct":"import { DeepReadonly } from 'react-redux-typescript';"}],"quickstart":{"code":"import { Omit, Assign, DeepReadonly } from 'react-redux-typescript';\n\ninterface UserProfile {\n  id: string;\n  name: string;\n  email: string;\n  settings: {\n    theme: 'dark' | 'light';\n    notifications: boolean\n  };\n  createdAt: Date;\n}\n\ninterface PartialUpdate {\n  name?: string;\n  email?: string;\n  updatedAt: Date;\n}\n\n// Example 1: Omit properties from a type\ntype UserWithoutSensitiveInfo = Omit<UserProfile, 'email' | 'createdAt'>;\n// Expected: { id: string; name: string; settings: { theme: 'dark' | 'light'; notifications: boolean }; }\n\nconst user1: UserWithoutSensitiveInfo = {\n  id: '123',\n  name: 'Alice',\n  settings: { theme: 'dark', notifications: true }\n};\n\n// Example 2: Assign (merge) properties, overwriting if they exist\ntype MergedProfile = Assign<UserProfile, PartialUpdate>;\n// Expected: { id: string; name: string; email: string; settings: { theme: 'dark' | 'light'; notifications: boolean }; createdAt: Date; updatedAt: Date; }\n\nconst user2: MergedProfile = {\n  id: '456',\n  name: 'Bob',\n  email: 'bob@example.com',\n  settings: { theme: 'light', notifications: false },\n  createdAt: new Date(),\n  updatedAt: new Date()\n};\n\n// Example 3: Make all properties and nested properties readonly\ntype ReadonlyUserProfile = DeepReadonly<UserProfile>;\n\nconst readonlyUser: ReadonlyUserProfile = {\n  id: '789',\n  name: 'Charlie',\n  email: 'charlie@example.com',\n  settings: {\n    theme: 'light',\n    notifications: true\n  },\n  createdAt: new Date()\n};\n\n// readonlyUser.name = 'David'; // This line would cause a TypeScript error\n\nconsole.log('User without sensitive info:', user1);\nconsole.log('Merged profile:', user2);\nconsole.log('Readonly user (check types):', readonlyUser);\n","lang":"typescript","description":"Demonstrates `Omit`, `Assign`, and `DeepReadonly` utility types for manipulating object shapes and immutability."},"warnings":[{"fix":"Replace `import { createAction } from 'react-redux-typescript';` with `import { createAction } from 'typesafe-actions';` for affected symbols.","message":"The 'Redux Typesafe Actions' utilities (e.g., createAction, getType, isActionOf) re-exported from `typesafe-actions` are deprecated and will be removed in the next major release. Users should migrate to importing these directly from `typesafe-actions`.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Replace `Falsey` with `Falsy` in your type definitions.","message":"The `Falsey` type alias was deprecated in v3.9.0 and replaced with `Falsy`. While `Falsey` is kept for backward compatibility, it is recommended to update to the new alias.","severity":"deprecated","affected_versions":">=3.9.0"},{"fix":"Be aware that the primary value of this library lies in its general TypeScript utility types. Consider `utility-types` as a more fitting alternative if not using the specific types offered here, though this library often provides more advanced versions.","message":"The package name `react-redux-typescript` is largely historical. Most of its current utility types are general-purpose TypeScript mapped types, with the React/Redux-specific re-exports being deprecated. This can be misleading for new users expecting only React/Redux-specific functionality.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Ensure you are using a recent version of `react-redux-typescript` (v3.6.1 or later) to benefit from the corrected `Omit` type. Always test thoroughly when upgrading TypeScript versions in combination with this library.","message":"An issue with TypeScript v3.5's native `Omit` implementation caused `react-redux-typescript` to revert to an older, custom `Omit` implementation in v3.6.1 to ensure correctness. While fixed internally, users should be aware of potential subtle differences or unexpected type inference if upgrading from very old versions or encountering edge cases with specific TS versions.","severity":"breaking","affected_versions":">=3.6.1 <3.7.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure that if you are using types like `DeepReadonly<T>`, you do not attempt to modify any properties, including nested ones. Create a mutable copy if modification is necessary.","cause":"Attempting to assign a value to a deeply `Readonly` type, which prevents modification of nested properties.","error":"TS2345: Argument of type 'string' is not assignable to parameter of type '{ theme: \"dark\" | \"light\"; notifications: boolean; }'."},{"fix":"Use ES Module import syntax: `import { OmitKeys } from 'react-redux-typescript';` Ensure your `tsconfig.json` `module` and `moduleResolution` settings are appropriate for your environment (e.g., 'NodeNext' or 'Bundler').","cause":"Attempting to use CommonJS `require()` syntax (e.g., `const { OmitKeys } = require('react-redux-typescript');`) in an ES Module context or when the package's `exports` map doesn't permit it.","error":"TypeError: Cannot read properties of undefined (reading 'OmitKeys')"},{"fix":"Verify that the keys you are attempting to `Omit` or `Pick` (`K`) are indeed present in the base type `T`. TypeScript's strictness prevents operating on non-existent keys, which helps catch typos.","cause":"Using `Omit<T, K>` or `Pick<T, K>` with a key `K` that is not a valid key of type `T`.","error":"TS2344: Type 'string | number' does not satisfy the constraint 'keyof T'."}],"ecosystem":"npm"}