IndexedDB Code Completion and Type Hinting

Posted by filed under Goodies to go, How to.

IndexedDB isn’t really a new API, but most (maybe even all) Editors don’t provide code completion for it. This is a little annoying, but there’s a quick fix available: You just need to port the relevant IDL definitions to JavaScript, and tell your IDE to include the resulting .js file as a library. I already did part one for you (you can download the result from GitHub), and this tutorial shoes how to add the IndexDB API to the popular WebStorm / PHPStorm IDEs. I assume that it will work pretty similar for other IDEs.

Step 1: Getting the definitions

The definitions are available from this repository: https://github.com/jensarps/indexeddb-types. You can clone or download the repository, or just download the IndexedDB.js file.

Step 2: Telling your IDE to use it as a library

This will work different among IDEs, but will probably pretty similar and straightforward. This is how it works for WebStorm and PHPStorm:

First, open the preferences panel and select “JavaScript” and then “Libraries” from the left section of the window:

step1

 

There, click the “Add…” button which will open the following window:

step2

Type “IndexedDB” as name and select “Global” as visibility. Next, click on the “Attach…” button to open up a file dialog:

step3

Navigate to the IndexedDB.js file, select it and click “OK”. The Library window now should look like this:

step4

Click “Apply” or “OK” and your done.

Step 3: Fun and Profit

Now you will have code completion, parameter info and argument type hinting, return type hinting and wrong type assignment checks.

Enjoy!

[Comments are automatically closed after 30 days.]

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close