Skip to content

Commit 437e11a

Browse files
committed
fix: fix ts errors
1 parent d507c06 commit 437e11a

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

addon/services/resize.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ declare global {
1212
export interface ResizeDefaults {
1313
widthSensitive?: boolean;
1414
heightSensitive?: boolean;
15-
debounceTimeout?: number ;
15+
debounceTimeout?: number;
1616
injectionFactories?: string[];
1717
}
1818

1919
class ResizeService extends Service.extend(Evented, {
20-
debounceTimeout: computed.oneWay('defaultDebounceTimeout'),
21-
heightSensitive: computed.oneWay('defaultHeightSensitive'),
22-
screenHeight: computed.readOnly('_oldHeight'),
23-
screenWidth: computed.readOnly('_oldWidth'),
24-
widthSensitive: computed.oneWay('defaultWidthSensitive'),
20+
debounceTimeout: computed.oneWay('defaultDebounceTimeout'),
21+
heightSensitive: computed.oneWay('defaultHeightSensitive'),
22+
screenHeight: computed.readOnly('_oldHeight'),
23+
screenWidth: computed.readOnly('_oldWidth'),
24+
widthSensitive: computed.oneWay('defaultWidthSensitive')
2525
}) {
2626
public _oldWidth = window.innerWidth;
2727
public _oldHeight = window.innerHeight;
2828
public _oldWidthDebounced = window.innerWidth;
2929
public _oldHeightDebounced = window.innerHeight;
3030

31-
public resizeServiceDefaults!: ResizeDefaults;
31+
public resizeServiceDefaults!: Partial<ResizeDefaults>;
3232

3333
public _onResizeHandler?: (this: Window, evt: UIEvent) => void;
3434
public _scheduledDebounce?: ReturnType<typeof debounce>;
3535
constructor() {
3636
super(...arguments);
3737
this._setDefaults();
38-
this._onResizeHandler = (evt) => {
38+
this._onResizeHandler = evt => {
3939
this._fireResizeNotification(evt);
4040
const scheduledDebounce = debounce(this, this._fireDebouncedResizeNotification, evt, this.get('debounceTimeout'));
4141
this._scheduledDebounce = scheduledDebounce;
@@ -55,9 +55,9 @@ class ResizeService extends Service.extend(Evented, {
5555
}
5656

5757
public _setDefaults() {
58-
const defaults = getWithDefault(this, 'resizeServiceDefaults', {});
58+
const defaults = getWithDefault(this, 'resizeServiceDefaults', {} as any);
5959

60-
Object.keys(defaults).map((key: keyof ResizeDefaults ) => {
60+
Object.keys(defaults).map((key: keyof ResizeDefaults) => {
6161
const classifiedKey = classify(key);
6262
const defaultKey = `default${classifiedKey}`;
6363
return set(this as any, defaultKey, defaults[key]);
@@ -68,8 +68,7 @@ class ResizeService extends Service.extend(Evented, {
6868
const wKey = debounced ? '_oldWidthDebounced' : '_oldWidth';
6969
const hKey = debounced ? '_oldHeightDebounced' : '_oldHeight';
7070
return (
71-
(this.get('widthSensitive') && w !== this.get(wKey)) ||
72-
(this.get('heightSensitive') && h !== this.get(hKey))
71+
(this.get('widthSensitive') && w !== this.get(wKey)) || (this.get('heightSensitive') && h !== this.get(hKey))
7372
);
7473
}
7574

@@ -81,17 +80,23 @@ class ResizeService extends Service.extend(Evented, {
8180
}
8281

8382
public _installResizeListener() {
84-
if (!this._onResizeHandler) { return; }
83+
if (!this._onResizeHandler) {
84+
return;
85+
}
8586
window.addEventListener('resize', this._onResizeHandler);
8687
}
8788

8889
public _uninstallResizeListener() {
89-
if (!this._onResizeHandler) { return; }
90+
if (!this._onResizeHandler) {
91+
return;
92+
}
9093
window.removeEventListener('resize', this._onResizeHandler);
9194
}
9295

9396
public _cancelScheduledDebounce() {
94-
if (!this._scheduledDebounce) { return; }
97+
if (!this._scheduledDebounce) {
98+
return;
99+
}
95100
cancel(this._scheduledDebounce);
96101
}
97102

tslint.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
{
22
"defaultSeverity": "error",
3-
"extends": [
4-
"tslint:recommended"
5-
],
3+
"extends": ["tslint:recommended"],
64
"linterOptions": {
7-
"exclude": [
8-
"tests/dummy/**/*",
9-
"node_modules/**/*"
10-
]
5+
"exclude": ["tests/dummy/**/*", "node_modules/**/*"]
116
},
127
"jsRules": {
138
"quotemark": [true, "single"],
@@ -17,7 +12,8 @@
1712
"quotemark": [true, "single"],
1813
"variable-name": [true, "allow-leading-underscore"],
1914
"interface-name": false,
20-
"member-access": false
15+
"member-access": false,
16+
"arrow-parens": false
2117
},
2218
"rulesDirectory": []
2319
}

0 commit comments

Comments
 (0)