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

fix: add @returns to @ucanto/validator Schema.dictionary() to avoid problematic inference when using derives #215

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

gobengo
Copy link
Contributor

@gobengo gobengo commented Feb 2, 2023

@gobengo gobengo requested a review from Gozala February 2, 2023 21:36
derives: (claim, proof) => {
// the motivation for this test was that tsc would previously complain at these assignments
// and the only workaround was a type assertion https://github.com/web3-storage/w3protocol/pull/420/commits/4f1f2931cecff1d1d1d29e889c4fdfb63ff3b327#diff-e434cc6c1a699df311a0b2faed199a2ff6b6b291d30f95e20b2ea5abfa7da3d9R125
/** @type {Schema.Dictionary|undefined} */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tsc will complain here without the change adding @returns to Schema.dictionary().

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is cool, but since we're testing inference as opposed to something at runtime I would suggest putting it in this file instead https://github.com/web3-storage/ucanto/blob/main/packages/validator/test/inference.spec.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, I did feel weird that it was a tsc-only test alongside a bunch of runtime ones, but figured you'd either tell me to just omit the test or lmk a good place to put it :) 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@Gozala Gozala left a comment

Choose a reason for hiding this comment

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

Thanks, minor suggestion but I'm ok with this being as is.

@gobengo gobengo changed the title add @returns to @ucanto/validator Schema.dictionary() to avoid problematic inference when using derives fix: add @returns to @ucanto/validator Schema.dictionary() to avoid problematic inference when using derives Feb 2, 2023
@gobengo gobengo merged commit 620421d into main Feb 2, 2023
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