Browse Source

cleanup: Remove unused deepFreeze() (#71836)

Related to https://github.com/getsentry/frontend-tsc/issues/13
Ryan Albrecht 9 months ago
parent
commit
740bedc4c7
2 changed files with 0 additions and 36 deletions
  1. 0 13
      static/app/utils.tsx
  2. 0 23
      static/app/utils/utils.spec.tsx

+ 0 - 13
static/app/utils.tsx

@@ -294,19 +294,6 @@ export function isWebpackChunkLoadingError(error: Error): boolean {
   );
 }
 
-export function deepFreeze<T>(object: T) {
-  // Retrieve the property names defined on object
-  const propNames = Object.getOwnPropertyNames(object);
-  // Freeze properties before freezing self
-  for (const name of propNames) {
-    const value = object[name];
-
-    object[name] = value && typeof value === 'object' ? deepFreeze(value) : value;
-  }
-
-  return Object.freeze(object);
-}
-
 export function generateQueryWithTag(prevQuery: Query, tag: EventTag): Query {
   const query = {...prevQuery};
 

+ 0 - 23
static/app/utils/utils.spec.tsx

@@ -1,7 +1,6 @@
 import {ProjectFixture} from 'sentry-fixture/project';
 
 import {
-  deepFreeze,
   descopeFeatureName,
   escapeDoubleQuotes,
   explodeSlug,
@@ -214,28 +213,6 @@ describe('utils.descopeFeatureName', function () {
   });
 });
 
-describe('deepFreeze', function () {
-  it('throws error on attempt to mutate frozen object', function () {
-    const testObj = deepFreeze({foo: [1, 2, 3]});
-
-    [
-      () => {
-        testObj.foo.push(4);
-      },
-      () => {
-        // @ts-expect-error
-        testObj.bar = '';
-      },
-      () => {
-        // @ts-expect-error
-        delete testObj.foo;
-      },
-    ].forEach(fn => {
-      expect(fn).toThrow();
-    });
-  });
-});
-
 describe('utils.escapeDoubleQuotes', function () {
   // test cases from https://gist.github.com/getify/3667624