How to fix Property 'x' in type 'X' is not assignable to the same property in base type 'Y' in TypeScript

TypeScriptINTERMEDIATEHIGHUpdated Dec 11, 2025· 160 views

This TypeScript error occurs when a class or interface extends another type but has incompatible property types. It's a type safety error that prevents inheritance violations where derived types must be assignable to their base types. Understanding type compatibility in inheritance hierarchies resolves this common object-oriented programming issue.

Quick fix

Fixes TS2416

// Base class with string property
class Animal {
  name: string = "";
}

// Derived class trying to change property type
class Dog extends Animal {
  name: number = 0; // ERROR: Property 'name' in type 'Dog' is not assignable to the same property in base type 'Animal'
}
  1. Identify the conflicting property and its types
  2. Ensure derived property type is assignable to base property type
  3. Use the same type or a compatible subtype
  4. Handle optional/required property mismatches
typescript — error
// Base class with string property
class Animal {
name: string = "";
}
// Derived class trying to change property type
class Dog extends Animal {
name: number = 0; // ERROR: Property 'name' in type 'Dog' is not assignable to the same property in base type 'Animal'
}
Property 'x' in type 'X' is not assignable to the same property in base type 'Y'

What this error means

This error indicates a type mismatch between a property in a derived class/interface and the same property in its base type. When a type extends another type (through inheritance or interface extension), all properties in the derived type must be assignable to their corresponding properties in the base type. This is a fundamental principle of type safety in object-oriented programming: a derived type should be usable wherever the base type is expected (Liskov Substitution Principle). The error occurs when you try to override a property with an incompatible type, making the derived type not assignable to the base type. For example, if a base class has a property of type `string`, a derived class cannot change it to `number` because code expecting the base type would receive incompatible values.

Typical symptoms

  • TypeScript compiler shows error "TS2416: Property 'x' in type 'X' is not assignable to the same property in base type 'Y'"
  • Class or interface extension is highlighted in red in your IDE
  • Build process fails when running `npm run build` or `tsc`
  • Error appears when extending classes or interfaces with property type mismatches
  • The error message shows both the derived type property and base type property types
  • Error occurs even if the property is not explicitly overridden (implicit inheritance conflict)

Common causes

  1. Changing property type in derived class to an incompatible type (string → number, number → boolean, etc.)
  2. Making a property optional in base type but required in derived type (or vice versa)
  3. Using a more restrictive type in derived class than in base class (contravariance violation)
  4. Inheriting from multiple interfaces with conflicting property types
  5. Generic type parameter mismatches in inherited properties
  6. Readonly/writable mismatch between base and derived property
  7. Using union types that are not assignable to the base type's union
  8. Mixin or multiple inheritance patterns causing type conflicts
  9. Interface merging creating incompatible property declarations

How to fix "Property 'x' in type 'X' is not assignable to the same property in base type 'Y'"

1Identify the conflicting property and its types

Read the error message carefully to identify which property has the type conflict and what the two types are. The error shows both the derived type's property type and the base type's property type.

typescript
// Base class with string property
class Animal {
  name: string = "";
}

// Derived class trying to change property type
class Dog extends Animal {
  name: number = 0; // ERROR: Property 'name' in type 'Dog' is not assignable to the same property in base type 'Animal'
}

The error tells us: Property 'name' in type 'Dog' (type: number) is not assignable to the same property in base type 'Animal' (type: string).

2Ensure derived property type is assignable to base property type

The derived property type must be assignable to (compatible with) the base property type. This usually means the derived type should be the same or a subtype of the base type.

typescript
// Base class with Animal type property
class Zoo {
  animal: Animal = new Animal();
}

// Derived class - OK: Dog is a subtype of Animal
class DogZoo extends Zoo {
  animal: Dog = new Dog(); // OK: Dog extends Animal
}

// Derived class - ERROR: Animal is not a subtype of Dog
class AnimalZoo extends Zoo {
  animal: Animal = new Animal(); // Actually OK here, but shows the principle
}

For primitive types, they must be exactly the same or compatible through union types.

3Use the same type or a compatible subtype

If you need different behavior, consider using a different property name or a union type that includes the base type.

typescript
// Base class
class Vehicle {
  speed: number = 0;
}

// WRONG - changing type
class Car extends Vehicle {
  speed: string = "fast"; // ERROR
}

// CORRECT - same type
class Car extends Vehicle {
  speed: number = 100; // OK
}

// CORRECT - union type that includes the base type
class HybridCar extends Vehicle {
  speed: number | "electric" = 0; // OK if "electric" is assignable to number
  // Actually, this might still error if "electric" is not assignable to number
}

// BETTER - use a different property
class Car extends Vehicle {
  speed: number = 100;
  speedDescription: string = "fast"; // Additional property
}
4Handle optional/required property mismatches

If the base property is optional (?), the derived property can be optional or required. If the base property is required, the derived property must also be required (cannot be optional).

typescript
interface Base {
  name?: string;  // Optional
}

// OK - making optional property required
interface Derived extends Base {
  name: string;   // Required - OK because all Base values have name? (maybe undefined)
}

interface Base2 {
  name: string;   // Required
}

// ERROR - making required property optional
interface Derived2 extends Base2 {
  name?: string;  // Optional - ERROR because Base2 requires name
}
5Fix generic type parameter issues

When using generics with inheritance, ensure type parameters are properly constrained and compatible.

typescript
class Container<T> {
  value: T;
  constructor(value: T) {
    this.value = value;
  }
}

// ERROR - generic constraint mismatch
class StringContainer extends Container<string> {
  value: number; // ERROR: changing type parameter instantiation
}

// CORRECT - same generic instantiation
class StringContainer extends Container<string> {
  value: string; // OK - same type
}

// CORRECT - additional methods with same property type
class StringContainer extends Container<string> {
  getLength(): number {
    return this.value.length;
  }
}
6Resolve interface merging conflicts

When multiple interfaces are merged or extended, ensure property types are compatible.

typescript
interface A {
  prop: string;
}

interface B {
  prop: number;
}

// ERROR - conflicting property types
interface C extends A, B {
  // prop: string & number is impossible
}

// SOLUTION 1: Use a union type in the extending interface
interface C extends A {
  prop: string | number; // Still error: not assignable to A.prop (string)
}

// SOLUTION 2: Omit and redefine
interface C extends Omit<A, "prop">, Omit<B, "prop"> {
  prop: string | number; // Now OK - not conflicting with parent interfaces
}

// SOLUTION 3: Use type intersection (not extension)
type C = A & B; // Creates type with prop: string & number (never)
7Use method override instead of property override when appropriate

If you need different behavior for a property, consider using a getter/setter method instead of overriding the property.

typescript
class Base {
  private _value: number = 0;
  
  get value(): number {
    return this._value;
  }
  
  set value(v: number) {
    this._value = v;
  }
}

class Derived extends Base {
  // Override getter with compatible return type
  get value(): number {
    return super.value * 2; // OK - still returns number
  }
}

// ERROR example with property
class Base2 {
  value: number = 0;
}

class Derived2 extends Base2 {
  value: string = "test"; // ERROR - property type mismatch
}
8Consider composition over inheritance

If you frequently encounter type conflicts, consider using composition instead of inheritance. This gives more flexibility with types.

typescript
// Instead of inheritance with type conflicts:
class Animal {
  name: string = "";
}

// class Dog extends Animal {
//   name: DogName; // ERROR if DogName not assignable to string
// }

// Use composition:
class Dog {
  private animal: Animal;
  name: DogName;
  
  constructor(name: DogName) {
    this.animal = new Animal();
    this.animal.name = name.toString(); // Convert if needed
    this.name = name;
  }
  
  getAnimalName(): string {
    return this.animal.name;
  }
}

Advanced notes

This error relates to the Liskov Substitution Principle (LSP) in object-oriented design: derived types must be substitutable for their base types without altering program correctness. TypeScript enforces this through structural typing. For properties, covariance is required: the derived property type must be assignable to the base property type. This differs from method parameters which are contravariant when strictFunctionTypes is enabled. The error TS2416 specifically addresses property type compatibility in class inheritance. For interfaces, the same rules apply but TypeScript uses declaration merging which can create complex conflicts. When working with mapped types or conditional types in inheritance, type inference might produce unexpected results. Generic constraints play a crucial role: class Derived<T> extends Base<T> requires the same type parameter, but class Derived<T extends U> extends Base<U> creates compatibility issues. Readonly properties have special rules: a readonly property in base can be made writable in derived (widening), but a writable property in base cannot become readonly in derived (narrowing). Index signatures also participate in type compatibility: [key: string]: T in base requires derived index values to be assignable to T.

Frequently asked questions

What does "TS2416" mean?
This error indicates a type mismatch between a property in a derived class/interface and the same property in its base type. When a type extends another type (through inheritance or interface extension), all properties in the derived type must be assignable to their corresponding properties in the base type. This is a fundamental principle of type safety in object-oriented programming: a derived type should be usable wherever the base type is expected (Liskov Substitution Principle).
How do I fix "TS2416"?
This TypeScript error occurs when a class or interface extends another type but has incompatible property types. It's a type safety error that prevents inheritance violations where derived types must be assignable to their base types. Understanding type compatibility in inheritance hierarchies resolves this common object-oriented programming issue.
What causes "TS2416"?
Changing property type in derived class to an incompatible type (string → number, number → boolean, etc.) Making a property optional in base type but required in derived type (or vice versa) Using a more restrictive type in derived class than in base class (contravariance violation)
Is the "TS2416" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading