abstract class A<T> {
protected abstract method1: () => T;
}
class B extends A<string> {
protected method1 = () => "helloword";
}
So I did :
a.ts :
import { Model, modelAction } from "mobx-keystone";
function createA<T>() {
abstract class A extends Model({}) {
@modelAction
protected abstract method1: () => T;
}
return A;
}
export default createA;
b.ts :
import { ExtendedModel, model } from "mobx-keystone";
import createA from "./a";
@model("B")
class B extends ExtendedModel(createA<string>(), {}) {
protected method1 = () => "helloword";
}
export default B;
but i'm getting those errors :
Return type of exported function has or is using private name 'A'.
'extends' clause of exported class 'B' has or is using private name 'A'.
errors
![Screenshot 2022-07-07 at 16 05 27](https://user-images.githubusercontent.com/26276665/177804777-d4f73d37-f681-47af-8f8a-f7de70343a57.png)
![Screenshot 2022-07-07 at 16 05 19](https://user-images.githubusercontent.com/26276665/177804800-f0f2d102-bf42-4990-9ddc-f2250e34451e.png)
If I set declaration to false in my tsconfig.js, there are no more errors. But I need declaration to be true because my project is a lib so I need to generate and export .d.ts.
Have you looked at the "Factory Pattern / Generics" section in the docs? If you don't need runtime type-checking, you can have generic models without a factory.
I would like to create something like this:
So I did :
a.ts :
b.ts :
but i'm getting those errors :
Return type of exported function has or is using private name 'A'.
'extends' clause of exported class 'B' has or is using private name 'A'.
errors
![Screenshot 2022-07-07 at 16 05 27](https://user-images.githubusercontent.com/26276665/177804777-d4f73d37-f681-47af-8f8a-f7de70343a57.png) ![Screenshot 2022-07-07 at 16 05 19](https://user-images.githubusercontent.com/26276665/177804800-f0f2d102-bf42-4990-9ddc-f2250e34451e.png)If I set
declaration
to false in my tsconfig.js, there are no more errors. But I needdeclaration
to be true because my project is a lib so I need to generate and export .d.ts.Can you help me to figure out what's wrong ?
Thanks :)