I'm new to Typescript. I just started an Ionic 1.2.4 (Angular) project using Typescript. When transpiling, I receive the error message Property 'Keyboard' does not exist on type 'CordovaPlugins'
due to the following function passed to angular.module.run()
in a file run.ts
///<reference path="../../typings/tsd.d.ts"/>
export function onRun($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
})
}
The cordova plugin is in fact installed and it's type definition file definitely exists. Here is the file tsd.d.ts
.
/// <reference path="angularjs/angular.d.ts" />
/// <reference path="cordova/cordova.d.ts" />
/// <reference path="cordova/plugins/BatteryStatus.d.ts" />
/// <reference path="cordova/plugins/Camera.d.ts" />
/// <reference path="cordova/plugins/Contacts.d.ts" />
/// <reference path="cordova/plugins/Device.d.ts" />
/// <reference path="cordova/plugins/DeviceMotion.d.ts" />
/// <reference path="cordova/plugins/DeviceOrientation.d.ts" />
/// <reference path="cordova/plugins/Dialogs.d.ts" />
/// <reference path="cordova/plugins/FileSystem.d.ts" />
/// <reference path="cordova/plugins/FileTransfer.d.ts" />
/// <reference path="cordova/plugins/Globalization.d.ts" />
/// <reference path="cordova/plugins/InAppBrowser.d.ts" />
/// <reference path="cordova/plugins/Keyboard.d.ts" />
/// <reference path="cordova/plugins/Media.d.ts" />
/// <reference path="cordova/plugins/MediaCapture.d.ts" />
/// <reference path="cordova/plugins/NetworkInformation.d.ts" />
/// <reference path="cordova/plugins/Push.d.ts" />
/// <reference path="cordova/plugins/Splashscreen.d.ts" />
/// <reference path="cordova/plugins/StatusBar.d.ts" />
/// <reference path="cordova/plugins/Vibration.d.ts" />
/// <reference path="cordova/plugins/WebSQL.d.ts" />
/// <reference path="ionic/ionic.d.ts" />
/// <reference path="jquery/jquery.d.ts" />
I have also tried placing the type definition for Keyboard directly in run.ts
. ///<reference path="../../typings/cordova/plugins/Keyboard.d.ts"/>
I'm not expecting the plugin to actually register because 'cordova.js' is not available until the app is built/packaged. I would however like to know how to get Typescript to recognize that Keyboard
does in fact exist on cordova.plugins
via type defs. Otherwise, how can I avoid this error during transpilation?