Search code examples
javascriptphpstormweb-audio-api

PhpStorm doesn't recognise web audio api


I'm currently using the web audio api in a javascript project, but my IDE (PhpStorm) doesn't recognise any of it's functions:

screenshot: unresolved type

So i started looking for some library definition to install (in Preferences / Languages & Frameworks / JavaScript / Libraries) and found the following:

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/webaudioapi

But after installing, things didn't get any better:

screenshot: interface can not be instantiated

Am I doing something wrong or is there another way to work with web audio api in PhpStorm?


Solution

  • 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