diff --git a/src/index.ts b/src/index.ts index 02907662..bc3dc4b1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1696,7 +1696,6 @@ export function Frozen(cst: T): T & Newable { }; } - const _seal = (obj: object) => { Object.seal(obj); }; @@ -1719,10 +1718,10 @@ const _seal = (obj: object) => { * john.age = 31; // Allowed * * // Existing properties cannot be re-configured or deleted - * delete john.age; // TypeError: Cannot delete property 'age' -* } -* ``` -* */ + * delete john.age; // TypeError: Cannot delete property 'age' + * } + * ``` + * */ export function Sealed(cst: T): T & Newable { return class Locked extends cst { constructor(...args: any[]) { @@ -1730,4 +1729,4 @@ export function Sealed(cst: T): T & Newable { _seal(this); } }; -} \ No newline at end of file +} diff --git a/tests/sealed-class.test.ts b/tests/sealed-class.test.ts index e141fa22..f05c3cd1 100644 --- a/tests/sealed-class.test.ts +++ b/tests/sealed-class.test.ts @@ -114,23 +114,23 @@ test('Should be allowed to mutate the properties of a sealed object', () => { }); test('Should not allow to delete the properties of a sealed object', () => { - @Sealed - class Foo { - private _foo: T; - bar?: string; - - constructor(foo: T) { - this._foo = foo; - this.bar = 'bar'; - } - someFoo(): T { - return this._foo; - } - } - expect(() => { - delete new Foo('foo').bar; - }).toThrow(TypeError); - }); + @Sealed + class Foo { + private _foo: T; + bar?: string; + + constructor(foo: T) { + this._foo = foo; + this.bar = 'bar'; + } + someFoo(): T { + return this._foo; + } + } + expect(() => { + delete new Foo('foo').bar; + }).toThrow(TypeError); +}); test('Should work when the final class is a subclass itself', () => { abstract class BaseFoo {