What is Type Inference in TypeScript?
Type Inference is TypeScript's ability to automatically determine the type of a variable, function return value, or expression without requiring explicit type annotations. For example, when you write let name = 'John', TypeScript automatically infers the type as string. This feature reduces boilerplate code while still providing strong type checking. Type inference works by analyzing assigned values, function return statements, and contextual usage. Although explicit types can improve readability in complex scenarios, TypeScript's inference system is powerful enough to handle most common cases while maintaining type safety.