I am giving error @State
here. error is here . how can I solve this error. I am using typescript 5.4.5
version.
Unable to resolve signature of property decorator when called as an expression.
The runtime will invoke the decorator with 3 arguments, but the decorator expects 2.ts(1240)
Decorator function return type is 'ClassAccessorDecoratorResult<unknown, unknown>' but is expected to be 'void' or 'any'.ts(1271)
function State<This, Return>(
target: ClassAccessorDecoratorTarget<This, Return>,
_context: ClassAccessorDecoratorContext<This, Return>
) {
const result: ClassAccessorDecoratorResult<This, Return> = {
get(this: This) {
return target.get.call(this);
},
set(e: any) {
// console.log(e)
target.set.call(this, e)
},
};
return result;
}
class GlobalStore {
constructor() { }
@State
accessor username = 'test'
setUsername(data: string): void {
this.username = data
}
getUsername(): string {
return this.username
}
}