Skip to content

FETCH / Give The json() Function The Power To Use Generic Type #59950

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
6 tasks done
SamJbori opened this issue Sep 12, 2024 · 1 comment
Closed
6 tasks done

FETCH / Give The json() Function The Power To Use Generic Type #59950

SamJbori opened this issue Sep 12, 2024 · 1 comment

Comments

@SamJbori
Copy link

πŸ” Search Terms

json fetch casting

βœ… Viability Checklist

⭐ Suggestion

The json function definition to be changed to allow the ability to specify a type

This is a minimal change that will require changing the line 3186 in the lib.dom.d.ts

from
3186 json(): Promise<any>;
to
3186 json<T = any>(): Promise<T>;

πŸ“ƒ Motivating Example

This simple change will allow calling the json function and organically feed the correct type instead of using type casting.

πŸ’» Use Cases

  1. What do you want to use this for? Calling the function without type casting.
  2. What shortcomings exist with current approaches? Must use type casting.
  3. What workarounds are you using in the meantime? Type casting.
@MartinJohns
Copy link
Contributor

Duplicate of #44603 / #30220. This has been rejected several times already.

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