From 071ad2ef3fd3f6694389afd627a107d99390e3b2 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 8 Dec 2016 11:17:43 -0600 Subject: [PATCH] chore(ts): fix noImplicitAny errors --- src/animations/animation.ts | 12 ++++----- src/components/app/app-root.ts | 2 +- src/components/app/app.ts | 4 +-- src/components/content/content.ts | 4 +-- src/components/tap-click/activator-base.ts | 8 +++--- src/components/tap-click/activator.ts | 2 +- src/util/debouncer.ts | 4 +-- src/util/dom-controller.ts | 6 ++--- src/util/dom.ts | 30 +++++++++++----------- src/util/events.ts | 8 +++--- src/util/form.ts | 4 +-- src/util/haptic.ts | 2 +- src/util/scroll-view.ts | 4 +-- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/animations/animation.ts b/src/animations/animation.ts index a3618d115e..47cf6c5b5c 100644 --- a/src/animations/animation.ts +++ b/src/animations/animation.ts @@ -183,7 +183,7 @@ export class Animation { } private _addProp(state: string, prop: string, val: any): EffectProperty { - let fxProp = this._getProp(prop); + let fxProp: any = this._getProp(prop); if (!fxProp) { // first time we've see this EffectProperty @@ -636,7 +636,7 @@ export class Animation { if (this._rv) { stepValue = ((stepValue * -1) + 1); } - var i, j; + var i: number, j: number; var finalTransform: string = ''; var elements = this._e; for (i = 0; i < effects.length; i++) { @@ -678,7 +678,7 @@ export class Animation { } else { for (j = 0; j < nuElements; j++) { // ******** DOM WRITE **************** - elements[j].style[prop] = val; + (elements[j].style)[prop] = val; } } } @@ -694,7 +694,7 @@ export class Animation { var cssTransform = CSS.transform; for (i = 0; i < elements.length; i++) { // ******** DOM WRITE **************** - elements[i].style[cssTransform] = finalTransform; + (elements[i].style)[cssTransform] = finalTransform; } } } @@ -718,7 +718,7 @@ export class Animation { const cssTransitionDuration = CSS.transitionDuration; const cssTransitionTimingFn = CSS.transitionTimingFn; - let eleStyle; + let eleStyle: any; for (var i = 0; i < this._eL; i++) { eleStyle = elements[i].style; if (dur > 0) { @@ -783,7 +783,7 @@ export class Animation { let ele: HTMLElement; let eleClassList: DOMTokenList; - let prop; + let prop: string; for (i = 0; i < this._eL; i++) { ele = this._e[i]; eleClassList = ele.classList; diff --git a/src/components/app/app-root.ts b/src/components/app/app-root.ts index 083c4e7ab3..c6558a342b 100644 --- a/src/components/app/app-root.ts +++ b/src/components/app/app-root.ts @@ -49,7 +49,7 @@ export class IonicApp extends Ion implements OnInit { super(config, elementRef, renderer); // register with App that this is Ionic's appRoot component. tada! app._appRoot = this; - this._stopScrollPlugin = window['IonicStopScroll']; + this._stopScrollPlugin = (window)['IonicStopScroll']; } ngOnInit() { diff --git a/src/components/app/app.ts b/src/components/app/app.ts index 7ca988bbbc..0afab2cd41 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -80,8 +80,8 @@ export class App { runInDev(() => { // During developement, navPop can be triggered by calling // window.ClickBackButton(); - if (!window['HWBackButton']) { - window['HWBackButton'] = () => { + if (!(window)['HWBackButton']) { + (window)['HWBackButton'] = () => { let p = this.goBack(); p && p.catch(() => console.debug('hardware go back cancelled')); }; diff --git a/src/components/content/content.ts b/src/components/content/content.ts index ad39606eca..7ca13d9eb9 100644 --- a/src/components/content/content.ts +++ b/src/components/content/content.ts @@ -777,7 +777,7 @@ export class Content extends Ion implements OnDestroy, OnInit { assert(fixedTop >= 0, 'fixedTop has to be positive'); // ******** DOM WRITE **************** - scrollEle.style[topProperty] = cssFormat(this._cTop); + (scrollEle.style)[topProperty] = cssFormat(this._cTop); // ******** DOM WRITE **************** fixedEle.style.marginTop = cssFormat(fixedTop); @@ -790,7 +790,7 @@ export class Content extends Ion implements OnDestroy, OnInit { assert(fixedBottom >= 0, 'fixedBottom has to be positive'); // ******** DOM WRITE **************** - scrollEle.style[bottomProperty] = cssFormat(this._cBottom); + (scrollEle.style)[bottomProperty] = cssFormat(this._cBottom); // ******** DOM WRITE **************** fixedEle.style.marginBottom = cssFormat(fixedBottom); diff --git a/src/components/tap-click/activator-base.ts b/src/components/tap-click/activator-base.ts index c20c4ece51..257369ab3c 100644 --- a/src/components/tap-click/activator-base.ts +++ b/src/components/tap-click/activator-base.ts @@ -2,13 +2,13 @@ import { PointerCoordinates } from '../../util/dom'; export abstract class ActivatorBase { - abstract clickAction(ev, activatableEle: HTMLElement, startCoord: PointerCoordinates); + abstract clickAction(ev: UIEvent, activatableEle: HTMLElement, startCoord: PointerCoordinates): void; - abstract downAction(ev: UIEvent, activatableEle: HTMLElement, startCoord: PointerCoordinates); + abstract downAction(ev: UIEvent, activatableEle: HTMLElement, startCoord: PointerCoordinates): void; - abstract upAction(ev: UIEvent, activatableEle: HTMLElement, startCoord: PointerCoordinates); + abstract upAction(ev: UIEvent, activatableEle: HTMLElement, startCoord: PointerCoordinates): void; - abstract clearState(animated: boolean); + abstract clearState(animated: boolean): void; } export function isActivatedDisabled(ev: any, activatableEle: any): boolean { diff --git a/src/components/tap-click/activator.ts b/src/components/tap-click/activator.ts index 7b1c2a3d83..8cf814594e 100644 --- a/src/components/tap-click/activator.ts +++ b/src/components/tap-click/activator.ts @@ -103,7 +103,7 @@ export class Activator implements ActivatorBase { this._queue.length = 0; - let ele; + let ele: HTMLElement; for (var i = 0; i < this._active.length; i++) { ele = this._active[i]; if (!animated) { diff --git a/src/util/debouncer.ts b/src/util/debouncer.ts index 91690094fd..e8b2269577 100644 --- a/src/util/debouncer.ts +++ b/src/util/debouncer.ts @@ -1,8 +1,8 @@ export interface Debouncer { - debounce(Function); - cancel(); + debounce(callback: Function): void; + cancel(): void; } export class TimeoutDebouncer implements Debouncer { diff --git a/src/util/dom-controller.ts b/src/util/dom-controller.ts index ca0edb7316..eb0a0d9381 100644 --- a/src/util/dom-controller.ts +++ b/src/util/dom-controller.ts @@ -88,14 +88,14 @@ export class DomController { const self = this; if (!self.q) { self.q = true; - nativeRaf(function rafCallback(timeStamp) { + nativeRaf(function rafCallback(timeStamp: number) { self.flush(timeStamp); }); } } protected flush(timeStamp: number) { - let err; + let err: any; try { dispatch(timeStamp, this.r, this.w); @@ -117,7 +117,7 @@ export class DomController { } function dispatch(timeStamp: number, r: Function[], w: Function[]) { - let task; + let task: Function; // ******** DOM READS **************** while (task = r.shift()) { diff --git a/src/util/dom.ts b/src/util/dom.ts index c7279de3ed..cce9dec313 100644 --- a/src/util/dom.ts +++ b/src/util/dom.ts @@ -1,16 +1,16 @@ +const win: any = window; // RequestAnimationFrame Polyfill (Android 4.3 and below) /*! @author Paul Irish */ /*! @source https://gist.github.com/paulirish/1579671 */ (function() { var rafLastTime = 0; - const win: any = window; if (!win.requestAnimationFrame) { win.requestAnimationFrame = function(callback: Function) { var currTime = Date.now(); var timeToCall = Math.max(0, 16 - (currTime - rafLastTime)); - var id = window.setTimeout(function() { + var id = win.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); @@ -25,16 +25,16 @@ })(); // use native raf rather than the zone wrapped one -let originalRaf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')]); +const originalRaf = (win[win['Zone']['__symbol__']('requestAnimationFrame')] || win[win['Zone']['__symbol__']('webkitRequestAnimationFrame')]); // if the originalRaf from the Zone symbol is not available, we need to provide the polyfilled version -export const nativeRaf = originalRaf !== undefined ? originalRaf['bind'](window) : window.requestAnimationFrame.bind(window); +export const nativeRaf = originalRaf !== undefined ? originalRaf['bind'](win) : win.requestAnimationFrame.bind(win); // zone wrapped raf -export const raf = window.requestAnimationFrame.bind(window); -export const cancelRaf = window.cancelAnimationFrame.bind(window); +export const raf = win.requestAnimationFrame.bind(win); +export const cancelRaf = win.cancelAnimationFrame.bind(win); -export const nativeTimeout = window[window['Zone']['__symbol__']('setTimeout')]['bind'](window); -export const clearNativeTimeout = window[window['Zone']['__symbol__']('clearTimeout')]['bind'](window); +export const nativeTimeout = win[win['Zone']['__symbol__']('setTimeout')]['bind'](win); +export const clearNativeTimeout = win[win['Zone']['__symbol__']('clearTimeout')]['bind'](win); /** * Run a function in an animation frame after waiting `framesToWait` frames. @@ -176,14 +176,14 @@ export function ready(callback?: Function) { } else { document.addEventListener('DOMContentLoaded', completed, false); - window.addEventListener('load', completed, false); + win.addEventListener('load', completed, false); } return promise; function completed() { document.removeEventListener('DOMContentLoaded', completed, false); - window.removeEventListener('load', completed, false); + win.removeEventListener('load', completed, false); callback(); } } @@ -201,13 +201,13 @@ export function windowLoad(callback?: Function) { } else { - window.addEventListener('load', completed, false); + win.addEventListener('load', completed, false); } return promise; function completed() { - window.removeEventListener('load', completed, false); + win.removeEventListener('load', completed, false); callback(); } } @@ -318,10 +318,10 @@ export function clearDimensions(id: string) { export function windowDimensions(): {width: number, height: number} { if (!dimensionCache.win) { // make sure we got good values before caching - if (window.innerWidth && window.innerHeight) { + if (win.innerWidth && win.innerHeight) { dimensionCache.win = { - width: window.innerWidth, - height: window.innerHeight + width: win.innerWidth, + height: win.innerHeight }; } else { // do not cache bad values diff --git a/src/util/events.ts b/src/util/events.ts index a4d64a4edc..3ba14e075f 100644 --- a/src/util/events.ts +++ b/src/util/events.ts @@ -139,16 +139,16 @@ export function setupEvents(platform: Platform, dom: DomController): Events { scroll.init(contentEle, 0, 0); // We need to stop scrolling if it's happening and scroll up - contentEle.style['WebkitBackfaceVisibility'] = 'hidden'; - contentEle.style['WebkitTransform'] = 'translate3d(0,0,0)'; + (contentEle.style)['WebkitBackfaceVisibility'] = 'hidden'; + (contentEle.style)['WebkitTransform'] = 'translate3d(0,0,0)'; nativeRaf(function() { contentEle.style.overflow = 'hidden'; function finish() { contentEle.style.overflow = ''; - contentEle.style['WebkitBackfaceVisibility'] = ''; - contentEle.style['WebkitTransform'] = ''; + (contentEle.style)['WebkitBackfaceVisibility'] = ''; + (contentEle.style)['WebkitTransform'] = ''; } let didScrollTimeout = setTimeout(() => { diff --git a/src/util/form.ts b/src/util/form.ts index bf6259dc0e..4246969da3 100644 --- a/src/util/form.ts +++ b/src/util/form.ts @@ -58,7 +58,7 @@ export class Form { export abstract class IonicTapInput implements IonicFormInput { - abstract initFocus(); + abstract initFocus(): void; abstract get checked(): boolean; @@ -72,6 +72,6 @@ export abstract class IonicTapInput implements IonicFormInput { export abstract class IonicFormInput { - abstract initFocus(); + abstract initFocus(): void; } diff --git a/src/util/haptic.ts b/src/util/haptic.ts index 3f9ae97c1b..84a67f28cf 100644 --- a/src/util/haptic.ts +++ b/src/util/haptic.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Platform } from '../platform/platform'; -declare var window; +declare var window: any; /** * @name Haptic diff --git a/src/util/scroll-view.ts b/src/util/scroll-view.ts index 9aa42685da..44e5f2f8c9 100644 --- a/src/util/scroll-view.ts +++ b/src/util/scroll-view.ts @@ -477,7 +477,7 @@ export class ScrollView { self.isScrolling = true; // chill out for a frame first - rafFrames(2, (timeStamp) => { + rafFrames(2, (timeStamp: number) => { startTime = timeStamp; step(timeStamp); }); @@ -537,7 +537,7 @@ export interface ScrollEvent { velocityX: number; directionY: string; directionX: string; - domWrite: {(fn: DomCallback, ctx?: any)}; + domWrite: {(fn: DomCallback, ctx?: any): void}; contentElement?: HTMLElement; fixedElement?: HTMLElement; scrollElement?: HTMLElement;