The title of this question is the message what the Angular CLI compiler throws.
I have this constructor in my app.component.ts:
export class AppComponent {
constructor(private userService: UserService, private auth: AuthService, router: Router) {
auth.user$.subscribe(user => {
if (user) {
userService.save(user);
let returnUrl = localStorage.getItem('returnUrl');
router.navigateByUrl(returnUrl);
}
});
}
}
In the above attached code part I have the 'returnURL' underlined and if I take the cursor above it says:
"Argument of type 'string | null' is not assignable to parameter of type 'string | UrlTree'. Type 'null' is not assignable to type 'string | UrlTree'."
I have a user.service.ts which is related to Firebase:
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import * as firebase from 'firebase';
@Injectable()
export class UserService {
constructor(private db: AngularFireDatabase) { }
save(user: firebase.User) {
this.db.object('/users/' + user.uid).update({
name: user.displayName,
email: user.email
});
}
}
Does anyone has an idea about what is the compiler's problem here? I also attached the console message.
