Skip to content

Add support for duplex: "half" in RequestInit interface #56882

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

Closed
1 task done
ruochenjia opened this issue Dec 26, 2023 · 2 comments
Closed
1 task done

Add support for duplex: "half" in RequestInit interface #56882

ruochenjia opened this issue Dec 26, 2023 · 2 comments

Comments

@ruochenjia
Copy link

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Latest Chrome browser requires setting duplex: "half" flag for the construction of all requests with a streaming body:
image
However this option does not seem to exist in the RequestInit interface in lib.dom.d.ts, so users cannot construct a Request object with a ReadableStream body without causing an error when running in Chrome.

Currently the only workaround for this issue is to cast the RequestInit object to any, but it is not considered to be a proper solution.

const body: ReadableStream<any> = ...
const request = new Request("https://example.com/", {
  body: body,
  method: "POST",
  duplex: "half"
} as any);
@MartinJohns
Copy link
Contributor

Duplicate of microsoft/TypeScript-DOM-lib-generator#1483.

Currently the only workaround for this issue is to cast the RequestInit object to any

Or use declaration merging and extend the type locally.

@RyanCavanaugh
Copy link
Member

There's a lib change template, please use it.

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