Set noImplicitOverride: true
It lets Typescript do more of what typescript is meant to do.
And its usually a quick and easy increase of type-safety in your codebase.
Here are 3 reasons why you should set tsconfig.json #noImplicitOverride
- Prevents Overrides that don't actually override:
It prevents your developers from mistakenly thinking they are overriding something when they are not, preventing errors like spelling mistakes or attempting to override a removed/updated method/variable on the base class.
- Ensures Up-to-Date Sub-classes:
Lets Typescript give an error if a subclass becomes outdated due to changes in the base class, such as the removal or modification of a method.
- Requires Explicit Method Signature:
The override
keyword shows clearly what the intention
of the method is. If it's not there you would have to go to the base class (and potentially to its base and so forth) to see if the method is overridden or not.
How to do it?
a. In your tsconfig.json
just add:
{
"compilerOptions": {
...
"noImplicitOverride": true
}
}
b. run a typecheck and fix all classes by adding override
to the methods and class variables.
Top comments (0)