Skip to content

chore(pass-style): only Promise<Passable> is passable#3068

Draft
michaelfig wants to merge 3 commits intomfig/readonly-array-is-passablefrom
mfig/passable-fulfilments-only
Draft

chore(pass-style): only Promise<Passable> is passable#3068
michaelfig wants to merge 3 commits intomfig/readonly-array-is-passablefrom
mfig/passable-fulfilments-only

Conversation

@michaelfig
Copy link
Member

@michaelfig michaelfig commented Jan 30, 2026

Description

This PR strengthens TypeScript type safety for passable promises by requiring them to accept only Promise<Passable> rather than Promise<any>. This prevents promises that will likely fulfill to non-passable values from being accepted at compile time.

Changes:

  • Added AwaitedPassable type, which only includes the non-Promise branches of the existing Passable union type.
  • Updated Passable type to be AwaitedPassable | Promise<AwaitedPassable> to break infinite promise expansion.
  • Simplified PassByRef type to use a single Promise<Passable> instead of multiple specific promise types
  • Added AwaitedPassableCap type, which only includes the non-Promise branches of the existing PassableCap union type.
  • Updated PassableCap type to be AwaitedPassableCap | Promise<Passable> instead of ... | Promise<any>.
  • Added test annotations to validate the new type constraints

Security Considerations

Guardrails only. By design, the TypeScript programming language provides pragmatic but unsound types.

Scaling Considerations

n/a

Documentation Considerations

Documented in NEWS.md, but should be intuitive enough, and can always be @ts-expect-errorred if it gets in the way.

Testing Considerations

CI, and types.test-d.ts linting.

Compatibility Considerations

Should not break naïve code, only code that is really doing something dodgy.

Upgrade Considerations

Types only. No effect on runtime execution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens TypeScript type safety for passable promises by constraining them to only accept Promise<Passable> instead of Promise<any>. This prevents promises that will likely fulfill to non-passable values from being accepted at compile time.

Changes:

  • Updated type definitions to require promises to be Promise<Passable> instead of Promise<any>
  • Simplified PassByRef type to use a single Promise<Passable> instead of multiple specific promise types
  • Made AwaitedPassableCap an internal type since it's only used within the type definitions
  • Added test annotations to validate the new type constraints

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
packages/pass-style/src/types.d.ts Tightened promise types from Promise<any> to Promise<Passable> across PassByRef, PassStyleOf, and PassableCap; made AwaitedPassableCap internal
packages/pass-style/src/types.test-d.ts Added @ts-expect-error annotations to verify promises of non-passable values are correctly rejected by the type system
packages/pass-style/NEWS.md Documented the type changes and their purpose

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelfig michaelfig force-pushed the mfig/passable-fulfilments-only branch from 9820996 to 63188ce Compare January 30, 2026 11:35
@michaelfig michaelfig self-assigned this Feb 2, 2026
@michaelfig michaelfig force-pushed the mfig/passable-fulfilments-only branch from 63188ce to 7de5605 Compare February 2, 2026 17:34
@mhofman
Copy link
Contributor

mhofman commented Feb 3, 2026

I have tried to do this before (taking over an attempt from @turadg), and things broke horribly in agoric-sdk (Agoric/agoric-sdk#9943)

@turadg
Copy link
Member

turadg commented Feb 3, 2026

I'd love to see this tightened up. But per what Mathieu pointed out, I'm requesting that the test plan include a green integration branch with agoric-sdk. (IMO that can use ts-expect-error and other escape hatches so we can correct Endo and catch in in agoric-sdk over time.)

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.

3 participants