Skip to content

Commit

Permalink
docs: fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
ashgw committed May 4, 2024
1 parent 60b2844 commit e75dc62
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,21 @@ type Baz = NewType<'Baz', string>;
type Secret = NewType<'Secret', string>;

abstract class BaseFoo<T> {
protected abstract get foo(): T;
abstract requestFoo(secret: Secret, baz: Baz): Optional<T>;
}

@Final
@Frozen
class Foo<T> extends BaseFoo<T> {
private readonly _foo: T;
readonly foo: T;
bar: Optional<Bar>;

constructor(foo: T, bar?: MaybeUndefined<Bar>) {
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<T> {
// A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value
Expand All @@ -218,7 +214,7 @@ const foo = new Foo<string>('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:
Expand Down
2 changes: 1 addition & 1 deletion src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Final = <CST extends Newable>(cst: CST): CST => {
super(...args);

Check warning on line 42 in src/decorators.ts

View workflow job for this annotation

GitHub Actions / lint / check

Unsafe spread of an `any` array type
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: `);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/final-class.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
abstract someFoo(): T;
}
Expand Down

0 comments on commit e75dc62

Please sign in to comment.