8000 add exception for code that shoukd not happen (#2074) · immutable-js/immutable-js@53237d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53237d2

Browse files
authored
add exception for code that shoukd not happen (#2074)
1 parent 81673ba commit 53237d2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/functional/updateIn.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ function updateInDeeply(
4747
);
4848
}
4949
const key = keyPath[i];
50+
51+
if (typeof key === 'undefined') {
52+
throw new TypeError(
53+
'Index can not be undefined in updateIn(). This should not happen'
54+
);
55+
}
56+
5057
const nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
5158
const nextUpdated = updateInDeeply(
5259
nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),

0 commit comments

Comments
 (0)
0