Independent of #156, but found alongside it.
The generated wrapper declares Candid types and the actor class into the same module scope, so a Candid type whose name equals the derived class name produces a duplicate identifier.
Reproduction
printf 'type My_backend = record { a : nat };\nservice : () -> { test: (My_backend) -> () }\n' > my_backend.did
npx @icp-sdk/bindgen --did-file ./my_backend.did --out-dir ./out --force
out/my_backend.ts:
export interface My_backend { // from the candid type
export class My_backend implements my_backendInterface { // from the service name
Both are emitted by add_type_definitions and create_actor_class into one module. Nothing detects the clash.
Notes
Needs a design decision rather than a mechanical fix — either uniquify the class name against the type names in env, or document the limitation and fail generation with a clear error instead of emitting a broken file. Failing loudly seems preferable to silently renaming a public export.
Verified on @icp-sdk/bindgen@0.4.0 and main.
Independent of #156, but found alongside it.
The generated wrapper declares Candid types and the actor class into the same module scope, so a Candid type whose name equals the derived class name produces a duplicate identifier.
Reproduction
out/my_backend.ts:Both are emitted by
add_type_definitionsandcreate_actor_classinto one module. Nothing detects the clash.Notes
Needs a design decision rather than a mechanical fix — either uniquify the class name against the type names in
env, or document the limitation and fail generation with a clear error instead of emitting a broken file. Failing loudly seems preferable to silently renaming a public export.Verified on
@icp-sdk/bindgen@0.4.0andmain.