Search code examples
javascriptcordovatypescriptwebstorm

Typescript extract knowledge from js object


I'm creating a ionic (cordova) product and I'd like to utilize typescript and its benefits for autocompletion optimally. But since many of the plugin objects don't stem from concrete classes I don't know how/if there is a way to utilize the knowledge from the plugin files (which are .js). If there is a way to do this I'd of course like to know this.


Solution

  • As mentioned in my comment you can use Typescript definition files to provide type information.

    There are definition files for common Cordova plugins on Definitly Typed.

    If you can't find type information for the plugin you're looking for, you can write your own definition file.