I am getting the following error:
Argument of type '(obj1: Class1) => JSX.Element' is not assignable to parameter of type '(value: Class1, index: number, array: Class1[]) => Element'.
Types of parameters 'obj1' and 'value' are incompatible.
Type 'Class1' is missing the following properties from type 'Class1': _privateField1, _privateField2 ts(2345)
I declare Class1 with the following code in ./global/types.d.ts
declare type ClassA = import('third-party-library').ClassA;
class Class1 extends ClassA {
// Inherited properties
inheritedProperty1: number;
inheritedProperty2: number;
entity: Entity | null;
readonly id: string;
constructor(superProp1, superProp2, obj1: Obj1Type);
}
which is defined here in ./model/Class1.ts:
class Class1 extends ClassA {
private _entity: Entity | null = null;
private _id: string;
get id() {
return this._id;
}
get entity() {
return this._entity;
}
set entity(entity: Entity | null) {
this._entity = entity;
}
constructor(superProp1, superProp2, obj1: Obj1Type) {
super(superProp1, superProp2);
this._id = generateId();
}
}
export default CustomHex;
tsconfig.json:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
},
"include": ["**/*.d.ts", "**/*.d.tsx", "**/*.ts", "**/*.tsx"]
}
Why do private fields need to be declared with the class? Is there a better or another way to organize my project besides adding private fields to ./global/types.d.ts?
The reason I am not importing type Class1 from ./model/Class1.ts is because Class2 or others may use Class1 (and vice versa) which would create a circular dependency.