I've got the following TypeScript classes:
class AnyBackendRoute {
public getProps() {...}
}
class AnyBFFRoute extends AnyBackendRoute {
public getProps() {...}
}
class UserSignUpRoute extends AnyBFFRoute {
public getSomethingElse() {...}
}
I transpile them to commonJS-ES6 and include them in another file (.js).
In the original code (in test file, before transpilation) I can easily do:
const route = new UserSignUpRoute()
// getProps() visible from AnyBFFRoute as it's a public method
console.log(route.getProps())
but when I try the same thing with the transpiled code (that contains also .d.ts file), I am getting a TypeScript error:
Type 'UserSignUpRoute' is missing the following properties from type 'AnyBFFRoute': getProps
In the transpiled code I would expect to find something like:
UserSignUpRoute.prototype.getProps = function () {
return this.props;
};
but it's not there! Same, in the appropriate .d.ts
file. I cannot see getProps()
method from the parent class but only the local public methods.
Am I wrong to think those methods should be available in the UserSignUpRoute.js as well?
If so, why there is an inconsistency so that I can call route.getProps()
in the pre-transpiled code and not afterwards?