diff --git a/src/lib_functional/candid/index.ts b/src/lib_functional/candid/index.ts index f9d4c6759b..9b39e53c2e 100644 --- a/src/lib_functional/candid/index.ts +++ b/src/lib_functional/candid/index.ts @@ -40,7 +40,8 @@ import { AzleResult, Result, AzleTuple, - AzleText + AzleText, + AzleVoid } from '../../lib_new'; export type TypeMapping = T extends () => any @@ -73,7 +74,7 @@ export type TypeMapping = T extends () => any ? float64 : T extends AzleFloat32 ? float32 - : T extends never[] + : T extends AzleVoid ? void : T extends AzleTuple ? { [K in keyof U]: TypeMapping } diff --git a/src/lib_new/primitives.ts b/src/lib_new/primitives.ts index 64f29e08af..fae5ebdf9b 100644 --- a/src/lib_new/primitives.ts +++ b/src/lib_new/primitives.ts @@ -225,7 +225,7 @@ export class Principal extends DfinityPrincipal { * a value, or `None` and does not. */ export type Opt = [Value] | []; -export const Void: [] = []; +export const Void: AzleVoid = AzleVoid as any; export type Void = void; /** @@ -302,6 +302,6 @@ export function Tuple(...types: T): AzleTuple { return new AzleTuple(types); } -export function Manual(t: any): void { +export function Manual(t: any): AzleVoid { return t; } diff --git a/src/lib_new/utils.ts b/src/lib_new/utils.ts index 4c17bf14ae..e9de3a961a 100644 --- a/src/lib_new/utils.ts +++ b/src/lib_new/utils.ts @@ -182,15 +182,13 @@ export function toParamIDLTypes(idl: CandidClass[]): IDL.Type[] { } export function toReturnIDLType(returnIdl: ReturnCandidClass): IDL.Type[] { - if (Array.isArray(returnIdl)) { - // If Void - if (returnIdl.length === 0) { - return []; - } - // Should be unreachable - return []; + const idlType = toIDLType(returnIdl, []); + + if (Array.isArray(idlType)) { + return [...idlType]; } - return [toIDLType(returnIdl, [])]; + + return [idlType]; } type CandidMap = { [key: string]: any };