Typescript: ReadableStream constructor args not supported

Created on 17 Jul 2017  路  8Comments  路  Source: microsoft/TypeScript

TypeScript Version: 2.4.1

It would be nice for this part of the spec to be supported: https://streams.spec.whatwg.org/#rs-constructor

Code

const stream = new ReadableStream({
  start(controller) {
    controller.close();
  }
});

Expected behavior: Code should compile

Actual behavior: Supplied parameters do not match any signature of call target. error. I assume this is because the built-in types aren't expecting any arguments passed into the constructor.

Bug lib.d.ts Fixed help wanted

Most helpful comment

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

All 8 comments

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

@mhegazy I made an implementation of the streams standard in TS and have a full d.ts file with all of the types, view it in my repo

Before I spend many hours trying to wrangle this into the added/deleted/modified JSONs, you may notice I made the types parameterised by their in/out data types. My Qs:

  1. is this possible to represent in the JSON even if the original types are not generic?
  2. will this end result, or something close to it, be accepted, with the changes in types, etc. Who has the last say on these things?

Thanks

For those still interested, I'm setting up a PR now to add/fix all streams-related types in the TSJS generator. But the tool is a bit quirky and has very obscure error messages so it's going a bit slow. I also decided against making the types generic to keep it simple.

The above mentioned pull request by @MattiasBuelens will fix this and all other missing parts of the streams types, and they're generic too!

https://github.com/Microsoft/TSJS-lib-generator/pull/541 has been merged and this issue can now be closed. @sandersn Not sure who to ping here from the TS team, but since you merged the PR you know the context. Thanks.

error TS2554: Expected 0 arguments, but got 1.

 14       body: new ReadableStream({
                ~~~~~~~~~~~~~~~~~~~~
 15         pull(c) {
    ~~~~~~~~~~~~~~~~~
... 
 18         }
    ~~~~~~~~~
 19       })

@EtherDream The improved types for streams were added in TypeScript 3.2. Can you verify that you're using an up-to-date version of TypeScript in your project? If that doesn't solve it, I recommend opening a separate issue for your problem.

@mhegazy or @RyanCavanaugh: This issue can be closed, as it has been fixed in TypeScript 3.2.

@MattiasBuelens thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

siddjain picture siddjain  路  3Comments

bgrieder picture bgrieder  路  3Comments

seanzer picture seanzer  路  3Comments

manekinekko picture manekinekko  路  3Comments

Antony-Jones picture Antony-Jones  路  3Comments