{"id":25640492,"url":"https://github.com/realytics/immutable-record-typings","last_synced_at":"2026-07-09T17:31:40.751Z","repository":{"id":57272833,"uuid":"94706076","full_name":"Realytics/immutable-record-typings","owner":"Realytics","description":"Provides better typings for immutable record.","archived":false,"fork":false,"pushed_at":"2017-06-18T22:05:27.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T18:48:12.125Z","etag":null,"topics":["immutable","immutablejs","typescript","typings"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Realytics.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-18T18:41:23.000Z","updated_at":"2023-08-22T15:28:16.000Z","dependencies_parsed_at":"2022-08-25T07:10:55.850Z","dependency_job_id":null,"html_url":"https://github.com/Realytics/immutable-record-typings","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Realytics%2Fimmutable-record-typings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Realytics%2Fimmutable-record-typings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Realytics%2Fimmutable-record-typings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Realytics%2Fimmutable-record-typings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Realytics","download_url":"https://codeload.github.com/Realytics/immutable-record-typings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271525,"owners_count":19774859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["immutable","immutablejs","typescript","typings"],"created_at":"2025-02-23T04:39:51.548Z","updated_at":"2025-10-25T15:05:53.500Z","avatar_url":"https://github.com/Realytics.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Immutable Record Typings\n[![Npm version](https://img.shields.io/npm/v/immutable-record-typings.svg?style=flat-square)](https://www.npmjs.com/package/immutable-record-typings)\n\nTypings for Immutable Record which provides better type safety out of the box.\n \n## Installation\nThis plugin requires minimum **immutable 3.8.1**, **typescript 2.3.0**\n```sh\nnpm install --save-dev immutable-record-typings\n```\n\nThere are two ways to enable typings augmentation:\n\nRecommended way is adding `\"./node_modules/immutable-record-typings/*\"` to `include` section in your `tsconfig.json`, here is an example:\n ```json\n {\n   \"compilerOptions\": {},\n   \"include\": [\n     \"./src/**/*\",\n     \"./node_modules/immutable-record-typings/*\"\n   ]\n }\n```\n\nYou can also `import 'immutable-record-typings'` in entry file of your application instead of adding it to `tsconfig.json`.\n\nWe don't provide it as a `@types` package because it would be not compatible with current typings.\nSo the safer way is to provide it as a separate npm package.\nAlso, Immutable v4 is on the way with similar typings :)\n\n## Features\nThis package adds generic type to the `Record` definition. Thanks to this, we can make records type safe \n(excluding `mergeIn`, `mergeDeepIn`, `setIn`, `deleteIn`, `removeIn` and `updateIn` methods - typescript limitations).\n\nLet's say that we have `Post.ts` file:\n```typescript\nimport { Record, List } from 'immutable';\nimport { User } from './User';\nimport { Comment } from './Comment';\n\n// we use PascalCase because of names conflicts issue in records - \n// for example, a groupBy field will not work, because Record already has the groupBy method\nexport interface Post {\n  Title: string;\n  Author: User;\n  Content: string;\n  Comments: List\u003cComment\u003e;\n}\n\nexport const PostRecord = Record\u003cPost\u003e({\n  Title: '',\n  Author: undefined,\n  Content: '',\n  Comments: List\u003cComment\u003e()\n});\n```\n\nOr if we are minimalist. we can make it even shorter - typescript will guess `PostRecord` type:\n```typescript\nimport { Record, List } from 'immutable';\nimport { UserRecord } from './User';\nimport { CommentRecord } from './Comment';\n\nexport const PostRecord = Record({\n  Title: '',\n  // we can't just set `undefined` - typescript will not be able to guess Author field type\n  // it's a small hack here - there is no `UNDEFINED` field on `UserRecord` object so the value will be `undefined`\n  // but because of typings (UNDEFINED: Record\u003cT\u003e) - it will use proper type :) \n  Author: UserRecord.UNDEFINED,\n  Content: '',\n  // another special field - it's the same as UserRecord.UNDEFINED, but with more suitable name\n  Comments: List\u003ctypeof CommentRecord.INSTANCE\u003e()\n});\n```\n\nTo create new record object, we can use functional or object-oriented approach:\n```typescript\nimport { PostRecord } from './Post';\n\nconst postA = PostRecord({ Title: 'TypeScript is awesome!' });\nconst postB = new PostRecord({ Title: 'Immutable.js too' });\n```\n\nTo extend record class, we can use `extends` keyword:\n```typescript\nimport { PostRecord } from './Post';\nimport { UserRecord } from './User';\n\nexport class AwesomePost extends PostRecord {\n  get Title(): string {\n    return `[AWESOME NEWS] ${this.get('Title')}!`;\n  }\n}\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealytics%2Fimmutable-record-typings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealytics%2Fimmutable-record-typings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealytics%2Fimmutable-record-typings/lists"}