Didc - TS2709: Cannot use namespace IDL as a type

I just generated a TypeScript definition file using the latest version of didc (v0.3.6), but I ended up with an invalid TypeScript file. Specifically, I encountered the error TS2709: Cannot use namespace 'IDL' as a type.

I’m using a script, but the didc command I use is straightforward: didc bind -t ts "${didfile}" >"${tsfile}".

I also face the issue with both the ICP ledger and II did files, therefore I assume it is a standardised error.

In this project the versio of @dfinity/candid is v0.20.2.

Why am I facing this issue, and how can it be fixed?

1 Like

@NathanosDev Can you take a look? It seems to come from your PR: fix: add missing typescript export for init args by nathanosdev · Pull Request #510 · dfinity/candid · GitHub

Yes, I know what the issue is, I can open a PR to fix it.

The generated output should be:

export declare const init: ({ idl }: { idl: typeof IDL }) => IDL.Type[];

instead of:

export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[];

Sorry @peterparker and thanks for reporting it!

2 Likes

No worries. It’s literally and by far not the biggest third party issue I discovered while implementing my feature (adding the ICP ledger to Juno docker). Thanks for the feedback and upcoming fix!