ByteNet icon indicating copy to clipboard operation
ByteNet copied to clipboard

index.d.ts `listen` method should use `Player` instead of `Player?`

Open NormalDuck opened this issue 1 year ago • 0 comments

I think the typing should switch from player?: Player to player: Player. This is because some arguments require Player, but the listen method returns Player | undefined which triggers the type system to raise an error. I have to use as keyword to force it to be Player type which is unnecessary. I am pretty sure player argument will return nil on the client side, I don't find any use case for using the nil so making the type from player?: Player to player: Player is more suitable I guess? before:

listen: (callback: (data: T["value"], player?: Player) => void) => void; 

after:

listen: (callback: (data: T["value"], player: Player) => void) => void;

NormalDuck avatar Jun 21 '24 17:06 NormalDuck