I have the following structures:
class Base
{
constructor(private input: number) {
// ...
}
getInput() {
// ...
}
/**
* Creat new instance
*/
public static fromGregory(i: number) {
//...
return new this(i);
}
}
class Child1 extends Base
{
public getDegrees() {
// ...
}
}
const test = Child1.fromGregory(1);
test.getInput(); // Correct type
test.getAge(); //Type Error: Property 'getAge' does not exist on type 'Base'.
When i make a new instance with child class by calling static method from parent, Typescript unknow about child’s public methods. How can I correct type for theme?
Thanks,