TypeScript Promise<undefined> instead of Promise<void>

When I generate the declaration for functions for which I don’t except any results, I get undefined as return types instead of void.

Am I doing something wrong in my Motoko code or is it just the way the dfx command generates the TypeScript declarations?

public shared({ caller }) func set(deck: Deck) : async () {
};

generates in ts :point_right:

set: (arg_0: Deck) => Promise<undefined>;

but I would like

set: (arg_0: Deck) => Promise<void>;

That’s expected. () means zero return value in Candid, so it maps to undefined in JS. If the Motoko code returns async (Null), you get Promise<null> in JS.

3 Likes

Aright. Thx for the feedback.

1 Like