Web Development TypeScript Subjective
Oct 04, 2025

Explain variance in TypeScript and its implications.

Detailed Explanation
Variance describes how subtyping relationships are preserved in generic types. Covariance allows subtypes in output positions (function return types). Contravariance allows supertypes in input positions (function parameters). This ensures type safety in function assignments and prevents runtime errors.
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback