-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add defineConfig in hardhat/config
#7464
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
Conversation
🦋 Changeset detectedLatest commit: 7774d44 The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a defineConfig helper function to the Hardhat configuration API, providing a more ergonomic way to define Hardhat configurations with better type safety and autocomplete support for both TypeScript and JavaScript users.
Key changes:
- Adds
defineConfigfunction tohardhat/configthat wraps configuration objects - Updates template files to use the new
defineConfigpattern instead of explicit type annotations - Provides comprehensive JSDoc documentation explaining usage and limitations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| v-next/hardhat/src/config.ts | Implements the defineConfig function with type safety and documentation |
| v-next/hardhat/templates/hardhat-3/02-mocha-ethers/hardhat.config.ts | Updates template to use defineConfig pattern |
| v-next/hardhat/templates/hardhat-3/01-node-test-runner-viem/hardhat.config.ts | Updates template to use defineConfig pattern |
| v-next/example-project/hardhat.config.ts | Updates example project to demonstrate defineConfig usage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
fd2ca39 to
1fa8f85
Compare
|
I initially thought this wasn't going to work, as the template packages needs to point to the newest version of hardhat. But turns out that changesets also bumps the version range in the template packages :) I added a PR to the website that needs to be merged once this is released. Also, I updated the readmes of all the packages. I don't think this requires bumping their peerDependency on hardhat, as it's just a documentation doc. /cc @kanej |
|
@michalbrabec this can be re-reviewed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Also, after releasing this we should update the branches |
This is an idea that @fvictorio had, based on
eslint, but also used byastro.Instead of letting the user do:
we can have a
defineConfigfunction so it's just:which is shorter, type-safe, and has autocomplete on javascript too (!)
Note: we can't use
defineConfigin our own tests, because we use--isolatedDeclarations. I added a comment about it to the tsdoc of the function.Documentation update: NomicFoundation/hardhat-website#125