Skip to content

Commit 7226462

Browse files
author
James Salas
committed
fix: ts strict type issues pt.1
1 parent e583a97 commit 7226462

File tree

14 files changed

+295
-274
lines changed

14 files changed

+295
-274
lines changed

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@
3737
"node": ">=8"
3838
},
3939
"devDependencies": {
40-
"@angular/animations": "7.2.0",
41-
"@angular/cli": "7.2.1",
42-
"@angular/common": "7.2.0",
43-
"@angular/compiler": "7.2.0",
44-
"@angular/compiler-cli": "7.2.0",
45-
"@angular/core": "7.2.0",
46-
"@angular/forms": "7.2.0",
47-
"@angular/platform-browser": "7.2.0",
48-
"@angular/platform-browser-dynamic": "7.2.0",
49-
"@angular/router": "7.2.0",
40+
"@angular/animations": "7.2.1",
41+
"@angular/cli": "7.2.2",
42+
"@angular/common": "7.2.1",
43+
"@angular/compiler": "7.2.1",
44+
"@angular/compiler-cli": "7.2.1",
45+
"@angular/core": "7.2.1",
46+
"@angular/forms": "7.2.1",
47+
"@angular/platform-browser": "7.2.1",
48+
"@angular/platform-browser-dynamic": "7.2.1",
49+
"@angular/router": "7.2.1",
5050
"@commitlint/cli": "7.0.0",
5151
"@commitlint/config-conventional": "7.0.1",
5252
"@commitlint/prompt-cli": "7.0.0",

packages/example-app/src/app/feedback/page.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ <h2>Feedback Form</h2>
2424
ngControl
2525
ngModel />
2626
</label>
27-
27+
2828
<label for="comments">Comments:
2929
<textarea
3030
name="comments"
3131
[maxLength]="getMaxCommentChars()"
3232
ngControl
3333
ngModel></textarea>
34-
<p>{{ charsLeft$ | async }} characters remaining.
34+
<p>{{ charsLeft | async }} characters remaining.
3535
</label>
3636

3737
<button>Send!</button>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<zoo-animal-list
22
animalsName="Lions"
33
animalType="lion"
4-
[animals]="animals$"
5-
[loading]="loading$"
6-
[error]="error$">
4+
[animals]="animals"
5+
[loading]="loading"
6+
[error]="error">
77
</zoo-animal-list>

packages/example-app/src/app/store/module.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Store Module', () => {
3333

3434
it('should configure the store when the module is loaded', async(() => {
3535
const configureSpy = spyOn(MockNgRedux.getInstance(), 'configureStore');
36-
new StoreModule(mockNgRedux, devTools, null, mockEpics as any);
36+
new StoreModule(mockNgRedux, devTools, null as any, mockEpics as any);
3737

3838
expect(configureSpy).toHaveBeenCalled();
3939
}));

packages/example-app/src/tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"outDir": "../dist/out-tsc",
1212
"sourceMap": true,
1313
"target": "es5",
14-
"typeRoots": ["../node_modules/@types"],
1514

1615
// Causes problems for @Outputs with AoT.
1716
// See https://github.com/angular/angular/issues/17131.

packages/router/src/reducer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface RouterAction extends Action {
99
}
1010

1111
export function routerReducer(
12-
state: string = DefaultRouterState,
12+
state: string | undefined = DefaultRouterState,
1313
action: RouterAction,
1414
): string {
1515
switch (action.type) {

packages/store/src/components/root-store.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ describe('NgRedux Observable Store', () => {
195195
it('should wait until store is configured before emitting values', () => {
196196
// tslint:disable-next-line:max-classes-per-file
197197
class SomeService {
198-
foo: string;
199-
bar: string;
200-
baz: number;
198+
foo!: string;
199+
bar!: string;
200+
baz!: number;
201201

202202
constructor(stateStore: NgRedux<any>) {
203203
stateStore.select(n => n.foo).subscribe(foo => (this.foo = foo));
@@ -217,9 +217,9 @@ describe('NgRedux Observable Store', () => {
217217
it('should have select decorators work before store is configured', done => {
218218
// tslint:disable-next-line:max-classes-per-file
219219
class SomeService {
220-
@select() foo$: Observable<string>;
221-
@select() bar$: Observable<string>;
222-
@select() baz$: Observable<number>;
220+
@select() foo$!: Observable<string>;
221+
@select() bar$!: Observable<string>;
222+
@select() baz$!: Observable<number>;
223223
}
224224

225225
ngRedux = new RootStore<AppState>(mockNgZone);

packages/store/src/components/root-store.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Middleware,
88
Reducer,
99
Store,
10+
StoreCreator,
1011
StoreEnhancer,
1112
Unsubscribe,
1213
} from 'redux';
@@ -49,12 +50,12 @@ export class RootStore<RootState> extends NgRedux<RootState> {
4950
enhancers: StoreEnhancer<RootState>[] = [],
5051
): void => {
5152
assert(!this.store, 'Store already configured!');
52-
5353
// Variable-arity compose in typescript FTW.
54-
this.setStore(
55-
compose.apply(null, [applyMiddleware(...middleware), ...enhancers])(
56-
createStore,
57-
)(enableFractalReducers(rootReducer), initState),
54+
this.setStore(compose<StoreCreator>(
55+
applyMiddleware(...middleware),
56+
...enhancers,
57+
)(createStore)
58+
(enableFractalReducers(rootReducer), initState),
5859
);
5960
};
6061

packages/store/src/decorators/dispatch.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('@dispatch', () => {
3131
instanceProperty: 'init-instanceProperty',
3232
};
3333

34-
rootReducer = (state = defaultState, action: PayloadAction) => {
34+
rootReducer = (state = defaultState, action: PayloadAction): any => {
3535
switch (action.type) {
3636
case 'TEST':
3737
const { value = null, instanceProperty = null } =
@@ -54,7 +54,7 @@ describe('@dispatch', () => {
5454
class TestClass {
5555
instanceProperty = 'test';
5656

57-
@dispatch() externalFunction: (value: string) => PayloadAction;
57+
@dispatch() externalFunction!: (value: string) => PayloadAction;
5858

5959
@dispatch()
6060
classMethod(value: string): PayloadAction {

packages/store/src/decorators/dispatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function dispatch(): PropertyDecorator {
1515
): PropertyDescriptor {
1616
let originalMethod: () => void;
1717

18-
const wrapped = function(this: any, ...args: any[]) {
18+
const wrapped = function(this: any, ...args: any) {
1919
const result = originalMethod.apply(this, args);
2020
if (result !== false) {
2121
const store = getBaseStore(this) || NgRedux.instance;

packages/store/src/decorators/select.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Select decorators', () => {
4040
describe('when passed no arguments', () => {
4141
it('binds to a store property that matches the name of the class property', done => {
4242
class MockClass {
43-
@select() baz: Observable<number>;
43+
@select() baz!: Observable<number>;
4444
}
4545
const mockInstance = new MockClass();
4646

@@ -59,7 +59,7 @@ describe('Select decorators', () => {
5959

6060
it('binds by name ignoring any $ characters in the class property name', done => {
6161
class MockClass {
62-
@select() baz$: Observable<number>;
62+
@select() baz$!: Observable<number>;
6363
}
6464
const mockInstance = new MockClass();
6565

@@ -80,7 +80,7 @@ describe('Select decorators', () => {
8080
describe('when passed a string', () => {
8181
it('binds to the store property whose name matches the string value', done => {
8282
class MockClass {
83-
@select('baz') obs$: Observable<number>;
83+
@select('baz') obs$!: Observable<number>;
8484
}
8585
const mockInstance = new MockClass();
8686

@@ -102,7 +102,7 @@ describe('Select decorators', () => {
102102
it('attempts to use that function as the selector function', done => {
103103
const selector = (state: AppState) => state.baz * 2;
104104
class MockClass {
105-
@select(selector) obs$: Observable<number>;
105+
@select(selector) obs$!: Observable<number>;
106106
}
107107
const mockInstance = new MockClass();
108108

@@ -124,7 +124,7 @@ describe('Select decorators', () => {
124124
const comparator = (_: any, y: any): boolean => y === 1;
125125
class MockClass {
126126
@select('baz', comparator)
127-
baz$: Observable<number>;
127+
baz$!: Observable<number>;
128128
}
129129

130130
it('should only trigger next when comparator returns true', done => {
@@ -147,7 +147,7 @@ describe('Select decorators', () => {
147147
const spy = jasmine.createSpy('spy');
148148
class LocalMockClass {
149149
@select('baz', spy)
150-
baz$: Observable<number>;
150+
baz$!: Observable<number>;
151151
}
152152

153153
const mockInstance = new LocalMockClass();
@@ -169,7 +169,7 @@ describe('Select decorators', () => {
169169
it('applies a transformer to the observable', done => {
170170
class MockClass {
171171
@select$('baz', transformer)
172-
baz$: Observable<number>;
172+
baz$!: Observable<number>;
173173
}
174174
const mockInstance = new MockClass();
175175

@@ -186,7 +186,7 @@ describe('Select decorators', () => {
186186
const comparator = (_: any, y: any): boolean => y === 1;
187187
class MockClass {
188188
@select$('baz', transformer, comparator)
189-
baz$: Observable<number>;
189+
baz$!: Observable<number>;
190190
}
191191

192192
it('should only trigger next when the comparator returns true', done => {
@@ -209,7 +209,7 @@ describe('Select decorators', () => {
209209
const spy = jasmine.createSpy('spy');
210210
class SpyClass {
211211
@select$('baz', transformer, spy)
212-
baz$: Observable<number>;
212+
baz$!: Observable<number>;
213213
}
214214

215215
const mockInstance = new SpyClass();

0 commit comments

Comments
 (0)