10000 Enable noImplicitOverride in our codebase · Issue #120675 · microsoft/vscode · GitHub
[go: up one dir, main page]

Skip to content
Enable noImplicitOverride in our codebase #120675
@mjbvz

Description

@mjbvz

--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)

Metadata

Metadata

Assignees

Labels

debtCode quality issues

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0