Description
Per https://heycam.github.io/webidl/#idl-nullable-type, dictionary types are allowed to be nullable (they're not excluded by any of the conditions), but unions containing dictionary types can't be nullable.
That is, MyDict?
is valid, but (MyDict or DOMString)?
is not.
This doesn't seem to make sense. Per https://heycam.github.io/webidl/#es-dictionary, JS null
is always acceptable to convert to a dictionary type; nullability doesn't enter into the equation at all. In other words, dictionary types are implicitly nullable. You can also see this more easily in https://heycam.github.io/webidl/#es-union, where both null
and undefined
can be turned into a dictionary type if a union includes one.
Tracing the blame back, this change occurred in 6ac261b, with the reasoning given being "Disallow dictionaries from being nullable only as operation argument types.". But that edit preserved the fact that JS null
is always convertable to a dictionary type, so I'm not sure what it was actually trying to do.
I suggest that we revert that change and just always disallow dictionary types from being nullable (since they're always implicitly nullable already).