TypeScript runtime error when calling funtion of a class instance

Hi, I use 3.2.1, write authoritative multiplayer logic with typescript, I define a class in typescript, and new a instance of it,then assignment the instance to a property of MatchState, when I call function of the instance (like below), I get error “TypeError: Object has no member ‘testFun’ at matchJoinAttempt” , at the same time the property of the instance can be access.
class define
1

assgin instance to State in matchInit

call function in matchJoinAttempt

@xiaoNiuNew We could figure out how to improve this is a future release of the server but at the moment I would recommend against storing a function signature to the match state itself.

Why not put these functions on your match handler and pass in the state object?

Thank you for reply!
I’ve seen version 3.3.0 fix the problem mentioned above. I was just doing some tests.
As for why not put all the methods in the match handler, it is because part of my game client logic needs to be shared with the server. If the fighting logic is complex, there are still many abstract classes to facilitate the logic writing

1 Like