TS1267
Property 'isStable' cannot have an initializer because it is marked abstract.
Broken Code ❌
abstract class Base {
abstract isStable: boolean = true;
}This error occurs because abstract properties in TypeScript cannot have initializers. Abstract properties only declare the type and must be implemented in derived classes.
Fixed Code ✔️
Remove the initializer from the abstract property and initialize it in the derived class:
abstract class Base {
abstract isStable: boolean;
}
class Derived extends Base {
isStable: boolean = true;
}
const derived = new Derived();
console.log(derived.isStable);