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

Type lost when calling asyncIterator.call #29

Closed
wong2 opened this issue Jul 20, 2024 · 3 comments · Fixed by #30
Closed

Type lost when calling asyncIterator.call #29

wong2 opened this issue Jul 20, 2024 · 3 comments · Fixed by #30

Comments

@wong2
Copy link

wong2 commented Jul 20, 2024

I have the following code:

for await (const event of asyncIterator.call(eventStream)) {
  ...
}

Where eventStream is of type ReadableStream<ParsedEvent>, but the event is now unknown.

@Sec-ant
Copy link
Owner

Sec-ant commented Jul 20, 2024

Thanks for reporting this issue. It's a TypeScript limitation that generics are lost in fn.call().

I refactored the asyncIterator ponyfill API in #30 to make it more functional.

Can you test it by installing the preview release package

npm i https://pkg.pr.new/@sec-ant/readable-stream@30

and change your code to this to check whether it fixes your problem?

for await (const event of asyncIterator(eventStream)) {
  ...
}

cc @ehmicky please be aware of this breaking change

@wong2
Copy link
Author

wong2 commented Jul 21, 2024

Thanks, it works.

@Sec-ant
Copy link
Owner

Sec-ant commented Jul 21, 2024

This is released in v0.5.0

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 a pull request may close this issue.

2 participants