-
Notifications
You must be signed in to change notification settings - Fork 944
Turn on Typescript strict option for Firestore #1941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm about to be OOO for almost 2 weeks and I think this probably needs a bit more scrutiny than I can give it today. Ideally I think we should try to avoid using !
as much as possible, since I think this basically just bypasses the strict check and TypeScript will happily let us fail to initialize the variable, right? But I'm not sure how hard it is to do that, and it probably depends on each case, and maybe it's not something we want to invest too much time in right now... Not sure.
Anyway, perhaps @schmidt-sebastian has time to look at this? Else, I can work through it when I get back (~7/17).
@@ -134,7 +134,7 @@ export class FirebaseCredentialsProvider implements CredentialsProvider { | |||
private tokenListener: ((token: string | null) => void) | null = null; | |||
|
|||
/** Tracks the current User. */ | |||
private currentUser: User; | |||
private currentUser?: User; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be initialized to User.UNAUTHENTICATED
instead.
@@ -192,7 +192,7 @@ export class FirebaseCredentialsProvider implements CredentialsProvider { | |||
typeof tokenData.accessToken === 'string', | |||
'Invalid tokenData returned from getToken():' + tokenData | |||
); | |||
return new OAuthToken(tokenData.accessToken, this.currentUser); | |||
return new OAuthToken(tokenData.accessToken, this.currentUser!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove !
after above suggestion.
This isn't urgent so I can definitely put this on the back burner until someone has time to properly review it. |
I've addressed the strict violations and enabled strict mode via #2078. Thanks! |
Set
strict: true
in Typescript compiler options. This required setting a lot of initial values for variables or promising the compiler (with!
) that these values would be set before being used, so please check I have guessed the correct values or that the guarantees are correct.