Skip to content

Commit

Permalink
chore(build): Enable strict on modules and example app
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts committed Feb 19, 2018
1 parent 2e4bea2 commit ab409b3
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 20 deletions.
4 changes: 2 additions & 2 deletions example-app/app/auth/effects/auth.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { User, Authenticate } from '../models/user';
export class AuthEffects {
@Effect()
login$ = this.actions$.pipe(
ofType(AuthActionTypes.Login),
map((action: Login) => action.payload),
ofType<Login>(AuthActionTypes.Login),
map(action => action.payload),
exhaustMap((auth: Authenticate) =>
this.authService
.login(auth)
Expand Down
9 changes: 7 additions & 2 deletions example-app/app/auth/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { createSelector, createFeatureSelector } from '@ngrx/store';
import {
createSelector,
createFeatureSelector,
ActionReducerMap,
} from '@ngrx/store';
import * as fromRoot from '../../reducers';
import * as fromAuth from './auth';
import * as fromLoginPage from './login-page';
import { AuthActions } from '../../auth/actions/auth';

export interface AuthState {
status: fromAuth.State;
Expand All @@ -12,7 +17,7 @@ export interface State extends fromRoot.State {
auth: AuthState;
}

export const reducers = {
export const reducers: ActionReducerMap<AuthState, AuthActions> = {
status: fromAuth.reducer,
loginPage: fromLoginPage.reducer,
};
Expand Down
2 changes: 1 addition & 1 deletion example-app/app/books/containers/selected-book-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Book } from '../models/book';
`,
})
export class SelectedBookPageComponent {
book$: Observable<Book>;
book$: Observable<'' | Book | null>;
isSelectedBookInCollection$: Observable<boolean>;

constructor(private store: Store<fromBooks.State>) {
Expand Down
8 changes: 4 additions & 4 deletions example-app/app/books/effects/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class CollectionEffects {

@Effect()
addBookToCollection$: Observable<Action> = this.actions$.pipe(
ofType(CollectionActionTypes.AddBook),
map((action: AddBook) => action.payload),
ofType<AddBook>(CollectionActionTypes.AddBook),
map(action => action.payload),
mergeMap(book =>
this.db
.insert('books', [book])
Expand All @@ -69,8 +69,8 @@ export class CollectionEffects {

@Effect()
removeBookFromCollection$: Observable<Action> = this.actions$.pipe(
ofType(CollectionActionTypes.RemoveBook),
map((action: RemoveBook) => action.payload),
ofType<RemoveBook>(CollectionActionTypes.RemoveBook),
map(action => action.payload),
mergeMap(book =>
this.db
.executeWrite('books', 'delete', [book.id])
Expand Down
11 changes: 8 additions & 3 deletions example-app/app/books/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { createSelector, createFeatureSelector } from '@ngrx/store';
import {
createSelector,
createFeatureSelector,
ActionReducerMap,
Action,
} from '@ngrx/store';
import * as fromSearch from './search';
import * as fromBooks from './books';
import * as fromCollection from './collection';
Expand All @@ -14,7 +19,7 @@ export interface State extends fromRoot.State {
books: BooksState;
}

export const reducers = {
export const reducers: ActionReducerMap<BooksState, any> = {
search: fromSearch.reducer,
books: fromBooks.reducer,
collection: fromCollection.reducer,
Expand Down Expand Up @@ -152,6 +157,6 @@ export const isSelectedBookInCollection = createSelector(
getCollectionBookIds,
getSelectedBookId,
(ids, selected) => {
return ids.indexOf(selected) > -1;
return ids.indexOf(selected as string) > -1;
}
);
5 changes: 3 additions & 2 deletions example-app/app/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { storeFreeze } from 'ngrx-store-freeze';
*/

import * as fromLayout from '../core/reducers/layout';
import { RouterAction } from '@ngrx/router-store';

/**
* As mentioned, we treat each reducer like a table in a database. This means
Expand All @@ -39,14 +40,14 @@ export interface State {
* These reducer functions are called with each dispatched action
* and the current or initial state and return a new immutable state.
*/
export const reducers: ActionReducerMap<State> = {
export const reducers: ActionReducerMap<State, any> = {
layout: fromLayout.reducer,
router: fromRouter.routerReducer,
};

// console.log all actions
export function logger(reducer: ActionReducer<State>): ActionReducer<State> {
return function(state: State, action: any): State {
return function(state: State | undefined, action: any): State {
console.log('state', state);
console.log('action', action);

Expand Down
3 changes: 3 additions & 0 deletions example-app/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"types": [],
"baseUrl": ".",
"rootDir": "../",
"skipLibCheck": true,
"strict": true,
"strictFunctionTypes": false,
"paths": {
"@ngrx/effects": [
"../modules/effects"
Expand Down
3 changes: 2 additions & 1 deletion modules/effects/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"inlineSources": true,
"lib": ["es2015", "dom"],
"target": "es2015",
"skipLibCheck": true
"skipLibCheck": true,
"strict": true
},
"files": [
"public_api.ts"
Expand Down
3 changes: 2 additions & 1 deletion modules/entity/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"inlineSources": true,
"lib": ["es2015", "dom"],
"target": "es2015",
"skipLibCheck": true
"skipLibCheck": true,
"strict": true
},
"files": [
"public_api.ts"
Expand Down
4 changes: 2 additions & 2 deletions modules/router-store/src/router_store_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export type RouterReducerState<T = RouterStateSnapshot> = {
};

export function routerReducer<T = RouterStateSnapshot>(
state: RouterReducerState<T>,
state: RouterReducerState<T> | undefined,
action: RouterAction<any, T>
): RouterReducerState<T> {
switch (action.type) {
Expand All @@ -108,7 +108,7 @@ export function routerReducer<T = RouterStateSnapshot>(
navigationId: action.payload.event.id,
};
default:
return state;
return state as RouterReducerState<T>;
}
}

Expand Down
3 changes: 2 additions & 1 deletion modules/router-store/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"inlineSources": true,
"lib": ["es2015", "dom"],
"target": "es2015",
"skipLibCheck": true
"skipLibCheck": true,
"strict": true
},
"files": [
"public_api.ts"
Expand Down
3 changes: 2 additions & 1 deletion modules/store-devtools/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"inlineSources": true,
"lib": ["es2015", "dom"],
"target": "es2015",
"skipLibCheck": true
"skipLibCheck": true,
"strict": true
},
"files": [
"public_api.ts"
Expand Down

0 comments on commit ab409b3

Please sign in to comment.