I am facing an issue with my TypeScript class implementation:
class FooClass
{
private _Id:number=0 ;
private _PrCode: number =0;
public get Id(): number {
return this._Id;
}
public set Id(id: number) {
this._Idproduit = id;
}
public get PrCode(): number {
return this._PrCode;
}
public set PrCode(prCode: number) {
this._PrCode = prCode;
}
}
When I create a reactive variable inside a component like this:
const Model = ref<FooClass|null>(null);
and try to pass it to a function as shown below:
let FooFunc = (FooClass|null) =>{//Do something}
using FooFunct(Model)
, I encounter the following error:
Argument of type '{ Id: number; PrCode: number; }is not assignable to parameter of type 'FooClass'. type { Id: number; PrCode: number; } is missing the following properties from type 'FooClass': {_Id,_PrCode}
It seems that the Ref Function is trying to access "the private fields" directly instead of using the getters and setters. How can I solve this issue?