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

TS: fix definitions to have ReadableStream compatible with WebStream, add tests #13

Merged
merged 3 commits into from
Feb 28, 2022

Conversation

larabr
Copy link
Collaborator

@larabr larabr commented Feb 28, 2022

Changes:

  • update WebStream definition so that type inference works when using a ReadableStream. Specifically, we cannot rely on the AsyncIterable interface, because ReadableStreams are not currently implemented by all browsers as including the necessary properties.
  • generalise readToEnd definition to support join function with arbitrary output type
  • add TS tests to CI

Partially addresses #10 .

@larabr larabr requested a review from twiss February 28, 2022 13:38

type Stream<T extends Data> = WebStream<T> | NodeStream<T>;
interface NodeStream<T extends Data> { // copied+simplified version of ReadableStream from @types/node/index.d.ts
Copy link
Member

@twiss twiss Feb 28, 2022

Choose a reason for hiding this comment

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

Probably we should keep

Suggested change
interface NodeStream<T extends Data> { // copied+simplified version of ReadableStream from @types/node/index.d.ts
interface NodeStream<T extends Data> extends AsyncIterable<T> { // copied+simplified version of ReadableStream from @types/node/index.d.ts

And also, just as a reminder, since we're removing AsyncIterable from WebStream (rightly so, as it isn't guaranteed to be there), we should update the examples in OpenPGP.js, as per openpgpjs/openpgpjs#1370.

test/typescript-definitions.ts Outdated Show resolved Hide resolved
@larabr larabr merged commit fb1ae49 into openpgpjs:master Feb 28, 2022
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.

2 participants