generate_typetext: better handling of only-optional cases