diff --git a/CHANGELOG.md b/CHANGELOG.md index 552de58a8..6decd667e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- fix: export the `GenericIdlFuncArgs`, `GenericIdlFuncRets`, and `GenericIdlServiceFields` types from `@dfinity/candid`. + ## [3.2.0] - 2025-08-07 - fix: do not subtract the replica permitted clock drift when calculating the ingress expiry. diff --git a/packages/candid/src/idl.ts b/packages/candid/src/idl.ts index 6a6205259..9873efb1c 100644 --- a/packages/candid/src/idl.ts +++ b/packages/candid/src/idl.ts @@ -1684,8 +1684,15 @@ export class PrincipalClass extends PrimitiveType { } } -type GenericFuncArgs = [Type, ...Type[]] | []; -type GenericFuncRets = [Type, ...Type[]] | []; +/** + * The generic type of the arguments of an {@link Func|IDL Function}. + */ +export type GenericIdlFuncArgs = [Type, ...Type[]] | []; + +/** + * The generic type of the return values of an {@link Func|IDL Function}. + */ +export type GenericIdlFuncRets = [Type, ...Type[]] | []; /** * Represents an IDL function reference. @@ -1694,8 +1701,8 @@ type GenericFuncRets = [Type, ...Type[]] | []; * @param annotations Function annotations. */ export class FuncClass< - Args extends GenericFuncArgs = GenericFuncArgs, - Rets extends GenericFuncRets = GenericFuncRets, + Args extends GenericIdlFuncArgs = GenericIdlFuncArgs, + Rets extends GenericIdlFuncRets = GenericIdlFuncRets, > extends ConstructType<[PrincipalId, string]> { get typeName() { return IdlTypeName.FuncClass; @@ -1806,11 +1813,14 @@ export class FuncClass< } } -type GenericServiceFields = Record; +/** + * The generic type of the fields of an {@link Service|IDL Service}. + */ +export type GenericIdlServiceFields = Record; export class ServiceClass< K extends string = string, - Fields extends GenericServiceFields = GenericServiceFields, + Fields extends GenericIdlServiceFields = GenericIdlServiceFields, > extends ConstructType { get typeName() { return IdlTypeName.ServiceClass; @@ -2327,8 +2337,8 @@ export function Rec(): RecClass { * @returns new FuncClass */ export function Func< - Args extends GenericFuncArgs = GenericFuncArgs, - Ret extends GenericFuncRets = GenericFuncRets, + Args extends GenericIdlFuncArgs = GenericIdlFuncArgs, + Ret extends GenericIdlFuncRets = GenericIdlFuncRets, >(args: Args, ret: Ret, annotations: string[] = []): FuncClass { return new FuncClass(args, ret, annotations); } @@ -2340,7 +2350,7 @@ export function Func< */ export function Service< K extends string = string, - Fields extends GenericServiceFields = GenericServiceFields, + Fields extends GenericIdlServiceFields = GenericIdlServiceFields, >(t: Fields): ServiceClass { return new ServiceClass(t); } diff --git a/packages/candid/src/index.ts b/packages/candid/src/index.ts index 34cae43d0..b7cfc5e12 100644 --- a/packages/candid/src/index.ts +++ b/packages/candid/src/index.ts @@ -1,6 +1,11 @@ export * from './candid-ui.ts'; export * from './candid-core.ts'; export * as IDL from './idl.ts'; +export { + type GenericIdlFuncArgs, + type GenericIdlFuncRets, + type GenericIdlServiceFields, +} from './idl.ts'; export * from './utils/hash.ts'; export * from './utils/leb128.ts'; export * from './utils/buffer.ts';