I have an audio that I load using HTML:
<audio>
<source src="file.ogg" />
<source src="file.mp3" />
</audio>
I have also extended the prototype to create a new function:
Audio.prototype.restart = function(){
this.pause();
this.currentTime = 0;
this.play();
}
However, when I fetch the audio element, typescript does not recognize it as an instance of Audio:
let file = document.querySelector("audio")! as Audio;
file.restart()
I get two errors:
'Audio' refers to a value, but is being used as a type here. Did you mean 'typeof Audio'?
ts(2749)
Property 'restart' does not exist on type 'HTMLAudioElement'
.ts(2339)
How do I fix this?