TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

Add Node and Deno in criteria to add a feature

Open regseb opened this issue 3 years ago • 1 comments

The addition of the static Response.json(data, init) method was refused because it isn't implemented by two major vendors. It's implemented in Blink, but not in Gecko and WebKit.

It's already implemented in Node and Deno because it's mostly useful on the backend:

  • Create easily a server response with JSON (cf. Deno v1.22):

    import { serve } from "https://deno.land/[email protected]/http/server.ts";
    await serve(() => Response.json({ foo: "bar" }), { port: 8080 });
    
  • Mock easily the response of a request:

    sinon.stub(globalThis, "fetch").resolves(Response.json({ foo: "bar" }));
    

I think Mozilla and Apple are in no rush to implement this method. We may have this lack for a while.


I propose to add Node and Deno in the list of vendors.

Why is my fancy API still not available here? A feature needs to be supported by two or more major browser engines or JavaScript runtime to be included here, to make sure there is a good consensus among vendors: Gecko (Firefox), Blink (Chrome/Edge), WebKit (Safari), Node and Deno.

If the condition is met but still is not available here, first check the contribution guidelines below and then please file an issue.

regseb avatar Jan 15 '23 16:01 regseb

I don't think this is the way to go since it's useless for browser purpose when only Blink/Node/Deno implements things and other browser engines do not.

Instead, I suggested #1402 for non-browser implementations so that we can have a set of lib for browsers and another lib for general JavaScript environments.

(That needs some interest from TypeScript team)

saschanaz avatar Jan 15 '23 16:01 saschanaz