-
Notifications
You must be signed in to change notification settings - Fork 139
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
Fix correctness issue in ZkProgram typing #1962
Conversation
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.
haven't tested intellisense yet, but this seems like a great idea to me!
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.
I merged main and fixed the type error, let's land this!
[I in keyof MethodSignatures]: Get<MethodSignatures[I], 'auxiliaryOutput'>; | ||
} | ||
Config extends ConfigBaseType, | ||
_ extends unknown = unknown // weird hack that makes methods infer correctly when their inputs are not annotated |
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.
this extra line fixed the type error in foreign-field-gadgets.unit-test.ts
I also noticed that you could remove the errors when explicitly annotating method inputs in that file. Which would be good practice, since if you don't do it the inputs will be typed as any
inside the method.
however, I also found that adding any extra generic type argument makes the error disappear. no idea why!
since writing a zkprogram is already hard, because you tend to get confusing type errors on an incomplete ZkProgram definition, I think it's worth keeping this hack to remove one more confusing error.
Currently, the ZkProgram method declares a lot of convenience types as generic parameters. However, this leads to wrong typings when explicitly typing those generic parameters as they become inconsistent with the original ZkProgram's Config and therefore the resulting ZkProgram.
Furthermore, this hugely increases friction when trying to type anything outside of o1js that does stuff with ZkPrograms in some way.