server triggerBrowser typization improvement
This commit is contained in:
parent
c94bab24f2
commit
7a506a02e2
@ -6,6 +6,7 @@ import {
|
||||
RageFW_CefArgs,
|
||||
RageFW_CefEvent,
|
||||
RageFW_CefReturn,
|
||||
_CefEventHasArgs,
|
||||
_ClientEventHasArgs,
|
||||
_ServerEventHasArgs,
|
||||
RageFW_ClientEvent,
|
||||
@ -128,7 +129,9 @@ class Player {
|
||||
public triggerBrowser<EventName extends RageFW_CefEvent>(
|
||||
player: PlayerMp,
|
||||
eventName: EventName,
|
||||
args: RageFW_CefArgs<EventName>,
|
||||
...args: _CefEventHasArgs<EventName> extends true
|
||||
? [RageFW_CefArgs<EventName>]
|
||||
: []
|
||||
): Promise<RageFW_CefReturn<EventName>> {
|
||||
return rpc.callBrowsers(player, eventName, args)
|
||||
}
|
||||
|
@ -9,3 +9,10 @@ export type RageFW_CefArgs<K extends RageFW_CefEvent> = Parameters<
|
||||
export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType<
|
||||
RageFW_ICustomCefEvent[K]
|
||||
>
|
||||
|
||||
export type _CefEventHasArgs<EventName extends keyof RageFW_ICustomCefEvent> =
|
||||
keyof RageFW_ICustomCefEvent extends never
|
||||
? false
|
||||
: Parameters<RageFW_ICustomCefEvent[EventName]>[0] extends undefined
|
||||
? false
|
||||
: true
|
||||
|
Loading…
Reference in New Issue
Block a user