In TypeScript, the any type is a valid override for every type. This occurs in a few places in the DOM. In the example below, BeforeUnloadEvent.returnValue cannot be declared within BeforeUnloadEvent, otherwise it will be an invalid override. If we expose it through an extension method instead, it circumvents the error.
@JS()
library X;
import "package:js/js.dart";
@JS()
abstract class Event {
external bool get returnValue;
external set returnValue(bool v);
}
@JS()
abstract class BeforeUnloadEvent implements Event {}
@JS()
abstract class _BeforeUnloadEvent {
external dynamic get returnValue;
external set returnValue(dynamic v);
}
extension BeforeUnloadEventExtensions on BeforeUnloadEvent {
dynamic get returnValue {
final Object t = this;
final _BeforeUnloadEvent tt = t;
return tt.returnValue();
}
}
In TypeScript, the
any
type is a valid override for every type. This occurs in a few places in the DOM. In the example below, BeforeUnloadEvent.returnValue cannot be declared within BeforeUnloadEvent, otherwise it will be an invalid override. If we expose it through an extension method instead, it circumvents the error.