-
Notifications
You must be signed in to change notification settings - Fork 34k
Description
--noImplicitOverride
TS 4.3 adds a new strictness option: --noImplicitOverride
. This requires that you use the override
keyword when overriding and method:
class Foo {
foo() {...}
}
class SubFoo extends Foo {
foo() { ... } // ERROR: missing override specifier
}
To fix this, simply add the override
keyword:
class SubFoo extends Foo {
override foo() { ... }
}
The override keyword does not change runtime behavior but can help programmers in a few ways:
-
When reading code, it alerts you that a method is overriding one from the base class
-
It is an error to try to override a method that does not exist on the base class. This can help catch errors caused by renaming a method in a base class but forgetting to update the method name in the subclasses.
Enabling
I propose enabling this new flag for both VS Code code and extensions.
Enabling it currently causes ~2200 compile errors, however unlike the previous strictness checks we enabled, I believe should simply use a script to automatically fix the vast majority of them (by inserting override
in the necessary location)