- From: Tab Atkins Jr. <notifications@github.com>
- Date: Fri, 12 Mar 2021 18:07:21 -0800
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <heycam/webidl/issues/967@github.com>
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 <https://github.com/heycam/webidl/commit/6ac261bd550ce99d62c54ccf831b4e0ab7dee5df>, 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). -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/heycam/webidl/issues/967
Received on Saturday, 13 March 2021 02:07:34 UTC