-
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
feat(compartment-mapper): add policy-related types #1839
feat(compartment-mapper): add policy-related types #1839
Conversation
cc @naugtur |
5519cab
to
4826f54
Compare
* @param {Record<PropertyKey, any>} originalObject | ||
* @param {Record<PropertyKey, any>} globalThis | ||
* @returns {void} | ||
* @todo Unsure if we can do much typing of `originalObject` and `globalThis` here. |
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.
originalObject
is the same as the value passed in as global
to importLocation
options. I don't think it's reasonable to thread it all the way if TS can't infer.
globalThis
is the Compartment instance's globalThis field, might be possible to derive from ses types eventually.
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.
Unsure if there's something actionable here
* @template [GlobalsPolicyItem=void] | ||
* @template [BuiltinsPolicyItem=void] | ||
* @typedef {object} PackagePolicy | ||
* @property {string} [defaultAttenuator] - The default attenuator. |
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.
(nit) There's no defaultAttenuator field on the individual resource in policy in the public API.
I'm guessing this is the consequence of defaultAttenuator being saved in the package policy of the attenuators compartment. Should we document it here? Should we sub-type internally? Should we implement a valid usecase for it?
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 saw it referenced here, but I can't answer your other questions. If it's intended to be public, then great, but if not, we should subtype.
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'd lean towards subtyping it (though I'm not sure where that type assignment needs to happen) for now unless there's an obvious use-case.
I wanted to rebase this and add cleanup to one of mine functions but noticed this is from a fork. patch I wish to apply after rebase on master:
|
16e065c
to
11b0c05
Compare
@naugtur Resolved |
11b0c05
to
f0d2d16
Compare
@naugtur OK, so, it's slightly different than the diff you gave me, since the diff you gave me did not match the snapshots; I retained the use of the Please take another look at the changes I made based on your comments. |
50d5c59
to
3e44c0d
Compare
This adds types for policies and exports them from the `compartment-mapper` entry point. It also updates some usages of existing and new types.
...as requested by @naugtur. also change some return types to use TS' `asserts` keyword.
The logic forbids it, but type inference doesn't necessarily--better to be safe.
3e44c0d
to
ece09e2
Compare
Description
This adds/narrows types for policies and exports them from the
compartment-mapper
entry point. It also updates some usages of existing and new types (e.g., removing "@typedef
references", squashing some null-reference bugs, etc.).Note
This does not change the fact that
@endo/compartment-mapper
does not export types properly tonode16
/nodenext
-resolution consumers (see #1803).Reviewers: please scrutinize the types added to
src/types.js
closely. The generics allow an attenuator implementation to define the types of custom params which it expects. For example:And in the attenuator:
Documentation Considerations
Does Endo consider type changes to be breaking? These types will likely change in the future, and am curious about whether that should be a major bump.
Testing Considerations
I could use
tsd
to test some of these to avoid regressions, if desired.Upgrade Considerations
none