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

Types are not generated if hardhat config file is not typescript #879

Open
FFdhorkin opened this issue Oct 13, 2023 · 1 comment
Open

Types are not generated if hardhat config file is not typescript #879

FFdhorkin opened this issue Oct 13, 2023 · 1 comment

Comments

@FFdhorkin
Copy link

I have a package.json with "type": "module" and am attempting to get Hardhat to play nice with TypeScript and ESM.

I've noticed that if I have a config file hardhat.config.cjs, then it doesn't generate any types. However, if I rename that same file to hardhat.config.cts (with a test patch for hardhat so that it supports this config file), suddenly it generates types. Here's a log to demo this:

╰─ ls hardhat*                                                                                                       ─╯
hardhat.config.cjs

╰─ hardhat clean && hardhat compile                                                                                  ─╯
Compiled 57 Solidity files successfully (evm target: paris).

╰─ mv hardhat.config.cjs hardhat.config.cts                                                                          ─╯

╰─ hardhat clean && hardhat compile                                                                                  ─╯
Generating typings for: 57 artifacts in dir: typechain-types for target: ethers-v6
Successfully generated 134 typings!
Compiled 57 Solidity files successfully (evm target: paris).
@simpsonphile
Copy link

had same problem

i set
alwaysGenerateOverloads: true,
in hardhat.config.js

module.exports = {
  solidity: "0.8.24",
  defaultNetwork: 'localhost',
  typechain: {
    // outDir: "./artifacts/types",  // Directory where TypeChain generates types
    target: "ethers-v6",  // Specify ethers.js version
    alwaysGenerateOverloads: true,
    dontOverrideCompile: false,
  }
};

and works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@simpsonphile @FFdhorkin and others