Skip to content

Commit 6211af5

Browse files
committed
strict null check
1 parent f33c784 commit 6211af5

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

src/app/components/micropost-list/micropost-list.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class MicropostListComponent implements OnInit {
4747
this.list(lastPost.id);
4848
}
4949

50-
private list(maxId: number = null): void {
50+
private list(maxId: number|null = null): void {
5151
this.userMicropostService.list(this.userId, {maxId: maxId, count: 5})
5252
.subscribe(posts => {
5353
this.posts = this.posts.concat(posts);
@@ -58,8 +58,8 @@ export class MicropostListComponent implements OnInit {
5858

5959
private loadUserStats() {
6060
this.userService.get(this.userId)
61-
.subscribe(resp => {
62-
this.userStats = resp.userStats;
61+
.subscribe(user => {
62+
if (user.userStats) this.userStats = user.userStats;
6363
}, e => this.errorHandler.handle(e))
6464
;
6565
}

src/app/components/micropost-list/micropost-list.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class MicropostListService {
1212
constructor(private http: JsonHttp) {
1313
}
1414

15-
list(userId: string, params: {maxId: number, count: number}): Observable<Micropost[]> {
15+
list(userId: string, params: {maxId: number|null, count: number}): Observable<Micropost[]> {
1616
return this.http.get(url(userId), {search: objToSearchParams(params)})
1717
.map(res => res.json())
1818
;

src/app/components/related-user-list/related-user-list.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {styles} from "./related-user-list.component.styles";
1010
})
1111
export class RelatedUserListComponent implements OnInit {
1212

13-
@Input() listProvider: (params: {maxId: number, count: number}) => Observable<RelatedUser[]>;
13+
@Input() listProvider: (params: {maxId: number|null, count: number}) => Observable<RelatedUser[]>;
1414

1515
styles: any = styles;
1616
users: RelatedUser[] = [];
@@ -29,7 +29,7 @@ export class RelatedUserListComponent implements OnInit {
2929
this.list(lastUser.relationshipId);
3030
}
3131

32-
private list(maxId = null) {
32+
private list(maxId: number|null = null) {
3333
this.listProvider({maxId: maxId, count: 5})
3434
.subscribe(users => {
3535
this.users = this.users.concat(users);

src/app/core/services/json-http.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Headers
99
} from "@angular/http";
1010

11-
const mergeAuthToken = (options: RequestOptionsArgs) => {
11+
const mergeAuthToken = (options: RequestOptionsArgs = {}) => {
1212
let newOptions = new RequestOptions({}).merge(options);
1313
let newHeaders = new Headers(newOptions.headers);
1414
const jwt = localStorage.getItem('jwt');

src/app/core/toast/toast.service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {Injectable} from "@angular/core";
22
import {Subject, Observable} from "rxjs";
3-
import {Toast} from "./toast";
3+
import {Toast, ToastEvent} from "./toast";
44

55
@Injectable()
66
export class ToastService {
77

8-
private toastEvents: Subject<Toast> = new Subject<Toast>();
8+
private toastEvents: Subject<ToastEvent> = new Subject<Toast>();
99

10-
get events(): Observable<Toast> {
10+
get events(): Observable<ToastEvent> {
1111
return this.toastEvents;
1212
}
1313

@@ -23,7 +23,7 @@ export class ToastService {
2323
this.publish({message: message, level: 'error'});
2424
}
2525

26-
private publish(toast: Toast) {
26+
private publish(toast: ToastEvent) {
2727
this.toastEvents.next(toast);
2828
}
2929

src/app/core/toast/toast.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
export interface ToastEvent {
2+
message: string;
3+
level: string;
4+
}
5+
16
export interface Toast {
27
message: string;
38
level: string;
4-
styles?: any[];
9+
styles: any[];
510
}

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"es2015",
1313
"dom"
1414
],
15-
"strictNullChecks": false,
15+
"strictNullChecks": true,
16+
"skipLibCheck": true,
1617
"baseUrl": "./src",
1718
"paths": {},
1819
"types": [

0 commit comments

Comments
 (0)