Capacitor TypeScript definitions for legacy projects

Capacitor is a cross-platform runtime that allows you to build apps using web technology, while having a native bridge for invoking native SDKs. It is basically the successor to Cordova.

I'm in the midst of upgrading a Cordova app to use Capacitor, but keeping the original application code, which was built in TypeScript and uses Ionic 1.x. It uses my Ionic/TypeScript Starter Project project template.

This template was created a few years back and uses TypeScript namespaces (previously known as "internal modules") as opposed to the more recent module format.

This essentially means that instead of using the more modern ES6 import directive, everything is accessible via namespaces in a single bundle. This is problematic when you want to use TypeScript definitions, which are written in the modern module format, for Capacitor.

I threw together some TypeScript definitions for Capacitor that are compatible with TypeScript projects using namespaces instead of modules. They're up on GitHub as a jumping-off point for others who might want to run their older TypeScript projects in Capacitor.

TypeScript definitions for Capacitor, adapted for use in projects that use the namespace ("internal modules") convention.

Author image
Northern California
A software geek who is into IoT devices, gaming, and Arcade restoration.