Skip to content

fix(utils): Make new non-enumerable properties mutable #4528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions packages/utils/src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ export function fill(source: { [key: string]: any }, name: string, replacementFa
}

/**
* Defines a non enumerable property. This creates a non enumerable property on an object.
* Defines a non-enumerable property on the given object.
*
* @param func The function to set a property to
* @param name the name of the special sentry property
* @param value the property to define
* @param obj The object on which to set the property
* @param name The name of the property to be set
* @param value The value to which to set the property
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function addNonEnumerableProperty(func: any, name: string, value: any): void {
Object.defineProperty(func, name, {
export function addNonEnumerableProperty(obj: { [key: string]: unknown }, name: string, value: unknown): void {
Object.defineProperty(obj, name, {
// enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
value: value,
writable: true,
configurable: true,
});
}

Expand Down