I'd like to have a final keyword on classes and methods, which specifies, that the class / method must not be overridden by any typescript class. Compile-time checks should be done, such that the following examples generate a tsc compiler error.
final class Foo {
}
class Bar extends Foo {
}
// => Bar cannot extend Foo, because it is final.
class Foo {
final fooIt():void{
}
}
class Bar {
fooIt():void {
}
}
// => Method fooIt of Bar cannot override fooIt of Foo, because it is final.
E.g. I often use following pattern, where I want to urgently avoid fooIt to be overridden:
import Whatever ...
abstract class Foo {
private ImportantVariable:boolean;
protected abstract fooIt_inner:Whatever();
public final fooIt():Whatever() {
//do somestate change to aprivate member here, which is very crucial for the functionality of every Foo:
ImportantVariable = true;
//call the abstract inner functionality:
return this.fooIt_inner();
}
}
legend80s, huan, lazarljubenovic, rotemgera and victorjonsson
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4