From e75dc62a44d684cc125cd04339026c8e87540a6a Mon Sep 17 00:00:00 2001 From: AshGw Date: Sat, 4 May 2024 15:45:19 +0100 Subject: [PATCH] docs: fix typos --- README.md | 12 ++++-------- src/decorators.ts | 2 +- tests/final-class.test.ts | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b203a179..0ab7216d 100644 --- a/README.md +++ b/README.md @@ -173,25 +173,21 @@ type Baz = NewType<'Baz', string>; type Secret = NewType<'Secret', string>; abstract class BaseFoo { - protected abstract get foo(): T; abstract requestFoo(secret: Secret, baz: Baz): Optional; } @Final @Frozen class Foo extends BaseFoo { - private readonly _foo: T; + readonly foo: T; bar: Optional; constructor(foo: T, bar?: MaybeUndefined) { super(); - this._foo = foo; + this.foo = foo; this.bar = bar ?? null; } - protected override get foo(): T { - console.log('do some stuff first'); - return this._foo; - } + requestFoo(secret: Secret, baz: Baz): Optional { // A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value @@ -218,7 +214,7 @@ const foo = new Foo('foo'); // Since the object is final: -// The line below will cause a TypeError: Cannot inherit from the finl class Foo +// The line below will cause a TypeError: Cannot inherit from the final class Foo const _ = new SubFoo('subFoo'); // Since the object is frozen: diff --git a/src/decorators.ts b/src/decorators.ts index 96c39aea..20bba09c 100644 --- a/src/decorators.ts +++ b/src/decorators.ts @@ -42,7 +42,7 @@ export const Final = (cst: CST): CST => { super(...args); const newTarget = new.target as unknown as typeof F; if (newTarget !== F) { - throw new FinalTypeError(`Cannot inherit from a final class`); + throw new FinalTypeError(`Cannot inherit from the final class: `); } } } diff --git a/tests/final-class.test.ts b/tests/final-class.test.ts index 7bb8de5b..e42728e3 100644 --- a/tests/final-class.test.ts +++ b/tests/final-class.test.ts @@ -92,7 +92,7 @@ test('Should work when the final class is a subclass itself', () => { }); test(`Should not allow inheritance, of the final class, when the final class - is a subclass itself, a TypeError should be thrown`, () => { + is a subclass itself, a FinalTypeError should be thrown`, () => { abstract class BaseFoo { abstract someFoo(): T; }