From 998a58e036f3e0752c03b3f3e38b2e8b303e7aba Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 10 Mar 2016 15:48:20 -0600 Subject: [PATCH] chore(): cleanup return values Addresses https://github.com/driftyco/ionic-native/issues/38. --- src/plugins/barcodescanner.ts | 9 +- src/plugins/ble.ts | 148 ++++++++----------------------- src/plugins/calendar.ts | 141 ++++------------------------- src/plugins/camera.ts | 9 +- src/plugins/clipboard.ts | 8 +- src/plugins/contacts.ts | 19 +--- src/plugins/datepicker.ts | 9 +- src/plugins/device.ts | 4 +- src/plugins/devicemotion.ts | 18 +--- src/plugins/deviceorientation.ts | 18 +--- src/plugins/dialogs.ts | 42 ++++----- src/plugins/facebook.ts | 85 +++--------------- src/plugins/flashlight.ts | 45 ++-------- src/plugins/geolocation.ts | 18 +--- src/plugins/imagepicker.ts | 9 +- src/plugins/launchnavigator.ts | 13 ++- src/plugins/push.ts | 14 +-- src/plugins/sms.ts | 13 ++- src/plugins/statusbar.ts | 4 +- src/plugins/toast.ts | 90 ++++--------------- src/plugins/touchid.ts | 36 +------- 21 files changed, 141 insertions(+), 611 deletions(-) diff --git a/src/plugins/barcodescanner.ts b/src/plugins/barcodescanner.ts index ae0eb481..63537300 100644 --- a/src/plugins/barcodescanner.ts +++ b/src/plugins/barcodescanner.ts @@ -28,14 +28,7 @@ export class BarcodeScanner { * @return Returns a Promise that resolves with scanner data, or rejects with an error. */ @Cordova() - static scan(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static scan(): Promise { return } // Not well supported // @Cordova() diff --git a/src/plugins/ble.ts b/src/plugins/ble.ts index f4db8b11..3e986454 100644 --- a/src/plugins/ble.ts +++ b/src/plugins/ble.ts @@ -181,14 +181,7 @@ export class BLE { @Cordova({ observable: true }) - static scan(services:string[], seconds:number) { - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static scan(services: string[], seconds: number): Observable { return } /** * Scan and discover BLE peripherals until `stopScan` is called. @@ -211,14 +204,7 @@ export class BLE { clearFunction: 'stopScan', clearWithArgs: true }) - static startScan(services:string[]){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - }; + static startScan(services: string[]): Observable { return } /** * Stop a scan started by `startScan`. @@ -235,14 +221,7 @@ export class BLE { * @return returns a Promise. */ @Cordova() - static stopScan(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static stopScan(): Promise { return } /** * Connect to a peripheral. @@ -263,14 +242,7 @@ export class BLE { clearFunction: 'disconnect', clearWithArgs: true }) - static connect(deviceId:string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - }; + static connect(deviceId: string): Observable { return } /** * Disconnect from a peripheral. @@ -284,14 +256,7 @@ export class BLE { * @return Returns a Promise */ @Cordova() - static disconnect(deviceId:string) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static disconnect(deviceId: string): Promise { return } /** * Read the value of a characteristic. @@ -302,14 +267,11 @@ export class BLE { * @return Returns a Promise */ @Cordova() - static read(deviceId:string, serviceUUID:string, characteristicUUID:string){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static read( + deviceId: string, + serviceUUID: string, + characteristicUUID: string + ): Promise { return }; /** * Write the value of a characteristic. @@ -340,14 +302,12 @@ export class BLE { * @return Returns a Promise */ @Cordova() - static write(deviceId:string, serviceUUID:string, characteristicUUID:string, value:ArrayBuffer){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static write( + deviceId: string, + serviceUUID: string, + characteristicUUID: string, + value: ArrayBuffer + ): Promise { return } /** * Write the value of a characteristic without waiting for confirmation from the peripheral. @@ -359,14 +319,12 @@ export class BLE { * @return Returns a Promise */ @Cordova() - static writeWithoutResponse(deviceId:string, serviceUUID:string, characteristicUUID:string, value:ArrayBuffer){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static writeWithoutResponse( + deviceId: string, + serviceUUID: string, + characteristicUUID: string, + value: ArrayBuffer + ): Promise { return } /** * Register to be notified when the value of a characteristic changes. @@ -388,14 +346,11 @@ export class BLE { clearFunction: 'stopNotification', clearWithArgs: true }) - static startNotification(deviceId:string, serviceUUID:string, characteristicUUID:string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - }; + static startNotification( + deviceId: string, + serviceUUID: string, + characteristicUUID: string + ): Observable { return } /** * Stop being notified when the value of a characteristic changes. @@ -406,14 +361,11 @@ export class BLE { * @return Returns a Promise. */ @Cordova() - static stopNotification(deviceId:string, serviceUUID:string, characteristicUUID:string){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static stopNotification( + deviceId: string, + serviceUUID: string, + characteristicUUID: string + ): Promise { return } /** * Report the connection status. @@ -429,14 +381,7 @@ export class BLE { * @return Returns a Promise. */ @Cordova() - static isConnected(deviceId:string){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static isConnected(deviceId: string): Promise { return } /** * Report if bluetooth is enabled. @@ -451,14 +396,7 @@ export class BLE { * @return Returns a Promise. */ @Cordova() - static isEnabled(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static isEnabled(): Promise { return } /** * Open System Bluetooth settings (Android only). @@ -466,14 +404,7 @@ export class BLE { * @return Returns a Promise. */ @Cordova() - static showBluetoothSettings(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static showBluetoothSettings(): Promise { return } /** * Enable Bluetooth on the device (Android only). @@ -481,12 +412,5 @@ export class BLE { * @return Returns a Promise. */ @Cordova() - static enable(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static enable(): Promise { return } } diff --git a/src/plugins/calendar.ts b/src/plugins/calendar.ts index f9a1377c..c581c963 100644 --- a/src/plugins/calendar.ts +++ b/src/plugins/calendar.ts @@ -48,14 +48,9 @@ export class Calendar { * @return Returns a Promise */ @Cordova() - static createCalendar(nameOrOptions: string | { calendarName: string, calendarColor: string }) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static createCalendar( + nameOrOptions: string | { calendarName: string, calendarColor: string } + ): Promise { return } /** * Delete a calendar. (iOS only) @@ -72,14 +67,7 @@ export class Calendar { * @return Returns a Promise */ @Cordova() - static deleteCalendar(name: string) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static deleteCalendar(name: string): Promise { return } /** * Returns the default calendar options. @@ -127,14 +115,7 @@ export class Calendar { notes?: string, startDate?: Date, endDate?: Date - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Silently create an event with additional options. @@ -155,14 +136,7 @@ export class Calendar { startDate?: Date, endDate?: Date, options?: CalendarOptions - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Interactively create an event. @@ -181,14 +155,7 @@ export class Calendar { notes?: string, startDate?: Date, endDate?: Date - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Interactively create an event with additional options. @@ -209,14 +176,7 @@ export class Calendar { startDate?: Date, endDate?: Date, options?: CalendarOptions - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } // deprecated // @Cordova() @@ -246,14 +206,7 @@ export class Calendar { notes?: string, startDate?: Date, endDate?: Date - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Find an event with additional options. @@ -274,14 +227,7 @@ export class Calendar { startDate?: Date, endDate?: Date, options?: CalendarOptions - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Find a list of events within the specified date range. (Android only) @@ -291,37 +237,21 @@ export class Calendar { * @return Returns a Promise that resolves with the list of events, or rejects with an error. */ @Cordova() - static listEventsInRange(startDate: Date, endDate: Date) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static listEventsInRange(startDate: Date, endDate: Date): Promise { return } /** * Get a list of all calendars. * @return A Promise that resolves with the list of calendars, or rejects with an error. */ @Cordova() - static listCalendars(){ - return new Promise((res, rej) => {}); - } + static listCalendars(){ return } /** * Get a list of all future events in the specified calendar. (iOS only) * @return Returns a Promise that resolves with the list of events, or rejects with an error. */ @Cordova() - static findAllEventsInNamedCalendar(calendarName: string) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static findAllEventsInNamedCalendar(calendarName: string): Promise { return } /** * Modify an event. (iOS only) @@ -350,14 +280,7 @@ export class Calendar { newNotes?: string, newStartDate?: Date, newEndDate?: Date - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Modify an event with additional options. (iOS only) @@ -388,14 +311,7 @@ export class Calendar { newStartDate?: Date, newEndDate?: Date, options?: CalendarOptions - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ) { return } /** * Delete an event. @@ -414,14 +330,7 @@ export class Calendar { notes?: string, startDate?: Date, endDate?: Date - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Delete an event from the specified Calendar. (iOS only) @@ -442,26 +351,12 @@ export class Calendar { startDate?: Date, endDate?: Date, calendarName?: string - ) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + ): Promise { return } /** * Open the calendar at the specified date. * @return {Date} date */ @Cordova() - static openCalendar(date: Date) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static openCalendar(date: Date): Promise { return } } diff --git a/src/plugins/camera.ts b/src/plugins/camera.ts index 10105989..29dc1059 100644 --- a/src/plugins/camera.ts +++ b/src/plugins/camera.ts @@ -115,14 +115,7 @@ export class Camera { @Cordova({ callbackOrder: 'reverse' }) - static getPicture(options: CameraOptions){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static getPicture(options: CameraOptions): Promise { return } /** * Remove intermediate image files that are kept in temporary storage after calling camera.getPicture. diff --git a/src/plugins/clipboard.ts b/src/plugins/clipboard.ts index 6b5ba9ee..a6690271 100644 --- a/src/plugins/clipboard.ts +++ b/src/plugins/clipboard.ts @@ -37,17 +37,13 @@ export class Clipboard { * @returns {Promise} */ @Cordova() - static copy(text : string) : Promise { - return new Promise((res, resj) => {}); - } + static copy(text: string): Promise { return } /** * Pastes the text stored in clipboard * @returns {Promise} */ @Cordova() - static paste() : Promise { - return new Promise((res, rej) => {}); - } + static paste(): Promise { return } } diff --git a/src/plugins/contacts.ts b/src/plugins/contacts.ts index 3fdaf731..ea6955be 100644 --- a/src/plugins/contacts.ts +++ b/src/plugins/contacts.ts @@ -246,26 +246,13 @@ export class Contacts { successIndex: 1, errorIndex: 2 }) - static find(fields: string[], options?: any){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static find(fields: string[], options?: any): Promise { return } + /** * Select a single Contact. * @return Returns a Promise that resolves with the selected Contact */ @Cordova() - static pickContact(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static pickContact(): Promise { return } } diff --git a/src/plugins/datepicker.ts b/src/plugins/datepicker.ts index 3758db96..3e9bd91e 100644 --- a/src/plugins/datepicker.ts +++ b/src/plugins/datepicker.ts @@ -99,13 +99,6 @@ export class DatePicker { * @returns {Promise} Returns a promise that resolves with the picked date and/or time, or rejects with an error. */ @Cordova() - static show(options: datePickerOptions): Promise { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static show(options: datePickerOptions): Promise { return } } \ No newline at end of file diff --git a/src/plugins/device.ts b/src/plugins/device.ts index 99829e45..c1b9f7a6 100644 --- a/src/plugins/device.ts +++ b/src/plugins/device.ts @@ -50,7 +50,5 @@ export class Device { * @returns {Object} The device object. */ @CordovaProperty - static get device() { - return window.device; - } + static get device() { return window.device; } } diff --git a/src/plugins/devicemotion.ts b/src/plugins/devicemotion.ts index 4196080b..69795f42 100644 --- a/src/plugins/devicemotion.ts +++ b/src/plugins/devicemotion.ts @@ -72,14 +72,7 @@ export class DeviceMotion { * @returns {Promise} Returns object with x, y, z, and timestamp properties */ @Cordova() - static getCurrentAcceleration () : Promise { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static getCurrentAcceleration(): Promise { return } /** * Watch the device acceleration. Clear the watch by unsubscribing from the observable. @@ -101,12 +94,5 @@ export class DeviceMotion { observable: true, clearFunction: 'clearWatch' }) - static watchAcceleration (options? : accelerometerOptions) : Observable { - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is PrObservableomise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static watchAcceleration (options?: accelerometerOptions): Observable { return } } diff --git a/src/plugins/deviceorientation.ts b/src/plugins/deviceorientation.ts index b9d9c749..c11d16ba 100644 --- a/src/plugins/deviceorientation.ts +++ b/src/plugins/deviceorientation.ts @@ -74,14 +74,7 @@ export class DeviceOrientation { * @returns {Promise} */ @Cordova() - static getCurrentHeading() : Promise { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static getCurrentHeading(): Promise { return } /** * Get the device current heading at a regular interval @@ -95,13 +88,6 @@ export class DeviceOrientation { observable: true, cancelFunction: 'clearWatch' }) - static watchHeading(options? : CompassOptions) : Observable { - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static watchHeading(options?: CompassOptions): Observable { return } } diff --git a/src/plugins/dialogs.ts b/src/plugins/dialogs.ts index 28e3d016..0395295a 100644 --- a/src/plugins/dialogs.ts +++ b/src/plugins/dialogs.ts @@ -42,14 +42,11 @@ export class Dialogs { successIndex: 1, errorIndex: 4 }) - static alert(message, title : string = 'Alert', buttonName : string = 'OK') : Promise{ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static alert( + message, + title: string = 'Alert', + buttonName: string = 'OK' + ): Promise{ return } /** * Displays a customizable confirmation dialog box. @@ -62,14 +59,11 @@ export class Dialogs { successIndex: 1, errorIndex: 4 }) - static confirm(message, title : string = 'Confirm', buttonLabels : Array = ['OK', 'Cancel']) : Promise{ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static confirm( + message, + title: string = 'Confirm', + buttonLabels: Array = ['OK', 'Cancel'] + ): Promise{ return } /** * Displays a native dialog box that is more customizable than the browser's prompt function. @@ -83,14 +77,12 @@ export class Dialogs { successIndex: 1, errorIndex: 5 }) - static prompt(message, title : string = 'Prompt', buttonLabels : Array = ['OK', 'Cancel'], defaultText : string = '') : Promise{ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static prompt( + message?: string, + title: string = 'Prompt', + buttonLabels: Array = ['OK', 'Cancel'], + defaultText: string = '' + ): Promise{ return } /** @@ -100,6 +92,6 @@ export class Dialogs { @Cordova({ sync: true }) - static beep(times : number) : void {} + static beep(times: number): void {} } \ No newline at end of file diff --git a/src/plugins/facebook.ts b/src/plugins/facebook.ts index 40f096ca..fce34683 100644 --- a/src/plugins/facebook.ts +++ b/src/plugins/facebook.ts @@ -102,14 +102,7 @@ export class Facebook { * @return Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails. */ @Cordova() - static login(permissions: string[]){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static login(permissions: string[]): Promise { return } /** * Logout of Facebook. @@ -118,14 +111,7 @@ export class Facebook { * @return Returns a Promise that resolves on a successful logout, and rejects if logout fails. */ @Cordova() - static logout(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static logout(): Promise { return } /** * Determine if a user is logged in to Facebook and has authenticated your app. There are three possible states for a user: @@ -154,14 +140,7 @@ export class Facebook { * @return Returns a Promise that resolves with a status, or rejects with an error */ @Cordova() - static getLoginStatus(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static getLoginStatus(): Promise { return } /** * Get a Facebook access token for using Facebook services. @@ -169,14 +148,7 @@ export class Facebook { * @return Returns a Promise that resolves with an access token, or rejects with an error */ @Cordova() - static getAccessToken(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static getAccessToken(): Promise { return } /** * Show one of various Facebook dialogs. Example of options for a Share dialog: @@ -196,14 +168,7 @@ export class Facebook { * @return Returns a Promise that resolves with success data, or rejects with an error */ @Cordova() - static showDialog(options: any){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static showDialog(options: any): Promise { return } /** * Make a call to Facebook Graph API. Can take additional permissions beyond those granted on login. @@ -219,14 +184,7 @@ export class Facebook { * @return Returns a Promise that resolves with the result of the request, or rejects with an error */ @Cordova() - static api(requestPath: string, permissions: string[]){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static api(requestPath: string, permissions: string[]): Promise { return } /** * Log an event. For more information see the Events section above. @@ -237,14 +195,11 @@ export class Facebook { * @return */ @Cordova() - static logEvent(name: string, params?: Object, valueToSum?: number){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static logEvent( + name: string, + params?: Object, + valueToSum?: number + ): Promise { return } /** * Log a purchase. For more information see the Events section above. @@ -254,14 +209,7 @@ export class Facebook { * @return Returns a Promise */ @Cordova() - static logPurchase(value: number, currency: string){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static logPurchase(value: number, currency: string): Promise { return } /** * Open App Invite dialog. Does not require login. @@ -282,12 +230,5 @@ export class Facebook { static appInvite(options: { url: string, picture: string - }){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + }): Promise { return } } diff --git a/src/plugins/flashlight.ts b/src/plugins/flashlight.ts index 68cd68f0..9a0ffa3c 100644 --- a/src/plugins/flashlight.ts +++ b/src/plugins/flashlight.ts @@ -22,60 +22,28 @@ export class Flashlight { * @returns {Promise} Returns a promise that resolves with a boolean stating if the flash light is available. */ @Cordova() - static available() : Promise{ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - - return new Promise((res,rej)=>{}); - } + static available(): Promise { return } /** * Switches the flashlight on * @returns {Promise} */ @Cordova() - static switchOn() : Promise{ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - - return new Promise((res,rej)=>{}); - } + static switchOn(): Promise { return } /** * Switches the flash light off * @returns {Promise} */ @Cordova() - static switchOff() : Promise{ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - - return new Promise((res,rej)=>{}); - } + static switchOff(): Promise { return } /** * Toggles the flashlight * @returns {Promise} */ @Cordova() - static toggle() : Promise { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - - return new Promise((res,rej)=>{}); - } + static toggle(): Promise { return } /** @@ -85,9 +53,6 @@ export class Flashlight { @Cordova({ sync: true }) - static isSwitchedOn() : boolean { - // DUMMY BOOLEAN, @Cordova decorator will replace value. - return true; - } + static isSwitchedOn(): boolean { return } } \ No newline at end of file diff --git a/src/plugins/geolocation.ts b/src/plugins/geolocation.ts index 524a9f5f..1c8d02d9 100644 --- a/src/plugins/geolocation.ts +++ b/src/plugins/geolocation.ts @@ -128,14 +128,7 @@ export class Geolocation { @Cordova({ callbackOrder: 'reverse' }) - static getCurrentPosition(options?: GeolocationOptions){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static getCurrentPosition(options?: GeolocationOptions): Promise { return } /** * Watch the current device's position. Clear the watch by unsubscribing from @@ -158,12 +151,5 @@ export class Geolocation { observable: true, clearFunction: 'clearWatch' }) - static watchPosition(options?: GeolocationOptions){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - }; + static watchPosition(options?: GeolocationOptions): Observable { return } } diff --git a/src/plugins/imagepicker.ts b/src/plugins/imagepicker.ts index 854fb5cf..f6fb90b6 100644 --- a/src/plugins/imagepicker.ts +++ b/src/plugins/imagepicker.ts @@ -50,12 +50,5 @@ export class ImagePicker { @Cordova({ callbackOrder: 'reverse' }) - static getPictures(options: ImagePickerOptions) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + static getPictures(options: ImagePickerOptions): Promise { return } } diff --git a/src/plugins/launchnavigator.ts b/src/plugins/launchnavigator.ts index 70805c37..eebc55bd 100644 --- a/src/plugins/launchnavigator.ts +++ b/src/plugins/launchnavigator.ts @@ -80,13 +80,10 @@ export class LaunchNavigator { successIndex: 2, errorIndex: 3 }) - static navigate(destination : any, start : any, options? : launchNavigatorOptions) : Promise { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static navigate( + destination: any, + start: any, + options?: launchNavigatorOptions + ): Promise { return } } diff --git a/src/plugins/push.ts b/src/plugins/push.ts index b55caa0c..920bf711 100644 --- a/src/plugins/push.ts +++ b/src/plugins/push.ts @@ -285,21 +285,13 @@ export class Push { @Cordova({ sync: true }) - static init(options: PushOptions){ - return new PushNotification(); - } + static init(options: PushOptions): PushNotification { return } /** * Check whether the push notification permission has been granted. * @return {Promise} Returns a Promise that resolves with an object with one property: isEnabled, a boolean that indicates if permission has been granted. */ @Cordova() - static hasPermission(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise<{ isEnabled: boolean }>((res, rej) => {}); - } + static hasPermission(): Promise<{ isEnabled: boolean }> { return } + } diff --git a/src/plugins/sms.ts b/src/plugins/sms.ts index be15d57d..e33796ed 100644 --- a/src/plugins/sms.ts +++ b/src/plugins/sms.ts @@ -51,13 +51,10 @@ export class SMS { * @returns {Promise} */ @Cordova() - static send(number : any, message : string, options? : smsOptions) : Promise { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static send( + number: string | string[], + message: string, + options?: smsOptions + ): Promise { return } } diff --git a/src/plugins/statusbar.ts b/src/plugins/statusbar.ts index 36ac19f2..bb938ec4 100644 --- a/src/plugins/statusbar.ts +++ b/src/plugins/statusbar.ts @@ -102,7 +102,5 @@ export class StatusBar { * Whether the StatusBar is currently visible or not. */ @CordovaProperty - static get isVisible() { - return window.StatusBar.isVisible; - } + static get isVisible() { return window.StatusBar.isVisible; } } diff --git a/src/plugins/toast.ts b/src/plugins/toast.ts index 92a8b8ad..a6444349 100644 --- a/src/plugins/toast.ts +++ b/src/plugins/toast.ts @@ -31,28 +31,18 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static show(message: string, duration: string, position: string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static show( + message: string, + duration: string, + position: string + ): Observable { return } /** * Manually hide any currently visible toast. * @return {Promise} Returns a Promise that resolves on success. */ @Cordova() - static hide(){ - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static hide(): Promise{ return } /** * Show a native toast with the given options. @@ -69,14 +59,7 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static showWithOptions(options: ToastOptions){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static showWithOptions(options: ToastOptions): Observable { return } /** * Shorthand for `show(message, 'short', 'top')`. @@ -86,14 +69,7 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static showShortTop(message: string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static showShortTop(message: string): Observable { return } /** * Shorthand for `show(message, 'short', 'center')`. @@ -103,14 +79,8 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static showShortCenter(message: string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static showShortCenter(message: string): Observable { return } + /** * Shorthand for `show(message, 'short', 'bottom')`. @@ -120,14 +90,8 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static showShortBottom(message: string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static showShortBottom(message: string): Observable { return } + /** * Shorthand for `show(message, 'long', 'top')`. @@ -137,14 +101,8 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static showLongTop(message: string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static showLongTop(message: string): Observable { return } + /** * Shorthand for `show(message, 'long', 'center')`. @@ -154,14 +112,8 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static showLongCenter(message: string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static showLongCenter(message: string): Observable { return } + /** * Shorthand for `show(message, 'long', 'bottom')`. @@ -171,12 +123,6 @@ export class Toast { observable: true, clearFunction: 'hide' }) - static showLongBottom(message: string){ - // This Observable is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Observable, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Observable(observer => {}); - } + static showLongBottom(message: string): Observable { return } + } diff --git a/src/plugins/touchid.ts b/src/plugins/touchid.ts index bd50118e..fc7a20de 100644 --- a/src/plugins/touchid.ts +++ b/src/plugins/touchid.ts @@ -34,14 +34,7 @@ export class TouchID { * @return {Promise} Returns a Promise that resolves if yes, rejects if no. */ @Cordova() - isAvailable() { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - }; + isAvailable(): Promise{ return } /** * Show TouchID dialog and wait for a fingerprint scan. If user taps 'Enter Password' button, brings up standard system passcode screen. @@ -50,14 +43,7 @@ export class TouchID { * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). */ @Cordova() - static verifyFingerprint(message: string) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static verifyFingerprint(message: string): Promise{ return } /** * Show TouchID dialog and wait for a fingerprint scan. If user taps 'Enter Password' button, rejects with code '-3' (see above). @@ -66,14 +52,7 @@ export class TouchID { * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). */ @Cordova() - static verifyFingerprintWithCustomPasswordFallback(message: string) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static verifyFingerprintWithCustomPasswordFallback(message: string): Promise { return } /** * Show TouchID dialog with custom 'Enter Password' message and wait for a fingerprint scan. If user taps 'Enter Password' button, rejects with code '-3' (see above). @@ -83,12 +62,5 @@ export class TouchID { * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). */ @Cordova() - static verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message: string, enterPasswordLabel: string) { - // This Promise is replaced by one from the @Cordova decorator that wraps - // the plugin's callbacks. We provide a dummy one here so TypeScript - // knows that the correct return type is Promise, because there's no way - // for it to know the return type from a decorator. - // See https://github.com/Microsoft/TypeScript/issues/4881 - return new Promise((res, rej) => {}); - } + static verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message: string, enterPasswordLabel: string): Promise { return } }