JavaScript AudioContext - 'Interface can not be instantiated'
I'm having problems making PhpStorm recognise the web audio api functions.
I found and downloaded 'webaudioapi-DefinitlyTyped' in 'JavaScript Libraries', but the following line:
var context = new AudioContext();
leads to the error 'Interface can not be instantiated'.
Is there a setting i am missing?
Please sign in to leave a comment.
the problem is that AudioContext is an interface in waa.d.ts. And interfaces can't be instantiated using new() operator.
I'd suggest using lib.es6.d.ts instead - it includes correct stubs for WebAudio API. Just add \plugins\JavaScriptLanguage\typescriptCompiler\external\lib.es6.d.ts as a javascript library to your project
for further comments on the topic, see http://stackoverflow.com/a/38223076/176140