From 03f451163502a029850fd5136309c7a3236b50e6 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 31 May 2016 18:40:29 -0500 Subject: [PATCH] chore(tslint): fix noImplicitAny errors --- src/animations/animation.ts | 4 ++-- src/animations/builtins.ts | 8 +++---- src/components/action-sheet/action-sheet.ts | 10 ++++---- src/components/alert/alert.ts | 16 ++++--------- src/components/app/app.ts | 2 +- src/components/badge/badge.ts | 3 ++- src/components/button/button.ts | 10 ++++---- src/components/checkbox/checkbox.ts | 4 ++-- src/components/content/content.ts | 19 ++++++++------- src/components/datetime/datetime.ts | 18 +++++++------- .../infinite-scroll/infinite-scroll.ts | 2 +- src/components/input/input.ts | 16 ++++++------- src/config/config.ts | 24 +++++++++---------- src/decorators/page.ts | 2 +- src/gestures/drag-gesture.ts | 8 +++---- src/gestures/gesture.ts | 12 ++++++---- src/gestures/slide-edge-gesture.ts | 2 +- src/gestures/slide-gesture.ts | 2 +- src/platform/platform.ts | 12 +++++----- src/util/click-block.ts | 9 +++---- src/util/datetime-util.ts | 2 +- 21 files changed, 92 insertions(+), 93 deletions(-) diff --git a/src/animations/animation.ts b/src/animations/animation.ts index 01d46a14cc9..bdd874d26d5 100644 --- a/src/animations/animation.ts +++ b/src/animations/animation.ts @@ -360,7 +360,7 @@ export class Animation { _asyncEnd(duration: number, shouldComplete: boolean) { var self = this; - function onTransitionEnd(ev) { + function onTransitionEnd(ev: any) { console.debug('Animation onTransitionEnd', ev.target.nodeName, ev.propertyName); // ensure transition end events and timeouts have been cleared @@ -817,7 +817,7 @@ interface EffectState { unit: string; } -const TRANSFORMS = { +const TRANSFORMS: any = { 'translateX': 1, 'translateY': 1, 'translateZ': 1, 'scale': 1, 'scaleX': 1, 'scaleY': 1, 'scaleZ': 1, 'rotate': 1, 'rotateX': 1, 'rotateY': 1, 'rotateZ': 1, diff --git a/src/animations/builtins.ts b/src/animations/builtins.ts index 1d2c2f5c8de..25200d77509 100644 --- a/src/animations/builtins.ts +++ b/src/animations/builtins.ts @@ -3,7 +3,7 @@ import {Animation} from './animation'; class SlideIn extends Animation { - constructor(element) { + constructor(element: any) { super(element); this .easing('cubic-bezier(0.1,0.7,0.1,1)') @@ -15,7 +15,7 @@ Animation.register('slide-in', SlideIn); class SlideOut extends Animation { - constructor(element) { + constructor(element: any) { super(element); this .easing('ease-out') @@ -27,7 +27,7 @@ Animation.register('slide-out', SlideOut); class FadeIn extends Animation { - constructor(element) { + constructor(element: any) { super(element); this .easing('ease-in') @@ -39,7 +39,7 @@ Animation.register('fade-in', FadeIn); class FadeOut extends Animation { - constructor(element) { + constructor(element: any) { super(element); this .easing('ease-out') diff --git a/src/components/action-sheet/action-sheet.ts b/src/components/action-sheet/action-sheet.ts index 727e4732e54..cede463ea37 100644 --- a/src/components/action-sheet/action-sheet.ts +++ b/src/components/action-sheet/action-sheet.ts @@ -273,9 +273,9 @@ class ActionSheetCmp { onPageLoaded() { // normalize the data - let buttons = []; + let buttons: any[] = []; - this.d.buttons.forEach(button => { + this.d.buttons.forEach((button: any) => { if (typeof button === 'string') { button = { text: button }; } @@ -327,7 +327,7 @@ class ActionSheetCmp { } } - click(button, dismissDelay?) { + click(button: any, dismissDelay?: number) { if (!this.isEnabled()) { return; } @@ -360,7 +360,7 @@ class ActionSheetCmp { } } - dismiss(role): Promise { + dismiss(role: any): Promise { return this._viewCtrl.dismiss(null, role); } @@ -380,7 +380,7 @@ export interface ActionSheetOptions { class ActionSheetSlideIn extends Transition { - constructor(enteringView, leavingView, opts: TransitionOptions) { + constructor(enteringView: ViewController, leavingView: ViewController, opts: TransitionOptions) { super(opts); let ele = enteringView.pageRef().nativeElement; diff --git a/src/components/alert/alert.ts b/src/components/alert/alert.ts index 678599f6659..57909909ad9 100644 --- a/src/components/alert/alert.ts +++ b/src/components/alert/alert.ts @@ -423,12 +423,6 @@ class AlertCmp { // normalize the data let data = this.d; - if (data['body']) { - // deprecated warning - console.warn('Alert `body` property has been renamed to `message`'); - data.message = data['body']; - } - data.buttons = data.buttons.map(button => { if (typeof button === 'string') { return { text: button }; @@ -451,7 +445,7 @@ class AlertCmp { // An alert can be created with several different inputs. Radios, // checkboxes and inputs are all accepted, but they cannot be mixed. - let inputTypes = []; + let inputTypes: any[] = []; data.inputs.forEach(input => { if (inputTypes.indexOf(input.type) < 0) { inputTypes.push(input.type); @@ -503,7 +497,7 @@ class AlertCmp { } } - btnClick(button, dismissDelay?) { + btnClick(button: any, dismissDelay?: number) { if (!this.isEnabled()) { return; } @@ -529,7 +523,7 @@ class AlertCmp { } } - rbClick(checkedInput) { + rbClick(checkedInput: any) { if (this.isEnabled()) { this.d.inputs.forEach(input => { input.checked = (checkedInput === input); @@ -538,7 +532,7 @@ class AlertCmp { } } - cbClick(checkedInput) { + cbClick(checkedInput: any) { if (this.isEnabled()) { checkedInput.checked = !checkedInput.checked; } @@ -556,7 +550,7 @@ class AlertCmp { } } - dismiss(role): Promise { + dismiss(role: any): Promise { return this._viewCtrl.dismiss(this.getValues(), role); } diff --git a/src/components/app/app.ts b/src/components/app/app.ts index cc027d32bf2..3ea0232765e 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -101,7 +101,7 @@ export class App { */ getActiveNav(): any { var nav = this._rootNav || null; - var activeChildNav; + var activeChildNav: any; while (nav) { activeChildNav = nav.getActiveChildNav(); diff --git a/src/components/badge/badge.ts b/src/components/badge/badge.ts index 0fb070fc9dc..7f18893bf69 100644 --- a/src/components/badge/badge.ts +++ b/src/components/badge/badge.ts @@ -31,7 +31,8 @@ export class Badge { */ private _readAttrs(element: HTMLElement) { let elementAttrs = element.attributes; - let attrName; + let attrName: string; + for (let i = 0, l = elementAttrs.length; i < l; i++) { if (elementAttrs[i].value !== '') continue; diff --git a/src/components/button/button.ts b/src/components/button/button.ts index 78d2aa59c4f..e4dc18445d9 100644 --- a/src/components/button/button.ts +++ b/src/components/button/button.ts @@ -233,8 +233,8 @@ export class Button { if (childNodes.length > 0) { childNodes = childNodes[0].childNodes; } - let childNode; - let nodes = []; + let childNode: Node; + let nodes: number[] = []; for (let i = 0, l = childNodes.length; i < l; i++) { childNode = childNodes[i]; @@ -274,7 +274,7 @@ export class Button { */ private _readAttrs(element: HTMLElement) { let elementAttrs = element.attributes; - let attrName; + let attrName: string; for (let i = 0, l = elementAttrs.length; i < l; i++) { if (elementAttrs[i].value !== '') continue; @@ -345,9 +345,9 @@ export class Button { /** * @private */ - static setRoles(contentButtonChildren, role: string) { + static setRoles(contentButtonChildren: any, role: string) { let buttons = contentButtonChildren.toArray(); - buttons.forEach(button => { + buttons.forEach((button: any) => { button.setRole(role); }); } diff --git a/src/components/checkbox/checkbox.ts b/src/components/checkbox/checkbox.ts index 5e3d086e9a7..4df3ef1a71b 100644 --- a/src/components/checkbox/checkbox.ts +++ b/src/components/checkbox/checkbox.ts @@ -102,7 +102,7 @@ export class Checkbox { * @private */ @HostListener('click', ['$event']) - private _click(ev) { + private _click(ev: UIEvent) { console.debug('checkbox, checked'); ev.preventDefault(); ev.stopPropagation(); @@ -158,7 +158,7 @@ export class Checkbox { /** * @private */ - registerOnTouched(fn) { this.onTouched = fn; } + registerOnTouched(fn: any) { this.onTouched = fn; } /** * @input {boolean} whether or not the checkbox is disabled or not. diff --git a/src/components/content/content.ts b/src/components/content/content.ts index 99c6e075763..0ab440e4c94 100644 --- a/src/components/content/content.ts +++ b/src/components/content/content.ts @@ -111,49 +111,49 @@ export class Content extends Ion { /** * @private */ - addScrollListener(handler) { + addScrollListener(handler: any) { return this._addListener('scroll', handler); } /** * @private */ - addTouchStartListener(handler) { + addTouchStartListener(handler: any) { return this._addListener('touchstart', handler); } /** * @private */ - addTouchMoveListener(handler) { + addTouchMoveListener(handler: any) { return this._addListener('touchmove', handler); } /** * @private */ - addTouchEndListener(handler) { + addTouchEndListener(handler: any) { return this._addListener('touchend', handler); } /** * @private */ - addMouseDownListener(handler) { + addMouseDownListener(handler: any) { return this._addListener('mousedown', handler); } /** * @private */ - addMouseUpListener(handler) { + addMouseUpListener(handler: any) { return this._addListener('mouseup', handler); } /** * @private */ - addMouseMoveListener(handler) { + addMouseMoveListener(handler: any) { return this._addListener('mousemove', handler); } @@ -177,8 +177,8 @@ export class Content extends Ion { * @param {Function} callback The method you want perform when scrolling has ended */ onScrollEnd(callback: Function) { - let lastScrollTop = null; - let framesUnchanged = 0; + let lastScrollTop: number = null; + let framesUnchanged: number = 0; let _scrollEle = this._scrollEle; function next() { @@ -187,6 +187,7 @@ export class Content extends Ion { if (Math.round(lastScrollTop) === Math.round(currentScrollTop)) { framesUnchanged++; + } else { framesUnchanged = 0; } diff --git a/src/components/datetime/datetime.ts b/src/components/datetime/datetime.ts index 370b3bca10b..73effec3fa5 100644 --- a/src/components/datetime/datetime.ts +++ b/src/components/datetime/datetime.ts @@ -433,7 +433,7 @@ export class DateTime { } @HostListener('click', ['$event']) - private _click(ev) { + private _click(ev: UIEvent) { if (ev.detail === 0) { // do not continue if the click event came from a form submit return; @@ -443,8 +443,8 @@ export class DateTime { this.open(); } - @HostListener('keyup.space', ['$event']) - private _keyup(ev) { + @HostListener('keyup.space') + private _keyup() { if (!this._isOpen) { this.open(); } @@ -474,7 +474,7 @@ export class DateTime { }, { text: this.doneText, - handler: (data) => { + handler: (data: any) => { console.log('datetime, done', data); this.onChange(data); this.ionChange.emit(data); @@ -594,7 +594,7 @@ export class DateTime { // default to assuming this month has 31 days let numDaysInMonth = 31; - let selectedMonth; + let selectedMonth: number; if (monthCol) { monthOpt = monthCol.options[monthCol.selectedIndex]; if (monthOpt) { @@ -655,7 +655,7 @@ export class DateTime { */ divyColumns(picker: Picker) { let pickerColumns = picker.getColumns(); - let columns = []; + let columns: number[] = []; pickerColumns.forEach((col, i) => { columns.push(0); @@ -803,7 +803,7 @@ export class DateTime { /** * @private */ - registerOnTouched(fn) { this.onTouched = fn; } + registerOnTouched(fn: any) { this.onTouched = fn; } /** * @private @@ -845,7 +845,7 @@ function convertToArrayOfNumbers(input: any, type: string): number[] { if (isArray(input)) { // ensure each value is an actual number in the returned array - input.forEach(num => { + input.forEach((num: any) => { num = parseInt(num, 10); if (!isNaN(num)) { values.push(num); @@ -877,7 +877,7 @@ function convertToArrayOfStrings(input: any, type: string): string[] { if (isArray(input)) { // trim up each string value - input.forEach(val => { + input.forEach((val: any) => { val = val.trim(); if (val) { values.push(val); diff --git a/src/components/infinite-scroll/infinite-scroll.ts b/src/components/infinite-scroll/infinite-scroll.ts index 09f5117dbfc..d661ada5e3b 100644 --- a/src/components/infinite-scroll/infinite-scroll.ts +++ b/src/components/infinite-scroll/infinite-scroll.ts @@ -147,7 +147,7 @@ export class InfiniteScroll { _content.addCssClass('has-infinite-scroll'); } - private _onScroll(ev) { + private _onScroll() { if (this.state === STATE_LOADING || this.state === STATE_DISABLED) { return 1; } diff --git a/src/components/input/input.ts b/src/components/input/input.ts index 386c460011b..b748e685452 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -92,15 +92,15 @@ export class TextInput extends InputBase { /** * @private */ - inputBlurred(event) { - this.blur.emit(event); + inputBlurred(ev: UIEvent) { + this.blur.emit(ev); } /** * @private */ - inputFocused(event) { - this.focus.emit(event); + inputFocused(ev: UIEvent) { + this.focus.emit(ev); } /** @@ -193,14 +193,14 @@ export class TextArea extends InputBase { /** * @private */ - inputBlurred(event) { - this.blur.emit(event); + inputBlurred(ev: UIEvent) { + this.blur.emit(ev); } /** * @private */ - inputFocused(event) { - this.focus.emit(event); + inputFocused(ev: UIEvent) { + this.focus.emit(ev); } } diff --git a/src/config/config.ts b/src/config/config.ts index 52613e74970..f2a56b82591 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -144,13 +144,13 @@ export class Config { // the user config's platforms, which already contains // settings from default platform configs - let userPlatformValue = undefined; - let userDefaultValue = this._s[key]; - let userPlatformModeValue = undefined; - let userDefaultModeValue = undefined; - let platformValue = undefined; - let platformModeValue = undefined; - let configObj = null; + let userPlatformValue: any = undefined; + let userDefaultValue: any = this._s[key]; + let userPlatformModeValue: any = undefined; + let userDefaultModeValue: any = undefined; + let platformValue: any = undefined; + let platformModeValue: any = undefined; + let configObj: any = null; if (this.platform) { let queryStringValue = this.platform.query('ionic' + key.toLowerCase()); @@ -223,7 +223,7 @@ export class Config { // or it was from the users platform configs // or it was from the default platform configs // in that order - let rtnVal; + let rtnVal: any; if (isFunction(this._c[key])) { rtnVal = this._c[key](this.platform); @@ -345,24 +345,24 @@ export class Config { /** * @private */ - setPlatform(platform) { + setPlatform(platform: Platform) { this.platform = platform; } /** * @private */ - static setModeConfig(mode, config) { + static setModeConfig(mode: string, config: any) { modeConfigs[mode] = config; } /** * @private */ - static getModeConfig(mode) { + static getModeConfig(mode: string) { return modeConfigs[mode] || null; } } -let modeConfigs = {}; +let modeConfigs: any = {}; diff --git a/src/decorators/page.ts b/src/decorators/page.ts index 162312f581c..6e84f7b6f4e 100644 --- a/src/decorators/page.ts +++ b/src/decorators/page.ts @@ -31,7 +31,7 @@ export interface PageMetadata { * @private */ export function Page(config: PageMetadata) { - return function(cls) { + return function(cls: any) { // deprecated warning: added beta.8 2016-05-27 console.warn('@Page decorator has been deprecated. Please use Angular\'s @Component instead.\nimport {Component} from \'@angular/core\';'); diff --git a/src/gestures/drag-gesture.ts b/src/gestures/drag-gesture.ts index 3a6651e06ba..76ba9084a4f 100644 --- a/src/gestures/drag-gesture.ts +++ b/src/gestures/drag-gesture.ts @@ -5,7 +5,7 @@ import {defaults} from '../util'; export class DragGesture extends Gesture { public dragging: boolean; - constructor(element, opts = {}) { + constructor(element: HTMLElement, opts = {}) { defaults(opts, {}); super(element, opts); } @@ -13,20 +13,20 @@ export class DragGesture extends Gesture { listen() { super.listen(); - this.on('panstart', ev => { + this.on('panstart', (ev: UIEvent) => { if (this.onDragStart(ev) !== false) { this.dragging = true; } }); - this.on('panmove', ev => { + this.on('panmove', (ev: UIEvent) => { if (!this.dragging) return; if (this.onDrag(ev) === false) { this.dragging = false; } }); - this.on('panend', ev => { + this.on('panend', (ev: UIEvent) => { if (!this.dragging) return; this.onDragEnd(ev); this.dragging = false; diff --git a/src/gestures/gesture.ts b/src/gestures/gesture.ts index c4cb8d4e653..0b48ed179c0 100644 --- a/src/gestures/gesture.ts +++ b/src/gestures/gesture.ts @@ -16,7 +16,7 @@ export class Gesture { public direction: string; public isListening: boolean = false; - constructor(element, opts: any = {}) { + constructor(element: HTMLElement, opts: any = {}) { defaults(opts, { domEvents: true }); @@ -55,11 +55,13 @@ export class Gesture { } unlisten() { - var type, i; + let eventType: string; + let i: number; + if (this._hammer && this.isListening) { - for (type in this._callbacks) { - for (i = 0; i < this._callbacks[type].length; i++) { - this._hammer.off(type, this._callbacks[type]); + for (eventType in this._callbacks) { + for (i = 0; i < this._callbacks[eventType].length; i++) { + this._hammer.off(eventType, this._callbacks[eventType]); } } this._hammer.destroy(); diff --git a/src/gestures/slide-edge-gesture.ts b/src/gestures/slide-edge-gesture.ts index af267932075..ea98eb956f5 100644 --- a/src/gestures/slide-edge-gesture.ts +++ b/src/gestures/slide-edge-gesture.ts @@ -33,7 +33,7 @@ export class SlideEdgeGesture extends SlideGesture { }; } - _checkEdge(edge, pos) { + _checkEdge(edge: string, pos: any) { switch (edge) { case 'left': return pos.x <= this._d.left + this.maxEdgeStart; case 'right': return pos.x >= this._d.width - this.maxEdgeStart; diff --git a/src/gestures/slide-gesture.ts b/src/gestures/slide-gesture.ts index 291fef48168..e8fcb6b18bc 100644 --- a/src/gestures/slide-gesture.ts +++ b/src/gestures/slide-gesture.ts @@ -5,7 +5,7 @@ import {clamp} from '../util'; export class SlideGesture extends DragGesture { public slide: SlideData = null; - constructor(element, opts = {}) { + constructor(element: HTMLElement, opts = {}) { super(element, opts); this.element = element; } diff --git a/src/platform/platform.ts b/src/platform/platform.ts index 6d57b4f819e..cfe208e73e8 100644 --- a/src/platform/platform.ts +++ b/src/platform/platform.ts @@ -43,7 +43,7 @@ export class Platform { private _resizeTm: any; private _zone: NgZone; - constructor(platforms = []) { + constructor(platforms: string[] = []) { this._platforms = platforms; this._readyPromise = new Promise(res => { this._readyResolve = res; } ); } @@ -727,8 +727,8 @@ class PlatformNode { return this; } - let platform = null; - let rootPlatform = null; + let platform: PlatformNode = null; + let rootPlatform: PlatformNode = null; for (let i = 0; i < parents.length; i++) { platform = new PlatformNode(parents[i]); @@ -745,11 +745,11 @@ class PlatformNode { return null; } - getSubsetParents(subsetPlatformName: string): Array { + getSubsetParents(subsetPlatformName: string): string[] { let platformRegistry = Platform.registry(); - let parentPlatformNames = []; - let platform = null; + let parentPlatformNames: string[] = []; + let platform: PlatformConfig = null; for (let platformName in platformRegistry) { platform = platformRegistry[platformName]; diff --git a/src/util/click-block.ts b/src/util/click-block.ts index 52f15a9fc79..008477dc1ed 100644 --- a/src/util/click-block.ts +++ b/src/util/click-block.ts @@ -3,7 +3,8 @@ import {nativeTimeout} from './dom'; const CSS_CLICK_BLOCK = 'click-block-active'; const DEFAULT_EXPIRE = 330; -let cbEle, fallbackTimerId; +let cbEle: HTMLElement; +let fallbackTimerId: number; let isShowing = false; /** @@ -15,14 +16,14 @@ export class ClickBlock { enable() { cbEle = document.createElement('click-block'); document.body.appendChild(cbEle); - cbEle.addEventListener('touchmove', function(ev) { + cbEle.addEventListener('touchmove', function(ev: UIEvent) { ev.preventDefault(); ev.stopPropagation(); }); this._enabled = true; } - show(shouldShow, expire) { + show(shouldShow: boolean, expire: number) { if (this._enabled) { if (shouldShow) { show(expire); @@ -35,7 +36,7 @@ export class ClickBlock { } -function show(expire) { +function show(expire: number) { clearTimeout(fallbackTimerId); fallbackTimerId = nativeTimeout(hide, expire || DEFAULT_EXPIRE); diff --git a/src/util/datetime-util.ts b/src/util/datetime-util.ts index cdc1f7a2346..7f80e1cfa57 100644 --- a/src/util/datetime-util.ts +++ b/src/util/datetime-util.ts @@ -6,7 +6,7 @@ export function renderDateTime(template: string, value: DateTimeData, locale: Lo return ''; } - let tokens = []; + let tokens: string[] = []; let hasText = false; FORMAT_KEYS.forEach((format, index) => { if (template.indexOf(format.f) > -1) {