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

Updating added types for `ReadableStreamReadDoneResult`

Open kraenhansen opened this issue 2 years ago • 7 comments

This fixes #1675.

kraenhansen avatar Jan 21 '24 19:01 kraenhansen

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

github-actions[bot] avatar Jan 21 '24 19:01 github-actions[bot]

Makes sense, bu you need to build and commit the result.

saschanaz avatar Jan 21 '24 19:01 saschanaz

Actually byte streams indeed return the value, btw. Perhaps split the type? https://streams.spec.whatwg.org/#byob-reader-internal-slots

saschanaz avatar Jan 21 '24 19:01 saschanaz

Hi @MattiasBuelens, would you be satisfied with this?

Also it would be good to have some unit tests here.

saschanaz avatar Jan 21 '24 19:01 saschanaz

I've updated the code to separate the ReadableStreamReadResult into two:

  • ReadableStreamDefaultReadResult
  • ReadableStreamBYOBReadResult

I've also added ReadableStreamReadResult which union both, to keep breaking changes to a minimum.

The two new types reuse ReadableStreamReadValueResult but have their separate "DoneResult" types:

  • ReadableStreamDefaultReadDoneResult
  • ReadableStreamBYOBReadDoneResult

The PR is currently failing tests:

Test failed: could not compile 'dom.generated.d.ts':
generated/dom.generated.d.ts(28201,75): error TS2552: Cannot find name 'ReadableStreamBYOBReadDoneResult'. Did you mean 'ReadableStreamBYOBReadResult'?
generated/dom.generated.d.ts(28203,78): error TS2552: Cannot find name 'ReadableStreamDefaultReadDoneResult'. Did you mean 'ReadableStreamDefaultReadResult'?

I can't seem to get the specialised *DoneResult types into the dom.generated.d.ts 🤔

kraenhansen avatar Jan 21 '24 19:01 kraenhansen

The PR is currently failing tests:

Test failed: could not compile 'dom.generated.d.ts':
generated/dom.generated.d.ts(28201,75): error TS2552: Cannot find name 'ReadableStreamBYOBReadDoneResult'. Did you mean 'ReadableStreamBYOBReadResult'?
generated/dom.generated.d.ts(28203,78): error TS2552: Cannot find name 'ReadableStreamDefaultReadDoneResult'. Did you mean 'ReadableStreamDefaultReadResult'?

I can't seem to get the specialised *DoneResult types into the dom.generated.d.ts 🤔

The Streams types have [Exposed=*] in their IDL, so I think you need to add "exposed": "*" (or something equivalent) to your addedTypes.jsonc changes?

MattiasBuelens avatar Jan 22 '24 08:01 MattiasBuelens

I can't seem to get the specialised *DoneResult types into the dom.generated.d.ts 🤔

I found the issue 👍

kraenhansen avatar Jan 22 '24 08:01 kraenhansen