Type Compatibility
In one line
Type compatibility is the rules TypeScript uses to determine if a value of one type can be assigned to a variable of another type, based on structural typing.
In simple words
Type compatibility determines whether TypeScript allows assigning a value of type A to a variable of type B. TypeScript uses structural typing: A is compatible with B if A has all the properties that B requires.
For example, { name: string; age: number } is compatible with { name: string } because it has all required properties (and more). This is called "excess property checking" in reverse — having extra properties is fine for assignment, but not for object literals.
Type compatibility also applies to functions (parameter bivariance), arrays (covariance), and generics. Understanding these rules helps you write types that accept the right range of values.
Example
interface Person { name: string; }
interface Employee { name: string; salary: number; }
const emp: Employee = { name: "Bob", salary: 50000 };
const person: Person = emp; // OK: Employee has all Person propertiesEmployee is compatible with Person because it has all of Person's required properties.
Related terms
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.