I have an external library stored in our GitLab with the following structure:
export default abstract class Client{
protected someProperty: string | undefined;
protected static get baseUrl(): string {
return 'www.test.de';
}
}
as well as an index.js
:
//other exports
export {default as Client} from './src/clients/Client';
Once I installed the library via npm, I attempted to use the base class like this:
import {Client} from 'my-external-library';
public class MyClient extends Client{
public static async getIndex(){
let url = this.baseUrl + '/somepath';
}
}
However, upon installing the library in my project and attempting to work with the base class, I encountered the error message TS2339 Property 'baseUrl'
does not exist on type 'MyClient'.
How can I correctly export the Client base class so that it can be used without any error messages?
The code functions as expected aside from the error message.
Furthermore, when trying to access the property someProperty
after creating an instance of the class MyClient
, I also receive an error message:
let myClient = new MyClient();
let test = myClient.someProperty
How can I access the property of the abstract class Client
?
Update
When the abstract class is in my main project, I am able to access its properties. However, when it is in my external library, the class does not seem to be recognized, resulting in the "Property does not exist exception" with the following code:
let myClient = new MyClient();
let test = myClient.someProperty
Could this issue be related to
export { default as Client} from './src/clients/Client';
?