docs: add twoslash compile-checking to Hardhat plugin guide - #94
Conversation
Convert the TS code blocks in the Hardhat plugin guide to twoslash, validated against @iexec-nox/nox-hardhat-plugin@0.2.0 and its Hardhat toolbox peers. Adds hidden ---cut--- preambles where needed to resolve Hardhat's viem/ethers type-extension augmentations without changing any rendered example code.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Update the version ranges added for twoslash-checking the Hardhat guide to match the currently-published releases instead of the plugin's peerDependency floors. All versions were already what npm resolved to in the lockfile, so this only changes the package.json range text.
There was a problem hiding this comment.
Pull request overview
Note
Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.
This PR updates the Hardhat guide to use twoslash-enabled TypeScript snippets (for type-checked documentation examples) and adds the required Hardhat/Nox dependencies to support that docs build.
Changes:
- Convert multiple TypeScript code fences in the Hardhat guide to
twoslashand add// ---cut---scaffolding for cleaner rendered snippets. - Add Hardhat, Nox plugin/contracts, and Hardhat plugin dependencies to
package.json.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/guides/build-confidential-smart-contracts/hardhat.md | Enables twoslash for Hardhat guide snippets and adds hidden imports for typechecking. |
| package.json | Adds Hardhat/Nox/Hardhat-plugin dependencies needed for twoslash compilation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Expand the "Connecting to an http network" example to show the plugin import, plugins array, and solidity field alongside the networks.nox block, rather than only the isolated networks fragment. The plugin import is now visible in the rendered snippet, so the hidden ---cut--- import used only to pull in the nox type-extension augmentation is no longer needed.
Apply the same treatment as the http network example: show the plugin import, plugins array, and solidity field alongside the networks block, rather than only the isolated networks fragment, for consistency between the two network sections.
Move @iexec-nox/handle and the packages added for the Hardhat guide's twoslash examples (@iexec-nox/nox-hardhat-plugin, @iexec-nox/nox-protocol-contracts, hardhat, @nomicfoundation/hardhat-toolbox-viem, @nomicfoundation/hardhat-ethers) from dependencies to devDependencies, alongside ethers/viem. This is a static VitePress site: everything is bundled at build time (including real site code like PiggyBankDemo.vue, which imports @iexec-nox/handle), and there is no separate runtime npm install step that would omit devDependencies, so dependencies is reserved for the handful of packages the build tooling itself needs unconditionally.
Requested by Pierre Jeanjacquot · Slack thread
Summary
Adds
twoslashcompile-checking to the TypeScript code examples insrc/guides/build-confidential-smart-contracts/hardhat.md, validated against@iexec-nox/nox-hardhat-plugin@0.2.0and its Hardhat toolbox peers.tsfenced blocks in the guide (including the Viem/Ethers code-grouptabs) are now type-checked at build time via twoslash.
against the v0.2.0 API, so this is purely an annotation/verification change.
// ---cut---marker, so it type-checks but never renders) purely to pull in Hardhat's
ambient type-extension augmentations that a standalone snippet wouldn't
otherwise see:
import '@iexec-nox/nox-hardhat-plugin'so the
noxfield onHttpNetworkUserConfigresolves.import '@nomicfoundation/hardhat-toolbox-viem'so
NetworkConnection.viemresolves.import '@nomicfoundation/hardhat-ethers'so
NetworkConnection.ethersresolves.Dependencies
Added to
package.jsonunderdependencies(matching the existing pattern forother twoslash-checked packages like
@iexec-nox/handle,ethers,viem):@iexec-nox/nox-hardhat-plugin@0.2.0@iexec-nox/nox-protocol-contractsandhardhat(required peers, per theplugin's
peerDependencies)@nomicfoundation/hardhat-toolbox-viemand@nomicfoundation/hardhat-ethers(needed so both the Viem and Ethers example tabs keep compiling)
viem/etherswere already present indevDependenciesand reused as-is.package-lock.jsonwas regenerated vianpm install.Testing
npm run buildpasses cleanly (vitepress build, which runs the twoslashtype-checking).
npm run format/npm run check-formatboth pass with no changes needed.