Skip to content

Add method static Response.json(data, init) #1444

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
regseb opened this issue Dec 7, 2022 · 1 comment
Closed

Add method static Response.json(data, init) #1444

regseb opened this issue Dec 7, 2022 · 1 comment

Comments

@regseb
Copy link

regseb commented Dec 7, 2022

Hi,

A new method has been added: static Response.json(data, init) to create a response that contains JSON (not to be confused with Response.prototype.json()).

declare var Response: {
    // ...
    json(data: any, init?: ResponseInit): Response;
};

Support:


I found that in this project:

"Response": {
"methods": {
"method": {
// BCD's api.Response.json is not about the static method but about Body#json.
// See:
// Firefox https://bugzil.la/1758943
// Chrome https://crbug.com/1305358
// Safari https://webkit.org/b/240375
// MDN https://github.com/mdn/content/discussions/5121#discussioncomment-2735488
"json": null
}
}
},

kodiakhq bot pushed a commit to vercel/vercel that referenced this issue Dec 15, 2022
### 🔖 What's in there?

Because Typescript's `libdom` does not have [`static Response.json()`](microsoft/TypeScript-DOM-lib-generator#1444) (which modern browsers and edge runtimes are supporting), Typescript users can't use easily use it.

This helper fills the gap.

### 🧪 How to test?

It's covered with unit tests
feugy added a commit to feugy/TypeScript-DOM-lib-generator that referenced this issue Jan 3, 2023
feugy added a commit to feugy/TypeScript-DOM-lib-generator that referenced this issue Jan 3, 2023
feugy added a commit to feugy/TypeScript-DOM-lib-generator that referenced this issue Jun 2, 2023
feugy added a commit to feugy/TypeScript-DOM-lib-generator that referenced this issue Jun 2, 2023
@karlhorky
Copy link

@regseb Now that #1462 has been closed and the Response.json() types will show up in TS 5.2, maybe this can be closed?

@regseb regseb closed this as completed Jun 13, 2023
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

2 participants