Skip to content

Commit 3ae988e

Browse files
smithad15SethDavenport
authored andcommitted
fix: add typescript unused checks (#32)
The library currently does not work in projects that have noUnusedLocals and noUnusedParameters set inside of tsconfig.json. This should bring the project into compliance with those rules.
1 parent 6880de7 commit 3ae988e

File tree

10 files changed

+22
-65
lines changed

10 files changed

+22
-65
lines changed

source/compose-reducers.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import {Reducer, Action} from 'redux';
22

3-
import {Iterable} from 'immutable';
4-
5-
import {FormException} from './form-exception';
63
import {State} from './state';
74

85
export const composeReducers =

source/configure.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import {FormControl} from '@angular/forms';
2-
31
import {
42
Action,
53
Store,

source/connect-array.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import {
1616
NG_VALUE_ACCESSOR,
1717
AbstractControl,
18-
DefaultValueAccessor,
1918
FormArray,
2019
FormArrayName,
2120
FormControl,
@@ -37,8 +36,6 @@ import {
3736
} from '@angular/forms';
3837
import {Unsubscribe} from 'redux';
3938

40-
import {Subscription} from 'rxjs';
41-
4239
import {ConnectBase} from './connect-base';
4340
import {FormStore} from './form-store';
4441
import {State} from './state';
@@ -62,8 +59,6 @@ export class ConnectArrayTemplate {
6259
export class ConnectArray extends ControlContainer implements OnInit {
6360
private stateSubscription: Unsubscribe;
6461

65-
private formSubscription: Subscription;
66-
6762
private array = new FormArray([]);
6863

6964
private valueAccessor: ControlValueAccessor;
@@ -180,8 +175,8 @@ export class ConnectArray extends ControlContainer implements OnInit {
180175
}
181176

182177
private registerInternals(array) {
183-
array.registerControl = c => {};
184-
array.registerOnChange = fn => {};
178+
array.registerControl = () => {};
179+
array.registerOnChange = () => {};
185180

186181
Object.defineProperties(this, {
187182
_rawValidators: {
@@ -251,7 +246,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
251246
return array;
252247
}
253248

254-
const associate = <T>(value): FormGroup => {
249+
const associate = (value): FormGroup => {
255250
const group = new FormGroup({});
256251
group.setParent(parent);
257252

@@ -286,8 +281,8 @@ export class ConnectArray extends ControlContainer implements OnInit {
286281
private simpleAccessor() {
287282
return {
288283
writeValue: value => this.control.setValue(value),
289-
registerOnChange(fn) {},
290-
registerOnTouched(fn) {}
284+
registerOnChange() {},
285+
registerOnTouched() {}
291286
};
292287
}
293288
}

source/connect-base.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import {
2-
Directive,
3-
Input,
4-
} from '@angular/core';
1+
import { Input } from '@angular/core';
52

63
import {
74
AbstractControl,
85
FormControl,
96
FormGroup,
107
FormArray,
11-
NgForm,
128
NgControl,
139
} from '@angular/forms';
1410

@@ -18,7 +14,6 @@ import { Unsubscribe } from 'redux';
1814

1915
import 'rxjs/add/operator/debounceTime';
2016

21-
import { FormException } from './form-exception';
2217
import { FormStore } from './form-store';
2318
import { State } from './state';
2419

@@ -66,13 +61,11 @@ export class ConnectBase {
6661
}
6762
}
6863

69-
private ngAfterContentInit() {
64+
ngAfterContentInit() {
7065
Promise.resolve().then(() => {
7166
this.resetState();
7267

73-
this.stateSubscription = this.store.subscribe(state => {
74-
this.resetState();
75-
});
68+
this.stateSubscription = this.store.subscribe(() => this.resetState());
7669

7770
Promise.resolve().then(() => {
7871
this.formSubscription = (<any>this.form.valueChanges).debounceTime(0).subscribe(values => this.publish(values));

source/connect-reactive.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import {
33
Input,
44
} from '@angular/core';
55

6-
import {
7-
NgForm
8-
} from '@angular/forms';
9-
106
import {FormStore} from './form-store';
117

128
import {ConnectBase} from './connect-base';

source/connect.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import {
2-
Directive,
3-
Input,
4-
} from '@angular/core';
5-
6-
import {
7-
NgForm
8-
} from '@angular/forms';
1+
import { Directive } from '@angular/core';
92

3+
import { NgForm } from '@angular/forms';
104

115
import {FormStore} from './form-store';
12-
import {State} from './state';
136
import {ConnectBase} from './connect-base';
147

158

source/form-reducer.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
import {
2-
Iterable,
3-
Map,
4-
fromJS
5-
} from 'immutable';
1+
import {Iterable} from 'immutable';
62

7-
import {Action, Reducer} from 'redux';
3+
import {Action} from 'redux';
84

9-
import {FormException} from './form-exception';
10-
11-
import {
12-
FORM_CHANGED,
13-
FormStore,
14-
} from './form-store';
5+
import {FORM_CHANGED} from './form-store';
156

167
import {State} from './state';
178

source/form-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {NgForm} from '@angular/forms';
44

55
import {NgRedux} from '@angular-redux/store';
66

7-
import {Action, Store, Unsubscribe} from 'redux';
7+
import {Action, Unsubscribe} from 'redux';
88

99
export interface AbstractStore<RootState> {
1010
/// Dispatch an action

source/state.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ export abstract class State {
6565
}
6666

6767
static assign<State>(state: State, path: string[], value?) {
68-
interface Modifiable {
69-
key: string;
70-
operations: {
71-
clone<T>(): T;
72-
update<T, V>(key: number | string, value: V): T;
73-
};
74-
};
75-
7668
const operations = State.inspect(state);
7769

7870
if (path.length === 0) {
@@ -157,7 +149,7 @@ export abstract class State {
157149
}
158150
},
159151
// Merge
160-
(parent, key: number | string | string[], value: K, setter: (v: K) => K) => {
152+
(parent, key: number | string | string[], value: K) => {
161153
if (key) {
162154
return parent.mergeDeepIn(Array.isArray(key) ? key : [key], value);
163155
}
@@ -185,7 +177,7 @@ export abstract class State {
185177
},
186178

187179
// Merge
188-
(parent, key: number | string, value: K, setter: (v: K) => K) => {
180+
(parent, _, value: K, setter: (v: K) => K) => {
189181
setter(parent.concat(value));
190182
return parent;
191183
},
@@ -210,7 +202,7 @@ export abstract class State {
210202
},
211203

212204
// Merge
213-
(parent: Map<string, any>, key: number | string, value: K, setter: (v: K) => K) => {
205+
(parent: Map<string, any>, _, value: K) => {
214206
const m = new Map<string, any>(<any> value);
215207
m.forEach((value, key) => parent.set(key, value));
216208
return parent;
@@ -238,7 +230,7 @@ export abstract class State {
238230
},
239231

240232
// Merge
241-
(parent: Set<any>, key: number | string, value, setter: (v: K) => K) => {
233+
(parent: Set<any>, _, value) => {
242234
for (const element of value) {
243235
parent.add(element);
244236
}
@@ -274,7 +266,7 @@ export abstract class State {
274266
}
275267
return Object.assign(parent, value);
276268
},
277-
(parent, key: number | string, value: K, setter: (v: K) => K) => {
269+
(parent, _, value: K) => {
278270
for (const k of Object.keys(value)) {
279271
parent[k] = value[k];
280272
}

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"inlineSourceMap": true,
1212
"declaration": true,
1313
"outDir": "dist",
14-
"rootDir": ""
14+
"rootDir": "",
15+
"noUnusedLocals": true,
16+
"noUnusedParameters": true
1517
},
1618
"awesomeTypescriptLoaderOptions": {
1719
"emitRequireType": false,

0 commit comments

Comments
 (0)