can you declare a class member as either a property or method?

Viewed 34

given the following classes

class Base {
  options?: (() => any) | object | undefined;
}

class A extends Base {
  options() {}
}

where options could either be an object or a function that returns an object, how do I properly type this up? right now I'm getting an error that says "class A defines instance member property options but extended class Base defines it as an instance member function"

1 Answers

No, you cannot declare a class member as either a property or method in TypeScript.

Related