type SerializableValue = undefined | null | string | number | boolean | { [key: string]: SerializableValue; } | SerializableValue[]; type SerializableReturnValue = SerializableValue | void | Promise | Promise; type AllSerializableValues = A extends [infer First, ...infer Rest] ? First extends SerializableValue ? AllSerializableValues : false : true; type Method = (...args: any[]) => any; type RPCMethod = T extends Method ? T extends (...arg: infer A) => infer R ? AllSerializableValues extends true ? R extends SerializableReturnValue ? T : never : never : never : never; export type { Method, RPCMethod, SerializableReturnValue, SerializableValue };