Skip to content

Commit

Permalink
typings: Fix RPC.register overload
Browse files Browse the repository at this point in the history
  • Loading branch information
xLuxy committed Oct 30, 2023
1 parent 8adcf79 commit 3f2665c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions types/client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,9 @@ declare module "@altv/client" {
export type GenericRpcEventHandler<T extends unknown[]> = (...args: T) => Promise<unknown> | unknown;

export function send<E extends keyof altShared.RPC.CustomPlayerToServerRpcEvent>(rpcName: E, ...args: Parameters<altShared.RPC.CustomPlayerToServerRpcEvent[E]>): Promise<ReturnType<altShared.RPC.CustomPlayerToServerRpcEvent[E]>>;

export function register<E extends keyof altShared.RPC.CustomServerToPlayerRpcEvent>(rpcName: E, handler: GenericRpcEventHandler<Parameters<altShared.RPC.CustomServerToPlayerRpcEvent[E]>>): RPCHandler;
export function register<E extends string>(rpcName: Exclude<E, keyof altShared.RPC.CustomServerToPlayerRpcEvent>, handler: GenericRpcEventHandler<unknown[]>): RPCHandler;
}

// DO NOT TOUCH THIS - This is only here so client / server can extend Utils namespace using merging
Expand Down
2 changes: 1 addition & 1 deletion types/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@altv/client",
"version": "0.0.6",
"version": "0.0.7",
"description": "This package contains the type definitions for the alt:V JS module v2 client types",
"types": "index.d.ts",
"files": [
Expand Down
3 changes: 2 additions & 1 deletion types/server/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,8 @@ declare module "@altv/server" {
export namespace RPC {
export type CustomPlayerRpcEventHandler<T extends unknown[], U extends Player = Player> = (player: U, ...args: T) => unknown | Promise<unknown>;

export function register<E extends keyof altShared.RPC.CustomPlayerToServerRpcEvent, T extends Player>(rpcName: E, handler: CustomPlayerRpcEventHandler<Parameters<altShared.RPC.CustomPlayerToServerRpcEvent[E]>, T>): RPCHandler;
export function register<U extends Player = Player, E extends keyof altShared.RPC.CustomPlayerToServerRpcEvent>(rpcName: E, handler: CustomPlayerRpcEventHandler<Parameters<altShared.RPC.CustomPlayerToServerRpcEvent[E]>, U>): RPCHandler;
export function register<U extends Player = Player, E extends string>(rpcName: Exclude<E, keyof altShared.RPC.CustomPlayerToServerRpcEvent>, handler: CustomPlayerRpcEventHandler<unknown[], U>): RPCHandler;
}

export abstract class ConnectionInfo {
Expand Down
2 changes: 1 addition & 1 deletion types/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@altv/server",
"version": "0.0.6",
"version": "0.0.7",
"description": "This package contains the type definitions for the alt:V JS module v2 server types",
"types": "index.d.ts",
"files": [
Expand Down

0 comments on commit 3f2665c

Please sign in to comment.