Skip to content

Commit

Permalink
simplify checkInRHS helper
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Nov 7, 2022
1 parent d4a066a commit afaaaf0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/babel-helpers/src/helpers-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default Object.freeze({
),
checkInRHS: helper(
"7.20.1",
'export default function _checkInRHS(value){var type=typeof value;if("object"!==type&&"function"!==type)throw TypeError("right-hand side of \'in\' should be an object, got "+type);return value}',
"export default function _checkInRHS(value){return value}",
),
jsx: helper(
"7.0.0-beta.0",
Expand Down
8 changes: 3 additions & 5 deletions packages/babel-helpers/src/helpers/checkInRHS.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* @minVersion 7.20.1 */

export default function _checkInRHS(value) {
var type = typeof value;
if (type !== "object" && type !== "function") {
throw TypeError("right-hand side of 'in' should be an object, got " + type);
}
return value;
// We don't care whether 0 is actually value's property,
// if value is not an object, 0 in value will throw a TypeError.
return 0 in value, value;
}

0 comments on commit afaaaf0

Please sign in to comment.