From 437e11ab600eb6b38753d9038a9d1a0e986f6e7a Mon Sep 17 00:00:00 2001 From: Mike North Date: Thu, 11 Oct 2018 10:05:39 -0700 Subject: [PATCH] fix: fix ts errors --- addon/services/resize.ts | 35 ++++++++++++++++++++--------------- tslint.json | 12 ++++-------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/addon/services/resize.ts b/addon/services/resize.ts index 8c93345c..4ef7ab0f 100644 --- a/addon/services/resize.ts +++ b/addon/services/resize.ts @@ -12,30 +12,30 @@ declare global { export interface ResizeDefaults { widthSensitive?: boolean; heightSensitive?: boolean; - debounceTimeout?: number ; + debounceTimeout?: number; injectionFactories?: string[]; } class ResizeService extends Service.extend(Evented, { - debounceTimeout: computed.oneWay('defaultDebounceTimeout'), - heightSensitive: computed.oneWay('defaultHeightSensitive'), - screenHeight: computed.readOnly('_oldHeight'), - screenWidth: computed.readOnly('_oldWidth'), - widthSensitive: computed.oneWay('defaultWidthSensitive'), + debounceTimeout: computed.oneWay('defaultDebounceTimeout'), + heightSensitive: computed.oneWay('defaultHeightSensitive'), + screenHeight: computed.readOnly('_oldHeight'), + screenWidth: computed.readOnly('_oldWidth'), + widthSensitive: computed.oneWay('defaultWidthSensitive') }) { public _oldWidth = window.innerWidth; public _oldHeight = window.innerHeight; public _oldWidthDebounced = window.innerWidth; public _oldHeightDebounced = window.innerHeight; - public resizeServiceDefaults!: ResizeDefaults; + public resizeServiceDefaults!: Partial; public _onResizeHandler?: (this: Window, evt: UIEvent) => void; public _scheduledDebounce?: ReturnType; constructor() { super(...arguments); this._setDefaults(); - this._onResizeHandler = (evt) => { + this._onResizeHandler = evt => { this._fireResizeNotification(evt); const scheduledDebounce = debounce(this, this._fireDebouncedResizeNotification, evt, this.get('debounceTimeout')); this._scheduledDebounce = scheduledDebounce; @@ -55,9 +55,9 @@ class ResizeService extends Service.extend(Evented, { } public _setDefaults() { - const defaults = getWithDefault(this, 'resizeServiceDefaults', {}); + const defaults = getWithDefault(this, 'resizeServiceDefaults', {} as any); - Object.keys(defaults).map((key: keyof ResizeDefaults ) => { + Object.keys(defaults).map((key: keyof ResizeDefaults) => { const classifiedKey = classify(key); const defaultKey = `default${classifiedKey}`; return set(this as any, defaultKey, defaults[key]); @@ -68,8 +68,7 @@ class ResizeService extends Service.extend(Evented, { const wKey = debounced ? '_oldWidthDebounced' : '_oldWidth'; const hKey = debounced ? '_oldHeightDebounced' : '_oldHeight'; return ( - (this.get('widthSensitive') && w !== this.get(wKey)) || - (this.get('heightSensitive') && h !== this.get(hKey)) + (this.get('widthSensitive') && w !== this.get(wKey)) || (this.get('heightSensitive') && h !== this.get(hKey)) ); } @@ -81,17 +80,23 @@ class ResizeService extends Service.extend(Evented, { } public _installResizeListener() { - if (!this._onResizeHandler) { return; } + if (!this._onResizeHandler) { + return; + } window.addEventListener('resize', this._onResizeHandler); } public _uninstallResizeListener() { - if (!this._onResizeHandler) { return; } + if (!this._onResizeHandler) { + return; + } window.removeEventListener('resize', this._onResizeHandler); } public _cancelScheduledDebounce() { - if (!this._scheduledDebounce) { return; } + if (!this._scheduledDebounce) { + return; + } cancel(this._scheduledDebounce); } diff --git a/tslint.json b/tslint.json index 5bd3b289..098ce12b 100644 --- a/tslint.json +++ b/tslint.json @@ -1,13 +1,8 @@ { "defaultSeverity": "error", - "extends": [ - "tslint:recommended" - ], + "extends": ["tslint:recommended"], "linterOptions": { - "exclude": [ - "tests/dummy/**/*", - "node_modules/**/*" - ] + "exclude": ["tests/dummy/**/*", "node_modules/**/*"] }, "jsRules": { "quotemark": [true, "single"], @@ -17,7 +12,8 @@ "quotemark": [true, "single"], "variable-name": [true, "allow-leading-underscore"], "interface-name": false, - "member-access": false + "member-access": false, + "arrow-parens": false }, "rulesDirectory": [] }