diff --git a/scripts/build/build.js b/scripts/build/build.js index bd81852f5..31730130b 100644 --- a/scripts/build/build.js +++ b/scripts/build/build.js @@ -53,14 +53,17 @@ const PLUGINS = fs.readdirSync(PLUGINS_PATH); // Build specific list of plugins to build from arguments, if any let pluginsToBuild = process.argv.slice(2); let ignoreErrors = false; +let errors = []; + +const index = pluginsToBuild.indexOf('ignore-errors'); +if (index > -1) { + ignoreErrors = true; + pluginsToBuild.splice(index, 1); + console.log('Build will continue even if errors were thrown. Errors will be printed when build finishes.'); +} + if (!pluginsToBuild.length) { pluginsToBuild = PLUGINS; -} else { - const index = pluginsToBuild.indexOf('--ignore-errors'); - if (index > -1) { - ignoreErrors = true; - pluginsToBuild.splice(index, 1); - } } // Create a queue to process tasks @@ -109,12 +112,14 @@ const addPluginToQueue = pluginName => { exec(`${ROOT}/node_modules/.bin/ngc -p ${tsConfigPath}`, (err, stdout, stderr) => { if (err) { - console.log(err); if (!ignoreErrors) { // oops! something went wrong. + console.log(err); callback(`\n\nBuilding ${pluginName} failed.`); return; + } else { + errors.push(err); } } @@ -137,6 +142,9 @@ QUEUE.start((err) => { if (err) { console.log('Error building plugins. ', err); + } else if (errors.length) { + errors.forEach(e => console.log(e.message) && console.log('\n')); + console.log('Build complete with errors'); } else { console.log('Done processing plugins!'); } diff --git a/scripts/build/tsconfig-core.json b/scripts/build/tsconfig-core.json index 44b50a3db..88250a7b8 100644 --- a/scripts/build/tsconfig-core.json +++ b/scripts/build/tsconfig-core.json @@ -13,7 +13,8 @@ "skipLibCheck": true, "lib": ["es2015", "dom"], "sourceMap": true, - "inlineSources": true + "inlineSources": true, + "noImplicitAny": true }, "files": [ "../../src/@ionic-native/core/index.ts" diff --git a/scripts/build/tsconfig-plugin.json b/scripts/build/tsconfig-plugin.json index 3cfd5dca3..3e4a6d6f8 100644 --- a/scripts/build/tsconfig-plugin.json +++ b/scripts/build/tsconfig-plugin.json @@ -16,7 +16,8 @@ "skipLibCheck": true, "lib": ["es2015", "dom"], "sourceMap": true, - "inlineSources": true + "inlineSources": true, + "noImplicitAny": true }, "files": [] } diff --git a/src/@ionic-native/core/bootstrap.ts b/src/@ionic-native/core/bootstrap.ts index a8557a182..09ac37f15 100644 --- a/src/@ionic-native/core/bootstrap.ts +++ b/src/@ionic-native/core/bootstrap.ts @@ -1,5 +1,3 @@ -declare var window; - export function checkReady() { const DEVICE_READY_TIMEOUT = 5000; @@ -16,7 +14,7 @@ export function checkReady() { }); setTimeout(() => { - if (!didFireReady && window.cordova) { + if (!didFireReady && !!window.cordova) { console.warn(`Ionic Native: deviceready did not fire within ${DEVICE_READY_TIMEOUT}ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.`); } }, DEVICE_READY_TIMEOUT); diff --git a/src/@ionic-native/core/decorators.ts b/src/@ionic-native/core/decorators.ts index a9dbab18f..3429c74c0 100644 --- a/src/@ionic-native/core/decorators.ts +++ b/src/@ionic-native/core/decorators.ts @@ -32,6 +32,8 @@ export interface PluginConfig { * Supported platforms */ platforms?: string[]; + + [key: string]: any; } export interface CordovaOptions { @@ -182,12 +184,12 @@ export function CordovaCheck(opts: CordovaCheckOptions = {}) { * } * ``` */ -export function Plugin(config: PluginConfig) { - return function(cls) { +export function Plugin(config: PluginConfig): ClassDecorator { + return function(cls: any) { // Add these fields to the class - for (let k in config) { - cls[k] = config[k]; + for (let prop in config) { + cls[prop] = config[prop]; } cls['installed'] = function(printWarning?: boolean) { diff --git a/src/@ionic-native/core/plugin.ts b/src/@ionic-native/core/plugin.ts index aaaeae298..f7fbedce1 100644 --- a/src/@ionic-native/core/plugin.ts +++ b/src/@ionic-native/core/plugin.ts @@ -7,8 +7,8 @@ import 'rxjs/add/observable/fromEvent'; checkReady(); -declare var window; -declare var Promise; +// declare const window; +// declare var Promise; /** @@ -16,8 +16,8 @@ declare var Promise; * @return {boolean | { error: string } } * @private */ -export function checkAvailability(pluginRef: string, methodName?: string, pluginName?: string); -export function checkAvailability(pluginObj: any, methodName?: string, pluginName?: string); +export function checkAvailability(pluginRef: string, methodName?: string, pluginName?: string): boolean | { error: string }; +export function checkAvailability(pluginObj: any, methodName?: string, pluginName?: string): boolean | { error: string }; export function checkAvailability(plugin: any, methodName?: string, pluginName?: string): boolean | { error: string } { let pluginRef, pluginInstance, pluginPackage; @@ -69,7 +69,7 @@ function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Func args.unshift(reject); args.unshift(resolve); } else if (opts.callbackStyle === 'node') { - args.push((err, result) => { + args.push((err: any, result: any) => { if (err) { reject(err); } else { @@ -135,8 +135,8 @@ function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts } function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any = {}) { - let pluginResult, rej; - const p = getPromise((resolve, reject) => { + let pluginResult: any, rej: Function; + const p = getPromise((resolve: Function, reject: Function) => { pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject); rej = reject; }); @@ -145,13 +145,13 @@ function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any // to error if (pluginResult && pluginResult.error) { p.catch(() => { }); - rej(pluginResult.error); + typeof rej === 'function' && rej(pluginResult.error); } return p; } function wrapOtherPromise(pluginObj: any, methodName: string, args: any[], opts: any = {}) { - return getPromise((resolve, reject) => { + return getPromise((resolve: Function, reject: Function) => { const pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts); if (pluginResult) { if (pluginResult.error) { @@ -239,7 +239,7 @@ export function overrideFunction(pluginObj: any, methodName: string, args: any[] * @private */ export const wrap = function(pluginObj: any, methodName: string, opts: CordovaOptions = {}) { - return (...args) => { + return (...args: any[]) => { if (opts.sync) { // Sync doesn't wrap the plugin with a promise or observable, it returns the result as-is return callCordovaPlugin(pluginObj, methodName, args, opts); @@ -259,7 +259,7 @@ export const wrap = function(pluginObj: any, methodName: string, opts: CordovaOp * @private */ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {}) { - return (...args) => { + return (...args: any[]) => { if (opts.sync) { return callInstance(pluginObj, methodName, args, opts); @@ -289,7 +289,7 @@ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {}) } else if (opts.otherPromise) { - return getPromise((resolve, reject) => { + return getPromise((resolve: Function, reject: Function) => { let result = callInstance(pluginObj, methodName, args, opts, resolve, reject); if (result && !result.error) { result.then(resolve, reject); @@ -298,14 +298,14 @@ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {}) } else { - let pluginResult, rej; - const p = getPromise((resolve, reject) => { + let pluginResult: any, rej: Function; + const p = getPromise((resolve: Function, reject: Function) => { pluginResult = callInstance(pluginObj, methodName, args, opts, resolve, reject); rej = reject; }); if (pluginResult && pluginResult.error) { p.catch(() => { }); - rej(pluginResult.error); + typeof rej === 'function' && rej(pluginResult.error); } return p; diff --git a/src/@ionic-native/core/util.ts b/src/@ionic-native/core/util.ts index cfc43e5f1..31d0a4533 100644 --- a/src/@ionic-native/core/util.ts +++ b/src/@ionic-native/core/util.ts @@ -1,27 +1,28 @@ -declare var window: any; +declare const window: any; /** * @private */ -export function get(obj, path) { - path = path.split('.'); - for (let i = 0; i < path.length; i++) { +export const get = (element: Element | Window, path: string): any => { + const paths: string[] = path.split('.'); + let obj: any = element; + for (let i: number = 0; i < paths.length; i++) { if (!obj) { return null; } - obj = obj[path[i]]; + obj = obj[paths[i]]; } return obj; -} +}; /** * @private */ -export function getPromise(cb) { +export const getPromise = (callback: Function): Promise => { const tryNativePromise = () => { if (window.Promise) { return new Promise((resolve, reject) => { - cb(resolve, reject); + callback(resolve, reject); }); } else { console.error('No Promise support or polyfill found. To enable Ionic Native support, please add the es6-promise polyfill before this script, or run with a library like Angular 2 or on a recent browser.'); @@ -29,21 +30,21 @@ export function getPromise(cb) { }; return tryNativePromise(); -} +}; /** * @private * @param pluginRef * @returns {null|*} */ -export function getPlugin(pluginRef: string): any { +export const getPlugin = (pluginRef: string): any => { return get(window, pluginRef); }; /** * @private */ -export const pluginWarn = function(pluginName: string, plugin?: string, method?: string) { +export const pluginWarn = (pluginName: string, plugin?: string, method?: string): void => { if (method) { console.warn('Native: tried calling ' + pluginName + '.' + method + ', but the ' + pluginName + ' plugin is not installed.'); } else { @@ -59,7 +60,7 @@ export const pluginWarn = function(pluginName: string, plugin?: string, method?: * @param pluginName * @param method */ -export const cordovaWarn = function(pluginName: string, method?: string) { +export const cordovaWarn = (pluginName: string, method?: string): void => { if (method) { console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'); } else { diff --git a/src/@ionic-native/plugins/app-rate/index.ts b/src/@ionic-native/plugins/app-rate/index.ts index 46388260f..99317a02a 100644 --- a/src/@ionic-native/plugins/app-rate/index.ts +++ b/src/@ionic-native/plugins/app-rate/index.ts @@ -1,9 +1,6 @@ import { Injectable } from '@angular/core'; import { Cordova, CordovaProperty, Plugin, IonicNativePlugin } from '@ionic-native/core'; - -declare var window; - export interface AppRatePreferences { /** diff --git a/src/@ionic-native/plugins/background-fetch/index.ts b/src/@ionic-native/plugins/background-fetch/index.ts index 2812ab1dd..67bcae52a 100644 --- a/src/@ionic-native/plugins/background-fetch/index.ts +++ b/src/@ionic-native/plugins/background-fetch/index.ts @@ -1,9 +1,6 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Injectable } from '@angular/core'; -declare var window; - - export interface BackgroundFetchConfig { /** diff --git a/src/@ionic-native/plugins/background-geolocation/index.ts b/src/@ionic-native/plugins/background-geolocation/index.ts index aba02ed21..fc7e94e4f 100644 --- a/src/@ionic-native/plugins/background-geolocation/index.ts +++ b/src/@ionic-native/plugins/background-geolocation/index.ts @@ -2,8 +2,6 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var window; - export interface BackgroundGeolocationResponse { /** diff --git a/src/@ionic-native/plugins/code-push/index.ts b/src/@ionic-native/plugins/code-push/index.ts index b12908925..59b5591cf 100644 --- a/src/@ionic-native/plugins/code-push/index.ts +++ b/src/@ionic-native/plugins/code-push/index.ts @@ -109,8 +109,8 @@ interface LocalPackage_Static { } /* tslint:enable */ -declare var RemotePackage: RemotePackage_Static; -declare var LocalPackage: LocalPackage_Static; +declare const RemotePackage: RemotePackage_Static; +declare const LocalPackage: LocalPackage_Static; /** * Defines the JSON format of the current package information file. diff --git a/src/@ionic-native/plugins/contacts/index.ts b/src/@ionic-native/plugins/contacts/index.ts index bdb3a7e90..4e17d4a00 100644 --- a/src/@ionic-native/plugins/contacts/index.ts +++ b/src/@ionic-native/plugins/contacts/index.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { CordovaInstance, InstanceProperty, Plugin, getPromise, InstanceCheck, checkAvailability, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; -declare var window: any, +declare const window: any, navigator: any; export type ContactFieldType = '*' | 'addresses' | 'birthday' | 'categories' | 'country' | 'department' | 'displayName' | 'emails' | 'familyName' | 'formatted' | 'givenName' | 'honorificPrefix' | 'honorificSuffix' | 'id' | 'ims' | 'locality' | 'middleName' | 'name' | 'nickname' | 'note' | 'organizations' | 'phoneNumbers' | 'photos' | 'postalCode' | 'region' | 'streetAddress' | 'title' | 'urls'; @@ -49,6 +49,7 @@ export interface IContactProperties { /** An array of web pages associated with the contact. */ urls?: IContactField[]; + } /** @@ -71,6 +72,8 @@ export class Contact implements IContactProperties { @InstanceProperty categories: IContactField[]; @InstanceProperty urls: IContactField[]; + [key: string]: any; + constructor() { if (checkAvailability('navigator.contacts', 'create', 'Contacts') === true) { this._objectInstance = navigator.contacts.create(); @@ -92,8 +95,8 @@ export class Contact implements IContactProperties { @InstanceCheck() save(): Promise { - return getPromise((resolve, reject) => { - this._objectInstance.save((contact) => { + return getPromise((resolve: Function, reject: Function) => { + this._objectInstance.save((contact: any) => { this._objectInstance = contact; resolve(this); }, reject); @@ -114,7 +117,7 @@ export interface IContactError { /** * @hidden */ -export declare var ContactError: { +export declare const ContactError: { new (code: number): IContactError; UNKNOWN_ERROR: number; INVALID_ARGUMENT_ERROR: number; @@ -312,8 +315,8 @@ export class Contacts extends IonicNativePlugin { */ @CordovaCheck() find(fields: ContactFieldType[], options?: IContactFindOptions): Promise { - return getPromise((resolve, reject) => { - navigator.contacts.find(fields, (contacts) => { + return getPromise((resolve: Function, reject: Function) => { + navigator.contacts.find(fields, (contacts: any[]) => { resolve(contacts.map(processContact)); }, reject, options); }); @@ -325,8 +328,8 @@ export class Contacts extends IonicNativePlugin { */ @CordovaCheck() pickContact(): Promise { - return getPromise((resolve, reject) => { - navigator.contacts.pickContact((contact) => resolve(processContact(contact)), reject); + return getPromise((resolve: Function, reject: Function) => { + navigator.contacts.pickContact((contact: any) => resolve(processContact(contact)), reject); }); } @@ -335,7 +338,7 @@ export class Contacts extends IonicNativePlugin { /** * @hidden */ -function processContact(contact) { +function processContact(contact: any) { let newContact = new Contact(); for (let prop in contact) { if (typeof contact[prop] === 'function') continue; diff --git a/src/@ionic-native/plugins/deeplinks/index.ts b/src/@ionic-native/plugins/deeplinks/index.ts index cea92ba02..f48dcf0ab 100644 --- a/src/@ionic-native/plugins/deeplinks/index.ts +++ b/src/@ionic-native/plugins/deeplinks/index.ts @@ -98,7 +98,7 @@ export class Deeplinks extends IonicNativePlugin { @Cordova({ observable: true }) - route(paths): Observable { return; } + route(paths: any): Observable { return; } /** * @@ -121,6 +121,6 @@ export class Deeplinks extends IonicNativePlugin { @Cordova({ observable: true }) - routeWithNavController(navController, paths): Observable { return; } + routeWithNavController(navController: any, paths: any): Observable { return; } } diff --git a/src/@ionic-native/plugins/device/index.ts b/src/@ionic-native/plugins/device/index.ts index 92a8cb57b..e2efd7e92 100644 --- a/src/@ionic-native/plugins/device/index.ts +++ b/src/@ionic-native/plugins/device/index.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { CordovaProperty, Plugin, IonicNativePlugin } from '@ionic-native/core'; -declare var window: any; +declare const window: any; /** * @name Device diff --git a/src/@ionic-native/plugins/dialogs/index.ts b/src/@ionic-native/plugins/dialogs/index.ts index 72fc98d3e..04ae9166a 100644 --- a/src/@ionic-native/plugins/dialogs/index.ts +++ b/src/@ionic-native/plugins/dialogs/index.ts @@ -75,7 +75,7 @@ export class Dialogs extends IonicNativePlugin { successIndex: 1, errorIndex: 4 }) - confirm(message, title?: string, buttonLabels?: string[]): Promise { return; } + confirm(message: string, title?: string, buttonLabels?: string[]): Promise { return; } /** * Displays a native dialog box that is more customizable than the browser's prompt function. diff --git a/src/@ionic-native/plugins/email-composer/index.ts b/src/@ionic-native/plugins/email-composer/index.ts index 41c08680c..fb21df3d7 100644 --- a/src/@ionic-native/plugins/email-composer/index.ts +++ b/src/@ionic-native/plugins/email-composer/index.ts @@ -1,7 +1,11 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; -declare var cordova: any; +interface Cordova { + plugins: CordovaPlugins & { email: any }; +} + +declare const cordova: Cordova; export interface EmailComposerOptions { @@ -88,7 +92,7 @@ export class EmailComposer extends IonicNativePlugin { isAvailable(app?: string): Promise { return new Promise((resolve, reject) => { if (app) { - cordova.plugins.email.isAvailable(app, (isAvailable) => { + cordova.plugins.email.isAvailable(app, (isAvailable: boolean) => { if (isAvailable) { resolve(); } else { @@ -96,7 +100,7 @@ export class EmailComposer extends IonicNativePlugin { } }); } else { - cordova.plugins.email.isAvailable((isAvailable) => { + cordova.plugins.email.isAvailable((isAvailable: boolean) => { if (isAvailable) { resolve(); } else { diff --git a/src/@ionic-native/plugins/file-path/index.ts b/src/@ionic-native/plugins/file-path/index.ts index 476db1c5d..29dc9b719 100644 --- a/src/@ionic-native/plugins/file-path/index.ts +++ b/src/@ionic-native/plugins/file-path/index.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; -declare var window: any; +declare const window: any; /** * @name File Path diff --git a/src/@ionic-native/plugins/file/index.ts b/src/@ionic-native/plugins/file/index.ts index c0b5d8ba0..63d1021b9 100644 --- a/src/@ionic-native/plugins/file/index.ts +++ b/src/@ionic-native/plugins/file/index.ts @@ -517,6 +517,11 @@ export declare class FileReader { readAsBinaryString(fe: IFile): void; readAsArrayBuffer(fe: IFile): void; + /** + * @hidden + */ + [key: string]: any; + } interface Window extends LocalFileSystem {} @@ -630,7 +635,7 @@ export class File extends IonicNativePlugin { @CordovaProperty sharedDirectory: string; - cordovaFileError: {} = { + cordovaFileError: any = { 1: 'NOT_FOUND_ERR', 2: 'SECURITY_ERR', 3: 'ABORT_ERR', diff --git a/src/@ionic-native/plugins/geofence/index.ts b/src/@ionic-native/plugins/geofence/index.ts index 25bfbe887..b0bf3c619 100644 --- a/src/@ionic-native/plugins/geofence/index.ts +++ b/src/@ionic-native/plugins/geofence/index.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, CordovaFunctionOverride, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var window: any; +declare const window: any; /** * @name Geofence diff --git a/src/@ionic-native/plugins/geolocation/index.ts b/src/@ionic-native/plugins/geolocation/index.ts index 3b1c100d3..16df4619d 100644 --- a/src/@ionic-native/plugins/geolocation/index.ts +++ b/src/@ionic-native/plugins/geolocation/index.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var navigator: any; +declare const navigator: any; export interface Coordinates { @@ -174,7 +174,7 @@ export class Geolocation extends IonicNativePlugin { * Observable changes. * * ```typescript - * var subscription = this.geolocation.watchPosition() + * const subscription = this.geolocation.watchPosition() * .filter((p) => p.coords !== undefined) //Filter Out Errors * .subscribe(position => { * console.log(position.coords.longitude + ' ' + position.coords.latitude); diff --git a/src/@ionic-native/plugins/google-analytics/index.ts b/src/@ionic-native/plugins/google-analytics/index.ts index 49a55b6b8..7dc4cba48 100644 --- a/src/@ionic-native/plugins/google-analytics/index.ts +++ b/src/@ionic-native/plugins/google-analytics/index.ts @@ -1,8 +1,6 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; -declare var window; - /** * @name Google Analytics * @description diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index 851db1253..9d386529e 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -3,7 +3,7 @@ import { Cordova, CordovaInstance, CordovaCheck, Plugin, InstanceProperty, Insta import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/fromEvent'; -declare var plugin: any; +declare const plugin: any; /** * @hidden @@ -1473,7 +1473,7 @@ export class GroundOverlay { return Promise.reject({ error: 'plugin_not_installed' }); } return new Promise( - resolve => this._objectInstance.addListenerOnce(eventName, resolve) + (resolve: Function) => this._objectInstance.addListenerOnce(eventName, resolve) ); } @@ -1766,7 +1766,7 @@ export class Geocoder { */ @CordovaCheck() geocode(request: GeocoderRequest): Promise { - return new Promise(resolve => { + return new Promise((resolve: Function) => { plugin.google.maps.Geocoder.geocode(request, resolve); }); } diff --git a/src/@ionic-native/plugins/gyroscope/index.ts b/src/@ionic-native/plugins/gyroscope/index.ts index 84ea35cee..87af80f2a 100644 --- a/src/@ionic-native/plugins/gyroscope/index.ts +++ b/src/@ionic-native/plugins/gyroscope/index.ts @@ -2,7 +2,7 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; import { Injectable } from '@angular/core'; -declare var navigator: any; +declare const navigator: any; /** * @hidden diff --git a/src/@ionic-native/plugins/ibeacon/index.ts b/src/@ionic-native/plugins/ibeacon/index.ts index a29961256..66c7fbc77 100644 --- a/src/@ionic-native/plugins/ibeacon/index.ts +++ b/src/@ionic-native/plugins/ibeacon/index.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var cordova: any; +declare const cordova: any; export interface Beacon { /** diff --git a/src/@ionic-native/plugins/in-app-browser/index.ts b/src/@ionic-native/plugins/in-app-browser/index.ts index 8a9ab0ef9..922bddbe9 100644 --- a/src/@ionic-native/plugins/in-app-browser/index.ts +++ b/src/@ionic-native/plugins/in-app-browser/index.ts @@ -3,7 +3,7 @@ import { Plugin, CordovaInstance, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/fromEvent'; -declare var cordova: any; +declare const cordova: Cordova & { InAppBrowser: any; }; export interface InAppBrowserOptions { /** Set to yes or no to turn the InAppBrowser's location bar on or off. */ @@ -48,6 +48,11 @@ export interface InAppBrowserOptions { /** (Windows only) Set to yes to create the browser control without a border around it. * Please note that if location=no is also specified, there will be no control presented to user to close IAB window. */ fullscreen?: 'yes'; + + /** + * @hidden + */ + [key: string]: any; } export interface InAppBrowserEvent extends Event { /** the eventname, either loadstart, loadstop, loaderror, or exit. */ @@ -80,12 +85,18 @@ export class InAppBrowserObject { */ constructor(url: string, target?: string, options?: string | InAppBrowserOptions) { try { - if (options && typeof options !== 'string') - options = Object.keys(options).map(key => `${key}=${options[key]}`).join(','); + + if (options && typeof options !== 'string') { + options = Object.keys(options).map((key: string) => `${key}=${(options)[key]}`).join(','); + } + this._objectInstance = cordova.InAppBrowser.open(url, target, options); + } catch (e) { - window.open(url); + + window.open(url, target); console.warn('Native: InAppBrowser is not installed or you are running on a browser. Falling back to window.open.'); + } } diff --git a/src/@ionic-native/plugins/intel-security/index.ts b/src/@ionic-native/plugins/intel-security/index.ts index 5b5df381d..9b28c5bc2 100644 --- a/src/@ionic-native/plugins/intel-security/index.ts +++ b/src/@ionic-native/plugins/intel-security/index.ts @@ -1,7 +1,7 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Injectable } from '@angular/core'; -declare var window: any; +declare const window: any; export interface IntelSecurityDataOptions { /** Non-empty string. **/ diff --git a/src/@ionic-native/plugins/jins-meme/index.ts b/src/@ionic-native/plugins/jins-meme/index.ts index 7f99c5c68..349a905aa 100644 --- a/src/@ionic-native/plugins/jins-meme/index.ts +++ b/src/@ionic-native/plugins/jins-meme/index.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Plugin, Cordova, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var cordova: any; +declare const cordova: any; /** * @name Jins Meme diff --git a/src/@ionic-native/plugins/media-capture/index.ts b/src/@ionic-native/plugins/media-capture/index.ts index 301a39344..136380184 100644 --- a/src/@ionic-native/plugins/media-capture/index.ts +++ b/src/@ionic-native/plugins/media-capture/index.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Cordova, CordovaProperty, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var navigator: any; +declare const navigator: any; export interface MediaFile { /** @@ -33,7 +33,7 @@ export interface MediaFile { * @param {Function} successCallback * @param {Function} errorCallback */ - getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any); + getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any): void; } export interface MediaFileData { diff --git a/src/@ionic-native/plugins/media/index.ts b/src/@ionic-native/plugins/media/index.ts index 576442f86..ac18d6717 100644 --- a/src/@ionic-native/plugins/media/index.ts +++ b/src/@ionic-native/plugins/media/index.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { CordovaInstance, Plugin, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; -declare var Media: any; +declare const Media: any; /** @@ -169,7 +169,7 @@ export type MediaErrorCallback = (error: MediaError) => void; * window.setTimeout(() => file.stopRecord(), 10000); * }); * ``` - * + * * You can find the reasons here: https://github.com/driftyco/ionic-native/issues/1452#issuecomment-299605906 * * @usage diff --git a/src/@ionic-native/plugins/paypal/index.ts b/src/@ionic-native/plugins/paypal/index.ts index 73005120d..1f8fecd52 100644 --- a/src/@ionic-native/plugins/paypal/index.ts +++ b/src/@ionic-native/plugins/paypal/index.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; + /** * @name PayPal * @description @@ -383,6 +384,11 @@ export interface PayPalConfigurationOptions { * PIN to use for sandbox if 'forceDefaultsInSandbox' is set. */ sandboxUserPin?: string; + + /** + * @hidden + */ + [key: string]: any; } /** * @hidden @@ -413,7 +419,7 @@ export class PayPalConfiguration implements PayPalConfigurationOptions { }; if (options && typeof options === 'object') { - for (var i in options) { + for (let i in options) { if (defaults.hasOwnProperty(i)) { defaults[i] = options[i]; } diff --git a/src/@ionic-native/plugins/screen-orientation/index.ts b/src/@ionic-native/plugins/screen-orientation/index.ts index 3baf6c7a4..5f79cb42a 100644 --- a/src/@ionic-native/plugins/screen-orientation/index.ts +++ b/src/@ionic-native/plugins/screen-orientation/index.ts @@ -2,8 +2,6 @@ import { Injectable } from '@angular/core'; import { Cordova, CordovaProperty, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var window; - /** * @name Screen Orientation * @description diff --git a/src/@ionic-native/plugins/screenshot/index.ts b/src/@ionic-native/plugins/screenshot/index.ts index 7e4926948..0ee4c620b 100644 --- a/src/@ionic-native/plugins/screenshot/index.ts +++ b/src/@ionic-native/plugins/screenshot/index.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; import { Plugin, IonicNativePlugin } from '@ionic-native/core'; +declare const navigator: any; -declare var navigator: any; /** * @name Screenshot * @description Captures a screen shot @@ -44,7 +44,7 @@ export class Screenshot extends IonicNativePlugin { return new Promise( (resolve, reject) => { navigator.screenshot.save( - (error, result) => { + (error: any, result: any) => { if (error) { reject(error); } else { @@ -70,7 +70,7 @@ export class Screenshot extends IonicNativePlugin { return new Promise( (resolve, reject) => { navigator.screenshot.URI( - (error, result) => { + (error: any, result: any) => { if (error) { reject(error); } else { diff --git a/src/@ionic-native/plugins/status-bar/index.ts b/src/@ionic-native/plugins/status-bar/index.ts index f0f6780d4..efeaaf169 100644 --- a/src/@ionic-native/plugins/status-bar/index.ts +++ b/src/@ionic-native/plugins/status-bar/index.ts @@ -1,9 +1,6 @@ import { Injectable } from '@angular/core'; import { Cordova, CordovaProperty, Plugin, IonicNativePlugin } from '@ionic-native/core'; - -declare var window; - /** * @name Status Bar * @description diff --git a/src/@ionic-native/plugins/transfer/index.ts b/src/@ionic-native/plugins/transfer/index.ts index 2d063a117..bf1cc0d92 100644 --- a/src/@ionic-native/plugins/transfer/index.ts +++ b/src/@ionic-native/plugins/transfer/index.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { CordovaInstance, Plugin, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core'; -declare var FileTransfer; +declare const FileTransfer: any; export interface FileUploadOptions { diff --git a/src/@ionic-native/plugins/video-capture-plus/index.ts b/src/@ionic-native/plugins/video-capture-plus/index.ts index 25a1e479b..1daaf6132 100644 --- a/src/@ionic-native/plugins/video-capture-plus/index.ts +++ b/src/@ionic-native/plugins/video-capture-plus/index.ts @@ -28,9 +28,9 @@ export interface MediaFile { /** * Retrieves the format information of the media file. * @param {Function} successCallback - * @param {Function} errorCallback + * @param {Function} [errorCallback] */ - getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any); + getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any): any; } export interface MediaFileData { diff --git a/src/@ionic-native/plugins/web-intent/index.ts b/src/@ionic-native/plugins/web-intent/index.ts index de003179a..cf98d0dca 100644 --- a/src/@ionic-native/plugins/web-intent/index.ts +++ b/src/@ionic-native/plugins/web-intent/index.ts @@ -2,8 +2,6 @@ import { Injectable } from '@angular/core'; import { Cordova, CordovaProperty, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; -declare var window; - /** * @beta * @name Web Intent diff --git a/tsconfig.json b/tsconfig.json index 30a6d65e8..9c5e2615a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "stripInternal": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, + "noImplicitAny": true, "module": "es2015", "moduleResolution": "node", "paths": {