override
Marks a method as intentionally overriding a base class member.
Syntax
override methodName(): Type Examples
class Base {
greet() { return 'hi'; }
}
class Sub extends Base {
override greet() { return 'hello'; }
}
class Wrong extends Base {
// override greeet() {} // Error: no base member 'greeet'
}
Notes
The `override` keyword makes the compiler verify that a base class actually
declares the member being overridden, catching renames and typos. Enable
`noImplicitOverride` to require the keyword on all overriding members.