person.ts 411 B

1234567891011121314151617181920212223
  1. interface Person {
  2. // If age exists, then it must be a number; but it is not required to exist.
  3. age?: number;
  4. formatName: () => string;
  5. name: string;
  6. }
  7. abstract class FooBase {
  8. age: number;
  9. name: string;
  10. }
  11. class Foo extends FooBase implements Person {
  12. constructor(props: string[]) {
  13. super();
  14. this.age = 0;
  15. this.name = "Doe";
  16. }
  17. formatName(): string {
  18. return this.name;
  19. }
  20. }