What I want to be able to do is ultimately have access to the class inside a constructor. Accessing this.constructor should be safe (I think?), and would allow for sub-classes to call their own static methods before calling the super:
class BaseProvider {
constructor(url: string) { ... };
}
abstract class GenericProvider {
constructor(something: any) {
let url = this.constructor.getUrl(something);
super(url);
}
static getUrl(something: any): string {
throw new Error("subclass must implement this");
}
}
class SpecificProvider {
// This class does not need to override the constructor, just the static method
static getUrl(something: any): string {
return "https://helloworld"
}
}
I have not been able to find a way to get around this, but if it already exists, awesome. Otherwise, this would go a long way to improving the use of static methods in TypeScript, and a the standard way to handle things like this.
Thanks!
What I want to be able to do is ultimately have access to the class inside a constructor. Accessing this.constructor should be safe (I think?), and would allow for sub-classes to call their own static methods before calling the super:
I have not been able to find a way to get around this, but if it already exists, awesome. Otherwise, this would go a long way to improving the use of static methods in TypeScript, and a the standard way to handle things like this.
Thanks!