Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228598

Ionic2 typescript project with cordova plugins

$
0
0

Hi

I've used the Typescript definitions as published on https://github.com/DefinitelyTyped/DefinitelyTyped. Great stuff there.

For emailing I had to use the typings for cordova and cordova email plugin (cordova-plugin-email-composer). In the *.ts file you need to reference to the typings so the transpiler includes them (/// <reference path="Cordova.d.ts"/>), besides including the typings for the plugin if they are not in the default list. Some of the default plugins have typings as part of the cordova.d.ts (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/cordova). Default it includes:

/// <reference path="plugins/BatteryStatus.d.ts"/>
/// <reference path="plugins/Camera.d.ts"/>
/// <reference path="plugins/Contacts.d.ts"/>
/// <reference path="plugins/Device.d.ts"/>
/// <reference path="plugins/DeviceMotion.d.ts"/>
/// <reference path="plugins/DeviceOrientation.d.ts"/>
/// <reference path="plugins/Dialogs.d.ts"/>
/// <reference path="plugins/FileSystem.d.ts"/>
/// <reference path="plugins/FileTransfer.d.ts"/>
/// <reference path="plugins/Globalization.d.ts"/>
/// <reference path="plugins/InAppBrowser.d.ts"/>
/// <reference path="plugins/Media.d.ts"/>
/// <reference path="plugins/MediaCapture.d.ts"/>
/// <reference path="plugins/NetworkInformation.d.ts"/>
/// <reference path="plugins/Push.d.ts"/>
/// <reference path="plugins/Splashscreen.d.ts"/>
/// <reference path="plugins/StatusBar.d.ts"/>
/// <reference path="plugins/Vibration.d.ts"/>
/// <reference path="plugins/WebSQL.d.ts"/>
/// <reference path="plugins/Keyboard.d.ts"/>

For the emailer plugin, I took a bit of a crude approach and just included the interface definitions in the ts file of the starter template.

Also got it to work with the camera in Ionic2 TS.

Hope it will work for you.

Regards,

Tom


Viewing all articles
Browse latest Browse all 228598

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>