Skip to content
This repository was archived by the owner on Dec 23, 2025. It is now read-only.

Conversation

@afsalthaj
Copy link
Contributor

@afsalthaj afsalthaj commented Dec 16, 2025

Fixes #182

For the following agent, with rpc calls

import {
    BaseAgent,
    agent,
    WithRemoteMethods
} from '@golemcloud/golem-ts-sdk';

@agent()
class HelloAgent extends BaseAgent {
    private readonly client: WithRemoteMethods<RemoteAgent>;
    private value: number = 0;

    constructor(name: string) {
        super()
        this.client = RemoteAgent.get(name);
    }

    async foo(input: MyResult1): Promise<MyResult1> {
       return await this.client.qux(input);
    }

    async bar(input: MyResult2): Promise<MyResult2> {
        return await this.client.corge(input);
    }

    async baz(input: MyResult3): Promise<MyResult3> {
        return await this.client.grault(input);
    }
}

@agent()
class RemoteAgent extends BaseAgent {
    private readonly id: string;

    constructor(name: string) {
        super()
        this.id = name;
    }

    async qux(input: MyResult1): Promise<MyResult1> {
        return input;
    }

    async corge(input: MyResult2): Promise<MyResult2> {
        return input;
    }

    async grault(input: MyResult3): Promise<MyResult3> {
        return input
    }
}


type MyResult1 = { tag: 'ok', okVal: void } | { tag: 'err', errVal: string };
type MyResult2 = { tag: 'ok', okVal: number } | { tag: 'err', errVal: void };
type MyResult3  = { tag: 'ok', okVal: void } | { tag: 'err', errVal: void };

Manual tests:

image

Also, exports shows

image

I will be adding these as tests back in golem once released

@afsalthaj afsalthaj changed the title Allow void in custom result type Allow void in ok/err in custom result type Dec 17, 2025
@vigoo vigoo merged commit 0178a15 into main Dec 17, 2025
2 checks passed
@vigoo vigoo deleted the fix_result_type branch December 17, 2025 07:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-SDK custom Result ("result shaped") types are not supporting void in ok and err variants

3 participants