Skip to content

Commit 91ae99c

Browse files
committed
Small cleanups.
1 parent 999bb65 commit 91ae99c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/jest-environment-node/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ class GlobalProxy implements ProxyHandler<typeof globalThis> {
277277
...this.leftovers,
278278
]) {
279279
/*
280-
* react-native invoke its custom `performance` property after env teardown.
281-
* its setup file should use `protectProperties` to prevent this.
280+
* React Native's test setup invokes their custom `performance` property after env teardown.
281+
* Once they start using `protectProperties`, we can get rid of this.
282282
*/
283283
if (property !== 'performance') {
284284
deleteProperties(value);

packages/jest-util/src/garbage-collection-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,10 @@ export function protectProperties<T extends object>(
5050
* @param value The given value.
5151
*/
5252
export function canDeleteProperties(value: unknown): value is object {
53-
return value !== null && ['object', 'function'].includes(typeof value);
53+
if (value !== null) {
54+
const type = typeof value;
55+
return type === 'object' || type === 'function';
56+
}
57+
58+
return false;
5459
}

0 commit comments

Comments
 (0)