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

Stream example in bun.sh docs has Typescript error #11903

Open
thesmart opened this issue Jun 16, 2024 · 0 comments
Open

Stream example in bun.sh docs has Typescript error #11903

thesmart opened this issue Jun 16, 2024 · 0 comments
Labels
bug Something isn't working docs Improvements or additions to documentation typescript Something for TypeScript

Comments

@thesmart
Copy link

thesmart commented Jun 16, 2024

What version of Bun is running?

1.1.13+bd6a60512

What platform is your computer?

Darwin 23.3.0 arm64 arm

What steps can reproduce the bug?

Take the stream example from the documentation:

const stream = new ReadableStream({
  start(controller) {
    controller.enqueue("hello");
    controller.enqueue("world");
    controller.close();
  },
});

for await (const chunk of stream) {
  console.info(chunk);
}

The code runs fine, but the stream symbol raises a typescript error in VSCode:

Type 'ReadableStream<any>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.ts(2504)

Here is my package.json, right out of bun init;

{
  "name": "foobar",
  "module": "index.ts",
  "type": "module",
  "devDependencies": {
    "@types/bun": "^1.1.4"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  }
}

What is the expected behavior?

Type ReadableStream should support async iteration.

What do you see instead?

Type 'ReadableStream<any>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.ts(2504)
@thesmart thesmart added bug Something isn't working typescript Something for TypeScript labels Jun 16, 2024
@thesmart thesmart changed the title Type 'ReadableStream<any>' must have a '[Symbol.asyncIterator]()' Stream example in bun.sh docs has Typescript error '[Symbol.asyncIterator]()' Jun 16, 2024
@thesmart thesmart changed the title Stream example in bun.sh docs has Typescript error '[Symbol.asyncIterator]()' Stream example in bun.sh docs has Typescript error Jun 16, 2024
@robobun robobun changed the title Stream example in bun.sh docs has Typescript error Stream example in bun.sh docs has Typescript error '[Symbol.asyncIterator]()' Jun 16, 2024
@robobun robobun changed the title Stream example in bun.sh docs has Typescript error '[Symbol.asyncIterator]()' Stream example in bun.sh docs has Typescript error Jun 16, 2024
@paperdave paperdave added the docs Improvements or additions to documentation label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docs Improvements or additions to documentation typescript Something for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants