Disallow object assign explanation

Summary:
> Explain the **motivation** for making this change. What existing problem does the pull request solve?

Provides better documentation for a confusing (and common) error message. Solves https://github.com/facebook/react-native/issues/3634

> **Test plan (required)**

This is just an error message shown in dev environment. I ran the tests and they pass.
Closes https://github.com/facebook/react-native/pull/10472

Differential Revision: D4053818

Pulled By: hramos

fbshipit-source-id: e80dc6ab787a8d8cabbcb442c438c07269401ff7
This commit is contained in:
Wojciech Ogrodowczyk 2016-11-10 00:15:05 -08:00 committed by Facebook Github Bot
parent 1fdb99efac
commit 9773229227
1 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,7 @@
// WARNING: This is an optimized version that fails on hasOwnProperty checks
// and non objects. It's not spec-compliant. It's a perf optimization.
// This is only needed for iOS 8 and current Android JSC.
/* eslint strict:0 */
Object.assign = function(target, sources) {
if (__DEV__) {
@ -55,7 +56,8 @@ Object.assign = function(target, sources) {
if (!hasOwnProperty.call(nextSource, key)) {
throw new TypeError(
'One of the sources for assign has an enumerable key on the ' +
'prototype chain. This is an edge case that we do not support. ' +
'prototype chain. Are you trying to assign a prototype property? ' +
'We don\'t allow it, as this is an edge case that we do not support. ' +
'This error is a performance optimization and not spec compliant.'
);
}