facebook / facebook/flow

Enforce an override keyword for class methods

Offen
#1,480 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
feature request
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hi flow team. Firstly, thanks so much for putting together this tool.

I have decently complex class hierarchy and I'd love to have the requirement (or the ability to set the requirement) that I explicitly state when a method is overriding another method. Something like:

```
class Animal {
goes () {
return '';
}
}

class Cow extends Animal {
override goes () {
return 'moo';
}
}
```

then in the case of a missing override:

```
class Cat extends Animal {
goes () {
return 'meow';
}
}
```

we could report something like `overriding method 'goes' missing 'override' keyword`

and in the case of an unnecessary override:

```
class Dog extends Animal {
override barks () {
return 'woof';
}
}
```

we could report something like `method 'bark' is not an overriding method`

My apologies if this change has already been discussed/is infeasible. I looked for a similar discussion and could not find one. If this sounds like an interesting idea please let me know and I can look into putting together a PR for it.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.