-
Notifications
You must be signed in to change notification settings - Fork 72
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
1488 Passable redux #2238
1488 Passable redux #2238
Conversation
(I just reran the windows-latest flake) |
@kriskowal , I defer to you on this. I'll just say I hope we can adopt that precedent as a general rule ;) |
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.
LGTM, thanks!
packages/marshal/src/marshal.js
Outdated
@@ -78,7 +78,7 @@ export const makeMarshal = ( | |||
const slotMap = new Map(); | |||
|
|||
/** | |||
* @param {Remotable | Promise} passable | |||
* @param {import('@endo/pass-style').PassableCap} passable |
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.
Now that we have @import
, and since you're changing these lines anyway, I prefer to gather these all the top into @import
declarations.
const extant = valMap.get(index); | ||
if (extant) { |
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.
Yeah, when the value is necessarily truthy, this pattern is better. (Likewise extant !== undefined
when the value is necessarily not undefined
.) Only problem in general is the refactoring hazard if a collection's use changes to include falsy or undefined
values. Not worried about that here.
@@ -284,9 +299,10 @@ harden(assertRankSorted); | |||
* function. This is a genuine bug for us NOW because sometimes we sort | |||
* in reverse order by passing a reversed rank comparison function. | |||
* | |||
* @param {Iterable<Passable>} passables | |||
* @template {Passable} T |
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 do you think of
* @template {Passable} T | |
* @template {Passable} [T=Passable] |
for all or most of these? It offloads the use site from needing to say <Passable>
when that's all it would say anyway. I've been doing essentially this elsewhere and been happy with the results.
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.
that makes sense for parameterized typedefs, but here the template slot's type is constrained by the first argument. Giving a default doesn't help.
@@ -30,6 +30,7 @@ export const hasOwnPropertyOf = (obj, prop) => | |||
apply(objectHasOwnProperty, obj, [prop]); | |||
harden(hasOwnPropertyOf); | |||
|
|||
/** @type {(val) => val is {}} */ |
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've never seen this inline before. Nice.
@@ -33,13 +33,10 @@ const isRemotable = remotable => passStyleOf(remotable) === 'remotable'; | |||
harden(isRemotable); | |||
|
|||
/** | |||
* @callback AssertArray |
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.
Yeah, I don't remember why I have these separate named @callable types. Good riddance, thanks.
@@ -126,14 +128,15 @@ export const checkKey = (val, check) => { | |||
harden(checkKey); | |||
|
|||
/** | |||
* @param {Passable} val | |||
* @param {Key} val |
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.
Shouldn't this be
* @param {Key} val | |
/** | |
* @param {any} val | |
* @returns {val is Key} | |
*/ |
?
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.
good one!
I've added a test showing how the is Key
gets used. I don't think we want to losen the param because if it's not even Passable
then that would be good static feedback. If you want to loosen it, please do in a separate PR across all the similar cases.
// @ts-expect-error M.any missing parens | ||
M.arrayOf(M.any); |
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.
;)
Did we stop requiring conventional commits? |
718b502
to
c9cdff1
Compare
My mistake. All your commits are fine. I was misled by the title, as my habit is to have the title also follow this convention (and usually be identical to the first commit). |
78ef12b
to
8462132
Compare
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’m substantially excited about this change. I would like to break out a PR for the change to the release and build process so that it can suffer a revert separately if necessary. I’d also like to replace temporary markers XXX
and FIXME
with something but it doesn’t have to be tedious. It could be a single explanation or link to a tracking issue with a bunch of dittos or daggers for the repeated cases.
resolutions
farther out, there’s not much reason to spare the major version bump.
packages/base64/package.json
Outdated
@@ -32,7 +32,7 @@ | |||
}, | |||
"scripts": { | |||
"build": "exit 0", | |||
"build:types": "tsc --build tsconfig.build.json", | |||
"prepack": "tsc --build tsconfig.build.json", |
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 would like to capture this process change in a separate PR.
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.
👍 #2258
packages/captp/src/captp.js
Outdated
*/ | ||
// @ts-expect-error intentional hack |
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’s the nature of the hack?
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.
bad comment. the type was wrong so I just removed it
packages/captp/src/captp.js
Outdated
@@ -413,6 +414,7 @@ export const makeCapTP = ( | |||
epoch, | |||
questionID, | |||
target, | |||
// @ts-expect-error XXX |
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.
Please expand XXX
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.
solved
@@ -1,3 +1,6 @@ | |||
export * from './src/exo-makers.js'; | |||
|
|||
// eslint-disable-next-line import/export -- ESLint not aware of type exports in types.d.ts |
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.
That’s unfortunate and might explain some of my experience.
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.
yeah. I think we should consider disabling the rule. I think it has more false positives and fewer true positives than TS
@@ -0,0 +1,2 @@ | |||
/** @file Empty twin for .d.ts */ |
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.
👍
packages/marshal/src/marshal.js
Outdated
decodeRemotableFromSmallcaps, | ||
// @ts-expect-error FIXME |
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.
👆
packages/marshal/src/rankOrder.js
Outdated
if (left < right) { | ||
return -1; | ||
} else { | ||
// @ts-expect-error FIXME narrowed |
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.
👆 Is the intention to address all FIXMEs before landing? These could be links to an issue, otherwise.
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.
not before landing. maybe never. I've taken out the FIXME
packages/marshal/src/rankOrder.js
Outdated
assert(left > right); | ||
return 1; | ||
} | ||
} | ||
case 'symbol': { | ||
return comparator( | ||
// @ts-expect-error FIXME narrowed |
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 would not object to ditto if these stick around.
// @ts-expect-error FIXME narrowed | |
// @ts-expect-error ditto, type narrowed |
@@ -173,10 +168,12 @@ const makePassStyleOf = passStyleHelpers => { | |||
} | |||
for (const helper of passStyleHelpers) { | |||
if (helper.canBeValid(inner)) { | |||
// @ts-expect-error XXX |
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.
👆
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.
solved
@@ -133,20 +133,25 @@ export const compareKeys = (left, right) => { | |||
// rank order. | |||
// Because the invariants above apply to the elements of the array, | |||
// they apply to the array as a whole. | |||
// @ts-expect-error FIXME narrowed |
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’m fine with a link and dittos if these are intended to commit. (but don’t like FIXME
because I like FIXME
and XXX
to be used as markers for work that needs to be ironed out before a merge.
Also, please add |
I had to rebase to resolve merge conflicts created by #2256 I squashed the fixups and rolled in other changes requested by review |
f22e68c
to
9444daf
Compare
fixes a problem with .js files having .d.ts twin
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.
You may want to look over the remaining XXX and TODO cases.
9444daf
to
1ae099d
Compare
closes: #1488
Description
Reattempting:
Again:
Passable
a generic type instead ofany
.passStyleOf
to return the actual style.Key
in terms ofPassable
any
'sSecurity Considerations
n/a
Scaling Considerations
n/a
Documentation Considerations
Better types are better documentation.
Testing Considerations
Upgrade Considerations
These changes may cause type errors downstream. I don't think we should call those breaking change à la semver because they don't affect the runtime.