@Sealed
class Person {
constructor(public name: string, public age?: number) {}
}
const john = new Person('John', 30);
// Trying to add a new property will throw an error
(john as any).email = 'john@example.com'; // TypeError: Cannot add property email, object is not extensible
// Existing properties can still be modified
john.age = 31; // Allowed
// Existing properties cannot be re-configured or deleted
delete john.age; // TypeError: Cannot delete property 'age'
}
When applied to a class, it creates a sealed instance of it, preventing extensions and making existing properties non-configurable.