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

Tagged helper for StartFunction #9315

Merged
merged 3 commits into from
May 2, 2024
Merged

Tagged helper for StartFunction #9315

merged 3 commits into from
May 2, 2024

Conversation

turadg
Copy link
Member

@turadg turadg commented May 2, 2024

refs: #9283

Description

#9283 was failing integration with,

Error: src/proposals/econ-behaviors.js(4,1): error TS9006: Declaration emit for this file requires using private name 'StartFunction' from module '"/home/runner/work/agoric-sdk/agoric-sdk/packages/zoe/src/zoeService/utils"'. An explicit type annotation may unblock declaration emit.

I've been meaning to adopt the Tagged helper from types-fest so I took this opportunity to try it and it solved this problem. So this PR adds it to @agoric/internal and uses it for the Installation and Instance types that need a tag. It doesn't use if for the three other declare const we have in the repo.

While debugging I also noticed we could cut a few ambient runtime imports so I did that. One required moving ManualTimer type into its impl module.

Security Considerations

I vendored the file instead of importing from NPM to not take the external dep

Scaling Considerations

n/a, types

Documentation Considerations

should not be developer-facing

Testing Considerations

CI

Upgrade Considerations

n/a, types

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

good stuff!

@@ -0,0 +1,155 @@
/** @file adapted from https://raw.githubusercontent.com/sindresorhus/type-fest/main/source/opaque.d.ts */
Copy link
Member

Choose a reason for hiding this comment

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

What's the license? ah. CC0 Public Domain Dedication. very well.

might be worth noting that.

// because TS is structural, without this the generic is ignored
[StartFunction]: SF;
};
export type Installation<SF extends ContractStartFunction | unknown> = Tagged<
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how to read this. X | unknown is unknown for any X, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

this used to be SF which was any. I constrained it to SF extends ContractStartFunction but some places explicitly pass unknown. So this continues to allow that.

@@ -13,22 +14,24 @@ type ContractFacet<T extends {} = {}> = {
/**
* Installation of a contract, typed by its start function.
*/
declare const StartFunction: unique symbol;
Copy link
Member

Choose a reason for hiding this comment

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

ok, so no more unique symbol... though we take on responsibility for any collisions for strings such as StartFunction.

@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label May 2, 2024
@mergify mergify bot merged commit 2e2466e into master May 2, 2024
77 checks passed
@mergify mergify bot deleted the ta/StartFunction-tag branch May 2, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants