-
Notifications
You must be signed in to change notification settings - Fork 74
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
pattern types #1721
base: master
Are you sure you want to change the base?
pattern types #1721
Conversation
8845ba4
to
950cd7f
Compare
* @template {string} [T=string] tag | ||
* @typedef {{ | ||
* [Symbol.toStringTag]: string, | ||
* [Symbol.toStringTag]: T, | ||
* payload: Passable, | ||
* [passStyle: symbol]: 'tagged' | string, | ||
* }} CopyTagged |
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.
Won't this equate CopyTagged with CopyTagged<string>, which is novel and unexpected because "string" is not a known tag?
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.
hmm, I don't think CopyTagged<string>
would satisfy the template because the parameter wouldn't be a string itself. It would have to by CopyTagged<'string'>
. That's not a known tag but it was valid before, right? (i.e. not a regression).
if (harden.isFake) { | ||
if ('isFake' in harden) { |
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.
What motivates these changes?
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.
the line started erroring because harden
doesn't have an isFake
property. I figure something in my changes fixed a resolution that had been falling back to any
refs: #6160 ## Description I ran again into the need for type narrowing with a shape object: https://github.com/Agoric/agoric-sdk/pull/8385/files#diff-b17d46d065ac769cdf1d70471b16d141f28672965c18522d58d39722d4852ad4R329-R331 endojs/endo#1721 approached the general problem of inferring the type from the shape. But until we have that, we can at least move the type description onto the shape object so users of that shape can automatically get the type a match implies. With this, the code referenced above would be, ```js const questionDesc = cast(info, QuestionSpecShape); ``` ### Security Considerations n/a ### Scaling Considerations n/a ### Documentation Considerations Once this settles in agoric-sdk, we may want to move it into Endo. Alternately, Endo waits for more general support. ### Testing Considerations Has a test. Maybe should use tsd instead of Ava ### Upgrade Considerations n/a
refs: #2392
Description
Make
mustMatch
assert type implied by matcher.TODO: rebase onto master. I have a working branch for that but it needs more work before overwriting this remote.
Security Considerations
Scaling Considerations
Documentation Considerations
Testing Considerations
Upgrade Considerations