[whatwg/webidl] Consider switching the default from optional dictionary members to required (Issue #1628)

twiss created an issue (whatwg/webidl#1628)

### What is the issue with the Web IDL Standard?

(This came up in https://github.com/w3c/webcrypto/pull/559#issuecomment-5357336396, and would be an alternative to https://github.com/whatwg/webidl/issues/1567.)

Currently, the default for dictionary members is to be optional, and to make them required you need to add the `required` attribute. However, this is "backwards" compared to function arguments, which have an `optional` keyword. So, it would be more consistent to match that. And, in code generation it also more cleanly maps to `std::optional` and such.

Also, for dictionaries that are only every returned or used in read-only attributes of other dictionaries, it would be nice to make it clear that the member will always be there, without having to (semi-redundantly) annotate all of them with `required`. By contrast, having an optional member of a read-only dictionary would be surprising and should probably be called out explicitly (if it's ever a possibility at all).

If it seems reasonable, I can make a PR, though I realize this would likely cause a lot of churn in other specs.

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

Message ID: <whatwg/webidl/issues/1628@github.com>

Received on Thursday, 20 August 2026 15:11:03 UTC