Sealed
Seals a class, preventing it from being extended.
Error is thrown when attempting to instantiate a derived class.
import { sealed } from 'aspectra/utils'
@sealed
class Base {}
class Derived extends Base {}
try {
new Derived()
} catch (error) {
console.table(error)
}
[auto-generated] output:
┌─────────┬─────────────────────────────────────────────────────┐
│ (index) │ Values │
├─────────┼─────────────────────────────────────────────────────┤
│ name │ 'SealedClassExtentionError' │
│ message │ 'Class [Base] is sealed but extended by [Derived].' │
└─────────┴─────────────────────────────────────────────────────┘
Last updated on