Also fixes several issues with code generation when a dom type is part of a dictionary. Part of #34866 Fixes #39398 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>