workers-types icon indicating copy to clipboard operation
workers-types copied to clipboard

Generic stream interfaces

Open jdanyow opened this issue 4 years ago • 2 comments

Related to #116

It would be easier for packages to support Cloudflare workers and service workers if the stream interfaces matched. Any chance you could update ReadableStream, TransformStream, etc to be generic similar to the standard/web versions?

https://github.com/microsoft/TypeScript/blob/26aea0df613c61edfbfe7b003ff564bea421d071/lib/lib.dom.d.ts#L11917

Couple more I've encountered while migrating cfworker packages:

  1. Generic stream interfaces
  2. setTimeout should not require 3rd arg
  3. BufferSource type is missing (type BufferSource = ArrayBufferView | ArrayBuffer;) https://github.com/microsoft/TypeScript/blob/26aea0df613c61edfbfe7b003ff564bea421d071/lib/lib.dom.d.ts#L18678 https://github.com/cfworker/cfworker/blob/6342b4653d56a0caa41c32090363354f63845b58/packages/cosmos/src/client.ts#L408
  4. RequestInfo type is missing (type RequestInfo = Request | string;) https://github.com/microsoft/TypeScript/blob/90600e1b17edb9072557816657254001a07c3ca0/lib/lib.webworker.d.ts#L5907
  5. FormData interface has incorrect iterable type:
    - [Symbol.iterator](): IterableIterator<([key: string, value: File | string])[]>;
    + [Symbol.iterator](): IterableIterator<[string, string | File]>;
    

jdanyow avatar Oct 18 '21 05:10 jdanyow

Agreed. The runtime currently isn't fully conformant here but I don't 100% know if this is just a typing issue or if the underlying implementation may have issues. I'll get someone to chime in.

vlovich avatar Oct 29 '21 17:10 vlovich

It's both. Our current implementation and the types aren't 100%. I can say it's being worked on actively as we speak. Can't say exactly when we'll have it delivered in the release, but updates to ensure spec compliance are coming.

jasnell avatar Oct 29 '21 17:10 jasnell

Hey! 👋 We'll get these fixed up the next major version of workers-types using the new type generation system. 👍

mrbbot avatar Oct 21 '22 13:10 mrbbot

Hey! 👋 As of @cloudflare/workers-types@4, all of these issues should've been fixed. 🎉

mrbbot avatar Jan 19 '23 15:01 mrbbot