leonardssh / rage-rpc

A universal, asynchronous RPC implementation for RAGE Multiplayer
https://rage.mp
MIT License
12 stars 7 forks source link

PlayerMp & BrowserMp is not assignable #1

Closed leonardssh closed 2 years ago

leonardssh commented 2 years ago

Current Behavior:

At the moment, properties from ProcedureListenerInfo cannot be used in the rage environment because they are hardcoded and do not have all the required properties and methods.

https://github.com/LeonardSSH/rage-rpc/blob/928742602a99dfbeda577e687f072166cd0d073d/types/index.d.ts#L1-L10

image

Possible solution:

export declare type ProcedureListener<T = any, K = any> = (args: any, info: ProcedureListenerInfo<T, K>) => any;

export declare interface ProcedureListenerInfo<T = any, K = any> {
    environment: string;
    id?: string;
    player?: T;
    browser?: K;
}
function myFunction({ player /* :any */ }: rpc.ProcedureListenerInfo) { ... }

// should be

function myFunction({ player /* :PlayerMp */  }: rpc.ProcedureListenerInfo<PlayerMp>) { ... }