Having an Angular component with a corresponding element host which is passed through to a method in TypeScript like this:
constructor(hostElementRef: ElementRef, ipeConfigurationService: IPEConfigurationService) {
this.ipeConfigurationService = ipeConfigurationService;
this.ipeConfigurationService.registerHostElement(hostElementRef.nativeElement);
}
public registerHostElement(value: HTMLElement) {
this._hostElement = value;
}
public toggleFullScreen(): void {
if (!this._isFullScreen && this._hostElement) {
if (this._hostElement.requestFullscreen) {
this._hostElement.requestFullscreen();
} else if (this._hostElement.mozRequestFullScreen) {
this._hostElement.mozRequestFullScreen();
} else if (this._hostElement.webkitRequestFullscreen) {
this._hostElement.webkitRequestFullscreen();
} else if (this._hostElement.msRequestFullscreen) {
this._hostElement.msRequestFullscreen();
}
} else if (this._isFullScreen && this._hostElement) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}
Gives an error when running: "mozRequestFullScreen does not exist on type HTMLElement".
If I change the hostElement to be: any there is no problem. I would like to declare the type usage as explicitly as possible preventing the use of any as much as possible. Any light or advice on this?