Skip to content

Reconsider advice to leave dictionary members optional when dictionary is used solely as a return type #1567

@weinig

Description

@weinig

What is the issue with the Web IDL Standard?

The WebIDL spec currently gives this advice for specification authors:

Note that specifying dictionary members as required only has an observable effect when converting other representations of dictionaries (like a JavaScript value supplied as an argument to an operation) to an IDL dictionary. Specification authors should leave the members optional in all other cases, including when a dictionary type is used solely as the return type of operations.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions