[whatwg/webidl] Reconsider advice to leave dictionary members optional when dictionary is used solely as a return type (Issue #1567)

weinig created an issue (whatwg/webidl#1567)

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

The WebIDL spec currently gives this advice for specification authors:

> Note that specifying [dictionary members](https://webidl.spec.whatwg.org/#dfn-dictionary-member) as [required](https://webidl.spec.whatwg.org/#required-dictionary-member) only has an observable effect when converting other representations of dictionaries (like a JavaScript value supplied as an argument to an [operation](https://webidl.spec.whatwg.org/#dfn-operation)) to an IDL dictionary. Specification authors should leave the members [optional](https://webidl.spec.whatwg.org/#dictionary-member-optional) in all other cases, including when a dictionary type is used solely as the [return type](https://webidl.spec.whatwg.org/#dfn-return-type) of [operations](https://webidl.spec.whatwg.org/#dfn-operation).

I think think this advice should be reconsidered, as even in the case of dictionary that is used solely as a return type, it can be useful for clients of the dictionary (authors writing web pages) to know which members of the dictionary will always be present, without having to delve into the prose. This allows them to avoid things like unnecessary undefined checks.

It also has a nice side benefit of allowing engines to optimize their internal representations more easily.

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

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

Received on Saturday, 31 January 2026 18:27:02 UTC