{"action":"created","issue":{"url":"https://api.github.com/repos/sindresorhus/deep-assign/issues/12","repository_url":"https://api.github.com/repos/sindresorhus/deep-assign","labels_url":"https://api.github.com/repos/sindresorhus/deep-assign/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/sindresorhus/deep-assign/issues/12/comments","events_url":"https://api.github.com/repos/sindresorhus/deep-assign/issues/12/events","html_url":"https://github.com/sindresorhus/deep-assign/issues/12","id":126028501,"number":12,"title":"Option to not throw TypeError for null or undefined targets","user":{"login":"whizkid77","id":2087689,"avatar_url":"https://avatars.githubusercontent.com/u/2087689?v=3","gravatar_id":"","url":"https://api.github.com/users/whizkid77","html_url":"https://github.com/whizkid77","followers_url":"https://api.github.com/users/whizkid77/followers","following_url":"https://api.github.com/users/whizkid77/following{/other_user}","gists_url":"https://api.github.com/users/whizkid77/gists{/gist_id}","starred_url":"https://api.github.com/users/whizkid77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whizkid77/subscriptions","organizations_url":"https://api.github.com/users/whizkid77/orgs","repos_url":"https://api.github.com/users/whizkid77/repos","events_url":"https://api.github.com/users/whizkid77/events{/privacy}","received_events_url":"https://api.github.com/users/whizkid77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-01-11T20:22:31Z","updated_at":"2016-02-17T09:41:45Z","closed_at":null,"body":"Object.assign does not throw TypeErrors, but the polyfill does.  Is it possible to make the behaviors consistent?\r\n\r\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\r\n\"Note that Object.assign() does not throw on null or undefined source values.\""},"comment":{"url":"https://api.github.com/repos/sindresorhus/deep-assign/issues/comments/185120305","html_url":"https://github.com/sindresorhus/deep-assign/issues/12#issuecomment-185120305","issue_url":"https://api.github.com/repos/sindresorhus/deep-assign/issues/12","id":185120305,"user":{"login":"jbellsey","id":1831399,"avatar_url":"https://avatars.githubusercontent.com/u/1831399?v=3","gravatar_id":"","url":"https://api.github.com/users/jbellsey","html_url":"https://github.com/jbellsey","followers_url":"https://api.github.com/users/jbellsey/followers","following_url":"https://api.github.com/users/jbellsey/following{/other_user}","gists_url":"https://api.github.com/users/jbellsey/gists{/gist_id}","starred_url":"https://api.github.com/users/jbellsey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbellsey/subscriptions","organizations_url":"https://api.github.com/users/jbellsey/orgs","repos_url":"https://api.github.com/users/jbellsey/repos","events_url":"https://api.github.com/users/jbellsey/events{/privacy}","received_events_url":"https://api.github.com/users/jbellsey/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T09:41:45Z","updated_at":"2016-02-17T09:41:45Z","body":"Fair enough; I will fork or find another solution. \r\n\r\nMy situation is this: the API returns a user record, which I cache locally. I poll the server for new data, and merge that into the local user record. \r\n\r\nAnd (you saw this coming) the server sends fields as `null` when there's no data.\r\n\r\n```javascript\r\n// first poll:\r\nuser = {\r\n  device_features: {\r\n    locked: null,     // here comes trouble...\r\n    pin: '1234'\r\n  },\r\n  settings: {\r\n    email: 'me@mine.com'\r\n  }\r\n};\r\n\r\n// poll for new device status, which should be merged into the user record:\r\nnew_device_data = {\r\n  locked: true,  // in some cases, this is an object; any non-null value fails\r\n  pin: '1234'   // this field is sometimes not included; we only get changed values\r\n};\r\n\r\n// here's where we error:\r\ndeepAssign(user.device_features, new_device_data);\r\n```\r\n\r\nThis breaks my mental model. It makes sense to error if the target itself is `null`, but not if a property somewhere inside the target is `null`. That, to me, is a very abstract notion of applied recursion...recursive algorithms always allow for a special case at the margin.\r\n\r\nAgain, your library, your call."}}