Remove the overloads in epheraml transport

This commit is contained in:
2026-02-27 00:38:27 +11:00
parent ddcd638937
commit 01bc9a8d15

View File

@@ -17,17 +17,17 @@ export class EphemeralTransport {
return response;
}
async receive<T extends ZodType>(url: string, schema: T): Promise<output<T>>;
async receive(url: string): Promise<unknown>;
async receive(url: string, schema?: ZodType): Promise<unknown> {
async receive<T extends ZodType | undefined>(url: string, schema?: T): Promise<T extends undefined ? unknown : output<T>> {
const transport = await this.transports(url);
const message = await transport.waitFor('message', () => true);
transport.disconnect();
if (schema) {
return schema.parse(message);
// TODO: Figure out how the hell to fix this assertion. It shouldnt be needed, but TS is being a bitch.
return schema.parse(message) as T extends undefined ? unknown : output<T>;
}
return message;
// TODO: Figure out how the hell to fix this assertion. It shouldnt be needed, but TS is being a bitch.
return message as T extends undefined ? unknown : output<T>;
}
}