I have the following class that I would like to access in a different file:
export class Person {
constructor() {}
static getDatabaseId(): string {
return '...';
}
}
It's injected and not actually imported. I want to make clear that it is a constructor function and that it can create new instances of type Person. This is what I tried:
let PersonConstructor: {new(): Person};
// inject Person constructor function
beforeEach(inject((_Person_) => {
PersonConstructor = _Person_;
}));
// create a new instance but also access the static variables
const p: Person = new PersonConstructor();
PersonConstructor.getDatabaseId(); // "property does not exist"
The compiler doesn't complain about instantiating new instances from Person anymore but of course it also doesn't know of Person's static variables now since they are missing on the newly declared type.
How can this be typed correctly?
getDatabaseId()method.