You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a contract named Provider. When I generate Typechain with target=ethers-v6, Provider_factory will unnecessarily import Provider from ethers. I checked other contracts, but there’s no Provider imported.
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import {
Contract,
ContractFactory,
ContractTransactionResponse,
Interface,
} from "ethers";
import type {
Signer,
ContractDeployTransaction,
Provider,
ContractRunner,
} from "ethers";
import type { NonPayableOverrides } from "../common";
import type { Provider, ProviderInterface } from "../Provider";
const _abi = [
{
inputs: [],
stateMutability: "nonpayable",
type: "constructor",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint256",
name: "newNumber",
type: "uint256",
...
I think this is a bug in Typechain. This incorrect import will lead to an error and an ambiguous type for the Provider when used in other scripts. 2 errors in Provider__factory.ts
Duplicate identifier 'Provider'.
Property 'deploy' in type 'Provider__factory' is not assignable to the same property in base type 'ContractFactory<any[], BaseContract>'. Type '(overrides?: (NonPayableOverrides & { from?: string | undefined; }) | undefined) => Promise<Provider & { deploymentTransaction(): ContractTransactionResponse; }>' is not assignable to type '(...args: ContractMethodArgs<any[]>) => Promise<BaseContract & { deploymentTransaction(): ContractTransactionResponse; } & Omit<...>>'. Type 'Promise<Provider & { deploymentTransaction(): ContractTransactionResponse; }>' is not assignable to type 'Promise<BaseContract & { deploymentTransaction(): ContractTransactionResponse; } & Omit<BaseContract, keyof BaseContract>>'. Type 'Provider & { deploymentTransaction(): ContractTransactionResponse; }' is not assignable to type 'BaseContract & { deploymentTransaction(): ContractTransactionResponse; } & Omit<BaseContract, keyof BaseContract>'. Type 'Provider & { deploymentTransaction(): ContractTransactionResponse; }' is missing the following properties from type 'BaseContract': target, interface, runner, filters, and 11 more.
Hi, I notice that you are importing provider twice. 1 from ether and another from /Provider. If you need both you can change the name of 1 to avoid conflicts. Could you provide more code and context around the other error message please?
Hi @NecEthan, Provider__factory.ts is auto-generated by TypeChain, I think Typechain is considering Provider contract's name as Provider of ethers, then Typechain will import both of them (contract instance and ethers) and I didn't import any of it. As I mentioned, if the Provider contract instance needs to be imported into another script, it will lead to ambiguous types. I can change it in the development environment after TypeChain generates it, but in the production environment or CI/CD, this file is generated automatically, and I cannot change anything.
I have a contract named
Provider
. When I generate Typechain withtarget=ethers-v6
,Provider_factory
will unnecessarily importProvider
fromethers
. I checked other contracts, but there’s noProvider
imported.This is my contract:
Import part of
Provider__factory.ts
:I think this is a bug in Typechain. This incorrect import will lead to an error and an ambiguous type for the Provider when used in other scripts. 2 errors in
Provider__factory.ts
Duplicate identifier 'Provider'.
Property 'deploy' in type 'Provider__factory' is not assignable to the same property in base type 'ContractFactory<any[], BaseContract>'. Type '(overrides?: (NonPayableOverrides & { from?: string | undefined; }) | undefined) => Promise<Provider & { deploymentTransaction(): ContractTransactionResponse; }>' is not assignable to type '(...args: ContractMethodArgs<any[]>) => Promise<BaseContract & { deploymentTransaction(): ContractTransactionResponse; } & Omit<...>>'. Type 'Promise<Provider & { deploymentTransaction(): ContractTransactionResponse; }>' is not assignable to type 'Promise<BaseContract & { deploymentTransaction(): ContractTransactionResponse; } & Omit<BaseContract, keyof BaseContract>>'. Type 'Provider & { deploymentTransaction(): ContractTransactionResponse; }' is not assignable to type 'BaseContract & { deploymentTransaction(): ContractTransactionResponse; } & Omit<BaseContract, keyof BaseContract>'. Type 'Provider & { deploymentTransaction(): ContractTransactionResponse; }' is missing the following properties from type 'BaseContract': target, interface, runner, filters, and 11 more.
My environment:
The text was updated successfully, but these errors were encountered: