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

Make void #2302

Closed
michaelfig opened this issue May 28, 2024 · 4 comments
Closed

Make void #2302

michaelfig opened this issue May 28, 2024 · 4 comments

Comments

@michaelfig
Copy link
Member

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @endo/pass-style@1.4.0 for the project I'm working on.

void is a TypeScript abstraction that reduces to a flavour of undefined when compiled to JS. It should be treated as a Primitive.

Without that, I get typing errors when trying to use PureData from @endo/pass-style:

    Types of property 'payload' are incompatible.
      Type 'VowPayload<string | number | bigint | boolean | symbol | void | CopyArrayI<never, never> | CopyRecordI<never, never> | CopyTaggedI<never, never> | null | undefined>' is not assignable to type 'VowPayload<PureData>'.

Here is the diff that solved my problem:

diff --git a/node_modules/@endo/pass-style/src/types.d.ts b/node_modules/@endo/pass-style/src/types.d.ts
index 6508067..ec59833 100644
--- a/node_modules/@endo/pass-style/src/types.d.ts
+++ b/node_modules/@endo/pass-style/src/types.d.ts
@@ -7,6 +7,7 @@ import { PASS_STYLE } from './passStyle-helpers.js';
 export type Primitive =
   | null
   | undefined
+  | void
   | string
   | number
   | boolean

This issue body was partially generated by patch-package.

@erights
Copy link
Contributor

erights commented May 28, 2024

Hi @michaelfig , are you sure this is correctness preserving? I thought TS void was a don't care that could admit and ignore any value, not just primitives.

@mhofman
Copy link
Contributor

mhofman commented May 28, 2024

void in a union type can have unintended consequences. I'm a little rusty on the exact problems, but I remember something about it erasing other types in the union in some cases (possibly only for return types)

@mhofman
Copy link
Contributor

mhofman commented May 28, 2024

Here is a TS issue with more info: microsoft/TypeScript#42709

@michaelfig
Copy link
Member Author

Here is a TS issue

Thanks for the pointer. Indeed, I was holding things wrong, and corrected the problem by improving the typing of the functions I wrote that I wanted to be compatible with PureData.

Closing.

@michaelfig michaelfig closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
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

No branches or pull requests

3 participants