Raise an exception if optional properties are used outside a trait or resource type.