Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error Unsafe argument of type any[] assigned to a parameter of type Type<any>[] #549

Open
peterpeterparker opened this issue May 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@peterpeterparker
Copy link
Member

peterpeterparker commented May 12, 2024

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 type Type<any>[] @typescript-eslint/no-unsafe-argument

(line 52 being the encode(init...) usage)

Liwise, my editor complains as well:

Capture d’écran 2024-05-12 à 21 24 51
@peterpeterparker peterpeterparker added the enhancement New feature or request label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant