refactor: add explicit annotations to SimulateContractReturnType#2557
refactor: add explicit annotations to SimulateContractReturnType#2557
Conversation
|
|
@ssalbdivad is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@arktype/attest@0.8.0 |
| export type SimulateContractReturnType< | ||
| abi extends Abi | readonly unknown[] = Abi, | ||
| functionName extends ContractFunctionName< | ||
| out abi extends Abi | readonly unknown[] = Abi, |
There was a problem hiding this comment.
Never knew about this syntax! Where can I find the docs?
There was a problem hiding this comment.
Yep! Here's the release notes as well:
There was a problem hiding this comment.
Sorry, not adding anything meaningful to the PR, but I am also only learning of this now and this is really cool. Cool to see more nuanced use of typescript and the performance comparison is really interesting too. How did you generate that graph for tsc build btw?
There was a problem hiding this comment.
@Yuripetusko There's a command for it in the attest CLI.
It's a thin wrapper around tsc --generateTrace + https://github.com/microsoft/typescript-analyze-trace
|
@tmm @jxom Is there any other information I can provide to get this merged? It made such a big difference for @latticexyz and I'd be it could have a significant impact more broadly as well. |
|
Deployment failed with the following error: |
This PR adds explicit variance annotations to
SimulateContractReturnTypebased on some type performance investigation done for Mud as documented here.In this case, avoiding the variance checks reduced the check time for a simple repo by over a second locally.
I based the annotations on those that were inferred from the TS compiler as documented in the trace here (from the Mud PR):
Unfortunately, it is impossible to annotate a bivariant relationship directly, and treating
chainas covariant required a// @ts-expect-errorcomment (I use this strategy somewhat often to cast variance inarktype, so no significant cause for concern).I don't completely understand all the contexts in which this type is used or how common it is to compare multiple instances of
SimulateContractReturnTypethat would cause these variance annotations to matter, so if you find you need to make adjustments to the annotations (e.g. by labeling more parameters asoutonly with error comments), please feel free to do so.It is likely if you are interested in optimizing perf, there are more scenarios like this that exist that you could find via tracing where explicit annotations could result in significant downstream perf improvements.
I also took the opportunity to update
@arktype/attestto the latest version under its new primary alias,@ark/attest.Let me know if you have any questions or if there is anything I can chance!
PR-Codex overview
This PR updates dependencies related to testing and documentation tools. It also refactors type definitions for better clarity.
Detailed summary
@ark/attestto^0.10.2simulateContract.ts