Type safety is one of the cornerstones of Swift programming, ensuring that values are used consistently and appropriately throughout an…