{"record":{"id":"b4d6cf32272792e6","repo":"immutable-js/immutable-js","slug":"can-not-call-record-with-an-immutable-record-as","errorCode":null,"errorMessage":"Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.","messagePattern":"Can not call `Record` with an immutable Record as default values\\. Use a plain javascript object instead\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Record.js","lineNumber":28,"sourceCode":"import { getIn } from './methods/getIn';\nimport { merge, mergeWith } from './methods/merge';\nimport { mergeDeep, mergeDeepWith } from './methods/mergeDeep';\nimport { mergeDeepIn } from './methods/mergeDeepIn';\nimport { mergeIn } from './methods/mergeIn';\nimport { setIn } from './methods/setIn';\nimport { update } from './methods/update';\nimport { updateIn } from './methods/updateIn';\nimport { withMutations } from './methods/withMutations';\n\nimport { isImmutable } from './predicates/isImmutable';\nimport { IS_RECORD_SYMBOL, isRecord } from './predicates/isRecord';\nimport { toJS } from './toJS';\nimport invariant from './utils/invariant';\nimport quoteString from './utils/quoteString';\n\nfunction throwOnInvalidDefaultValues(defaultValues) {\n  if (isRecord(defaultValues)) {\n    throw new Error(\n      'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.'\n    );\n  }\n\n  if (isImmutable(defaultValues)) {\n    throw new Error(\n      'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.'\n    );\n  }\n\n  if (defaultValues === null || typeof defaultValues !== 'object') {\n    throw new Error(\n      'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.'\n    );\n  }\n}\n\nexport class Record {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/immutable-js/immutable-js/blob/59fdaae67606ceedee7902a44703c893949f673b/src/Record.js#L10-L46","documentation":"Record defaults must be a plain object; any other immutable Collection (Map, List, Seq, Set, etc.) is rejected. Immutable cannot use a Collection as a defaults template because defaults are copied per-field into plain properties.","triggerScenarios":"Record(Immutable.Map({ a: 1 })) or Record(someList) — passing any immutable Collection where the defaults object is expected.","commonSituations":"Building Record defaults dynamically from an existing Map or fromJS() output; refactoring code where a Map was previously spread into a plain object.","solutions":["Convert to plain object: Record(map.toObject()) or Record(fromJS(obj).toJS())","Build defaults with a plain object literal or Object.fromEntries(map.entrySeq())","If you want a Record with dynamic keys, use a Map instead — Records require a fixed key set"],"exampleFix":"// before\nconst R = Record(Immutable.Map({ a: 1 })); // throws\n// after\nconst R = Record({ a: 1 });","handlingStrategy":"type-guard","validationCode":"import { isImmutable, isCollection } from 'immutable';\nfunction plainDefaults(v) {\n  return isImmutable(v) ? v.toObject() : v;\n}","typeGuard":"const isPlainObj = (v: unknown): v is Record<string, unknown> =>\n  !!v && typeof v === 'object' && !Array.isArray(v) && !isImmutable(v);","tryCatchPattern":null,"preventionTips":["Convert Map/Set/Seq defaults with .toObject()/.toJS() first","Keep a helper toPlain(v) used before all Record() calls"],"tags":["record","constructor","type-error"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"59fdaae67606ceedee7902a44703c893949f673b","analyzedAt":"2026-08-27T20:14:53.132Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}