-
-
Notifications
You must be signed in to change notification settings - Fork 945
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
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/[email protected] |
@@ -84,33 +84,34 @@ export type SimulateContractParameters< | |||
> | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never knew about this syntax! Where can I find the docs?
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.
Found: microsoft/TypeScript#48240. nice
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.
Yep! Here's the release notes as well:
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
SimulateContractReturnType
based 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
chain
as covariant required a// @ts-expect-error
comment (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
SimulateContractReturnType
that 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 asout
only 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/attest
to 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/attest
to^0.10.2
simulateContract.ts