error Unsafe argument of type `any[]` assigned to a parameter of type `Type<any>[]`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 301
- Forks
- 85
- Avg merge
- 1h 4m
- Merged PRs (30d)
- 4
Description
Issue
TypeScript types description for init function generated by Candid are not descriptive or generic enough to comply with linters.
For example, the generated types of the ICP ledger:
export declare const init: (args: {IDL: typeof IDL}) => IDL.Type[];
Have to be implemented as following:
const initArgs: InitArgs = {
send_whitelist: [],
token_symbol: ['ICP'],
transfer_fee: [{e8s: 10_000n}],
minting_account: minterAccountIdentifier,
maximum_number_of_accounts: [],
accounts_overflow_trim_quantity: [],
transaction_window: [],
max_message_size_bytes: [],
icrc1_minting_account: [],
archive_options: [],
initial_values: [[ledgerAccountIdentifier, {e8s: 100_000_000_000n}]],
token_name: ['Internet Computer'],
feature_flags: []
};
const upgradeArgs = [];
const arg = IDL.encode(init({IDL}), {Init: initArgs});
But lead to following linter error when examinated by eslint:
52:28 error Unsafe argument of type
any[]assigned to a parameter of typeType<any>[]@typescript-eslint/no-unsafe-argument
(line 52 being the encode(init...) usage)
Liwise, my editor complains as well:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Candid TypeScript declaration generation for the init function and trace the generated IDL.Type[] into the shown IDL.encode(init({IDL}), ...) call. Done means the generated types are descriptive and generic enough that this ledger-style usage no longer triggers TypeScript or ESLint unsafe-argument diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100