[whatwg/streams] Misuse of `Assert` in spec (Issue #1327)

### What is the issue with the Streams Standard?

In the streams spec, "Assert:" is used in a way that deviates significantly from the ECMAScript spec. e.g. the `pipeTo` method eventually calls `ReadableStreamPipeTo` which starts with checking caller-provided values.

> 1. Assert: source [implements](https://webidl.spec.whatwg.org/#implements) [ReadableStream](https://streams.spec.whatwg.org/#readablestream).
> 2. Assert: dest [implements](https://webidl.spec.whatwg.org/#implements) [WritableStream](https://streams.spec.whatwg.org/#writablestream).
> 3. Assert: preventClose, preventAbort, and preventCancel are all booleans.
> 4. If signal was not given, let signal be undefined.
> 5. Assert: either signal is undefined, or signal [implements](https://webidl.spec.whatwg.org/#implements) [AbortSignal](https://dom.spec.whatwg.org/#abortsignal).

This usage of "Assert:" can't be consistent with the ECMAScript spec meaning, which indicates a logically entailed invariant[^1]. I believe that most instances in this spec of "Assert:" should actually be changed to throwing a `TypeError`.

[^1]: > A step that begins with “Assert:” asserts an invariant condition of its algorithm. Such assertions are used to make explicit algorithmic invariants that would otherwise be implicit. Such assertions add no additional semantic requirements and hence need not be checked by an implementation. They are used simply to clarify algorithms.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1327
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1327@github.com>

Received on Friday, 13 September 2024 02:24:41 UTC