Open
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:
