Skip to content
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

Accept .provable and some other type improvements #284

Merged
merged 7 commits into from
Jul 23, 2024

Conversation

mitschabaude
Copy link
Collaborator

@mitschabaude mitschabaude commented Jul 16, 2024

companion for o1-labs/o1js#1751

handles .provable in type deriver methods & inferring types

| GenericProvable<any, any, Field>
| [NestedProvable<Field>, ...NestedProvable<Field>[]]
| NestedProvable<Field>[]
| { [key: string]: NestedProvable<Field> };

type InferProvable<A, Field> = A extends Constructor<infer U>
type InferProvable<A, Field> = A extends { provable: Constructor<infer U> }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing better than a nested conditional type :D imagine if TS would allow if, else and brackets here

@mitschabaude mitschabaude merged commit 57c8d7e into main Jul 23, 2024
1 check passed
@mitschabaude mitschabaude deleted the feature/infer-nested branch July 23, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants